/*
* pga23xx.h: burr brown volume control chip (spi based)
*
*
* (part of the "VoluMaster(tm)" system)
*
* An open-source arduino controller-based digital volume control and input/output selector
*
*
* LICENSE
* -------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
#ifndef PGA23XX_H
#define PGA23XX_H
#include
#include "config.h"
#ifdef USE_PGA_SPI
#define PGA_CS_PIN 12 // (my orange wire)
#define PGA_SDATA_PIN 11 // (my yellow wire)
#define PGA_SCK_PIN 10 // (my green wire)
#endif
#ifdef USE_PGA_I2C
// You will have to change the address for the PCF8574A to B0111000
// (with all three address pins tied to ground). The Wire library will
// take care of the last bit (the R/W) so make sure you leave that
// out of the address. Note that the R/W bit is not part of this address.
#define I2C_PGA_PE_ADDR B0111111 // PCF8574A with three address pins tied to Vcc!
//#define I2C_PGA_PE_ADDR B0100000 // Address with three address pins grounded.
#define PGA_I2C_CS B10000000
#define PGA_I2C_SDATA B00100000
#define PGA_I2C_SCK B00010000
#define PGA_I2C_CS_LOW B00000000
#define PGA_I2C_CS_HI B10000000
#define PGA_I2C_SDATA_LOW B00000000
#define PGA_I2C_SDATA_HI B00100000
#define PGA_I2C_SCK_LOW B00000000
#define PGA_I2C_SCK_HI B00010000
#endif // USE_PGA
class PGA23XX {
public:
PGA23XX( void );
void init( void );
void map_pga_value_to_db( uint8_t pga_int_value, uint8_t *db_value, uint8_t *negative_db, uint8_t *half_db_flag );
void set_volume( uint8_t left, uint8_t right );
void SPI_write( uint8_t out_spi_byte );
uint8_t PCF8574_PE_read( void );
void PCF8574_PE_write( uint8_t _data );
};
#endif // PGA23XX_H