/********************************************************************* * * OS_InitHW() * * Initialize the hardware (timer) required for the OS to run. * May be modified, if an other timer should be used */ void OS_InitHW(void) { OS_IncDI(); // // We assume, the PLL and core clock was already set by the SystemInit() function // which was called from the startup code // Therefore, we don't have to initailize any hardware here, // we just ensure that the system clock variable is updated and then // set the periodic system timer tick for embOS. // SystemCoreClockUpdate(); // Update the system clock variable (might not have been set before) if (SysTick_Config (OS_PCLK_TIMER / OS_TICK_FREQ)) { // Setup SysTick Timer for 1 msec interrupts while (1); // Handle Error } // // Initialize NVIC vector base address. Might be necessary for RAM targets or application not running from 0 // NVIC_VTOR = (OS_U32)&__Vectors; // // Set the interrupt priority for the system timer to 2nd lowest level to ensure the timer can preempt PendSV handler // NVIC_SetPriority(SysTick_IRQn, (1u << __NVIC_PRIO_BITS) - 2u); OS_COM_INIT(); OS_DecRI(); }
int main(void) { OS_IncDI(); /* Initially disable interrupts */ OS_InitKern(); /* Initialize OS */ OS_InitHW(); /* Initialize Hardware for OS */ OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP); OS_Start(); /* Start multitasking */ return 0; }
int main(void) { WDTCTL = WDTPW + WDTHOLD ; Init_CLK() ; Init_J60SPI() ; MAIN_POWER_ON ; __delay_cycles(5000000) ; P9DIR |= IrDA_OUT ; P9OUT &=~IrDA_OUT ; Init_EtherNet() ; ENC_SLEEP() ; // 省电 OS_IncDI() ; // 屏蔽中断 OS_InitKern() ; // 初始化系统内核 OS_InitHW() ; // 初始化硬件 Init_Func() ; Init_UART() ; Init_RSUART() ; Ini_LED(8) ; Init_ADC() ; Init_RTC() ; LCD_Init() ; LED_POWER_ON ; BackLight() ; OS_CREATERSEMA(&SemaLCD) ; OS_CREATERSEMA(&SemaSPI) ; LED_Disp_Float(3.1415925,7,FIT_ZERO) ; LED_Flicker_Digit(8,1) ; Color = Black ; Color_BK = 0xEF9F ; OS_CREATETASK(&Seg7LED_TASK_TCB, "Seg7LedTask", Seg7LedRefresh, 100, Seg7LED_TASK_STACK ) ; OS_CREATETASK(&LCD_TASK_TCB, "LCD_Task", LCD_Task, 100, LCD_TASK_STACK ) ; OS_CREATETASK(&MENU_OP_TASK_TCB, "MENU_OP_Task", MENU_OP_Task, 100, MENU_OP_TASK_STACK) ; OS_CREATETASK(&KEY_TP_TASK_TCB, "KEY_TP_Task", Key_TP_Task, 100, KEY_TP_TASK_STACK ) ; OS_Start() ; return 0 ; }
void OS_InitHW(void) { OS_IncDI(); OS_ARM_CACHE_Sync(); // Ensure, caches are synchronized /* Initialize PIT as OS timer, enable timer + timer interrupt */ PIT_MR = ((OS_TIMER_RELOAD & 0x000FFFFF) | (1uL << 25) | (1uL << 24)); OS_ARM_InstallISRHandler(SYSTEM_IRQ_ID, _OS_SystemIrqhandler); OS_ARM_EnableISR(SYSTEM_IRQ_ID); OS_COM_Init(); OS_DecRI(); }
int main(void) { OS_IncDI(); /* Disable interrupts */ OS_InitKern(); /* Initialize OS */ OS_InitHW(); /* Initialize Hardware */ BSP_Init(); /* Initialize LED ports */ /* You need to create at least one task before calling OS_Start() */ OS_CREATETASK(&WLFTASK, "Tests task", wolfTask, 100, WLFSTACK); OS_Start(); /* Start the OS */ return 0; }
/********************************************************************* * * main */ int main(void) { OS_IncDI(); // Initially disable interrupts OS_InitKern(); // Initialize OS OS_InitHW(); // Initialize Hardware for OS BSP_Init(); // Initialize LED ports OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP); OS_CREATETASK(&TCBLP, "LP Task", LPTask, 99, StackLP); OS_Start(); // Start multitasking return 0; }
/********************************************************************* * * main */ int main(void) { OS_IncDI(); /* Initially disable interrupts */ OS_InitKern(); /* Initialize OS */ OS_InitHW(); /* Initialize Hardware for OS */ /* You need to create at least one task here ! */ OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP); OS_CREATETASK(&TCBLP, "LP Task", LPTask, 50, StackLP); OS_Start(); /* Start multitasking */ return 0; }
/********************************************************************* * * main * *********************************************************************/ int main(void) { OS_IncDI(); /* Initially disable interrupts */ OS_InitKern(); /* Initialize OS */ OS_InitHW(); /* Initialize Hardware for OS */ _start_kernel(0); OS_Start(); /* Start multitasking */ return 0; }
void osInitKernel(void) { //Initialize tables memset(tcbTable, 0, sizeof(tcbTable)); memset(stkTable, 0, sizeof(stkTable)); //Disable interrupts OS_IncDI(); //Kernel initialization OS_InitKern(); //Hardware initialization OS_InitHW(); }
int main(void) { OS_IncDI(); /* Initially disable interrupts */ OS_InitKern(); /* Initialize OS */ OS_InitHW(); /* Initialize Hardware for OS */ OS_Q_Create(&_MyQ, &_MyQBuffer, sizeof(_MyQBuffer)); /* You need to create at least one task before calling OS_Start() */ OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP); OS_CREATETASK(&TCBLP, "LP Task", LPTask, 50, StackLP); OS_DecRI(); /* Enable interrupts before sending */ OS_SendString("embOS OS_Q example"); OS_SendString("\n\nDemonstrating message passing\n"); OS_Start(); /* Start multitasking */ return 0; }
int main(void) { //remove to enable for detection of m16cs1. use interrupt. OS_IncDI(); /* Initially disable interrupts */ //initialize OS OS_InitKern(); //initialize Hardware for OS OS_InitHW(); //Start lepton kernel _start_kernel(0); OS_Start(); /* Start multitasking */ return 0; }
/********************************************************************* * * IP_OS_DisableInterrupt */ void IP_OS_DisableInterrupt(void) { OS_IncDI(); }
/********************************************************** * * USB_OS_IncDI * * Function description * Increment interrupt disable count and disable interrupts */ void USB_OS_IncDI(void) { OS_IncDI(); }
extern "C" void DisplayMainTask(void) { int start_task_time, end_task_time, task_time_diff; #ifndef __PC__ int i; for (i = 4*INITIAL_BACKLIGHT; i > 0; i -= 4) { SetDutyCycleHW_1(i); GUI_Delay(1); } #endif #ifdef __PC__ // Kill the rest of the system running on PC HWND main_wnd_handle = PcDevToolService::GetInstance()->GetControllerWindow(); if(main_wnd_handle) { ShowWindow(main_wnd_handle, SW_SHOWNORMAL); } #endif // __PC__ while (display_running) { start_task_time = OS_GetTime(); mpc::display::DisplayController::GetInstance()->Run(); GUI_Delay(5); #ifdef __PC__ if( HasOSMessage() ) { OS_EnterRegion(); OS_IncDI(); OSMessage* msg; // Get message from queue without removing it. msg = PeekOSMessage(); switch(msg->message) { case 0: break; case OSMSG_LOAD_DISPLAY: msg->rc = PcDevToolService::GetInstance()->LoadDisplay((const char*)(msg->data)); break; case OSMSG_LOAD_DISPLAY_ID: msg->rc = PcDevToolService::GetInstance()->LoadDisplay(*(int*)(msg->data)); break; case OSMSG_SET_LANGUAGE: Languages::GetInstance()->SetLanguage(*((LANGUAGE_TYPE*)msg->data)); msg->rc = 0; break; case OSMSG_GET_LANGUAGE: msg->rc = Languages::GetInstance()->GetLanguage(); break; case OSMSG_DUMP_SCREEN: mpc::display::DisplayDumper::GetInstance()->DumpScreen(false); msg->rc = 0; break; case OSMSG_DUMP_SCREENS: mpc::display::DisplayDumper::GetInstance()->DumpScreens(true, false); msg->rc = 0; break; case OSMSG_SET_SUBJECT_VALUE: msg->rc = PcDevToolService::GetInstance()->SetSubjectValue( ((SubjectValueParameters*)msg->data) ); break; case OSMSG_GET_SUBJECT_VALUE_AS_FLOAT: msg->rc = PcDevToolService::GetInstance()->GetSubjectValue( ((SubjectValueParameters*)msg->data) ); break; case OSMSG_SET_SUBJECT_QUALITY: msg->rc = PcDevToolService::GetInstance()->SetSubjectQuality( ((QualityParameters*)msg->data) ); break; case OSMSG_SET_DI_VALUE: msg->rc = PcSimulatorService::GetInstance()->SetDiValue( ((DiParameters*)msg->data) ); break; case OSMSG_SET_AI_VALUE_PERCENT: msg->rc = PcSimulatorService::GetInstance()->SetAiValueInPercent( ((AiParameters*)msg->data) ); break; case OSMSG_SET_AI_VALUE_INTERNAL: msg->rc = PcSimulatorService::GetInstance()->SetAiValueInInternalUnit( ((AiParameters*)msg->data) ); break; case OSMSG_SELECT_LISTVIEW_ITEM_BY_INDEX: msg->rc = PcDevToolService::GetInstance()->SelectListViewItem(*(int*)(msg->data)); break; case OSMSG_KEY_PRESS: GUI_StoreKey(*(int*)(msg->data)); msg->rc = 0; break; case OSMSG_SET_ERROR_PRESENT: msg->rc = PcSimulatorService::GetInstance()->SimulateAlarm( ((AlarmParameters*)msg->data) ); break; case OSMSG_EXPORT_STRING_LENGTHS: mpc::display::StringWidthCalculator::GetInstance()->ExportStringWidths((const char*)(msg->data)); msg->rc = 0; break; case OSMSG_EXPORT_STRING_LENGTHS_ADV: mpc::display::StringWidthCalculator::GetInstance()->ExportStringWidthsAdv(((mpc::display::StringWidthParameters*)(msg->data))); msg->rc = 0; break; case OSMSG_SET_IO111_VALUES: msg->rc = PcSimulatorService::GetInstance()->SetIO111Values( ((Io111Parameters*)msg->data) ); break; default: msg->rc = -1; break; } // Remove message from queue DisposeOSMessage(); OS_DecRI(); OS_LeaveRegion(); OS_Delay(1); } #endif //__PC__ // calculate time to wait end_task_time = OS_GetTime(); task_time_diff = end_task_time - start_task_time; if( task_time_diff <= 1 ) OS_WaitSingleEventTimed( POWER_DOWN_EVENT, DISPLAY_SAMPLE_TIME ); // We will skip ... else if ( task_time_diff > (DISPLAY_SAMPLE_TIME-1) ) OS_WaitSingleEventTimed( POWER_DOWN_EVENT, 1 ); // Run again, now else OS_WaitSingleEventTimed( POWER_DOWN_EVENT, DISPLAY_SAMPLE_TIME - task_time_diff ); } #ifndef __PC__ LCDPowerDown(); // TODO: Check the for-loops !! It takes a lot of time #endif SignalEventToPowerDown(DISPLAY_POWERED_DOWN_EVENT); #ifndef __PC__ while (1) // We will die anyway { GUI_Delay(1000); } #endif }