本帖最后由 lemonboard@sina.com 于 2016-10-23 20:41 编辑
实时操作系统对于嵌入式开发来说还是非常有帮助的,也是略有难度的。本帖子楼主将FreeRTOS
移植到了宝马 NXP LPC1768
开发板上,并建立一个任务来闪烁小灯。官方虽然提供了移植示例,但并没有给出在Keil
开发环境下的示例,楼主将工程文件上传,供大家参考。
int main (void)
{
LED_config();
/* Create the simple LED flash task. */
xTaskCreate( LedBlinkTask, "Blink", configMINIMAL_STACK_SIZE, ( void * ) NULL, LED_BLINK_TASK_PRIORITY, NULL );
/* Start the scheduler. */
vTaskStartScheduler();
while(1)
{
;
}
}
static void LedBlinkTask( void *pvParameters)
{
TickType_t xLastDelayTime;
/* We need to initialise xLastFlashTime prior to the first call to
vTaskDelayUntil(). */
xLastDelayTime = xTaskGetTickCount();
LPC_GPIO2->FIOPIN = 0;
for(;;)
{
/* Simply toggle the LED between delays. */
vTaskDelayUntil( &xLastDelayTime, 200 );
LPC_GPIO2->FIOPIN ^= 0x01;
}
}
工程文件可是恢复可见的哟~~
本帖最后由 lemonboard@sina.com 于 2016-10-23 20:41 编辑
实时操作系统对于嵌入式开发来说还是非常有帮助的,也是略有难度的。本帖子楼主将FreeRTOS
移植到了宝马 NXP LPC1768
开发板上,并建立一个任务来闪烁小灯。官方虽然提供了移植示例,但并没有给出在Keil
开发环境下的示例,楼主将工程文件上传,供大家参考。
int main (void)
{
LED_config();
/* Create the simple LED flash task. */
xTaskCreate( LedBlinkTask, "Blink", configMINIMAL_STACK_SIZE, ( void * ) NULL, LED_BLINK_TASK_PRIORITY, NULL );
/* Start the scheduler. */
vTaskStartScheduler();
while(1)
{
;
}
}
static void LedBlinkTask( void *pvParameters)
{
TickType_t xLastDelayTime;
/* We need to initialise xLastFlashTime prior to the first call to
vTaskDelayUntil(). */
xLastDelayTime = xTaskGetTickCount();
LPC_GPIO2->FIOPIN = 0;
for(;;)
{
/* Simply toggle the LED between delays. */
vTaskDelayUntil( &xLastDelayTime, 200 );
LPC_GPIO2->FIOPIN ^= 0x01;
}
}
工程文件可是恢复可见的哟~~