diff --git a/Middlewares/Coulomb/coulomb.c b/Middlewares/Coulomb/coulomb.c index 661e626..a2870a6 100644 --- a/Middlewares/Coulomb/coulomb.c +++ b/Middlewares/Coulomb/coulomb.c @@ -3,15 +3,15 @@ bool is_coulomb_ready() { - HAL_I2C_IsDeviceReady(hi2c1,COULOMB_ADDR); +// HAL_I2C_IsDeviceReady(hi2c1,COULOMB_ADDR); } -coulomb_write_reg() +void coulomb_write_reg(uint8_t reg_addr,uint8_t *data) { - HAL_I2C_IsDeviceReady(COULOMB_ADDR); + HAL_I2C_Master_Transmit(&hi2c1,((COULOMB_ADDR<<1) | COULOMB_WRITE_CMD), data, 1, 100); } -coulomb_read_reg() +void coulomb_read_reg(uint8_t reg_addr,uint8_t *data) { - + HAL_I2C_Master_Receive(&hi2c1,((COULOMB_ADDR<<1) | COULOMB_READ_CMD), data, 1, 100); } diff --git a/Middlewares/Coulomb/coulomb.h b/Middlewares/Coulomb/coulomb.h index f9baea0..1ee16aa 100644 --- a/Middlewares/Coulomb/coulomb.h +++ b/Middlewares/Coulomb/coulomb.h @@ -8,9 +8,17 @@ #ifndef _COULOMB_H_ #define _COULOMB_H_ +#include "stdbool.h" + #define COULOMB_ADDR 0x64 //device address #define COULOMB_WRITE_CMD 0x00 //coulomb write command #define COULOMB_READ_CMD 0x01 //coulomb read command +bool is_coulomb_ready(); +void coulomb_write_reg(uint8_t reg_addr,uint8_t *data); +void coulomb_read_reg(uint8_t reg_addr,uint8_t *data); + +bool coulomb_read_alcc() + #endif /* _COULOMB_H_ */