Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • e-24/public/ahoi/firmware
1 result
Show changes
Commits on Source (2)
/**
* Copyright 2016-2018
* Copyright 2016-2023
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -37,7 +37,7 @@
#include "hal_txamp.h"
#include "txamp.h"
#include "hal_gpio.h"
#include "dev_mcp4561.h"
#include "dev_mcp4551.h"
#pragma message "building BRIDGE TX AMP"
......@@ -148,9 +148,9 @@ txamp_disable()
void
txamp_connectOutput()
{
// use non-volatile write here here
mcp4561_send(POTI_CMD_WRITE_DATA, TXGAIN[txLvl]);
// use volatile write here to prevent memory corruption of poti
mcp4551_send(MCP4551_CMD_WRITE_DATA, TXGAIN[txLvl]);
// only enable output, after gain has been set
gpio_set(TXRX_SW_PIN);
}
......
/**
* Copyright 2016-2018
* Copyright 2016-2023
*
* Timo Kortbrae,
* Bernd-Christian Renner, and
......@@ -35,30 +35,30 @@
*/
#ifndef DEV_MCP4561
#define DEV_MCP4561
#ifndef DEV_MCP4551
#define DEV_MCP4551
#include "mcu_i2c.h"
#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
*/
static inline bool
mcp4561_init(void)
mcp4551_init(void)
{
return true;
}
......@@ -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
static inline bool
mcp4561_send(uint8_t cmd, uint16_t data)
mcp4551_send(uint8_t cmd, uint16_t data)
{
if (data > 256) {
return false;
}
// 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
// - 9 data bits spread
uint8_t temp[2];
temp[0] = cmd | (uint8_t)((data >> 8) & 0x01);
temp[1] = (uint8_t)(data & 0xFF);
return i2c_transmitDMA(MCP4561_ADDR, temp, 2);
return i2c_transmitDMA(MCP4551_ADDR, temp, 2);
}
......