标签:style blog io ar color os 使用 sp for
RTX作为MDK自带的操作系统,比起ucOS使用之前先要做一大堆移植工作,无疑是要简单多了。
#include<main.h> void job1 (voidconst*argument){// thread function ‘job1‘ while(1){ bsp_led_toggle(2); osDelay (200);// delay execution for 10 milliseconds } }
osThreadDef(job1, osPriorityAboveNormal,1,0);// define job1 as thread function
int main(void)
{
osThreadId id_job1;
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, Flash preread and Buffer caches
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Low Level Initialization
*/
HAL_Init();
/* Configure the System clock to have a frequency of 168 MHz */
SystemClock_Config();
bsp_led_init();
osKernelInitialize();
id_job1 = osThreadCreate (osThread(job1),NULL);
osKernelStart();
}
void job1 (voidconst*argument){// thread function ‘job1‘
int*ptr;
ptr =(int*)argument;
while(1){
bsp_led_toggle(*ptr);
osDelay (200);// delay execution for 10 milliseconds
}
}
int main(void)
{
osThreadId id_job1;
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, Flash preread and Buffer caches
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Low Level Initialization
*/
HAL_Init();
/* Configure the System clock to have a frequency of 168 MHz */
SystemClock_Config();
bsp_led_init();
osKernelInitialize();
id_job1 = osThreadCreate (osThread(job1),(void*)&tt1);
id_job1 = osThreadCreate (osThread(job1),(void*)&tt2);
osKernelStart();
}
标签:style blog io ar color os 使用 sp for
原文地址:http://www.cnblogs.com/sprone/p/4f2c78892e70992f29bf0c307dd63ad3.html