#define MCP4561_ADDR ((uint8_t)0x2E) //!< I2C slave address of the digital potentiometer (mcp4561), 0101 prefix, A2 = A1 = 1 (pull-up), A0 as on PCB (0), Tbl. 6-2
#define MCP4551_ADDR ((uint8_t)0x2E) //!< I2C slave address of the digital potentiometer (mcp4551), 0101 prefix, A2 = A1 = 1 (pull-up), A0 as on PCB (0), Tbl. 6-2 in data sheet
/**
* \defgroup mcp4561_commands Commands for the digital potentiometer (mcp4561)
* \defgroup mcp4551_commands Commands for the digital potentiometer (mcp4551)
* @{
*/
/// commands for the potentiometer (mcp4561)
/// commands for the potentiometer (mcp4551)
enum{
POTI_CMD_WRITE_DATA=0x00
MCP4551_CMD_WRITE_DATA=0x00
};
/** @} */
/**
* @brief initialisation of mcp4561 - nothing to do at the moment
* @brief initialisation of mcp4551 - nothing to do at the moment
*
* @retval true if the initialisation was successful
*/
staticinlinebool
mcp4561_init(void)
mcp4551_init(void)
{
returntrue;
}
...
...
@@ -66,9 +66,9 @@ mcp4561_init(void)
/**
* @brief send a command to the digital potentiometer (mcp4561)
* @brief send a command to the digital potentiometer (mcp4551)
*
* @param cmd: command to be send - has to be one of the commands listed @link mcp4561_commands here@endlink
* @param cmd: command to be send - has to be one of the commands listed @link mcp4551_commands here@endlink
* @param data: data to be send
*
* @retval true if the i2c transmission was started successfully
...
...
@@ -77,17 +77,21 @@ mcp4561_init(void)
__attribute__((__always_inline__))
#endif
staticinlinebool
mcp4561_send(uint8_tcmd,uint16_tdata)
mcp4551_send(uint8_tcmd,uint16_tdata)
{
if(data>256){
returnfalse;
}
// max value is 256, which is in second byte
// see MCP455X i2c data sheet, Sect 7.4 (page 54pp)
// max value is 256 with bit D8 in command byte
// CMD6:0,D8 | D7:0
// - 7 command bits including device memory address