58 #include "HL_system.h"
69 #define N775_MAX_SUPPORTED_CELLS (12u)
74 #define N775_SAVELASTSTATES() \
75 n775_state.lastState = n775_state.state; \
76 n775_state.lastSubState = n775_state.subState
86 #pragma SET_DATA_SECTION(".sharedRAM")
89 #pragma SET_DATA_SECTION()
123 .errRequestCounter = 0,
128 .txTransmitOngoing =
false,
129 .rxTransmitOngoing =
false,
131 .remainingMessages = 0u,
137 static void N775_WakeUp(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress);
138 static void N775_Write(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data);
140 uint16_t daisyChainAddress,
141 uint16_t deviceAddress,
142 uint16_t registerAddress,
143 uint16_t totalNumberOfRequestedRegister);
172 uint16_t local_remainder = remainder;
174 local_remainder ^= item;
176 for (i = 0; i < 16; i++) {
180 if ((local_remainder & 0x8000u) > 0u) {
181 local_remainder = (local_remainder << 1u) ^ ((0x9eb2u << 1u) + 0x1u);
183 local_remainder = (local_remainder << 1u);
187 return (local_remainder);
200 uint16_t remainder = 0;
363 bool n775_goToTrigger =
true;
370 n775_goToTrigger =
false;
377 n775_goToTrigger =
false;
386 n775_goToTrigger =
false;
395 n775_goToTrigger =
false;
402 if (n775_goToTrigger ==
true) {
454 MC33775_SYS_COM_CFG_OFFSET,
456 (MC33775_SYS_COM_CFG_BUSFW_ENABLED_ENUM_VAL << MC33775_SYS_COM_CFG_BUSFW_POS));
466 MC33775_SYS_COM_CFG_OFFSET,
468 (MC33775_SYS_COM_CFG_BUSFW_ENABLED_ENUM_VAL << MC33775_SYS_COM_CFG_BUSFW_POS));
571 buffer[0] = message->
head;
575 buffer[i + 2u] = message->
data[i];
577 buffer[i + 3u] = message->
crc;
592 static void N775_WakeUp(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress) {
593 uint16_t messageCounter = 0u;
651 static void N775_Write(uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data) {
652 uint16_t messageCounter = 0u;
714 uint16_t daisyChainAddress,
715 uint16_t deviceAddress,
716 uint16_t registerAddress,
717 uint16_t totalNumberOfRequestedRegister) {
718 uint16_t messageCounter = 0u;
719 uint16_t dataLen = 0u;
720 uint16_t readParameters = 0u;
747 readParameters = (0u << 11u) +
750 ((totalNumberOfRequestedRegister - 1u) << 0);
Headers for the driver for the general DMA module of monitoring ICs.
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
#define BS_NR_OF_CELL_BLOCKS_PER_STRING
#define BS_NR_OF_TEMP_SENSORS_PER_STRING
#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.
DATA_BLOCK_HEADER_s header
uint8_t balancingState[BS_NR_OF_STRINGS][BS_NR_OF_CELL_BLOCKS_PER_STRING]
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_CELL_BLOCKS_PER_STRING]
int16_t minimumTemperature_ddegC[BS_NR_OF_STRINGS]
uint16_t nrSensorMinimumTemperature[BS_NR_OF_STRINGS]
uint16_t nrModuleMinimumTemperature[BS_NR_OF_STRINGS]
uint16_t nrModuleMaximumTemperature[BS_NR_OF_STRINGS]
int16_t maximumTemperature_ddegC[BS_NR_OF_STRINGS]
uint16_t nrSensorMaximumTemperature[BS_NR_OF_STRINGS]
uint16_t nrCellMaximumCellVoltage[BS_NR_OF_STRINGS]
uint16_t nrCellMinimumCellVoltage[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
uint16_t nrModuleMinimumCellVoltage[BS_NR_OF_STRINGS]
uint16_t nrModuleMaximumCellVoltage[BS_NR_OF_STRINGS]
int16_t maximumCellVoltage_mV[BS_NR_OF_STRINGS]
int16_t minimumCellVoltage_mV[BS_NR_OF_STRINGS]
STD_RETURN_TYPE_e firstMeasurementMade
N775_STATE_REQUEST_e stateReq
STD_RETURN_TYPE_e checkSpiFlag
uint32_t errRequestCounter
uint16_t remainingMessages