62 #include "HL_reg_system.h"
64 #include "bender_iso165c.h"
75 #define CAN_TIMING_LOWER_LIMIT_COUNTS (95u)
78 #define CAN_TIMING_UPPER_LIMIT_COUNTS (105u)
81 #define CAN_BOOT_MESSAGE_MAXIMUM_RELEASE_DISTANCE (31u)
82 #if CAN_BOOT_MESSAGE_MAXIMUM_RELEASE_DISTANCE > UINT8_MAX
83 #error "This code assumes that the define is smaller or equal to UINT8_MAX")
87 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_VERSION_CONTROL (0u)
90 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DIRTY_FLAG (1u)
93 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_OVERFLOW_FLAG (2u)
96 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_COUNTER (3u)
146 #if CURRENT_SENSOR_PRESENT == true
223 if (canIsTxMessagePending(pNode, messageBox) == 0u) {
228 canUpdateID(pNode, messageBox, ((
id << 18) | (1U << 29)));
229 canTransmit(pNode, messageBox, pData);
246 static uint32_t counterTicks = 0;
247 uint8_t data[8] = {0};
275 uint32_t current_time;
278 #if CURRENT_SENSOR_PRESENT == true
299 #if CURRENT_SENSOR_PRESENT == true
303 for (uint8_t stringNumber = 0u; stringNumber <
BS_NR_OF_STRINGS; stringNumber++) {
352 while (pdPASS == xQueueReceive(
ftsk_canRxQueue, (
void *)&can_rxBuffer, 0u)) {
375 if (command ==
true) {
382 #if CURRENT_SENSOR_PRESENT == true
384 if (command ==
true) {
396 if (command ==
true) {
408 if (command ==
true) {
441 uint8_t data[8] = {0};
443 canGetData(pNode, messageBox, (uint8 *)&data[0]);
451 uint32_t
id = canGetID(pNode, messageBox) >> 18;
452 can_rxBuffer.
id = id;
453 can_rxBuffer.
data[0] = data[0];
454 can_rxBuffer.
data[1] = data[1];
455 can_rxBuffer.
data[2] = data[2];
456 can_rxBuffer.
data[3] = data[3];
457 can_rxBuffer.
data[4] = data[4];
458 can_rxBuffer.
data[5] = data[5];
459 can_rxBuffer.
data[6] = data[6];
460 can_rxBuffer.
data[7] = data[7];
461 if (pdPASS == xQueueSendToBackFromISR(
ftsk_canRxQueue, (
void *)&can_rxBuffer, NULL)) {
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
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_PIN_TOGGLE_DELAY_US
#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(uint16_t value1, 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
volatile bool ftsk_allQueuesCreated
QueueHandle_t ftsk_canRxQueue
Header of task driver implementation.
#define SETBIT(register, bit)
sets a bit to 1u
#define REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
#define UNIT_TEST_WEAK_IMPL
void IO_PinSet(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
void IO_PinReset(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
Header for the driver for the IO module.
void MCU_delay_us(uint32_t delay_us)
Wait blocking a certain time in microseconds.
Headers for the driver for the MCU module.
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.
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