移植FreeRTOS

This commit is contained in:
2026-07-23 19:55:06 +08:00
parent d07f065b1c
commit b803acc521
66 changed files with 48667 additions and 18 deletions
+13 -12
View File
@@ -113,6 +113,7 @@ void DebugMon_Handler(void)
}
}
#if !IS_USE_FREERTOS
/*!
\brief this function handles SVC exception
\param[in] none
@@ -139,6 +140,18 @@ void PendSV_Handler(void)
}
}
/*!
\brief this function handles SysTick exception
\param[in] none
\param[out] none
\retval none
*/
void SysTick_Handler(void)
{
delay_decrement();
}
#endif
/*!
\brief this function handles FPU exception
\param[in] none
@@ -150,15 +163,3 @@ void FPU_IRQHandler(void)
while(1) {
}
}
/*!
\brief this function handles SysTick exception
\param[in] none
\param[out] none
\retval none
*/
void SysTick_Handler(void)
{
delay_decrement();
}
+117 -2
View File
@@ -1,18 +1,79 @@
#include <stdio.h>
/**
* @file main.c
* @author
* @brief
* @version 0.1
* @date 2025-12-05
*
* @copyright Copyright (c) 2025
*
*/
#include <FreeRTOS.h>
#include <queue.h>
#include "gd32h7xx.h"
#include "systick.h"
void cache_enable(void);
void mpu_config(void);
void cache_enable(void);
void mpu_config(void);
///< 主任务配置
#define MAIN_TASK_STACK_SIZE 1024
static StaticTask_t mainTaskTCB;
static StackType_t mainTaskStack[MAIN_TASK_STACK_SIZE];
static void MainTask(void * parameters);
#define EVENT1_TASK_STACK_SIZE 512
static StaticTask_t event1TaskTCB;
static StackType_t event1TaskStack[EVENT1_TASK_STACK_SIZE];
static void Event1Task(void* parameters);
#define EVENT2_TASK_STACK_SIZE 512
static StaticTask_t event2TaskTCB;
static StackType_t event2TaskStack[EVENT2_TASK_STACK_SIZE];
static void Event2Task(void* parameters);
QueueHandle_t xQueue1, xQueue2;
int main()
{
cache_enable();
mpu_config();
systick_config();
// systick_config();
///< 创建主线程
(void)xTaskCreateStatic(MainTask,
"Main",
MAIN_TASK_STACK_SIZE,
NULL,
configMAX_PRIORITIES - 1U,
&( mainTaskStack[ 0 ] ),
&( mainTaskTCB ));
///< 创建事件1线程
(void)xTaskCreateStatic(Event1Task,
"Event1",
EVENT1_TASK_STACK_SIZE,
NULL,
configMAX_PRIORITIES - 5U,
&( event1TaskStack[ 0 ] ),
&( event1TaskTCB ));
///< 创建事件1线程
(void)xTaskCreateStatic(Event2Task,
"Event2",
EVENT2_TASK_STACK_SIZE,
NULL,
configMAX_PRIORITIES - 5U,
&( event2TaskStack[ 0 ] ),
&( event2TaskTCB ));
/* Start the scheduler. */
vTaskStartScheduler();
while (1)
{
@@ -70,3 +131,57 @@ void mpu_config(void)
ARM_MPU_Enable(MPU_MODE_PRIV_DEFAULT);
}
uint32_t ulVar = 10U;
static void MainTask( void * parameters )
{
/* Unused parameters. */
( void ) parameters;
xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
if( xQueue1 == 0 ) {
}
xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
if( xQueue2 == 0 ) {
}
for( ; ; )
{
/* Example Task Code */
if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) {
ulVar++;
}
vTaskDelay( 100 ); /* delay 100 ticks */
/* Example Task Code */
if( xQueueSend( xQueue2, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) {
ulVar++;
}
vTaskDelay( 100 ); /* delay 100 ticks */
}
}
static void Event1Task(void* parameters) {
while(1) {
struct AMessage *pxRxedMessage = NULL;
xQueueReceive(xQueue1, (void*)&pxRxedMessage, (TickType_t) 0);
if(pxRxedMessage != NULL) {
}
}
}
static void Event2Task(void* parameters) {
while(1) {
struct AMessage *pxRxedMessage = NULL;
xQueueReceive(xQueue2, (void*)&pxRxedMessage, (TickType_t) 0);
if(pxRxedMessage != NULL) {
}
}
}