master
ThinkPad 2020-04-27 18:28:35 +08:00
parent 24f2105fd6
commit 68e32687b2
2 changed files with 13 additions and 5 deletions

View File

@ -3,15 +3,15 @@
bool is_coulomb_ready() 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);
} }

View File

@ -8,9 +8,17 @@
#ifndef _COULOMB_H_ #ifndef _COULOMB_H_
#define _COULOMB_H_ #define _COULOMB_H_
#include "stdbool.h"
#define COULOMB_ADDR 0x64 //device address #define COULOMB_ADDR 0x64 //device address
#define COULOMB_WRITE_CMD 0x00 //coulomb write command #define COULOMB_WRITE_CMD 0x00 //coulomb write command
#define COULOMB_READ_CMD 0x01 //coulomb read 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_ */ #endif /* _COULOMB_H_ */