测试代码以上步骤就已经完成了 FreeRTOS 的集成, 可以使用以下代码检测结果. 对于 Bluepill 板载 LED PC13 的亮灯测试.
需要注意的是, 如果使用了 FreeRTOS, 就不要再调用 SysTick_Config()
方法, 会和 FreeRTOS 冲突.
#include <stm32f10x.h>#include <stm32f10x_gpio.h>#include <stm32f10x_rcc.h>#include "FreeRTOS.h"#include "task.h"#include "queue.h"void vTaskFunction(void *pvParameters){(void)(pvParameters);// Suppress "unused parameter" warningwhile (1){GPIO_ResetBits(GPIOC, GPIO_Pin_13);vTaskDelay(500);GPIO_SetBits(GPIOC, GPIO_Pin_13);vTaskDelay(500);}}void LED_Config(void){// GPIO structure for port initializationGPIO_InitTypeDef GPIO_InitStructure;// enable clock on APB2RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);/* configure port PC13 for driving an LED* Use GPIO_Pin_All if you want to drive the whole port*/GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;// output push-pull modeGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // highest speedGPIO_Init(GPIOC, &GPIO_InitStructure);// initialize port}int main(void){BaseType_t xReturned;/** Don't use Delay_Init(), which conflict with FreeRTOS tick handling*/LED_Config();xReturned = xTaskCreate(vTaskFunction,// Task function point"TaskLED",// Task nameconfigMINIMAL_STACK_SIZE,// Use the minimum stack size, each take 4 bytes(32bit)NULL,// Parameters2,// PriorityNULL);// Task handlerif (xReturned != pdPASS){while (1);}/* Start the scheduler. */vTaskStartScheduler();/* Will only get here if there was not enough heap space to create the idle task. */return 0;}
参考
- 快速上手 https://www.freertos.org/FreeRTOS-quick-start-guide.html
- 如何集成, 需要哪些文件 https://www.freertos.org/Creating-a-new-FreeRTOS-project.html
- FreeRTOS 作者 Richard Barry 的演讲,2013年 https://www.youtube.com/watch?v=1oagM_tEyeA
经验总结扩展阅读
- 如何评价cosplay只要有爱就没问题这种言论
- 长安55csplus暖风怎么使用?
- iphone尺寸大全对照表 苹果6splus屏幕显示多少平方厘米
- 购买苹果6s/Plus的5个理由 iphone6splus还值得买吗
- 详述iPhone6S和6SPlus差异 6s和6splus的区别哪个好
- 苹果iPhone 6S Plus规格 6splus机身尺寸是多少
- 历代iPhone手机发售日期及售价盘点 苹果6splus哪一年上市的
- 苹果手机触屏失灵的解决方法 iPhone6splus屏幕间歇性失灵怎么办
- iPhone 6s Plus 屏幕质量测评 苹果6splus屏幕尺寸多少
- oppor9splus和vivox9plus哪个好?