41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
|
|
#ifndef BQ_COM
|
|
#define BQ_COM
|
|
|
|
#include "BQ_Register_Definitions.h"
|
|
|
|
#include "stm32f4xx_hal.h"
|
|
|
|
#define FRM_WRT_NR 0x90
|
|
#define FRM_WRT_R 0x81
|
|
|
|
#define DEFAULTNUMOFCELLS 10
|
|
#define DEFAULTNUMOFDIETEMPS 0
|
|
|
|
#define BQUARTTIMEOUT 200
|
|
|
|
typedef enum { BQ_COMM_OK, BQ_COMM_ERR_HAL, BQ_COMM_ERR_CRC } BQ_Comm_Status;
|
|
|
|
void init_BQCom(UART_HandleTypeDef* uarthandle);
|
|
|
|
uint16_t Calculate_CRC(uint8_t* message_buffer, uint16_t bufferlength);
|
|
uint16_t Check_CRC(uint8_t* message_buffer, uint16_t bufferlength);
|
|
|
|
uint32_t BQ_Write_Register(uint8_t registeraddress, uint8_t registersize,
|
|
uint32_t data);
|
|
uint8_t BQ_Read_Register(uint8_t registeraddress, uint8_t registersize,
|
|
uint32_t* data);
|
|
/**
|
|
* @brief Reads Voltage Measurements from the BQ76
|
|
*
|
|
* Result are Written into the Buffer
|
|
* Buffer size should be 2xMeasured Voltages
|
|
*/
|
|
BQ_Comm_Status BQ_ReadMeasurements(uint8_t* buffer, uint8_t bufferlength);
|
|
uint8_t Communication_Reset();
|
|
|
|
uint8_t BQ_UART_Transmit(uint8_t* message_buffer, uint16_t bufferlength);
|
|
uint8_t BQ_UART_Receive(uint8_t* message_buffer, uint16_t bufferlength);
|
|
|
|
#endif
|