Working CAN communication with forwarding to tasks

This commit is contained in:
@CarlWachter 2024-03-08 19:04:28 +01:00
parent 7732fa2823
commit fd7c123a5e
10 changed files with 58 additions and 36 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
635E684B79701B039C64EA45C3F84D30=44DBEC1DE4EBA9B0485911FBE58BFC80 635E684B79701B039C64EA45C3F84D30=44DBEC1DE4EBA9B0485911FBE58BFC80
66BE74F758C12D739921AEA421D593D3=3 66BE74F758C12D739921AEA421D593D3=3
8DF89ED150041C4CBC7CB9A9CAA90856=7B5B92F1162457C6ECACD202698061B0 8DF89ED150041C4CBC7CB9A9CAA90856=7B5B92F1162457C6ECACD202698061B0
DC22A860405A8BF2F2C095E5B6529F12=3C8525AE6BF206AA629BF4979058680C DC22A860405A8BF2F2C095E5B6529F12=7B5B92F1162457C6ECACD202698061B0
eclipse.preferences.version=1 eclipse.preferences.version=1

View File

@ -32,7 +32,7 @@ namespace sta
// ###### Register different threads for different states here. ###### // ###### Register different threads for different states here. ######
// The dummy task runs for state 0. // The dummy task runs for state 0.
Manager::instance()->registerThread(std::make_shared<demo::CanTask>("CAN test", 0x22), {ALL_STATES}); Manager::instance()->registerThread(std::make_shared<demo::CanTask>("CAN test", 0x123), {ALL_STATES});
STA_DEBUG_PRINTF("The answer to everything is %d", 42); STA_DEBUG_PRINTF("The answer to everything is %d", 42);

View File

@ -27,7 +27,7 @@ namespace demo
void CanTask::func() void CanTask::func()
{ {
STA_DEBUG_PRINTLN("Can Task awaiting message"); //STA_DEBUG_PRINTLN("Can Task awaiting message");
if (CAN_queue_.available() > 0) if (CAN_queue_.available() > 0)
{ {
// Receiving message // Receiving message
@ -35,9 +35,16 @@ namespace demo
CAN_queue_.get(&msg); CAN_queue_.get(&msg);
STA_DEBUG_PRINTLN("Can Task received message"); STA_DEBUG_PRINTLN("Can Task received message");
// Sending it back // Sending it back with one changed bit
msg.payload[1] = 3;
msg.header.sid = getCanID();
msg.header.eid = 0;
msg.header.format = 0;
sta::tacos::queueCanBusMsg(msg, 0); sta::tacos::queueCanBusMsg(msg, 0);
STA_DEBUG_PRINTLN("Can Task sent message"); STA_DEBUG_PRINTLN("Can Task sent message");
HAL_Delay(500);
} }
} }
} // namespace demo } // namespace demo

View File

@ -40,7 +40,7 @@
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/> <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/> <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/> <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/> <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/> <booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/> <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/> <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>

View File

@ -11,11 +11,13 @@ CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Presca
CAN1.NART=ENABLE CAN1.NART=ENABLE
CAN1.Prescaler=8 CAN1.Prescaler=8
CAN1.SJW=CAN_SJW_1TQ CAN1.SJW=CAN_SJW_1TQ
FREERTOS.IPParameters=Tasks01,configRECORD_STACK_HIGH_ADDRESS,configTIMER_TASK_PRIORITY,configUSE_NEWLIB_REENTRANT,configTOTAL_HEAP_SIZE FREERTOS.IPParameters=Tasks01,configRECORD_STACK_HIGH_ADDRESS,configTIMER_TASK_PRIORITY,configUSE_NEWLIB_REENTRANT,configTOTAL_HEAP_SIZE,configMINIMAL_STACK_SIZE,configCHECK_FOR_STACK_OVERFLOW
FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL FREERTOS.Tasks01=defaultTask,24,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2
FREERTOS.configMINIMAL_STACK_SIZE=512
FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1 FREERTOS.configRECORD_STACK_HIGH_ADDRESS=1
FREERTOS.configTIMER_TASK_PRIORITY=55 FREERTOS.configTIMER_TASK_PRIORITY=55
FREERTOS.configTOTAL_HEAP_SIZE=20360 FREERTOS.configTOTAL_HEAP_SIZE=30360
FREERTOS.configUSE_NEWLIB_REENTRANT=1 FREERTOS.configUSE_NEWLIB_REENTRANT=1
File.Version=6 File.Version=6
GPIO.groupedBy=Group By Peripherals GPIO.groupedBy=Group By Peripherals

View File

@ -67,13 +67,14 @@
#define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configCPU_CLOCK_HZ ( SystemCoreClock )
#define configTICK_RATE_HZ ((TickType_t)1000) #define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 56 ) #define configMAX_PRIORITIES ( 56 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configMINIMAL_STACK_SIZE ((uint16_t)512)
#define configTOTAL_HEAP_SIZE ((size_t)20360) #define configTOTAL_HEAP_SIZE ((size_t)30360)
#define configMAX_TASK_NAME_LEN ( 16 ) #define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 1 #define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 1 #define configUSE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 8 #define configQUEUE_REGISTRY_SIZE 8
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
@ -92,7 +93,7 @@
#define configUSE_TIMERS 1 #define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( 55 ) #define configTIMER_TASK_PRIORITY ( 55 )
#define configTIMER_QUEUE_LENGTH 10 #define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH 256 #define configTIMER_TASK_STACK_DEPTH 1024
/* The following flag must be enabled only when using newlib */ /* The following flag must be enabled only when using newlib */
#define configUSE_NEWLIB_REENTRANT 1 #define configUSE_NEWLIB_REENTRANT 1

View File

@ -51,7 +51,7 @@ typedef StaticSemaphore_t osStaticMutexDef_t;
osThreadId_t defaultTaskHandle; osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = { const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask", .name = "defaultTask",
.stack_size = 128 * 4, .stack_size = 512 * 4,
.priority = (osPriority_t) osPriorityNormal, .priority = (osPriority_t) osPriorityNormal,
}; };
@ -64,6 +64,18 @@ void StartDefaultTask(void *argument);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
/* Hook prototypes */
void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName);
/* USER CODE BEGIN 4 */
void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName)
{
/* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
called if a stack overflow is detected. */
}
/* USER CODE END 4 */
/** /**
* @brief FreeRTOS initialization * @brief FreeRTOS initialization
* @param None * @param None

@ -1 +1 @@
Subproject commit 7147d6de8308110eace178b11ab88548ca29177a Subproject commit 39024e4a8c53ed19f9313a1d52adff763d06ba75

@ -1 +1 @@
Subproject commit 1925a1668e847e048423499f523f3293ea9d923a Subproject commit a6704f4c45a82cf607907854a0005d6450cb0f06