ina3221 mcp4725 pcf8574 hd44780 upgrade
This commit is contained in:
parent
d93c441da0
commit
e7d619b882
11 changed files with 107 additions and 95 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <hd44780/hd44780.h>
|
#include <hd44780/hd44780.h>
|
||||||
|
|
||||||
|
#define I2C_BUS 0
|
||||||
#define SCL_PIN 5
|
#define SCL_PIN 5
|
||||||
#define SDA_PIN 4
|
#define SDA_PIN 4
|
||||||
#define ADDR 0x27
|
#define ADDR 0x27
|
||||||
|
|
@ -27,10 +28,11 @@ void user_init(void)
|
||||||
uart_set_baud(0, 115200);
|
uart_set_baud(0, 115200);
|
||||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||||
|
|
||||||
i2c_init(SCL_PIN, SDA_PIN);
|
i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);
|
||||||
|
|
||||||
hd44780_t lcd = {
|
hd44780_t lcd = {
|
||||||
.addr = ADDR,
|
.i2c_dev.bus = I2C_BUS,
|
||||||
|
.i2c_dev.addr = ADDR,
|
||||||
.font = HD44780_FONT_5X8,
|
.font = HD44780_FONT_5X8,
|
||||||
.lines = 2,
|
.lines = 2,
|
||||||
.pins = {
|
.pins = {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "ina3221/ina3221.h"
|
#include "ina3221/ina3221.h"
|
||||||
|
|
||||||
|
#define I2C_BUS 0
|
||||||
#define PIN_SCL 5
|
#define PIN_SCL 5
|
||||||
#define PIN_SDA 2
|
#define PIN_SDA 2
|
||||||
#define ADDR INA3221_ADDR_0
|
#define ADDR INA3221_ADDR_0
|
||||||
|
|
@ -33,7 +34,8 @@ void ina_measure(void *pvParameters)
|
||||||
|
|
||||||
// Create ina3221 device
|
// Create ina3221 device
|
||||||
ina3221_t dev = {
|
ina3221_t dev = {
|
||||||
.addr = ADDR,
|
.i2c_dev.bus = I2C_BUS,
|
||||||
|
.i2c_dev.addr = ADDR,
|
||||||
.shunt = { 100 ,100 ,100 }, // shunt values are 100 mOhm for each channel
|
.shunt = { 100 ,100 ,100 }, // shunt values are 100 mOhm for each channel
|
||||||
.mask.mask_register = INA3221_DEFAULT_MASK, // Init
|
.mask.mask_register = INA3221_DEFAULT_MASK, // Init
|
||||||
.config.config_register = INA3221_DEFAULT_CONFIG, // Init
|
.config.config_register = INA3221_DEFAULT_CONFIG, // Init
|
||||||
|
|
@ -120,7 +122,7 @@ void user_init(void)
|
||||||
uart_set_baud(0, 115200);
|
uart_set_baud(0, 115200);
|
||||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||||
|
|
||||||
i2c_init(PIN_SCL,PIN_SDA);
|
i2c_init(I2C_BUS, PIN_SCL, PIN_SDA, I2C_FREQ_400K);
|
||||||
|
|
||||||
xTaskCreate(ina_measure, "Measurements_task", 512, NULL, 2, NULL);
|
xTaskCreate(ina_measure, "Measurements_task", 512, NULL, 2, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,15 @@
|
||||||
#include <FreeRTOS.h>
|
#include <FreeRTOS.h>
|
||||||
#include <task.h>
|
#include <task.h>
|
||||||
|
|
||||||
|
#define I2C_BUS 0
|
||||||
#define SCL_PIN 5
|
#define SCL_PIN 5
|
||||||
#define SDA_PIN 4
|
#define SDA_PIN 4
|
||||||
#define ADDR MCP4725A0_ADDR0
|
#define ADDR MCP4725A0_ADDR0
|
||||||
#define VDD 3.3
|
#define VDD 3.3
|
||||||
|
|
||||||
inline static void wait_for_eeprom()
|
inline static void wait_for_eeprom(i2c_dev_t* dev)
|
||||||
{
|
{
|
||||||
while (mcp4725_eeprom_busy(ADDR))
|
while (mcp4725_eeprom_busy(dev))
|
||||||
{
|
{
|
||||||
printf("...DAC is busy, waiting...\n");
|
printf("...DAC is busy, waiting...\n");
|
||||||
vTaskDelay(1);
|
vTaskDelay(1);
|
||||||
|
|
@ -33,21 +34,25 @@ void user_init(void)
|
||||||
uart_set_baud(0, 115200);
|
uart_set_baud(0, 115200);
|
||||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||||
|
|
||||||
i2c_init(SCL_PIN, SDA_PIN);
|
i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);
|
||||||
|
i2c_dev_t dev = {
|
||||||
|
.addr = ADDR,
|
||||||
|
.bus = I2C_BUS,
|
||||||
|
};
|
||||||
|
|
||||||
// setup EEPROM values
|
// setup EEPROM values
|
||||||
if (mcp4725_get_power_mode(ADDR, true) != MCP4725_PM_NORMAL)
|
if (mcp4725_get_power_mode(&dev, true) != MCP4725_PM_NORMAL)
|
||||||
{
|
{
|
||||||
printf("DAC was sleeping... Wake up Neo!\n");
|
printf("DAC was sleeping... Wake up Neo!\n");
|
||||||
mcp4725_set_power_mode(ADDR, MCP4725_PM_NORMAL, true);
|
mcp4725_set_power_mode(&dev, MCP4725_PM_NORMAL, true);
|
||||||
wait_for_eeprom();
|
wait_for_eeprom(&dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Set default DAC ouptut value to MAX...\n");
|
printf("Set default DAC ouptut value to MAX...\n");
|
||||||
mcp4725_set_raw_output(ADDR, MCP4725_MAX_VALUE, true);
|
mcp4725_set_raw_output(&dev, MCP4725_MAX_VALUE, true);
|
||||||
wait_for_eeprom();
|
wait_for_eeprom(&dev);
|
||||||
|
|
||||||
printf("And now default DAC output value is 0x%03x\n", mcp4725_get_raw_output(ADDR, true));
|
printf("And now default DAC output value is 0x%03x\n", mcp4725_get_raw_output(&dev, true));
|
||||||
|
|
||||||
printf("Now let's generate the sawtooth wave in slow manner\n");
|
printf("Now let's generate the sawtooth wave in slow manner\n");
|
||||||
|
|
||||||
|
|
@ -58,7 +63,7 @@ void user_init(void)
|
||||||
if (vout > VDD) vout = 0;
|
if (vout > VDD) vout = 0;
|
||||||
|
|
||||||
printf("Vout: %.02f\n", vout);
|
printf("Vout: %.02f\n", vout);
|
||||||
mcp4725_set_voltage(ADDR, VDD, vout, false);
|
mcp4725_set_voltage(&dev, VDD, vout, false);
|
||||||
|
|
||||||
// It will be very low freq wave
|
// It will be very low freq wave
|
||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ static void write_nibble(const hd44780_t *lcd, uint8_t b, bool rs)
|
||||||
| (rs ? 1 << lcd->pins.rs : 0)
|
| (rs ? 1 << lcd->pins.rs : 0)
|
||||||
| (lcd->backlight ? 1 << lcd->pins.bl : 0);
|
| (lcd->backlight ? 1 << lcd->pins.bl : 0);
|
||||||
|
|
||||||
pcf8574_port_write(lcd->addr, data | (1 << lcd->pins.e));
|
pcf8574_port_write(&lcd->i2c_dev, data | (1 << lcd->pins.e));
|
||||||
pcf8574_port_write(lcd->addr, data);
|
pcf8574_port_write(&lcd->i2c_dev, data);
|
||||||
#else
|
#else
|
||||||
gpio_write(lcd->pins.d7, (b >> 3) & 1);
|
gpio_write(lcd->pins.d7, (b >> 3) & 1);
|
||||||
gpio_write(lcd->pins.d6, (b >> 2) & 1);
|
gpio_write(lcd->pins.d6, (b >> 2) & 1);
|
||||||
|
|
@ -164,7 +164,7 @@ void hd44780_set_backlight(hd44780_t *lcd, bool on)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if (HD44780_I2C)
|
#if (HD44780_I2C)
|
||||||
pcf8574_gpio_write(lcd->addr, lcd->pins.bl, on);
|
pcf8574_gpio_write(&lcd->i2c_dev, lcd->pins.bl, on);
|
||||||
#else
|
#else
|
||||||
gpio_write(lcd->pins.bl, on);
|
gpio_write(lcd->pins.bl, on);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,10 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifndef HD44780_I2C
|
#ifndef HD44780_I2C
|
||||||
#define HD44780_I2C 0
|
#define HD44780_I2C 1
|
||||||
|
#endif
|
||||||
|
#if (HD44780_I2C)
|
||||||
|
#include <i2c/i2c.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
@ -36,7 +39,9 @@ typedef enum
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t addr; //!< PCF8574 address (0b0100<A2><A1><A0>)
|
#if (HD44780_I2C)
|
||||||
|
i2c_dev_t i2c_dev; //!< PCF8574 device settings (0b0100<A2><A1><A0>)
|
||||||
|
#endif
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint8_t rs; //!< gpio/register bit used for RS pin
|
uint8_t rs; //!< gpio/register bit used for RS pin
|
||||||
|
|
|
||||||
|
|
@ -18,32 +18,32 @@
|
||||||
#define debug(fmt, ...)
|
#define debug(fmt, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int _wireWriteRegister (uint8_t addr, uint8_t reg, uint16_t value)
|
static int _wireWriteRegister (const i2c_dev_t* dev, uint8_t reg, uint16_t value)
|
||||||
{
|
{
|
||||||
uint8_t d[2] = { 0 , 0 };
|
uint8_t d[2] = { 0 , 0 };
|
||||||
d[1] = value & 0x00FF;
|
d[1] = value & 0x00FF;
|
||||||
d[0] = (value >> 8) & 0x00FF;
|
d[0] = (value >> 8) & 0x00FF;
|
||||||
debug("Data write to %02X : %02X+%04X\n",addr,reg,value);
|
debug("Data write to bus %u at %02X : %02X+%04X\n",dev->bus, dev->addr, reg, value);
|
||||||
return i2c_slave_write(addr, ®, d, sizeof(d));
|
return i2c_slave_write(dev->bus, dev->addr, ®, d, sizeof(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _wireReadRegister(uint8_t addr, uint8_t reg, uint16_t *value)
|
static int _wireReadRegister(const i2c_dev_t* dev, uint8_t reg, uint16_t *value)
|
||||||
{
|
{
|
||||||
uint8_t d[] = {0, 0};
|
uint8_t d[] = {0, 0};
|
||||||
int error = i2c_slave_read(addr, ®, d, sizeof(d))
|
int error = i2c_slave_read(dev->bus, dev->addr, ®, d, sizeof(d))
|
||||||
debug("Data read from %02X: %02X+%04X\n",addr,reg,*value);
|
debug("Data read from bus %u at %02X: %02X+%04X\n",dev->bus, dev->addr, reg, *value);
|
||||||
*value = d[1] | (d[0] << 8);
|
*value = d[1] | (d[0] << 8);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_trigger(ina3221_t *dev)
|
int ina3221_trigger(ina3221_t *dev)
|
||||||
{
|
{
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_CONFIG, dev->config.config_register);
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_CONFIG, dev->config.config_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_getStatus(ina3221_t *dev)
|
int ina3221_getStatus(ina3221_t *dev)
|
||||||
{
|
{
|
||||||
return _wireReadRegister(dev->addr, INA3221_REG_MASK, &dev->mask.mask_register);
|
return _wireReadRegister(&dev->i2c_dev, INA3221_REG_MASK, &dev->mask.mask_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_sync(ina3221_t *dev)
|
int ina3221_sync(ina3221_t *dev)
|
||||||
|
|
@ -51,17 +51,17 @@ int ina3221_sync(ina3221_t *dev)
|
||||||
uint16_t ptr_data;
|
uint16_t ptr_data;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
//////////////////////// Sync config register
|
//////////////////////// Sync config register
|
||||||
if ((err = _wireReadRegister(dev->addr, INA3221_REG_CONFIG, &ptr_data))) // Read config
|
if ((err = _wireReadRegister(&dev->i2c_dev, INA3221_REG_CONFIG, &ptr_data))) // Read config
|
||||||
return err;
|
return err;
|
||||||
if( ptr_data != dev->config.config_register) {
|
if( ptr_data != dev->config.config_register) {
|
||||||
if ((err = _wireWriteRegister(dev->addr, INA3221_REG_CONFIG, dev->config.config_register))) // Update config
|
if ((err = _wireWriteRegister(&dev->i2c_dev, INA3221_REG_CONFIG, dev->config.config_register))) // Update config
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
//////////////////////// Sync mask register config
|
//////////////////////// Sync mask register config
|
||||||
if ((err = _wireReadRegister(dev->addr, INA3221_REG_MASK, &ptr_data))) // Read mask
|
if ((err = _wireReadRegister(&dev->i2c_dev, INA3221_REG_MASK, &ptr_data))) // Read mask
|
||||||
return err;
|
return err;
|
||||||
if( (ptr_data & INA3221_MASK_CONFIG) != (dev->mask.mask_register & INA3221_MASK_CONFIG)) {
|
if( (ptr_data & INA3221_MASK_CONFIG) != (dev->mask.mask_register & INA3221_MASK_CONFIG)) {
|
||||||
if ((err = _wireWriteRegister(dev->addr, INA3221_REG_MASK, dev->mask.mask_register & INA3221_MASK_CONFIG))) // Update config
|
if ((err = _wireWriteRegister(&dev->i2c_dev, INA3221_REG_MASK, dev->mask.mask_register & INA3221_MASK_CONFIG))) // Update config
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -72,7 +72,7 @@ int ina3221_setting(ina3221_t *dev ,bool mode, bool bus, bool shunt)
|
||||||
dev->config.mode = mode;
|
dev->config.mode = mode;
|
||||||
dev->config.ebus = bus;
|
dev->config.ebus = bus;
|
||||||
dev->config.esht = shunt;
|
dev->config.esht = shunt;
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_CONFIG, dev->config.config_register);
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_CONFIG, dev->config.config_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_enableChannel(ina3221_t *dev ,bool ch1, bool ch2, bool ch3)
|
int ina3221_enableChannel(ina3221_t *dev ,bool ch1, bool ch2, bool ch3)
|
||||||
|
|
@ -80,7 +80,7 @@ int ina3221_enableChannel(ina3221_t *dev ,bool ch1, bool ch2, bool ch3)
|
||||||
dev->config.ch1 = ch1;
|
dev->config.ch1 = ch1;
|
||||||
dev->config.ch2 = ch2;
|
dev->config.ch2 = ch2;
|
||||||
dev->config.ch3 = ch3;
|
dev->config.ch3 = ch3;
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_CONFIG, dev->config.config_register);
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_CONFIG, dev->config.config_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_enableChannelSum(ina3221_t *dev ,bool ch1, bool ch2, bool ch3)
|
int ina3221_enableChannelSum(ina3221_t *dev ,bool ch1, bool ch2, bool ch3)
|
||||||
|
|
@ -88,32 +88,32 @@ int ina3221_enableChannelSum(ina3221_t *dev ,bool ch1, bool ch2, bool ch3)
|
||||||
dev->mask.scc1 = ch1;
|
dev->mask.scc1 = ch1;
|
||||||
dev->mask.scc2 = ch2;
|
dev->mask.scc2 = ch2;
|
||||||
dev->mask.scc3 = ch3;
|
dev->mask.scc3 = ch3;
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_MASK, dev->mask.mask_register & INA3221_MASK_CONFIG);
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_MASK, dev->mask.mask_register & INA3221_MASK_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_enableLatchPin(ina3221_t *dev ,bool warning, bool critical)
|
int ina3221_enableLatchPin(ina3221_t *dev ,bool warning, bool critical)
|
||||||
{
|
{
|
||||||
dev->mask.wen = warning;
|
dev->mask.wen = warning;
|
||||||
dev->mask.cen = critical;
|
dev->mask.cen = critical;
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_MASK, dev->mask.mask_register & INA3221_MASK_CONFIG);
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_MASK, dev->mask.mask_register & INA3221_MASK_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_setAverage(ina3221_t *dev, ina3221_avg_t avg)
|
int ina3221_setAverage(ina3221_t *dev, ina3221_avg_t avg)
|
||||||
{
|
{
|
||||||
dev->config.avg = avg;
|
dev->config.avg = avg;
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_CONFIG, dev->config.config_register);
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_CONFIG, dev->config.config_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_setBusConversionTime(ina3221_t *dev,ina3221_ct_t ct)
|
int ina3221_setBusConversionTime(ina3221_t *dev,ina3221_ct_t ct)
|
||||||
{
|
{
|
||||||
dev->config.vbus = ct;
|
dev->config.vbus = ct;
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_CONFIG, dev->config.config_register);
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_CONFIG, dev->config.config_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_setShuntConversionTime(ina3221_t *dev,ina3221_ct_t ct)
|
int ina3221_setShuntConversionTime(ina3221_t *dev,ina3221_ct_t ct)
|
||||||
{
|
{
|
||||||
dev->config.vsht = ct;
|
dev->config.vsht = ct;
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_CONFIG, dev->config.config_register);
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_CONFIG, dev->config.config_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_reset(ina3221_t *dev)
|
int ina3221_reset(ina3221_t *dev)
|
||||||
|
|
@ -121,14 +121,14 @@ int ina3221_reset(ina3221_t *dev)
|
||||||
dev->config.config_register = INA3221_DEFAULT_CONFIG ; //dev reset
|
dev->config.config_register = INA3221_DEFAULT_CONFIG ; //dev reset
|
||||||
dev->mask.mask_register = INA3221_DEFAULT_CONFIG ; //dev reset
|
dev->mask.mask_register = INA3221_DEFAULT_CONFIG ; //dev reset
|
||||||
dev->config.rst = 1 ;
|
dev->config.rst = 1 ;
|
||||||
return _wireWriteRegister(dev->addr, INA3221_REG_CONFIG, dev->config.config_register); // send reset to device
|
return _wireWriteRegister(&dev->i2c_dev, INA3221_REG_CONFIG, dev->config.config_register); // send reset to device
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_getBusVoltage(ina3221_t *dev, ina3221_channel_t channel, float *voltage)
|
int ina3221_getBusVoltage(ina3221_t *dev, ina3221_channel_t channel, float *voltage)
|
||||||
{
|
{
|
||||||
int16_t raw_value;
|
int16_t raw_value;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if ((err = _wireReadRegister(dev->addr,INA3221_REG_BUSVOLTAGE_1+channel*2, (uint16_t*)&raw_value)))
|
if ((err = _wireReadRegister(&dev->i2c_dev,INA3221_REG_BUSVOLTAGE_1+channel*2, (uint16_t*)&raw_value)))
|
||||||
return err;
|
return err;
|
||||||
*voltage = raw_value*0.001 ; //V 8mV step
|
*voltage = raw_value*0.001 ; //V 8mV step
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -138,12 +138,12 @@ int ina3221_getShuntValue(ina3221_t *dev, ina3221_channel_t channel, float *volt
|
||||||
{
|
{
|
||||||
int16_t raw_value;
|
int16_t raw_value;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if ((err = _wireReadRegister(dev->addr,INA3221_REG_SHUNTVOLTAGE_1+channel*2, (uint16_t*)&raw_value)))
|
if ((err = _wireReadRegister(&dev->i2c_dev,INA3221_REG_SHUNTVOLTAGE_1+channel*2, (uint16_t*)&raw_value)))
|
||||||
return err;
|
return err;
|
||||||
*voltage = raw_value*0.005; //mV 40uV step
|
*voltage = raw_value*0.005; //mV 40uV step
|
||||||
if(!dev->shunt[channel])
|
if(!dev->shunt[channel])
|
||||||
{
|
{
|
||||||
debug("No shunt configured for channel %u. Dev:%X\n",channel+1, dev->addr);
|
debug("No shunt configured for channel %u. Dev:%u:%X\n",channel+1, dev->bus, dev->addr);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
*current = (*voltage*1000.0)/dev->shunt[channel] ; //mA
|
*current = (*voltage*1000.0)/dev->shunt[channel] ; //mA
|
||||||
|
|
@ -154,7 +154,7 @@ int ina3221_getSumShuntValue(ina3221_t *dev, float *voltage)
|
||||||
{
|
{
|
||||||
int16_t raw_value;
|
int16_t raw_value;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if ((err = _wireReadRegister(dev->addr,INA3221_REG_SHUNT_VOLTAGE_SUM, (uint16_t*)&raw_value)))
|
if ((err = _wireReadRegister(&dev->i2c_dev,INA3221_REG_SHUNT_VOLTAGE_SUM, (uint16_t*)&raw_value)))
|
||||||
return err;
|
return err;
|
||||||
*voltage = raw_value*0.02; //uV 40uV step
|
*voltage = raw_value*0.02; //uV 40uV step
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -163,39 +163,39 @@ int ina3221_getSumShuntValue(ina3221_t *dev, float *voltage)
|
||||||
int ina3221_setCriticalAlert(ina3221_t *dev, ina3221_channel_t channel, float current)
|
int ina3221_setCriticalAlert(ina3221_t *dev, ina3221_channel_t channel, float current)
|
||||||
{
|
{
|
||||||
int16_t raw_value = current*dev->shunt[channel]*0.2; // format
|
int16_t raw_value = current*dev->shunt[channel]*0.2; // format
|
||||||
return _wireWriteRegister(dev->addr,INA3221_REG_CRITICAL_ALERT_1+channel*2, *(uint16_t*)&raw_value);
|
return _wireWriteRegister(&dev->i2c_dev,INA3221_REG_CRITICAL_ALERT_1+channel*2, *(uint16_t*)&raw_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_setWarningAlert(ina3221_t *dev, ina3221_channel_t channel, float current)
|
int ina3221_setWarningAlert(ina3221_t *dev, ina3221_channel_t channel, float current)
|
||||||
{
|
{
|
||||||
int16_t raw_value = current*dev->shunt[channel]*0.2 ; // format
|
int16_t raw_value = current*dev->shunt[channel]*0.2 ; // format
|
||||||
return _wireWriteRegister(dev->addr,INA3221_REG_WARNING_ALERT_1+channel*2, *(uint16_t*)&raw_value);
|
return _wireWriteRegister(&dev->i2c_dev,INA3221_REG_WARNING_ALERT_1+channel*2, *(uint16_t*)&raw_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_setSumWarningAlert(ina3221_t *dev, float voltage)
|
int ina3221_setSumWarningAlert(ina3221_t *dev, float voltage)
|
||||||
{
|
{
|
||||||
int16_t raw_value = voltage*50.0 ; // format
|
int16_t raw_value = voltage*50.0 ; // format
|
||||||
return _wireWriteRegister(dev->addr,INA3221_REG_SHUNT_VOLTAGE_SUM_LIMIT, *(uint16_t*)&raw_value);
|
return _wireWriteRegister(&dev->i2c_dev,INA3221_REG_SHUNT_VOLTAGE_SUM_LIMIT, *(uint16_t*)&raw_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_setPowerValidUpperLimit(ina3221_t *dev, float voltage)
|
int ina3221_setPowerValidUpperLimit(ina3221_t *dev, float voltage)
|
||||||
{
|
{
|
||||||
if(!dev->config.ebus)
|
if(!dev->config.ebus)
|
||||||
{
|
{
|
||||||
debug("Bus not enable. Dev:%X\n", dev->addr);
|
debug("Bus not enable. Dev:%u:%X\n", dev->bus, dev->addr);
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
int16_t raw_value = voltage*1000.0; //format
|
int16_t raw_value = voltage*1000.0; //format
|
||||||
return _wireWriteRegister(dev->addr,INA3221_REG_VALID_POWER_UPPER_LIMIT, *(uint16_t*)&raw_value);
|
return _wireWriteRegister(&dev->i2c_dev,INA3221_REG_VALID_POWER_UPPER_LIMIT, *(uint16_t*)&raw_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ina3221_setPowerValidLowerLimit(ina3221_t *dev, float voltage)
|
int ina3221_setPowerValidLowerLimit(ina3221_t *dev, float voltage)
|
||||||
{
|
{
|
||||||
if(!dev->config.ebus)
|
if(!dev->config.ebus)
|
||||||
{
|
{
|
||||||
debug("Bus not enable. Dev:%X\n", dev->addr);
|
debug("Bus not enable. Dev:%u:%X\n", dev->bus, dev->addr);
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
int16_t raw_value = voltage*1000.0; // round and format
|
int16_t raw_value = voltage*1000.0; // round and format
|
||||||
return _wireWriteRegister(dev->addr,INA3221_REG_VALID_POWER_LOWER_LIMIT, *(uint16_t*)&raw_value);
|
return _wireWriteRegister(&dev->i2c_dev,INA3221_REG_VALID_POWER_LOWER_LIMIT, *(uint16_t*)&raw_value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ typedef union
|
||||||
* Device description
|
* Device description
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const uint8_t addr; // ina3221 I2C address
|
const i2c_dev_t i2c_dev; // ina3221 I2C address
|
||||||
const uint16_t shunt[BUS_NUMBER]; //Memory of shunt value (mOhm)
|
const uint16_t shunt[BUS_NUMBER]; //Memory of shunt value (mOhm)
|
||||||
ina3221_config_t config; //Memory of ina3221 config
|
ina3221_config_t config; //Memory of ina3221 config
|
||||||
ina3221_mask_t mask; //Memory of mask_config
|
ina3221_mask_t mask; //Memory of mask_config
|
||||||
|
|
|
||||||
|
|
@ -6,62 +6,59 @@
|
||||||
* BSD Licensed as described in the file LICENSE
|
* BSD Licensed as described in the file LICENSE
|
||||||
*/
|
*/
|
||||||
#include "mcp4725.h"
|
#include "mcp4725.h"
|
||||||
#include <i2c/i2c.h>
|
|
||||||
|
|
||||||
#define CMD_DAC 0x40
|
#define CMD_DAC 0x40
|
||||||
#define CMD_EEPROM 0x60
|
#define CMD_EEPROM 0x60
|
||||||
#define BIT_READY 0x80
|
#define BIT_READY 0x80
|
||||||
|
|
||||||
static void read_data(uint8_t addr, uint8_t *buf, uint8_t size)
|
static void read_data(i2c_dev_t* dev, uint8_t *buf, uint8_t size)
|
||||||
{
|
{
|
||||||
i2c_slave_read(addr, NULL, buf, size);
|
i2c_slave_read(dev->bus, dev->addr , NULL, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mcp4725_eeprom_busy(uint8_t addr)
|
bool mcp4725_eeprom_busy(i2c_dev_t* dev)
|
||||||
{
|
{
|
||||||
uint8_t res;
|
uint8_t res;
|
||||||
read_data(addr, &res, 1);
|
read_data(dev, &res, 1);
|
||||||
|
|
||||||
return !(res & BIT_READY);
|
return !(res & BIT_READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
mcp4725_power_mode_t mcp4725_get_power_mode(uint8_t addr, bool eeprom)
|
mcp4725_power_mode_t mcp4725_get_power_mode(i2c_dev_t* dev, bool eeprom)
|
||||||
{
|
{
|
||||||
uint8_t buf[4];
|
uint8_t buf[4];
|
||||||
read_data(addr, buf, eeprom ? 4 : 1);
|
read_data(dev, buf, eeprom ? 4 : 1);
|
||||||
|
|
||||||
return (eeprom ? buf[3] >> 5 : buf[0] >> 1) & 0x03;
|
return (eeprom ? buf[3] >> 5 : buf[0] >> 1) & 0x03;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mcp4725_set_power_mode(uint8_t addr, mcp4725_power_mode_t mode, bool eeprom)
|
void mcp4725_set_power_mode(i2c_dev_t* dev, mcp4725_power_mode_t mode, bool eeprom)
|
||||||
{
|
{
|
||||||
uint16_t value = mcp4725_get_raw_output(addr, eeprom);
|
uint16_t value = mcp4725_get_raw_output(dev, eeprom);
|
||||||
uint8_t data[] = {
|
uint8_t data[] = {
|
||||||
(eeprom ? CMD_EEPROM : CMD_DAC) | ((uint8_t)mode << 1),
|
(eeprom ? CMD_EEPROM : CMD_DAC) | ((uint8_t)mode << 1),
|
||||||
value >> 4,
|
value >> 4,
|
||||||
value << 4
|
value << 4
|
||||||
};
|
};
|
||||||
i2c_slave_write(addr, &data[0], &data[1], 2);
|
i2c_slave_write(dev->bus, dev->addr, &data[0], &data[1], 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t mcp4725_get_raw_output(uint8_t addr, bool eeprom)
|
uint16_t mcp4725_get_raw_output(i2c_dev_t* dev, bool eeprom)
|
||||||
{
|
{
|
||||||
uint8_t buf[5];
|
uint8_t buf[5];
|
||||||
read_data(addr, buf, eeprom ? 5 : 3);
|
read_data(dev, buf, eeprom ? 5 : 3);
|
||||||
|
|
||||||
return eeprom
|
return eeprom
|
||||||
? ((uint16_t)(buf[3] & 0x0f) << 8) | buf[4]
|
? ((uint16_t)(buf[3] & 0x0f) << 8) | buf[4]
|
||||||
: ((uint16_t)buf[0] << 4) | (buf[1] >> 4);
|
: ((uint16_t)buf[0] << 4) | (buf[1] >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mcp4725_set_raw_output(uint8_t addr, uint16_t value, bool eeprom)
|
void mcp4725_set_raw_output(i2c_dev_t* dev, uint16_t value, bool eeprom)
|
||||||
{
|
{
|
||||||
uint8_t data[] = {
|
uint8_t data[] = {
|
||||||
(eeprom ? CMD_EEPROM : CMD_DAC),
|
(eeprom ? CMD_EEPROM : CMD_DAC),
|
||||||
value >> 4,
|
value >> 4,
|
||||||
value << 4
|
value << 4
|
||||||
};
|
};
|
||||||
i2c_slave_write(addr, &data[0], &data[1], 2);
|
i2c_slave_write(dev->bus, dev->addr, &data[0], &data[1], 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <i2c/i2c.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
@ -41,7 +42,7 @@ typedef enum
|
||||||
* @param addr Device address
|
* @param addr Device address
|
||||||
* @return true when EEPROM is busy
|
* @return true when EEPROM is busy
|
||||||
*/
|
*/
|
||||||
bool mcp4725_eeprom_busy(uint8_t addr);
|
bool mcp4725_eeprom_busy(i2c_dev_t* dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get power mode
|
* Get power mode
|
||||||
|
|
@ -49,7 +50,7 @@ bool mcp4725_eeprom_busy(uint8_t addr);
|
||||||
* @param eeprom Read power mode from EEPROM if true
|
* @param eeprom Read power mode from EEPROM if true
|
||||||
* @return Power mode
|
* @return Power mode
|
||||||
*/
|
*/
|
||||||
mcp4725_power_mode_t mcp4725_get_power_mode(uint8_t addr, bool eeprom);
|
mcp4725_power_mode_t mcp4725_get_power_mode(i2c_dev_t* dev, bool eeprom);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set power mode
|
* Set power mode
|
||||||
|
|
@ -57,7 +58,7 @@ mcp4725_power_mode_t mcp4725_get_power_mode(uint8_t addr, bool eeprom);
|
||||||
* @param mode Power mode
|
* @param mode Power mode
|
||||||
* @param eeprom Store mode to device EEPROM if true
|
* @param eeprom Store mode to device EEPROM if true
|
||||||
*/
|
*/
|
||||||
void mcp4725_set_power_mode(uint8_t addr, mcp4725_power_mode_t mode, bool eeprom);
|
void mcp4725_set_power_mode(i2c_dev_t* dev, mcp4725_power_mode_t mode, bool eeprom);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current DAC value
|
* Get current DAC value
|
||||||
|
|
@ -65,7 +66,7 @@ void mcp4725_set_power_mode(uint8_t addr, mcp4725_power_mode_t mode, bool eeprom
|
||||||
* @param eeprom Read value from device EEPROM if true
|
* @param eeprom Read value from device EEPROM if true
|
||||||
* @return Raw output value, 0..4095
|
* @return Raw output value, 0..4095
|
||||||
*/
|
*/
|
||||||
uint16_t mcp4725_get_raw_output(uint8_t addr, bool eeprom);
|
uint16_t mcp4725_get_raw_output(i2c_dev_t* dev, bool eeprom);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set DAC output value
|
* Set DAC output value
|
||||||
|
|
@ -73,7 +74,7 @@ uint16_t mcp4725_get_raw_output(uint8_t addr, bool eeprom);
|
||||||
* @param value Raw output value, 0..4095
|
* @param value Raw output value, 0..4095
|
||||||
* @param eeprom Store value to device EEPROM if true
|
* @param eeprom Store value to device EEPROM if true
|
||||||
*/
|
*/
|
||||||
void mcp4725_set_raw_output(uint8_t addr, uint16_t value, bool eeprom);
|
void mcp4725_set_raw_output(i2c_dev_t* dev, uint16_t value, bool eeprom);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current DAC output voltage
|
* Get current DAC output voltage
|
||||||
|
|
@ -82,9 +83,9 @@ void mcp4725_set_raw_output(uint8_t addr, uint16_t value, bool eeprom);
|
||||||
* @param eeprom Read voltage from device EEPROM if true
|
* @param eeprom Read voltage from device EEPROM if true
|
||||||
* @return Current output voltage, volts
|
* @return Current output voltage, volts
|
||||||
*/
|
*/
|
||||||
inline float mcp4725_get_voltage(uint8_t addr, float vdd, bool eeprom)
|
inline float mcp4725_get_voltage(i2c_dev_t* dev, float vdd, bool eeprom)
|
||||||
{
|
{
|
||||||
return vdd / MCP4725_MAX_VALUE * mcp4725_get_raw_output(addr, eeprom);
|
return vdd / MCP4725_MAX_VALUE * mcp4725_get_raw_output(dev, eeprom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -94,9 +95,9 @@ inline float mcp4725_get_voltage(uint8_t addr, float vdd, bool eeprom)
|
||||||
* @param value Output value, volts
|
* @param value Output value, volts
|
||||||
* @param eeprom Store value to device EEPROM if true
|
* @param eeprom Store value to device EEPROM if true
|
||||||
*/
|
*/
|
||||||
inline void mcp4725_set_voltage(uint8_t addr, float vdd, float value, bool eeprom)
|
inline void mcp4725_set_voltage(i2c_dev_t* dev, float vdd, float value, bool eeprom)
|
||||||
{
|
{
|
||||||
mcp4725_set_raw_output(addr, MCP4725_MAX_VALUE / vdd * value, eeprom);
|
mcp4725_set_raw_output(dev, MCP4725_MAX_VALUE / vdd * value, eeprom);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -1,47 +1,46 @@
|
||||||
#include "pcf8574.h"
|
#include "pcf8574.h"
|
||||||
#include <i2c/i2c.h>
|
|
||||||
|
|
||||||
uint8_t pcf8574_port_read(uint8_t addr)
|
uint8_t pcf8574_port_read(i2c_dev_t* dev)
|
||||||
{
|
{
|
||||||
uint8_t res;
|
uint8_t res;
|
||||||
if (i2c_slave_read(addr, NULL, &res, 1))
|
if (i2c_slave_read(dev->bus, dev->addr, NULL, &res, 1))
|
||||||
return 0;
|
return 0;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pcf8574_port_read_buf(uint8_t addr, void *buf, size_t len)
|
size_t pcf8574_port_read_buf(i2c_dev_t* dev, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
if (!len || !buf) return 0;
|
if (!len || !buf) return 0;
|
||||||
uint8_t *_buf = (uint8_t *)buf;
|
uint8_t *_buf = (uint8_t *)buf;
|
||||||
|
|
||||||
if (i2c_slave_read(addr, NULL, _buf, len))
|
if (i2c_slave_read(dev->bus, dev->addr, NULL, _buf, len))
|
||||||
return 0;
|
return 0;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pcf8574_port_write_buf(uint8_t addr, void *buf, size_t len)
|
size_t pcf8574_port_write_buf(i2c_dev_t* dev, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
if (!len || !buf) return 0;
|
if (!len || !buf) return 0;
|
||||||
uint8_t *_buf = (uint8_t *)buf;
|
uint8_t *_buf = (uint8_t *)buf;
|
||||||
|
|
||||||
if (i2c_slave_write(addr, NULL, _buf, len))
|
if (i2c_slave_write(dev->bus, dev->addr, NULL, _buf, len))
|
||||||
return 0;
|
return 0;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcf8574_port_write(uint8_t addr, uint8_t value)
|
void pcf8574_port_write(i2c_dev_t* dev, uint8_t value)
|
||||||
{
|
{
|
||||||
i2c_slave_write(addr, NULL, &value, 1);
|
i2c_slave_write(dev->bus, dev->addr, NULL, &value, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pcf8574_gpio_read(uint8_t addr, uint8_t num)
|
bool pcf8574_gpio_read(i2c_dev_t* dev, uint8_t num)
|
||||||
{
|
{
|
||||||
return (bool)((pcf8574_port_read(addr) >> num) & 1);
|
return (bool)((pcf8574_port_read(dev) >> num) & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcf8574_gpio_write(uint8_t addr, uint8_t num, bool value)
|
void pcf8574_gpio_write(i2c_dev_t* dev, uint8_t num, bool value)
|
||||||
{
|
{
|
||||||
uint8_t bit = (uint8_t)value << num;
|
uint8_t bit = (uint8_t)value << num;
|
||||||
uint8_t mask = ~(1 << num);
|
uint8_t mask = ~(1 << num);
|
||||||
pcf8574_port_write (addr, (pcf8574_port_read(addr) & mask) | bit);
|
pcf8574_port_write (dev, (pcf8574_port_read(dev) & mask) | bit);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <i2c/i2c.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
@ -19,7 +20,7 @@ extern "C"
|
||||||
* \param addr I2C register address (0b0100<A2><A1><A0> for PCF8574)
|
* \param addr I2C register address (0b0100<A2><A1><A0> for PCF8574)
|
||||||
* \return 8-bit GPIO port value
|
* \return 8-bit GPIO port value
|
||||||
*/
|
*/
|
||||||
uint8_t pcf8574_port_read(uint8_t addr);
|
uint8_t pcf8574_port_read(i2c_dev_t* dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Continiously read GPIO port values to buffer
|
* \brief Continiously read GPIO port values to buffer
|
||||||
|
|
@ -28,14 +29,14 @@ uint8_t pcf8574_port_read(uint8_t addr);
|
||||||
* @param len Buffer length
|
* @param len Buffer length
|
||||||
* @return Number of bytes read
|
* @return Number of bytes read
|
||||||
*/
|
*/
|
||||||
size_t pcf8574_port_read_buf(uint8_t addr, void *buf, size_t len);
|
size_t pcf8574_port_read_buf(i2c_dev_t* dev, void *buf, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Write value to GPIO port
|
* \brief Write value to GPIO port
|
||||||
* \param addr I2C register address (0b0100<A2><A1><A0> for PCF8574)
|
* \param addr I2C register address (0b0100<A2><A1><A0> for PCF8574)
|
||||||
* \param value GPIO port value
|
* \param value GPIO port value
|
||||||
*/
|
*/
|
||||||
void pcf8574_port_write(uint8_t addr, uint8_t value);
|
void pcf8574_port_write(i2c_dev_t* dev, uint8_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Continiously write GPIO values to GPIO port
|
* \brief Continiously write GPIO values to GPIO port
|
||||||
|
|
@ -44,7 +45,7 @@ void pcf8574_port_write(uint8_t addr, uint8_t value);
|
||||||
* @param len Buffer length
|
* @param len Buffer length
|
||||||
* @return Number of bytes written
|
* @return Number of bytes written
|
||||||
*/
|
*/
|
||||||
size_t pcf8574_port_write_buf(uint8_t addr, void *buf, size_t len);
|
size_t pcf8574_port_write_buf(i2c_dev_t* dev, void *buf, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Read input value of a GPIO pin
|
* \brief Read input value of a GPIO pin
|
||||||
|
|
@ -52,7 +53,7 @@ size_t pcf8574_port_write_buf(uint8_t addr, void *buf, size_t len);
|
||||||
* \param num pin number (0..7)
|
* \param num pin number (0..7)
|
||||||
* \return GPIO pin value
|
* \return GPIO pin value
|
||||||
*/
|
*/
|
||||||
bool pcf8574_gpio_read(uint8_t addr, uint8_t num);
|
bool pcf8574_gpio_read(i2c_dev_t* dev, uint8_t num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set GPIO pin output
|
* \brief Set GPIO pin output
|
||||||
|
|
@ -62,7 +63,7 @@ bool pcf8574_gpio_read(uint8_t addr, uint8_t num);
|
||||||
* \param num pin number (0..7)
|
* \param num pin number (0..7)
|
||||||
* \param value true for high level
|
* \param value true for high level
|
||||||
*/
|
*/
|
||||||
void pcf8574_gpio_write(uint8_t addr, uint8_t num, bool value);
|
void pcf8574_gpio_write(i2c_dev_t* dev, uint8_t num, bool value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue