L4 adaptaions

This commit is contained in:
2024-02-05 22:34:44 +01:00
parent 23eef2d46c
commit 22e79f75e9
4 changed files with 16 additions and 10 deletions

3
CLS.c
View File

@@ -5,11 +5,10 @@
osTimerId_t CLS_HeatbeatTimerId; // Timer ID
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) {
// 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_BSP_CAN_AddMessageToSend(&cls_hartbeat_header, &cls_hartbeat_counter);
}

4
CLS.h
View File

@@ -1,9 +1,7 @@
#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);

View File

@@ -17,5 +17,4 @@ target_sources(${PROJECT_NAME}
)
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)

View File

@@ -1,9 +1,17 @@
#include "CanDataHandler.h"
#include "string.h"
#ifndef MAX_DATA_STORAGE
#define MAX_DATA_STORAGE 100
#endif
#ifndef MAX_EVENT_STORAGE
#define MAX_EVENT_STORAGE 100
#endif
#ifndef MAX_FILTER_SLOTS
#define MAX_FILTER_SLOTS 100
#endif
// storage for upto MAX_DATA_STORAGE diffrent messages
static CanDataMessageSlot CanDataStore[MAX_DATA_STORAGE] = {0};
@@ -76,8 +84,8 @@ CanDataFilterRef CanData_unusedFilterSlot(CanDataSlotFifo reqest_fifo) {
if (CanFilterSlots[i].free < CANDATA_FULL) {
// either the fifo settig matches or is undefined
if(CanFilterSlots[i].fifo == reqest_fifo || CanFilterSlots[i].fifo == CANDATA_FIFOX_UNDEFIEND)
filterRef.ref = &CanFilterSlots[i];
if(CanFilterSlots[i].fifo == reqest_fifo || CanFilterSlots[i].fifo == CANDATA_FIFOX_UNDEFIEND) {
filterRef.ref = &CanFilterSlots[i];
if (CanFilterSlots[i].fifo == CANDATA_FIFOX_UNDEFIEND) {
CanFilterSlots[i].fifo = reqest_fifo;
}
@@ -101,6 +109,8 @@ CanDataFilterRef CanData_unusedFilterSlot(CanDataSlotFifo reqest_fifo) {
}
break;
}
}
}
return filterRef;
@@ -216,7 +226,7 @@ size_t CanData_regDataManualMsg(const CanDataId* canid, size_t id_count, CLS_BSP
if (!dataSlot) {
return i; // No unused data slot available
}
dataSlot->msg.canid = canid[i];
dataSlot->filter = filterRef;
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
CanDataFilterRef filter = CanData_unusedFilterSlot(CANDATA_FIFO0_DATA);
CanDataFilterRef filter = CanData_unusedFilterSlot(CANDATA_FIFO1_EVENT);
if (filter.ref == NULL) {
return false; // No unused filter slot available
}