adbmsFunctionTest/Core/Inc/ADBMS_LL_Driver.h

46 lines
1.2 KiB
C

/*
* ADBMS_LL_Driver.h
*
* Created on: 05.06.2022
* Author: max
*/
#ifndef ADBMS_LL_DRIVER_H_
#define ADBMS_LL_DRIVER_H_
#define TARGET_STM32
#include "main.h"
#ifdef TARGET_STM32
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
#endif
uint8 adbmsDriverInit(SPI_HandleTypeDef* hspi);
uint8 calculateCommandPEC(uint8* data, uint8 datalen);
uint16 updateCommandPEC(uint16 currentPEC, uint8 din);
uint8 checkCommandPEC(uint8* data, uint8 datalen);
uint8 calculateDataPEC(uint8* data, uint8 datalen);
uint16 updateDataPEC(uint16 currentPEC, uint8 din);
uint8 checkDataPEC(uint8* data, uint8 datalen);
uint8 writeCMD(uint16 command, uint8* args, uint8 arglen);
uint8 writeCMD_I2C(uint16 command, uint8* args, uint8 arglen);
uint8 readCMD(uint16 command, uint8* buffer, uint8 buflen);
uint8 pollCMD(uint16 command);
void mcuAdbmsCSLow();
void mcuAdbmsCSHigh();
uint8 mcuSPITransmit(uint8* buffer, uint8 buffersize);
uint8 mcuSPIReceive(uint8* buffer, uint8 buffersize);
uint8 mcuSPITransmitReceive(uint8* rxbuffer, uint8* txbuffer, uint8 buffersize);
uint8 wakeUpCmd();
void mcuDelay(uint16 delay);
#endif /* ADBMS_LL_DRIVER_H_ */