int main( void ) { // Target board initialisation BoardInitMcu(); LOG_DEBUG("Mcu initialized."); OSA_Init(); LOG_DEBUG("OS initialized."); BoardInitPeriph(); LOG_DEBUG("Peripherals initialized."); // These tasks will not start in BM. s_result = OSA_TaskCreate(task_led_rtos, (uint8_t *) "led_rtos", TASK_LED_RTOS_STACK_SIZE, task_led_rtos_stack, TASK_LED_RTOS_PRIO, (task_param_t) 0, false, &task_led_rtos_task_handler); if ( s_result != kStatus_OSA_Success ) { LOG_ERROR("Failed to create led_rtos task"); } s_result = OSA_TaskCreate(task_fxos_rtos, (uint8_t *) "fxos_rtos", TASK_FXOS_RTOS_STACK_SIZE, task_fxos_rtos_stack, TASK_FXOS_RTOS_PRIO, (task_param_t) 0, false, &task_fxos_rtos_task_handler); if ( s_result != kStatus_OSA_Success ) { LOG_ERROR("Failed to create fxos_rtos task"); } // Print the initial banner LOG_DEBUG("Hello World!\r\n"); OSA_Start(); for ( ;; ) { } // Should not achieve here }
void APP_Start (void) { hardware_init(); /* initialize the hardware */ /* create tasks */ #if USE_SDK_RTOS SDK_CreateTask(); /* create a task with the Kinetis SDK API */ OSA_Start(); #else CreateTask(); /* create a task with the 'traditional' FreeRTOS API */ vTaskStartScheduler(); /* start FreeRTOS scheduler, does usually not return! */ #endif }
/*! * @brief main function */ int main(void) { #if FSL_FEATURE_ADC16_HAS_CALIBRATION adc16_calibration_param_t tempSnseCalibraitionParam; #endif hardware_init(); GPIO_DRV_Init(NULL, ledPins); // Configure the power mode protection SMC_HAL_SetProtection(SMC_BASE_PTR, kAllowPowerModeVlp); ADC16_DRV_StructInitUserConfigDefault(&tempSnseAdcConfig); #if (FSL_FEATURE_ADC16_MAX_RESOLUTION >= 16) tempSnseAdcConfig.resolution = kAdc16ResolutionBitOf16; #endif #if BOARD_ADC_USE_ALT_VREF tempSnseAdcConfig.refVoltSrc = kAdc16RefVoltSrcOfValt; #endif // Init ADC ADC16_DRV_Init(ADC_INSTANCE, &tempSnseAdcConfig); // Calibrate VDD and ADCR_TEMP25 #if FSL_FEATURE_ADC16_HAS_CALIBRATION // Auto calibraion ADC16_DRV_GetAutoCalibrationParam(ADC_INSTANCE, &tempSnseCalibraitionParam); ADC16_DRV_SetCalibrationParam(ADC_INSTANCE, &tempSnseCalibraitionParam); #endif // FSL_FEATURE_ADC16_HAS_CALIBRATION calibrateParams(); // get cpu uid low value for slave gSlaveId = SIM_UIDL_UID(SIM_BASE_PTR); PRINTF("i2c_rtos_slave_bm demo\r\n"); // task list initialize OSA_Init(); // create task(in BM: only the first registered task can be executed) OSA_TaskCreate(task_slave, (uint8_t *)"slave", 512, task_slave_stack, 0, (void *)0, false, &task_slave_task_handler); OSA_Start(); return 0; }
/* main Note: Program entry, do nessary initialization and lanuch scheduler, in baremetal OSA, it simplely call all tasks in sequence */ int main(void) { OSA_Init(); hardware_init(); dbg_uart_init(); comm_init(); audio_init(); usb_init(); OS_Task_create(usb_user_task, NULL, 9L, 3000L, "usb task", NULL); OSA_Start(); return 1; }
int main (void) { OS_ERR err; #if (CPU_CFG_NAME_EN == DEF_ENABLED) CPU_ERR cpu_err; #endif hardware_init(); GPIO_DRV_Init(switchPins, ledPins); #if (CPU_CFG_NAME_EN == DEF_ENABLED) CPU_NameSet((CPU_CHAR *)"MK64FN1M0VMD12", (CPU_ERR *)&cpu_err); #endif OSA_Init(); /* Init uC/OS-III. */ OSSemCreate(&MySem1, /* Create Semaphore 1 */ "sem 1", 0, &err); OSSemCreate(&MySem2, /* Create Semaphore 2 */ "sem 2", 0, &err); INT_SYS_InstallHandler(PORTC_IRQn, SW1_Intr_Handler); // associate ISR with sw1 intr source INT_SYS_InstallHandler(PORTA_IRQn, SW2_Intr_Handler); // associate ISR with sw2 intr source OSTaskCreate(&AppTaskStartTCB, /* Create the start task */ "App Task Start", AppTaskStart, 0u, APP_CFG_TASK_START_PRIO, &AppTaskStartStk[0u], (APP_CFG_TASK_START_STK_SIZE / 10u), APP_CFG_TASK_START_STK_SIZE, 0u, 0u, 0u, (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR | OS_OPT_TASK_SAVE_FP), &err); OSA_Start(); /* Start multitasking (i.e. give control to uC/OS-III). */ while (DEF_ON) { /* Should Never Get Here */ ; } }
int main(void) #endif { hardware_init(); OSA_Init(); dbg_uart_init(); #if !(USE_RTOS) APP_init(); #endif OS_Task_create(Task_Start, NULL, 4L, 3000L, "task_start", NULL); OSA_Start(); #if !defined(FSL_RTOS_MQX) return 1; #endif }
int main (void) { OSA_Init(); /* Initialize clocks, debug console interface and configure required pins */ hardware_init(); /* Disable Memory Protection Unit */ MPU_HAL_Disable(MPU); testPin.pinName = test_pin_name; testPin.config.outputLogic = 0; testPin.config.slewRate = kPortFastSlewRate; testPin.config.driveStrength = kPortHighDriveStrength; testPin.config.isOpenDrainEnabled = false; GPIO_DRV_OutputPinInit(&testPin); // Structure of initialize PIT channel No.0 pit_user_config_t chn0Confg; chn0Confg.isInterruptEnabled = true; chn0Confg.periodUs = 1000000u; // Init pit module and enable run in debug PIT_DRV_Init(BOARD_PIT_INSTANCE, false); // Initialize PIT timer instance for channel 0 and 1 PIT_DRV_InitChannel(BOARD_PIT_INSTANCE, 0, &chn0Confg); // Start channel 0 PRINTF("\n\rStarting channel No.0 ..."); PIT_DRV_StartTimer(BOARD_PIT_INSTANCE, 0); // drv_Mpu9250.Init(); sdCard.Init(1); OSA_TaskCreate((task_t)MainTask, (uint8_t*)"Main Task", 4096, NULL, 2, NULL, true, NULL); //OSA_TaskCreate((task_t)FnetTask, (uint8_t*)"FNET Task", 2048, NULL, 3, NULL, true, NULL); OSA_Start(); // This function will not return while(1); return(0); }
void main(void) #endif #endif { hardware_init(); OSA_Init(); dbg_uart_init(); #if !(USE_RTOS) APP_init(); #endif OS_Task_create(Task_Start, NULL, 4L, 1000L, "task_start", NULL); OSA_Start(); #if (!defined(FSL_RTOS_MQX))&(defined(__CC_ARM) || defined(__GNUC__)) return 1; #endif }
int main (void) { OS_ERR err; #if (CPU_CFG_NAME_EN == DEF_ENABLED) CPU_ERR cpu_err; #endif hardware_init(); GPIO_DRV_Init(switchPins, ledPins); #if (CPU_CFG_NAME_EN == DEF_ENABLED) CPU_NameSet((CPU_CHAR *)"MK64FN1M0VMD12", (CPU_ERR *)&cpu_err); #endif OSA_Init(); /* Init uC/OS-III. */ OSTaskCreate(&AppTaskStartTCB, /* Create the start task */ "App Task Start", AppTaskStart, 0u, APP_CFG_TASK_START_PRIO, &AppTaskStartStk[0u], (APP_CFG_TASK_START_STK_SIZE / 10u), APP_CFG_TASK_START_STK_SIZE, 0u, 0u, 0u, (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR | OS_OPT_TASK_SAVE_FP), &err); OSA_Start(); /* Start multitasking (i.e. give control to uC/OS-III). */ while (DEF_ON) { /* Should Never Get Here */ ; } }
/************************* Configure for MQX************************************/ #if (defined FSL_RTOS_MQX)&&(MQX_COMMON_CONFIG == MQX_LITE_CONFIG) #if MQX_STDIO #error "MQX Lite configuration is designed to work with tool provided STD Library.\ Remove reference to MQX STD library from your build tool project options:\ IAR:\ Linker->Library->aditional_libraries - remove lib_mqx_stdlib.a path \ C/C++ Compiler->Preprocessor->Additional include directories: - remove mqx_stdlib \ \ KEIL: \ Linker->Misc controls - remove lib_mqx_stdlib.lib path \ C/C++->Include Paths - remove mqx_stdlib \ \ KDS: \ C/C++ Build\Settings->Cross ARM C Linker\Miscellaneous - remove lib_mqx_stdlib.a path\ C/C++ Build\Settings->Cross ARM C Compiler\Includes - remove mqx_stdlib (on 4th line)\ \ Atollic: \ C/C++ Build\Settings->C Linker/Libraries->Librarie search path - remove lib_mqx_stdlib \ C/C++ Build\Settings->C Compiler/Directories->Include Paths - remove mqx_stdlib \ CMAKE : \ Remove following lines from CMakeList.txt: \ INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/mqx/lib/twrk22f120m.armgcc/debug/mqx_stdlib) \ INCLUDE_DIRECTORIES(${ProjDirPath}/../../../../../rtos/mqx/lib/twrk22f120m.armgcc/release/mqx_stdlib) \ \ TARGET_LINK_LIBRARIES(lpm_rtos_mqx ${ProjDirPath}/../../../../../rtos/mqx/lib/twrk22f120m.armgcc/debug/mqx_stdlib/lib_mqx_stdlib.a) \ TARGET_LINK_LIBRARIES(lpm_rtos_mqx ${ProjDirPath}/../../../../../rtos/mqx/lib/twrk22f120m.armgcc/release/mqx_stdlib/lib_mqx_stdlib.a) \ ." #endif /* MQX_STDIO */ #elif (defined FSL_RTOS_MQX)&&(MQX_COMMON_CONFIG != MQX_LITE_CONFIG) #define MAIN_TASK 8 void main_task(uint32_t param); const TASK_TEMPLATE_STRUCT MQX_template_list[] = { { MAIN_TASK, main_task, 0xC00, 20, "main_task", MQX_AUTO_START_TASK}, { 0L, 0L, 0L, 0L, 0L, 0L } }; #endif /* (FSL_RTOS_MQX)&&(MQX_COMMON_CONFIG != MQX_LITE_CONFIG) */ /////////////////////////////////////////////////////////////////////////////// // Code /////////////////////////////////////////////////////////////////////////////// #if (defined FSL_RTOS_MQX) && (MQX_COMMON_CONFIG != MQX_LITE_CONFIG) void main_task(uint32_t param) #else /* (FSL_RTOS_MQX) && (MQX_COMMON_CONFIG != MQX_LITE_CONFIG) */ int main(void) #endif /* (FSL_RTOS_MQX) && (MQX_COMMON_CONFIG != MQX_LITE_CONFIG) */ { #if (defined FSL_RTOS_MQX) // In deffault, MQX enables echo flag for stdin. // For power manager demo, disable MQX flag to doesn't echo character. ioctl( 0, IOCTL_NIO_TTY_SET_FLAGS, NIO_TTY_FLAGS_EOL_RN); // 0 - stdin #endif memset(&s_dbgState, 0, sizeof(s_dbgState)); hardware_init(); OSA_Init(); #if (!defined FSL_RTOS_MQX) //init the uart module with base address and config structure g_uartStatePtr[BOARD_DEBUG_UART_INSTANCE] = &s_dbgState; /* Init the interrupt sync object. */ OSA_SemaCreate(&s_dbgState.txIrqSync, 0); OSA_SemaCreate(&s_dbgState.rxIrqSync, 0); NVIC_EnableIRQ(g_uartRxTxIrqId[BOARD_DEBUG_UART_INSTANCE]); #endif // Initializes GPIO driver for LEDs and buttons #if (defined FSL_RTOS_BM) GPIO_DRV_Init(switchPins, 0); #else GPIO_DRV_Init(switchPins, ledPins); #endif NVIC_SetPriority(PM_DBG_UART_IRQn, 6U); NVIC_SetPriority(RTC_IRQn, 6U); NVIC_SetPriority(LPTMR0_IRQn, 6U); NVIC_SetPriority(ADC_IRQ_N, 6U); NVIC_SetPriority(LLWU_IRQn, 6U); #if (defined FSL_RTOS_MQX) OSA_InstallIntHandler(PM_DBG_UART_IRQn, PM_MQX_DBG_UART_IRQ_HANDLER); #endif adc16Init(&adcUserConfig, &adcChnConfig, &adcCalibraitionParam); // Low power manager task. s_result = OSA_TaskCreate(task_lpm, (uint8_t *)"lpm", TASK_LPM_STACK_SIZE, task_lpm_stack, TASK_LPM_PRIO, (task_param_t)0, false, &task_lpm_task_handler); if (s_result != kStatus_OSA_Success) { PRINTF("Failed to create lpm task\r\n"); } // These tasks will not start in BM. #if (!defined FSL_RTOS_BM) s_result = OSA_TaskCreate(task_led_rtos, (uint8_t *)"led_rtos", TASK_LED_RTOS_STACK_SIZE, task_led_rtos_stack, TASK_LED_RTOS_PRIO, (task_param_t)0, false, &task_led_rtos_task_handler); if (s_result != kStatus_OSA_Success) { PRINTF("Failed to create led_rtos task\r\n"); } s_result = OSA_TaskCreate(task_led_clock, (uint8_t *)"led_clock", TASK_LED_CLOCK_STACK_SIZE, task_led_clock_stack, TASK_LED_CLOCK_PRIO, (task_param_t)0, false, &task_led_clock_task_handler); if (s_result != kStatus_OSA_Success) { PRINTF("Failed to create led_clock task\r\n"); } #endif OSA_Start(); for(;;) {} // Should not achieve here }
void ping_init(void) { sys_thread_new("ping_thread", ping_thread, NULL, PING_STACKSIZE, PING_PRIORITY); OSA_Start(); while(1){} }