当前位置:网站首页>FreeRTOS startup - based on stm32
FreeRTOS startup - based on stm32
2022-06-11 04:08:00 【z_ Curtain】
FreeRTOS Startup process
1、Reset_Handler
The first assembly function executed after the system is powered on , The system initializes through this function
1 Reset_Handler PROC
2 EXPORT Reset_Handler [WEAK]
3 IMPORT __main
4 IMPORT SystemInit
5 LDR R0, =SystemInit
6 BLX R0
7 LDR R0, =__main
8 BX R0
9 ENDP
2、__main
C Library function , This function will be called after system initialization , To carry out C Code
3、main()
main The function is C Language code is the first function to execute , Generally, the creation and startup of the operating system are in main Call in function .
int main(void)
{
BaseType_t xReturn = pdPASS;/* Define a return value for creation information , The default is pdPASS */
/* Hardware initialization of development board */
BSP_Init();
taskENTER_CRITICAL(); // Enter the critical area
/* establish AppTaskCreate Mission */
xReturn = xTaskCreate((TaskFunction_t )AppTaskCreate,/* Task entry function */
(const char* )"AppTaskCreate",/* Task name */
(uint16_t )512, /* Task stack size */
(void* )NULL,/* Task entry function parameters */
(UBaseType_t )1, /* Task priority */
(TaskHandle_t*)&AppTaskCreate_Handle);/* Task control block pointer */
taskEXIT_CRITICAL(); // Exit critical region
/* Start task scheduling */
if (pdPASS == xReturn)
vTaskStartScheduler(); /* Start the task , Turn on scheduling */ (3)
else
return -1;
while (1); /* Normal will not be implemented here */
}
4、 Create tasks
By calling FreeRTOS The task creation function of creates a task , In task creation ,FreeRTOS It will automatically perform a series of operating system initialization , Such as initializing memory .
// Create task function prototype
BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
const char * const pcName,
const uint16_t usStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * const pxCreatedTask )
5、 Start the task
When the task is created , We need to turn on the scheduler , Because creating is just adding tasks to the system , Not really scheduled yet , And idle tasks are not realized , The timer task has not been realized , All of these are starting the scheduling function vTaskStartScheduler() Implemented in .
Why idle tasks ? because FreeRTOS Once started , It is necessary to ensure that a task in the system is running at all times (Runing), And idle tasks cannot be suspended or deleted , Idle tasks have the lowest priority , So that other tasks in the system can preempt idle tasks at any time CPU Right to use .
These are all necessary things for the system , There is no need for users to implement ,FreeRTOS It's all done for us . After handling these necessary things , The system really starts up .
Reference resources
Wildfire FreeRTOS Actual combat of Kernel Implementation and application development
边栏推荐
- Embedded basic interface -spi
- [cnn]| translation invariance
- This artifact is highly recommended. One line command will convert the web page to PDF!
- 域名解析耗时是什么?域名解析耗时影响因素有哪些?
- B - wall painting (C language)
- Market prospect analysis and Research Report of integrated scanner in 2022
- unforgettable moments
- WPF of open source project hero alliance
- 【CustomView】Glide+BitmapTransformation 图片上下边框波浪处理(WaveTransformation)
- Docker builds a redis Cluster - three machines, three masters and three slaves
猜你喜欢

What great open source projects does Google have?

Source insight 4.0 setting shortcut keys for comments and uncomments

Management system of College Students' associations based on SSM

Docker builds a redis Cluster - three machines, three masters and three slaves

Detailed explanation of scenario method for common test case design methods

店铺门面转让出租小程序开发制作功能介绍

Vulkan-官方示例解读-RayTracing

写给通信年轻人的27个忠告

Google 有哪些牛逼的开源项目?

Programming battle -- challenging college entrance examination questions
随机推荐
写给通信年轻人的27个忠告
域名解析耗时是什么?域名解析耗时影响因素有哪些?
[signalr complete series] Net6 Zhongshi signalr communication
Embedded basic interface-i2s
Summary of C language implementation of BP neural network
Market prospect analysis and Research Report of integrated scanner in 2022
app直播源码,平台登录页面实现和修改密码页面实现
Market prospect analysis and Research Report of electronic pelletizing counter in 2022
Pci/pcie related knowledge
A Security Analysis Of Browser Extensions
Host computer development (how to develop host computer)
如何做编程知识投资及减少知识失效的影响
7. 列表标签
图像检测相关模型数据格式
Composition and configuration of GPS Beidou clock synchronization (satellite time synchronization system) in power plant
数据分析师必知必会的统计学知识
ESP8266_ RTOS modifies IP address and hostname in AP mode
Construction of esp8266/esp32 development environment
Build local source 2.0 for Galaxy Kirin server version
A.前缀极差(C语言)