[开发板] 【CW32L031CxTx StartKit评估板测评】移植freertos系统

[复制链接]
 楼主| tlled 发表于 2023-10-27 09:42 | 显示全部楼层 |阅读模式
移植freertos系统到CW32L031CxTx StartKit评估板。
一、添加FreeRTOS系统

在之前创建的项目基础上,增加freertos系统。

1.1、添加系统源码
001.png

1.2、添加到工程文件
002.png

二、编译

添加源码后,编译项目,根据提示的错误,对文件进行修改,遇到的错误如下

2.1、文件重复定义
003.png

修改文件,屏蔽掉相关的函数
004.png
005.png

006.png


2.2、编译项目
007.png

编译完成,没有报错。

三、程序

编写测试程序

main.c
  1. #include "main.h"
  2. #include "led/led.h"
  3. #include "key/key.h"
  4. #include "usart/usart.h"

  5. #include "FreeRTOS.h"
  6. #include "task.h"

  7. typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;

  8. #define START_TASK_PRIO      1                  
  9. #define START_STK_SIZE  64               
  10. static TaskHandle_t            StartTask_Handler = NULL;

  11. #define TASK1_PRIO      2                  
  12. #define TASK1_STK_SIZE  64                 
  13. static TaskHandle_t            Task1Task_Handler = NULL;  
  14.            
  15. #define TASK2_PRIO      3                  
  16. #define TASK2_STK_SIZE  64                 
  17. static TaskHandle_t            Task2Task_Handler = NULL;  

  18. void start_task(void *pvParameters);
  19. void task1(void *pvParameters);  
  20. void task2(void *pvParameters);

  21. void NVIC_Configuration(void);
  22. void RCC_Configuration(void);

  23. int main(void)
  24. {
  25.         RCC_Configuration();
  26.   NVIC_Configuration();
  27.         init_uart(115200);
  28.         init_led();
  29.         init_key();

  30.         printf("cw32l031 board test! \r\n");
  31.        
  32.         xTaskCreate((TaskFunction_t )start_task,                  
  33.                                                         (const char*    )"start_task",               
  34.                                                         (uint16_t       )START_STK_SIZE,         
  35.                                                         (void*          )NULL,                  
  36.                                                         (UBaseType_t    )START_TASK_PRIO,            
  37.                                                         (TaskHandle_t*  )&StartTask_Handler);           
  38.         vTaskStartScheduler();
  39.         return 0;
  40. }


  41. void start_task(void *pvParameters)
  42. {
  43.         taskENTER_CRITICAL();
  44.         xTaskCreate((TaskFunction_t )task1,                  
  45.                                                         (const char*    )"task1",               
  46.                                                         (uint16_t       )TASK1_STK_SIZE,         
  47.                                                         (void*          )NULL,                  
  48.                                                         (UBaseType_t    )TASK1_PRIO,            
  49.                                                         (TaskHandle_t*  )&Task1Task_Handler);
  50.         xTaskCreate((TaskFunction_t )task2,                  
  51.                                                         (const char*    )"task2",               
  52.                                                         (uint16_t       )TASK2_STK_SIZE,        
  53.                                                         (void*          )NULL,                  
  54.                                                         (UBaseType_t    )TASK2_PRIO,            
  55.                                                         (TaskHandle_t*  )&Task2Task_Handler);
  56.                                                        
  57.         vTaskDelete(StartTask_Handler);
  58.         taskEXIT_CRITICAL();
  59. }


  60. //task1
  61. void task1(void *pvParameters)
  62. {
  63.     while (1)
  64.     {
  65.         printf("cw32l031 task1 run ...\r\n");
  66.         led1_tog();
  67.         vTaskDelay(500);
  68.     }
  69. }

  70. //task2
  71. void task2(void *pvParameters)
  72. {
  73.     while (1)
  74.     {       
  75.                                 led2_tog();
  76.         printf("cw32l031 task2 run ...\r\n");
  77.         vTaskDelay(100);
  78.     }
  79. }



四、程序运行

开发板运行后,串口输出
008.png

评论

赞  发表于 2023-10-30 21:45
foliages 发表于 2023-10-28 11:31 | 显示全部楼层
你的这个 是 基于那个型号 移植的 ?移植FreeRTOS ,好搞吗?
foliages 发表于 2023-10-28 11:51 | 显示全部楼层
我 的一个板子,是8K的ram,64K的flash.

可以的话,我也移植一下,玩玩
 楼主| tlled 发表于 2023-10-30 08:25 | 显示全部楼层
foliages 发表于 2023-10-28 11:51
我 的一个板子,是8K的ram,64K的flash.

可以的话,我也移植一下,玩玩

ARM内核是可以的
foliages 发表于 2023-11-2 13:35 | 显示全部楼层
C:\Users\yuwell\Desktop\img
这个图片 怎么没有RTOS?
foliages 发表于 2023-11-2 13:40 | 显示全部楼层
你的第一个图片 中,RTOS 我的KEIL  里面怎么没有?
或者 我怎么做keil 中 才有?
foliages 发表于 2023-11-2 13:41 | 显示全部楼层
freertos_evr.c
port.c
stream_buffer.c

我使用的S FreeRTOS 9. 0  这几个文件 也 没有,
您需要登录后才可以回帖 登录 | 注册

本版积分规则

132

主题

701

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部

132

主题

701

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部