Motion_EC_Stm32_archived/Middlewares/Coulomb/coulomb.c

22 lines
502 B
C
Raw Normal View History

2020-04-27 18:19:02 +08:00
#include "coulomb.h"
#include "i2c.h"
bool is_coulomb_ready()
{
2020-04-27 18:28:35 +08:00
// HAL_I2C_IsDeviceReady(hi2c1,COULOMB_ADDR);
2020-04-27 18:19:02 +08:00
}
2020-04-27 18:28:35 +08:00
void coulomb_write_reg(uint8_t reg_addr,uint8_t *data)
2020-04-27 18:19:02 +08:00
{
2020-04-27 18:28:35 +08:00
HAL_I2C_Master_Transmit(&hi2c1,((COULOMB_ADDR<<1) | COULOMB_WRITE_CMD), data, 1, 100);
2020-04-27 18:19:02 +08:00
}
2020-04-27 18:28:35 +08:00
void coulomb_read_reg(uint8_t reg_addr,uint8_t *data)
2020-04-27 18:19:02 +08:00
{
2020-04-27 18:28:35 +08:00
HAL_I2C_Master_Receive(&hi2c1,((COULOMB_ADDR<<1) | COULOMB_READ_CMD), data, 1, 100);
2020-04-27 18:19:02 +08:00
}
bool coulomb_read_alcc()
{
return HAL_GPIO_ReadPin(COULOMB_ALCC_GPIO_Port,COULOMB_ALCC_Pin);
}