make libCLS more independen of HW
goal is to reuse libCLS on an diffrent MCU
This commit is contained in:
@@ -1,33 +1,17 @@
|
||||
#include "CLS_BSP.h"
|
||||
#include "CLS.h"
|
||||
#include "CLSAddress.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "fdcan.h"
|
||||
|
||||
osTimerId_t CLS_HeatbeatTimerId; // Timer ID
|
||||
|
||||
|
||||
static uint8_t cls_hartbeat_counter = 0;
|
||||
static FDCAN_TxHeaderTypeDef cls_hartbeat_header = {
|
||||
.IdType = FDCAN_STANDARD_ID,
|
||||
.Identifier = GENERATE_CLS_ADDRESS(CLS_CODE_STATUS,CLS_DEVICE,CLS_CH_STA_HEATBEAT),
|
||||
.TxFrameType = FDCAN_DATA_FRAME,
|
||||
.DataLength = FDCAN_DLC_BYTES_1,
|
||||
.ErrorStateIndicator = FDCAN_ESI_PASSIVE,
|
||||
.BitRateSwitch = FDCAN_BRS_OFF,
|
||||
.FDFormat = FDCAN_CLASSIC_CAN,
|
||||
.TxEventFifoControl = FDCAN_NO_TX_EVENTS,
|
||||
.MessageMarker = 0xCC,
|
||||
};
|
||||
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);
|
||||
|
||||
uint8_t TxData[8];
|
||||
FDCAN_TxHeaderTypeDef TxHeader;
|
||||
|
||||
void CLS_Heatbeat(void *argument) {
|
||||
// Code to be executed every 500ms
|
||||
cls_hartbeat_counter++;
|
||||
if (HAL_FDCAN_GetTxFifoFreeLevel(&hfdcan1) > 1){
|
||||
HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &cls_hartbeat_header, &cls_hartbeat_counter);
|
||||
}
|
||||
CLS_BSP_CAN_AddMessageToSend(&cls_hartbeat_header, &cls_hartbeat_counter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include "fdcan.h"
|
||||
#include "CanDataHandler.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "FreeRTOS.h"
|
||||
@@ -17,7 +16,6 @@ const osThreadAttr_t CLS_FW_Task_attr = {
|
||||
.stack_mem = CLS_FW_Task_stk,
|
||||
.stack_size = sizeof(CLS_FW_Task_stk),
|
||||
.priority = osPriorityNormal,
|
||||
.tz_module = 0U,
|
||||
.reserved = 0U
|
||||
};
|
||||
|
||||
|
||||
@@ -8,11 +8,14 @@ target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/CLS.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/CLSFirmware.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/CanDataHandler.c
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/CLS.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/CLSAddress.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/CLSFirmware.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/CanDataHandler.h
|
||||
)
|
||||
|
||||
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)
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "CanDataHandler.h"
|
||||
#include "fdcan.h"
|
||||
#include "string.h"
|
||||
|
||||
#define MAX_DATA_STORAGE 100
|
||||
@@ -16,17 +15,25 @@ static CanDataEventSlot CanEventStore[MAX_DATA_STORAGE] = {0};
|
||||
static CanDataFilterSlot CanFilterSlots[MAX_FILTER_SLOTS] = {0};
|
||||
|
||||
// this will setup the canfilter accoridng to the settings
|
||||
void setup_StmFdCanFilter(const CanDataFilterSlot* filterSetting ) {
|
||||
void setup_StmCanFilter(const CanDataFilterSlot* filterSetting ) {
|
||||
size_t f_index = filterSetting - CanFilterSlots;// index of the filter in CanFilterSlots
|
||||
|
||||
FDCAN_FilterTypeDef sFilterConfig;
|
||||
sFilterConfig.IdType = FDCAN_STANDARD_ID;
|
||||
sFilterConfig.FilterIndex = f_index;
|
||||
sFilterConfig.FilterType = FDCAN_FILTER_DUAL;
|
||||
sFilterConfig.FilterConfig = filterSetting->fifo;
|
||||
sFilterConfig.FilterID1 = filterSetting->id[0];
|
||||
sFilterConfig.FilterID2 = filterSetting->id[1];
|
||||
HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig);
|
||||
CLS_BSP_CAN_UniversalFilter clsFilterConfig = {
|
||||
.filterIndex = f_index,
|
||||
.filterDestination = filterSetting->fifo,
|
||||
.filterMode = CLS_BSP_CAN_FILTER_LIST,
|
||||
.id0 = filterSetting->id[0],
|
||||
.id1 = filterSetting->id[1],
|
||||
};
|
||||
|
||||
CLS_BSP_CAN_SetUniversalFilter(&clsFilterConfig);
|
||||
}
|
||||
|
||||
// this will setup the canfilter using a custom defined filter
|
||||
void setup_StmCanFilterManual(const CanDataFilterSlot* filterSetting, CLS_BSP_CAN_UniversalFilter * filter ) {
|
||||
size_t f_index = filterSetting - CanFilterSlots;// index of the filter in CanFilterSlots
|
||||
filter->filterIndex = f_index;
|
||||
CLS_BSP_CAN_SetUniversalFilter(filter);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,11 +73,14 @@ CanDataFilterRef CanData_unusedFilterSlot(CanDataSlotFifo reqest_fifo) {
|
||||
|
||||
for (size_t i = 0; i < MAX_FILTER_SLOTS; i++) {
|
||||
// find a slot with free some id
|
||||
if (CanFilterSlots[i].free != CANDATA_FULL) {
|
||||
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 == CANDATA_FIFOX_UNDEFIEND) {
|
||||
CanFilterSlots[i].fifo = reqest_fifo;
|
||||
}
|
||||
|
||||
// Determine the index based on the 'free' field
|
||||
switch (CanFilterSlots[i].free) {
|
||||
@@ -115,7 +125,7 @@ void CanData_clearFilterSlot(CanDataFilterRef filter) {
|
||||
|
||||
|
||||
// finaly write new HW config
|
||||
setup_StmFdCanFilter(filter.ref);
|
||||
setup_StmCanFilter(filter.ref);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +178,7 @@ bool CanData_regDataMsg(CanDataId canid) {
|
||||
filter.ref->id[filter.index] = canid;
|
||||
|
||||
// Set up the filter with the new settings
|
||||
setup_StmFdCanFilter(filter.ref);
|
||||
setup_StmCanFilter(filter.ref);
|
||||
|
||||
|
||||
// Register the data message with the data slot
|
||||
@@ -178,6 +188,42 @@ bool CanData_regDataMsg(CanDataId canid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Function to register a Set of ID for Data Messages using a Manual filter
|
||||
size_t CanData_regDataManualMsg(const CanDataId* canid, size_t id_count, CLS_BSP_CAN_UniversalFilter * filter) {
|
||||
// first check all id to be new
|
||||
for (size_t i = 0; i < id_count; i++) {
|
||||
if(CanData_getDataMessage(canid[i]) != NULL) {
|
||||
return 0; // invalid operation one id is already used
|
||||
}
|
||||
}
|
||||
|
||||
// Find and configure one unused slot for the manual filter
|
||||
CanDataFilterRef filterRef = CanData_unusedFilterSlot(CANDATA_FIFOX_MANUAL);
|
||||
if (filterRef.ref == NULL) {
|
||||
return 0; // No unused filter slot available
|
||||
}
|
||||
|
||||
// setup the manual filters
|
||||
filterRef.ref->fifo = CANDATA_FIFOX_MANUAL;
|
||||
filterRef.ref->free = CANDATA_MANUAL;
|
||||
setup_StmCanFilterManual(filterRef.ref, filter);
|
||||
|
||||
|
||||
for (size_t i = 0; i < id_count; i++) {
|
||||
// Find an unused slot in the data store
|
||||
CanDataMessageSlot *dataSlot = CanData_unusedDataSlot();
|
||||
if (!dataSlot) {
|
||||
return i; // No unused data slot available
|
||||
}
|
||||
|
||||
dataSlot->filter = filterRef;
|
||||
dataSlot->filter.index = -1; // this idecates is a manual filter
|
||||
}
|
||||
|
||||
return id_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a event message with given CanDataId. Returns true if registration is successful, false otherwise.
|
||||
*/
|
||||
@@ -211,7 +257,7 @@ bool CanData_regEventMsg(CanDataId canid, EventCallback event_callback) {
|
||||
filter.ref->id[filter.index] = canid;
|
||||
|
||||
// Set up the filter with the new settings
|
||||
setup_StmFdCanFilter(filter.ref);
|
||||
setup_StmCanFilter(filter.ref);
|
||||
|
||||
// Register the event message with the event slot
|
||||
eventSlot->canid = canid;
|
||||
@@ -22,8 +22,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "fdcan.h"
|
||||
|
||||
#include "CLS_BSP.h"
|
||||
// Define the maximum length of data for a Data Message
|
||||
#define MAX_DATA_LENGTH 8
|
||||
|
||||
@@ -35,17 +34,19 @@ typedef void (*EventCallback)(CanDataId canid, uint8_t* data, uint8_t len);
|
||||
|
||||
// type of fifo that this slot uses
|
||||
typedef enum {
|
||||
CANDATA_FIFOX_UNDEFIEND = FDCAN_FILTER_DISABLE,
|
||||
CANDATA_FIFO0_DATA = FDCAN_FILTER_TO_RXFIFO0,
|
||||
CANDATA_FIFO1_EVENT = FDCAN_FILTER_TO_RXFIFO1,
|
||||
CANDATA_FIFOX_UNDEFIEND = CLS_CAN_FILTER_DISABLE,
|
||||
CANDATA_FIFO0_DATA = CLS_CAN_FILTER_TO_RXFIFO0,
|
||||
CANDATA_FIFO1_EVENT = CLS_CAN_FILTER_TO_RXFIFO1,
|
||||
CANDATA_FIFOX_MANUAL = 0x0f,
|
||||
} CanDataSlotFifo;
|
||||
|
||||
// count of free ids in the slot
|
||||
typedef enum {
|
||||
CANDATA_ALLFREE = 0,
|
||||
CANDATA_FREE1 = 1,
|
||||
CANDATA_FREE0 = 2,
|
||||
CANDATA_FULL = 3,
|
||||
CANDATA_ALLFREE = 0x00,
|
||||
CANDATA_FREE1 = 0x01,
|
||||
CANDATA_FREE0 = 0x02,
|
||||
CANDATA_FULL = 0x03,
|
||||
CANDATA_MANUAL = 0x0f,
|
||||
} CanDataSlotFree;
|
||||
|
||||
// Define s structer for a used filter slot
|
||||
@@ -92,6 +93,9 @@ void CanDataHandler_init(void);
|
||||
// Function to register a CAN ID for Data Messages
|
||||
bool CanData_regDataMsg(CanDataId canid);
|
||||
|
||||
// Function to register a Set of ID for Data Messages using a Manual filter
|
||||
size_t CanData_regDataManualMsg(const CanDataId* canid, size_t id_count, CLS_BSP_CAN_UniversalFilter * filter);
|
||||
|
||||
// Function to register a CAN ID for Event Messages and associate it with a callback function
|
||||
bool CanData_regEventMsg(CanDataId canid, EventCallback event_callback);
|
||||
|
||||
28
Application/CLS_BSP/CLS_BSP.c
Normal file
28
Application/CLS_BSP/CLS_BSP.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "CLS_BSP.h"
|
||||
|
||||
|
||||
#ifdef CLS_BSP_FDCAN
|
||||
|
||||
HAL_StatusTypeDef CLS_BSP_CAN_AddMessageToSend(CLS_BSP_TxHeaderType * header, uint8_t * data) {
|
||||
if (HAL_FDCAN_GetTxFifoFreeLevel(&hfdcan1) > 0) {
|
||||
return HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, header, data);
|
||||
}
|
||||
return HAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
HAL_StatusTypeDef CLS_BSP_CAN_SetUniversalFilter(const CLS_BSP_CAN_UniversalFilter * filter) {
|
||||
FDCAN_FilterTypeDef sFilterConfig;
|
||||
sFilterConfig.IdType = FDCAN_STANDARD_ID;
|
||||
sFilterConfig.FilterIndex = filter->filterIndex;
|
||||
sFilterConfig.FilterType = filter->filterMode;
|
||||
sFilterConfig.FilterConfig = filter->filterDestination;
|
||||
sFilterConfig.FilterID1 = filter->id0;
|
||||
sFilterConfig.FilterID2 = filter->id1;
|
||||
return HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
53
Application/CLS_BSP/CLS_BSP.h
Normal file
53
Application/CLS_BSP/CLS_BSP.h
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
|
||||
#define CLS_BSP_FDCAN
|
||||
|
||||
#ifdef CLS_BSP_FDCAN
|
||||
|
||||
#include "fdcan.h"
|
||||
|
||||
typedef FDCAN_TxHeaderTypeDef CLS_BSP_TxHeaderType;
|
||||
|
||||
#define CREATE_BSP_CAN_HEADER(identifier, datalength) \
|
||||
{ \
|
||||
.IdType = FDCAN_STANDARD_ID, \
|
||||
.Identifier = identifier, \
|
||||
.TxFrameType = FDCAN_DATA_FRAME, \
|
||||
.DataLength = datalength, \
|
||||
.ErrorStateIndicator = FDCAN_ESI_PASSIVE, \
|
||||
.BitRateSwitch = FDCAN_BRS_OFF, \
|
||||
.FDFormat = FDCAN_CLASSIC_CAN, \
|
||||
.TxEventFifoControl = FDCAN_NO_TX_EVENTS, \
|
||||
.MessageMarker = 0xCC, \
|
||||
}
|
||||
|
||||
#define CLS_BSP_DLC_BYTES_1 FDCAN_DLC_BYTES_1
|
||||
#define CLS_BSP_DLC_BYTES_2 FDCAN_DLC_BYTES_2
|
||||
#define CLS_BSP_DLC_BYTES_3 FDCAN_DLC_BYTES_3
|
||||
#define CLS_BSP_DLC_BYTES_4 FDCAN_DLC_BYTES_4
|
||||
#define CLS_BSP_DLC_BYTES_5 FDCAN_DLC_BYTES_5
|
||||
#define CLS_BSP_DLC_BYTES_6 FDCAN_DLC_BYTES_6
|
||||
#define CLS_BSP_DLC_BYTES_7 FDCAN_DLC_BYTES_7
|
||||
#define CLS_BSP_DLC_BYTES_8 FDCAN_DLC_BYTES_8
|
||||
|
||||
#define CLS_CAN_FILTER_DISABLE FDCAN_FILTER_DISABLE
|
||||
#define CLS_CAN_FILTER_TO_RXFIFO0 FDCAN_FILTER_TO_RXFIFO0
|
||||
#define CLS_CAN_FILTER_TO_RXFIFO1 FDCAN_FILTER_TO_RXFIFO1
|
||||
|
||||
#define CLS_BSP_CAN_FILTER_LIST FDCAN_FILTER_DUAL
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t filterIndex;
|
||||
uint32_t filterDestination;
|
||||
uint32_t filterMode;
|
||||
uint16_t id0;
|
||||
uint16_t id1;
|
||||
} CLS_BSP_CAN_UniversalFilter;
|
||||
|
||||
|
||||
HAL_StatusTypeDef CLS_BSP_CAN_AddMessageToSend(CLS_BSP_TxHeaderType * header, uint8_t * data);
|
||||
|
||||
HAL_StatusTypeDef CLS_BSP_CAN_SetUniversalFilter(const CLS_BSP_CAN_UniversalFilter * filter);
|
||||
14
Application/CLS_BSP/CMakeLists.txt
Normal file
14
Application/CLS_BSP/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
project(CLS_BSP C)
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC "")
|
||||
|
||||
target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/CLS_BSP.c
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/CLS_BSP.h
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||
@@ -1,2 +1,3 @@
|
||||
add_subdirectory(Tasks)
|
||||
add_subdirectory(CLS_BSP)
|
||||
add_subdirectory(CLS)
|
||||
@@ -7,15 +7,14 @@ add_library(${PROJECT_NAME} STATIC "")
|
||||
target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/UsbDataHandler.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/CanDataHandler.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/CanDataTask.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/FirmwareHandler.c
|
||||
INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/UsbDataHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/CanDataHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/CanDataTask.h
|
||||
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC PROTOS)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC PROTOS CLS)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE CLS_BSP)
|
||||
@@ -23,8 +23,6 @@ const osThreadAttr_t CanDataTask_attr = {
|
||||
.stack_mem = CanDataTask_stk,
|
||||
.stack_size = sizeof(CanDataTask_stk),
|
||||
.priority = osPriorityNormal,
|
||||
.tz_module = 0U,
|
||||
.reserved = 0U
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ include_directories(${PROJECT_BINARY_DIR})
|
||||
add_executable(${CMAKE_PROJECT_NAME})
|
||||
target_sources(${CMAKE_PROJECT_NAME} PUBLIC ${sources_SRCS})
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Tasks CLS)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Tasks CLS CLS_BSP)
|
||||
#target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC PROTOS)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC uart_driver)
|
||||
#target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC lwrb)
|
||||
|
||||
@@ -30,8 +30,14 @@ add_library(PROTOS ${PROTO_SRCS} ${PROTO_HDRS})
|
||||
target_include_directories(PROTOS PUBLIC ${NANOPB_INCLUDE_DIRS} ${PROJECT_BINARY_DIR})
|
||||
include_directories(${PROJECT_BINARY_DIR})
|
||||
|
||||
|
||||
add_library(CLS_BSP mock_os/CLS_BSP.c)
|
||||
target_include_directories(CLS_BSP PUBLIC
|
||||
./
|
||||
../lib/Unity/src
|
||||
)
|
||||
|
||||
add_subdirectory(../../Application/Tasks Tasks)
|
||||
add_subdirectory(../../Application/CLS CLS)
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Tasks)
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Tasks CLS)
|
||||
@@ -202,6 +202,40 @@ void test_CanData_removeEvent() {
|
||||
}
|
||||
|
||||
|
||||
void test_CanData_regDataManualMsg(void) {
|
||||
CanDataHandler_init(); // Reset the state of the module
|
||||
|
||||
{
|
||||
CanDataId canids[] = {1, 2, 3};
|
||||
size_t id_count = sizeof(canids) / sizeof(canids[0]);
|
||||
CLS_BSP_CAN_UniversalFilter filter = {
|
||||
.filterDestination = CLS_CAN_FILTER_TO_RXFIFO0,
|
||||
.filterMode = 0xff,
|
||||
.id0 = 0x7ff,
|
||||
.id1 = 0x003,
|
||||
};
|
||||
|
||||
size_t result = CanData_regDataManualMsg(canids, id_count, &filter);
|
||||
TEST_ASSERT_EQUAL(id_count, result);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
CanDataId canids[] = {4, 5, 7};
|
||||
size_t id_count = sizeof(canids) / sizeof(canids[0]);
|
||||
CLS_BSP_CAN_UniversalFilter filter = {
|
||||
.filterDestination = CLS_CAN_FILTER_TO_RXFIFO0,
|
||||
.filterMode = 0xf8,
|
||||
.id0 = 0x777,
|
||||
.id1 = 0x073,
|
||||
};
|
||||
|
||||
size_t result = CanData_regDataManualMsg(canids, id_count, &filter);
|
||||
|
||||
TEST_ASSERT_EQUAL(id_count, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Create a test runner function
|
||||
@@ -217,4 +251,5 @@ void test_CanData(void) {
|
||||
RUN_TEST(test_CanData_canFifo0RxCallback_data_invalid);
|
||||
RUN_TEST(test_CanData_canFifo1RxCallback_data_valid);
|
||||
RUN_TEST(test_CanData_removeEvent);
|
||||
RUN_TEST(test_CanData_regDataManualMsg);
|
||||
}
|
||||
|
||||
10
tests/native/mock_os/CLS_BSP.c
Normal file
10
tests/native/mock_os/CLS_BSP.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "CLS_BSP.h"
|
||||
#include "stdio.h"
|
||||
|
||||
HAL_StatusTypeDef CLS_BSP_CAN_AddMessageToSend(CLS_BSP_TxHeaderType * header, uint8_t * data) {
|
||||
printf("CAN: %x : %x %x %x %x %x %x %x %x \n", header, data[0], data[1], data[2], data[3], data[4], data[5], data[6],data[7]);
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef CLS_BSP_CAN_SetUniversalFilter(const CLS_BSP_CAN_UniversalFilter * filter) {
|
||||
printf("FILTER: %x : %x %x : %x %x \n", filter->filterIndex, filter->filterDestination, filter->filterMode,filter->id0, filter->id1);
|
||||
}
|
||||
35
tests/native/mock_os/CLS_BSP.h
Normal file
35
tests/native/mock_os/CLS_BSP.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "stdint.h"
|
||||
|
||||
typedef uint16_t CLS_BSP_TxHeaderType;
|
||||
|
||||
typedef unsigned int HAL_StatusTypeDef;
|
||||
|
||||
typedef struct {
|
||||
uint32_t filterIndex;
|
||||
uint32_t filterDestination;
|
||||
uint32_t filterMode;
|
||||
uint16_t id0;
|
||||
uint16_t id1;
|
||||
} CLS_BSP_CAN_UniversalFilter;
|
||||
|
||||
#define CLS_BSP_DLC_BYTES_1 1
|
||||
#define CLS_BSP_DLC_BYTES_2 2
|
||||
#define CLS_BSP_DLC_BYTES_3 3
|
||||
#define CLS_BSP_DLC_BYTES_4 4
|
||||
#define CLS_BSP_DLC_BYTES_5 5
|
||||
#define CLS_BSP_DLC_BYTES_6 6
|
||||
#define CLS_BSP_DLC_BYTES_7 7
|
||||
#define CLS_BSP_DLC_BYTES_8 8
|
||||
|
||||
#define CLS_CAN_FILTER_DISABLE 0
|
||||
#define CLS_CAN_FILTER_TO_RXFIFO0 2
|
||||
#define CLS_CAN_FILTER_TO_RXFIFO1 3
|
||||
|
||||
#define CLS_BSP_CAN_FILTER_LIST 1
|
||||
|
||||
|
||||
#define CREATE_BSP_CAN_HEADER(identifier, datalength) 0
|
||||
|
||||
HAL_StatusTypeDef CLS_BSP_CAN_AddMessageToSend(CLS_BSP_TxHeaderType * header, uint8_t * data);
|
||||
|
||||
HAL_StatusTypeDef CLS_BSP_CAN_SetUniversalFilter(const CLS_BSP_CAN_UniversalFilter * filter);
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "stdint.h"
|
||||
|
||||
#include "stddef.h"
|
||||
#define osWaitForever 0xFFFFFFFFU ///< Wait forever timeout value.
|
||||
|
||||
/// Status code values returned by CMSIS-RTOS functions.
|
||||
@@ -96,15 +96,47 @@ typedef struct {
|
||||
} osMessageQueueAttr_t;
|
||||
|
||||
|
||||
/// Attributes structure for timer.
|
||||
typedef struct {
|
||||
const char *name; ///< name of the timer
|
||||
uint32_t attr_bits; ///< attribute bits
|
||||
void *cb_mem; ///< memory for control block
|
||||
uint32_t cb_size; ///< size of provided memory for control block
|
||||
} osTimerAttr_t;
|
||||
|
||||
|
||||
/// Timer callback function.
|
||||
typedef void (*osTimerFunc_t) (void *argument);
|
||||
|
||||
typedef void (*osThreadFunc_t) (void *argument);
|
||||
typedef void* osMessageQueueId_t;
|
||||
typedef void* osThreadId_t;
|
||||
typedef void* osTimerId_t;
|
||||
void Error_Handler();
|
||||
|
||||
|
||||
/// Timer type.
|
||||
typedef enum {
|
||||
osTimerOnce = 0, ///< One-shot timer.
|
||||
osTimerPeriodic = 1 ///< Repeating timer.
|
||||
} osTimerType_t;
|
||||
|
||||
// Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait).
|
||||
#define osFlagsWaitAny 0x00000000U ///< Wait for any flag (default).
|
||||
#define osFlagsWaitAll 0x00000001U ///< Wait for all flags.
|
||||
#define osFlagsNoClear 0x00000002U ///< Do not clear flags which have been specified to wait for.
|
||||
|
||||
|
||||
osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
|
||||
osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout);
|
||||
osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout);
|
||||
osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr) ;
|
||||
osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr);
|
||||
osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks);
|
||||
|
||||
uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout);
|
||||
uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags);
|
||||
void osThreadExit (void);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1714,3 +1714,12 @@ do{ \
|
||||
|
||||
|
||||
HAL_StatusTypeDef HAL_FDCAN_ConfigFilter(FDCAN_HandleTypeDef *hfdcan, FDCAN_FilterTypeDef *sFilterConfig);
|
||||
uint32_t HAL_FDCAN_GetRxFifoFillLevel(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo);
|
||||
uint32_t HAL_FDCAN_GetTxFifoFreeLevel(FDCAN_HandleTypeDef *hfdcan);
|
||||
HAL_StatusTypeDef HAL_FDCAN_GetRxMessage(FDCAN_HandleTypeDef *hfdcan, uint32_t RxLocation, FDCAN_RxHeaderTypeDef *pRxHeader, uint8_t *pRxData);
|
||||
HAL_StatusTypeDef HAL_FDCAN_ConfigGlobalFilter(FDCAN_HandleTypeDef *hfdcan, uint32_t NonMatchingStd, uint32_t NonMatchingExt, uint32_t RejectRemoteStd, uint32_t RejectRemoteExt);
|
||||
HAL_StatusTypeDef HAL_FDCAN_Start(FDCAN_HandleTypeDef *hfdcan);
|
||||
|
||||
|
||||
#define HAL_OK 0
|
||||
#define HAL_ERROR 1
|
||||
|
||||
Reference in New Issue
Block a user