/* * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc. * Copyright 2016-2017 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include "fsl_device_registers.h" #include "fsl_debug_console.h" #include "board.h" #include "pin_mux.h" #include "clock_config.h" #include "cmsis_os.h" /******************************************************************************* * Definitions ******************************************************************************/ #define EXAMPLE_LED_GPIO BOARD_USER_LED_GPIO #define EXAMPLE_LED_GPIO_PIN BOARD_USER_LED_PIN /******************************************************************************* * Prototypes ******************************************************************************/ /******************************************************************************* * Code ******************************************************************************/ #define TASK1_STK_SIZE 512 void task1(void *arg); osThreadDef(task1, osPriorityNormal, 1, TASK1_STK_SIZE); #define TASK2_STK_SIZE 512 void task2(void *arg); osThreadDef(task2, osPriorityNormal, 1, TASK2_STK_SIZE); void task1(void *arg) { /* The PIN status */ static volatile bool g_pinSet = false; int count = 0; while(1) { PRINTF("++++++++This is Task 1, count is %d \r\n",count++); if (g_pinSet) { GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 0U); g_pinSet = false; } else { GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 1U); g_pinSet = true; } /* Delay 1000 ms */ osDelay(1000U); } } void task2(void *arg) { int count = 0; while(1) { PRINTF("********This is Task 2, count is %d \r\n",count++); osDelay(2000U); } } /*! * @brief Main function */ int main(void) { /* Init board hardware. */ BOARD_ConfigMPU(); BOARD_InitPins(); BOARD_InitBootClocks(); BOARD_InitDebugConsole(); PRINTF("Hello world from i.MX RT1050.\r\n"); PRINTF("Welcome to TencentOS tiny\r\n"); osKernelInitialize(); // TencentOS Tiny kernel initialize osThreadCreate(osThread(task1), NULL); // Create task1 osThreadCreate(osThread(task2), NULL); // Create task2 osKernelStart(); // Start TencentOS Tiny return 0; }