57 #include "HL_system.h"
68 #define N775_MAX_SUPPORTED_CELLS (12u)
73 #define N775_SAVELASTSTATES() \
74 n775_state.lastState = n775_state.state; \
75 n775_state.lastSubState = n775_state.subState
80 #pragma SET_DATA_SECTION(".sharedRAM")
83 #pragma SET_DATA_SECTION()
115 .errRequestCounter = 0,
120 .txTransmitOngoing =
false,
121 .rxTransmitOngoing =
false,
123 .remainingMessages = 0u,
129 static void N775_WakeUp(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress);
130 static void N775_Write(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data);
132 uint16_t daisyChainAddress,
133 uint16_t deviceAddress,
134 uint16_t registerAddress,
135 uint16_t totalNumberOfRequestedRegister);
164 uint16_t local_remainder = remainder;
166 local_remainder ^= item;
168 for (i = 0; i < 16; i++) {
172 if ((local_remainder & 0x8000u) > 0u) {
173 local_remainder = (local_remainder << 1u) ^ ((0x9eb2u << 1u) + 0x1u);
175 local_remainder = (local_remainder << 1u);
179 return (local_remainder);
192 uint16_t remainder = 0;
215 for (uint8_t stringNumber = 0u; stringNumber <
BS_NR_OF_STRINGS; stringNumber++) {
355 bool n775_goToTrigger =
true;
362 n775_goToTrigger =
false;
369 n775_goToTrigger =
false;
378 n775_goToTrigger =
false;
387 n775_goToTrigger =
false;
394 if (n775_goToTrigger ==
true) {
446 MC33775_SYS_COM_CFG_OFFSET,
448 (MC33775_SYS_COM_CFG_BUSFW_ENABLED_ENUM_VAL << MC33775_SYS_COM_CFG_BUSFW_POS));
458 MC33775_SYS_COM_CFG_OFFSET,
460 (MC33775_SYS_COM_CFG_BUSFW_ENABLED_ENUM_VAL << MC33775_SYS_COM_CFG_BUSFW_POS));
563 buffer[0] = message->
head;
567 buffer[i + 2u] = message->
data[i];
569 buffer[i + 3u] = message->
crc;
584 static void N775_WakeUp(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress) {
585 uint16_t messageCounter = 0u;
643 static void N775_Write(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data) {
644 uint16_t messageCounter = 0u;
706 uint16_t daisyChainAddress,
707 uint16_t deviceAddress,
708 uint16_t registerAddress,
709 uint16_t totalNumberOfRequestedRegister) {
710 uint16_t messageCounter = 0u;
711 uint16_t dataLen = 0u;
712 uint16_t readParameters = 0u;
739 readParameters = (0u << 11u) +
742 ((totalNumberOfRequestedRegister - 1u) << 0);
Headers for the driver for the general DMA module of monitoring ICs.
#define BS_NR_OF_TEMP_SENSORS_PER_STRING
#define BS_NR_OF_BAT_CELLS
#define DATA_WRITE_DATA(...)
@ DATA_BLOCK_ID_BALANCING_CONTROL
@ DATA_BLOCK_ID_CELL_TEMPERATURE_BASE
@ DATA_BLOCK_ID_CELL_VOLTAGE_BASE
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
uint16_t n775_TXbuffer[N775_TX_MESSAGE_LENGTH]
void TEST_N775_SetFirstMeasurementCycleFinished(N775_STATE_s *n775_state)
N775_STATE_REQUEST_e N775_TransferStateRequest()
transfers the current state request to the state machine.
N775_MESSAGE_s n775_sentData
bool N775_IsFirstMeasurementCycleFinished(void)
gets the measurement initialization status.
uint16_t n775_CrcAddItem(uint16_t remainder, uint16_t item)
Called to calculate the CRC of a message. NXP function.
N775_STATE_REQUEST_e N775_GetStateRequest(void)
gets the current state request.
static DATA_BLOCK_MIN_MAX_s n775_minMax
static void N775_Initialize_Database(void)
in the database, initializes the fields related to the N775 driver.
static DATA_BLOCK_CELL_TEMPERATURE_s n775_cellTemperature
uint16_t n775_CalcCrc(const N775_MESSAGE_s *msg)
Calculate the CRC of a message. NXP function.
static void N775_Read(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t totalNumberOfRequestedRegister)
sends a read command to the daisy-chain.
static void N775_SetFirstMeasurementCycleFinished(N775_STATE_s *n775_state)
sets the measurement initialization status.
uint16_t n775_RXbuffer[N775_MAX_N_BYTES_FOR_DATA_RECEPTION]
static DATA_BLOCK_CELL_VOLTAGE_s n775_cellVoltage
static void N775_WakeUp(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress)
sends a wake-up command to the daisy-chain.
#define N775_SAVELASTSTATES()
static DATA_BLOCK_BALANCING_CONTROL_s n775_balancingControl
uint8_t n775_enumerateAddress
static N775_RETURN_TYPE_e N775_CheckStateRequest(N775_STATE_REQUEST_e statereq)
checks the state requests that are made.
static void N775_CopyStructToTxBuffer(N775_MESSAGE_s *message, uint16_t *buffer)
sends a write command to the daisy-chain.
static void N775_StateTransition(N775_STATEMACH_e state, uint8_t substate, uint16_t timer_ms)
function for setting N775_Trigger state transitions
void N775_Trigger(void)
trigger function for the N775 driver state machine.
uint8_t TEST_N775_CheckReEntrance(void)
static void N775_Write(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data)
sends a write command to the daisy-chain.
N775_STATEMACH_e N775_GetState(void)
gets the current state.
N775_RETURN_TYPE_e N775_SetStateRequest(N775_STATE_REQUEST_e statereq)
sets the current state request of the state variable n775_state.
N775_MESSAGE_s n775_receivedData
uint8_t N775_CheckReEntrance(void)
re-entrance check of N775 state machine trigger function
Headers for the driver for the MC33775A monitoring chip.
#define N775_MAX_N_BYTES_FOR_DATA_RECEPTION
#define N775_SendData(txbuf, rxbuf, length)
#define N775_TIME_DAISYCHAIN_WAKEUP_MS
#define N775_TX_MESSAGE_LENGTH
#define N775_TIME_AFTER_ENUMERATION_MS
#define N775_STATEMACH_SHORTTIME
@ N775_ALREADY_INITIALIZED
@ N775_STATE_INIT_REQUEST
@ N775_ENTRY_UNINITIALIZED
@ N775_STATEMACH_ENUMERATE
@ N775_STATEMACH_BALANCECONTROL
@ N775_STATEMACH_STARTMEAS
@ N775_STATEMACH_READVOLTAGE
@ N775_STATEMACH_INITIALIZED
@ N775_STATEMACH_INITIALIZATION
@ N775_STATEMACH_UNINITIALIZED
bool AFE_IsTxTransmitOngoing(void)
gets the SPI transmit status.
bool AFE_IsRxTransmitOngoing(void)
gets the SPI transmit status.
Declaration of the OS wrapper interface.
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
uint8_t balancingState[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]
DATA_BLOCK_HEADER_s header
int16_t cellTemperature_ddegC[BS_NR_OF_STRINGS][BS_NR_OF_TEMP_SENSORS_PER_STRING]
DATA_BLOCK_HEADER_s header
int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]
DATA_BLOCK_HEADER_s header
uint16_t nrCellMinimumCellVoltage[BS_NR_OF_STRINGS]
uint16_t nrSensorMinimumTemperature[BS_NR_OF_STRINGS]
int16_t maximumTemperature_ddegC[BS_NR_OF_STRINGS]
int16_t minimumTemperature_ddegC[BS_NR_OF_STRINGS]
uint16_t nrModuleMaximumCellVoltage[BS_NR_OF_STRINGS]
uint16_t nrCellMaximumCellVoltage[BS_NR_OF_STRINGS]
uint16_t nrSensorMaximumTemperature[BS_NR_OF_STRINGS]
int16_t maximumCellVoltage_mV[BS_NR_OF_STRINGS]
uint16_t nrModuleMinimumCellVoltage[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
uint16_t nrModuleMaximumTemperature[BS_NR_OF_STRINGS]
uint16_t nrModuleMinimumTemperature[BS_NR_OF_STRINGS]
int16_t minimumCellVoltage_mV[BS_NR_OF_STRINGS]
STD_RETURN_TYPE_e checkSpiFlag
uint32_t errRequestCounter
uint16_t remainingMessages
N775_STATE_REQUEST_e stateReq
STD_RETURN_TYPE_e firstMeasurementMade