Motion_EC_Stm32_archived/Middlewares/Coulomb/coulomb.c

22 lines
502 B
C

#include "coulomb.h"
#include "i2c.h"
bool is_coulomb_ready()
{
// HAL_I2C_IsDeviceReady(hi2c1,COULOMB_ADDR);
}
void coulomb_write_reg(uint8_t reg_addr,uint8_t *data)
{
HAL_I2C_Master_Transmit(&hi2c1,((COULOMB_ADDR<<1) | COULOMB_WRITE_CMD), data, 1, 100);
}
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);
}
bool coulomb_read_alcc()
{
return HAL_GPIO_ReadPin(COULOMB_ALCC_GPIO_Port,COULOMB_ALCC_Pin);
}