L4 adaptaions
This commit is contained in:
3
CLS.c
3
CLS.c
@@ -5,11 +5,10 @@
|
|||||||
|
|
||||||
osTimerId_t CLS_HeatbeatTimerId; // Timer ID
|
osTimerId_t CLS_HeatbeatTimerId; // Timer ID
|
||||||
static uint8_t cls_hartbeat_counter = 0;
|
static uint8_t cls_hartbeat_counter = 0;
|
||||||
static CLS_BSP_TxHeaderType cls_hartbeat_header = CREATE_BSP_CAN_HEADER(GENERATE_CLS_ADDRESS(CLS_CODE_STATUS,CLS_DEVICE,CLS_CH_STA_HEATBEAT), CLS_BSP_DLC_BYTES_1);
|
|
||||||
|
|
||||||
|
|
||||||
void CLS_Heatbeat(void *argument) {
|
void CLS_Heatbeat(void *argument) {
|
||||||
// Code to be executed every 500ms
|
// Code to be executed every 500ms
|
||||||
|
CLS_BSP_TxHeaderType cls_hartbeat_header = CREATE_BSP_CAN_HEADER(GENERATE_CLS_ADDRESS(CLS_CODE_STATUS,gCLS_DEVICE_ADDRESS,CLS_CH_STA_HEATBEAT), CLS_BSP_DLC_BYTES_1);
|
||||||
cls_hartbeat_counter++;
|
cls_hartbeat_counter++;
|
||||||
CLS_BSP_CAN_AddMessageToSend(&cls_hartbeat_header, &cls_hartbeat_counter);
|
CLS_BSP_CAN_AddMessageToSend(&cls_hartbeat_header, &cls_hartbeat_counter);
|
||||||
}
|
}
|
||||||
|
|||||||
4
CLS.h
4
CLS.h
@@ -1,9 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define CLS_DEVICE_MASTER 0x11
|
|
||||||
#define CLS_SLAVE_AR(n) n
|
|
||||||
|
|
||||||
#define CLS_DEVICE CLS_DEVICE_MASTER
|
extern uint8_t gCLS_DEVICE_ADDRESS;
|
||||||
|
|
||||||
|
|
||||||
void CLS_Init(void);
|
void CLS_Init(void);
|
||||||
|
|||||||
@@ -17,5 +17,4 @@ target_sources(${PROJECT_NAME}
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Tasks)
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE CLS_BSP)
|
target_link_libraries(${PROJECT_NAME} PRIVATE CLS_BSP)
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
#include "CanDataHandler.h"
|
#include "CanDataHandler.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
#ifndef MAX_DATA_STORAGE
|
||||||
#define MAX_DATA_STORAGE 100
|
#define MAX_DATA_STORAGE 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX_EVENT_STORAGE
|
||||||
#define MAX_EVENT_STORAGE 100
|
#define MAX_EVENT_STORAGE 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX_FILTER_SLOTS
|
||||||
#define MAX_FILTER_SLOTS 100
|
#define MAX_FILTER_SLOTS 100
|
||||||
|
#endif
|
||||||
|
|
||||||
// storage for upto MAX_DATA_STORAGE diffrent messages
|
// storage for upto MAX_DATA_STORAGE diffrent messages
|
||||||
static CanDataMessageSlot CanDataStore[MAX_DATA_STORAGE] = {0};
|
static CanDataMessageSlot CanDataStore[MAX_DATA_STORAGE] = {0};
|
||||||
@@ -76,7 +84,7 @@ CanDataFilterRef CanData_unusedFilterSlot(CanDataSlotFifo reqest_fifo) {
|
|||||||
if (CanFilterSlots[i].free < CANDATA_FULL) {
|
if (CanFilterSlots[i].free < CANDATA_FULL) {
|
||||||
|
|
||||||
// either the fifo settig matches or is undefined
|
// either the fifo settig matches or is undefined
|
||||||
if(CanFilterSlots[i].fifo == reqest_fifo || CanFilterSlots[i].fifo == CANDATA_FIFOX_UNDEFIEND)
|
if(CanFilterSlots[i].fifo == reqest_fifo || CanFilterSlots[i].fifo == CANDATA_FIFOX_UNDEFIEND) {
|
||||||
filterRef.ref = &CanFilterSlots[i];
|
filterRef.ref = &CanFilterSlots[i];
|
||||||
if (CanFilterSlots[i].fifo == CANDATA_FIFOX_UNDEFIEND) {
|
if (CanFilterSlots[i].fifo == CANDATA_FIFOX_UNDEFIEND) {
|
||||||
CanFilterSlots[i].fifo = reqest_fifo;
|
CanFilterSlots[i].fifo = reqest_fifo;
|
||||||
@@ -102,6 +110,8 @@ CanDataFilterRef CanData_unusedFilterSlot(CanDataSlotFifo reqest_fifo) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return filterRef;
|
return filterRef;
|
||||||
}
|
}
|
||||||
@@ -216,7 +226,7 @@ size_t CanData_regDataManualMsg(const CanDataId* canid, size_t id_count, CLS_BSP
|
|||||||
if (!dataSlot) {
|
if (!dataSlot) {
|
||||||
return i; // No unused data slot available
|
return i; // No unused data slot available
|
||||||
}
|
}
|
||||||
|
dataSlot->msg.canid = canid[i];
|
||||||
dataSlot->filter = filterRef;
|
dataSlot->filter = filterRef;
|
||||||
dataSlot->filter.index = -1; // this idecates is a manual filter
|
dataSlot->filter.index = -1; // this idecates is a manual filter
|
||||||
}
|
}
|
||||||
@@ -248,7 +258,7 @@ bool CanData_regEventMsg(CanDataId canid, EventCallback event_callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find and configure an unused slot for the data message
|
// Find and configure an unused slot for the data message
|
||||||
CanDataFilterRef filter = CanData_unusedFilterSlot(CANDATA_FIFO0_DATA);
|
CanDataFilterRef filter = CanData_unusedFilterSlot(CANDATA_FIFO1_EVENT);
|
||||||
if (filter.ref == NULL) {
|
if (filter.ref == NULL) {
|
||||||
return false; // No unused filter slot available
|
return false; // No unused filter slot available
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user