62 #include "HL_reg_system.h"
64 #include "bender_iso165c.h"
74 #define CAN_TIMING_LOWER_LIMIT_COUNTS (95u)
77 #define CAN_TIMING_UPPER_LIMIT_COUNTS (105u)
80 #define CAN_BOOT_MESSAGE_MAXIMUM_RELEASE_DISTANCE (31u)
81 #if CAN_BOOT_MESSAGE_MAXIMUM_RELEASE_DISTANCE > UINT8_MAX
82 #error "This code assumes that the define is smaller or equal to UINT8_MAX")
86 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_VERSION_CONTROL (0u)
89 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DIRTY_FLAG (1u)
92 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_OVERFLOW_FLAG (2u)
95 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_COUNTER (3u)
98 #define CAN_HAL_RETVAL_NO_DATA_LOST (1u)
148 #if CURRENT_SENSOR_PRESENT == true
218 if (canIsTxMessagePending(pNode, messageBox) == 0u) {
223 canUpdateID(pNode, messageBox, ((
id << 18) | (1U << 29)));
224 canTransmit(pNode, messageBox, pData);
241 static uint32_t counterTicks = 0;
242 uint8_t data[8] = {0};
268 uint32_t current_time;
271 #if CURRENT_SENSOR_PRESENT == true
292 #if CURRENT_SENSOR_PRESENT == true
296 for (uint8_t stringNumber = 0u; stringNumber <
BS_NR_OF_STRINGS; stringNumber++) {
368 if (command ==
true) {
375 #if CURRENT_SENSOR_PRESENT == true
377 if (command ==
true) {
389 if (command ==
true) {
401 if (command ==
true) {
434 uint8_t messageData[
CAN_DLC] = {0u};
441 uint32_t retval = canGetData(pNode, messageBox, (uint8 *)&messageData[0]);
448 uint32_t
id = canGetID(pNode, messageBox) >> 18u;
451 can_rxBuffer.
id = id;
452 can_rxBuffer.
data[0] = messageData[0];
453 can_rxBuffer.
data[1] = messageData[1];
454 can_rxBuffer.
data[2] = messageData[2];
455 can_rxBuffer.
data[3] = messageData[3];
456 can_rxBuffer.
data[4] = messageData[4];
457 can_rxBuffer.
data[5] = messageData[5];
458 can_rxBuffer.
data[6] = messageData[6];
459 can_rxBuffer.
data[7] = messageData[7];
492 uint8_t versionControlByte = 0u;
516 uint32_t deviceRegister = systemREG1->DEVID;
530 #ifdef UNITY_UNIT_TEST
#define BS_COULOMB_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS
#define BS_ENERGY_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS
#define BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS
static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox)
Called in case of CAN RX interrupt.
bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber)
get flag if CC message from current sensor is received.
void CAN_MainFunction(void)
Calls the functions to drive the CAN interface. Makes the CAN timing checks and sends the periodic me...
static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
static STD_RETURN_TYPE_e CAN_PeriodicTransmit(void)
Handles the processing of messages that are meant to be transmitted. This function looks for the repe...
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_OVERFLOW_FLAG
#define CAN_HAL_RETVAL_NO_DATA_LOST
static void CAN_CheckCanTiming(void)
Checks if the CAN messages come in the specified time window If the (current time stamp) - (previous ...
#define CAN_TIMING_LOWER_LIMIT_COUNTS
static void CAN_InitializeTransceiver(void)
void UNIT_TEST_WEAK_IMPL canMessageNotification(canBASE_t *node, uint32 messageBox)
bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber)
get flag if EC message from current sensor is received
static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox)
Called in case of CAN TX interrupt.
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_COUNTER
STD_RETURN_TYPE_e CAN_DataSend(canBASE_t *pNode, uint32_t id, uint8 *pData)
Sends over CAN the data passed in parameters. This function goes over the messageboxes and marks the ...
void CAN_ReadRxBuffer(void)
Checks the data received per CAN. A receive buffer is used because CAN frames are received in an inte...
bool CAN_IsCurrentSensorPresent(uint8_t stringNumber)
set flag for presence of current sensor.
static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
STD_RETURN_TYPE_e CAN_TransmitBootMessage(void)
Transmit startup boot message.
#define CAN_TIMING_UPPER_LIMIT_COUNTS
#define CAN_BOOT_MESSAGE_MAXIMUM_RELEASE_DISTANCE
static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor is present.
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_DIRTY_FLAG
void CAN_Initialize(void)
Enables the CAN transceiver.. This function sets th pins to enable the CAN transceiver....
static CAN_STATE_s can_state
void CAN_EnablePeriodic(bool command)
enable/disable the periodic transmit/receive.
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_VERSION_CONTROL
Header for the driver for the CAN module.
#define CAN_NR_OF_TX_MESSAGE_BOX
const CAN_MSG_RX_TYPE_s can_rxMessages[]
const uint8_t can_txLength
const CAN_MSG_TX_TYPE_s can_txMessages[]
const CAN_SHIM_s can_kShim
const uint8_t can_rxLength
#define CAN_ID_BOOT_MESSAGE
Headers for the helper functions for the CAN module.
#define CAN_BYTE_2_POSITION
#define CAN_BYTE_4_POSITION
#define CAN_BYTE_0_POSITION
#define CAN_BYTE_6_POSITION
#define CAN_BYTE_7_POSITION
#define CAN_BYTE_3_POSITION
#define CAN_BYTE_5_POSITION
#define CAN_BYTE_1_POSITION
#define DATA_READ_DATA(...)
@ DATA_BLOCK_ID_CURRENT_SENSOR
@ DATA_BLOCK_ID_ERRORSTATE
@ DATA_BLOCK_ID_STATEREQUEST
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diag_id, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
@ DIAG_ID_CAN_CC_RESPONDING
@ DIAG_ID_CURRENT_SENSOR_RESPONDING
@ DIAG_ID_CAN_RX_QUEUE_FULL
@ DIAG_ID_CAN_EC_RESPONDING
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
uint16_t MATH_MinimumOfTwoUint16_t(const uint16_t value1, const uint16_t value2)
Returns the minimum of the passed uint16_t values.
math library for often used math functions
#define NULL_PTR
Null pointer.
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
Header of task driver implementation.
volatile bool ftsk_allQueuesCreated
QueueHandle_t ftsk_canRxQueue
#define REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
#define UNIT_TEST_WEAK_IMPL
OS_STD_RETURN_e OS_ReceiveFromQueue(OS_QUEUE xQueue, void *const pvBuffer, uint32_t ticksToWait)
Receive an item from a queue.
OS_STD_RETURN_e OS_SendToBackOfQueueFromIsr(OS_QUEUE xQueue, const void *const pvItemToQueue, long *const pxHigherPriorityTaskWoken)
Post an item to the back the provided queue during an ISR.
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.
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
void PEX_SetPin(uint8_t portExpander, uint8_t pin)
sets pin to high.
void PEX_SetPinDirectionOutput(uint8_t portExpander, uint8_t pin)
sets pin to input.
Header for the driver for the NXP PCA9539 port expander module.
#define PEX_PORT_EXPANDER2
uint8_t data[CAN_MAX_DLC]
can_callback_funcPtr callbackFunction
can_callback_funcPtr callbackFunction
bool currentSensorECPresent[BS_NR_OF_STRINGS]
bool currentSensorCCPresent[BS_NR_OF_STRINGS]
bool currentSensorPresent[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
uint32_t timestampEnergyCounting[BS_NR_OF_STRINGS]
uint32_t timestampCurrentCounting[BS_NR_OF_STRINGS]
DATA_BLOCK_HEADER_s header
DATA_BLOCK_HEADER_s header
const uint16_t distanceFromLastRelease
const bool underVersionControl
Header file for the version information that is generated by the toolchain.
const VERSION_s foxbmsVersionInfo