代码:
- #include "at32l021_board.h"
- #include "at32l021_clock.h"
- #include "FreeRTOS.h"
- #include "task.h"
- /** @addtogroup UTILITIES_examples
- * @{
- */
- static const char *pcTextForTask1="Task 1 is running\r\n";
- static const char *pcTextForTask2="Task 2 is running\r\n";
- /** @addtogroup FreeRTOS_demo
- * @{
- */
- /* led2 task function */
- void vTaskFunction(void *pvParameters)
- {
- char *pcTaskName;
- pcTaskName=(char * )pvParameters;
- while(1)
- {
- printf("%s\r\n",pcTaskName);
- vTaskDelay(1000);
- }
- }
- //void vTask1(void *pvParameters);
- //void vTask2(void *pvParameters);
- /**
- * [url=home.php?mod=space&uid=247401]@brief[/url] main function.
- * @param none
- * @retval none
- */
- int main(void)
- {
- system_clock_config();
- /* init led2 and led3 */
- at32_led_init(LED2);
- at32_led_init(LED3);
- /* init usart1 */
- uart_print_init(115200);
- /* enter critical */
- taskENTER_CRITICAL();
- /* create led2 task */
- xTaskCreate((TaskFunction_t )vTaskFunction,
- (const char* )"vTask1",
- (uint16_t )512,
- (void* )pcTextForTask1,
- (UBaseType_t )1,
- (TaskHandle_t* )NULL);
-
- /* create led3 task */
- xTaskCreate((TaskFunction_t )vTaskFunction,
- (const char* )"vTask2",
- (uint16_t )512,
- (void* )pcTextForTask2,
- (UBaseType_t )2,
- (TaskHandle_t* )NULL) ;
-
- /* exit critical */
- taskEXIT_CRITICAL();
- /* start scheduler */
- vTaskStartScheduler();
- }
运行效果:
|