//====== MAIN Function ========================================================= int main(void) { Task_Init(); Task_Main(); return 0; }
VOID IpuToDsp_Init(IpuToDsp *pThis) { pIpuToDsp = pThis; // Backup pointer used in the doorbell callbacl Signal_Init(&pThis->SigL2PakRcv, "DBSigL2PakRcv"); memset((VOID *)0x85310080, 0x00, sizeof(DUC_PakFrmIPU)); memset(DUC_PakFrmIPU, 0x00, sizeof(DUC_PakFrmIPU)); pThis->pL1TxC1 = &oL1TxC1; pThis->pL1TxC2 = &oL1TxC2; pThis->pL2PakBaseAddr = DUC_PakFrmIPU; ICoreQ_Init(pThis->pL1TxC1, (CHAR *)"L1_IPU_DSP_C1Q", gHeapMem[SEG_ICOREQ_BURST_TO_FPGA_ID].nElements, HSEM_L2PACKET_C1, // Lock for guarding C0 - C1 LINK_C1_L1TRANSMITTER_C0); /* ICoreQ_Init2(pThis->pL1TxC2, // Common ITaskQ for request from C1 and C2. pThis->pL1TxC1, HSEM_L2PACKET_C2, // Lock for guarding C0 - C2 LINK_C2_L1TRANSMITTER_C0);*/ Task_Init(&pThis->IPURx_Tsk, "IPU_Rx_Task", IpuToDsp_Task, pThis); IpuToDsp_Initialized = TRUE; pThis->lL2PakBufferSize = MAX_DUCTX_PAK_BLOCKS; }
/********************************************************************* ** @fn : ** ** @brief : ** ** @param : ** ** @return : *********************************************************************/ static void Module_Init(void) { EVL_Board_Init(); UART_Init(); Task_Init(); BuffPool_Init(); GPRS_Init(); GPS_Init(); NetFrame_Init(); Systick_Init(); }
/** * @brief main() is the entry of user code. * * * @return void */ int Testlegacy_main(void) { Board_Init(); Driver_Init(); legacy_Init(); GAP_Init(); Profile_Init(); PwrMgr_Init(); Task_Init(); //vTaskStartScheduler(); return 0; }
/** * @brief main() is the entry of user code. * * * @return void */ int test_peripheral_main(void) { Board_Init(); Driver_Init(); BtStack_Init_Peripheral(); BtStack_Init_Gap(); BtProfile_Init(); PwrMgr_Init(); Task_Init(); //vTaskStartScheduler(); return 0; }
VOID DUCTx_Init(DUCTx *pThis) { if (IpuToDsp_isInitialized() == FALSE) { // LOG_FATAL( "DUCTx: IPU to DSP is not initialized"); LOG_FATAL0( "DUCTx: IPU to DSP is not initialized"); } memset(pThis, 0, sizeof(DUCTx)); Task_Init(&pThis->oTskReceiveJob, "oTskReceiveJob", (pfnTask)DUCTx_TskReceiveJob, pThis); Task_Init1(&pThis->oTskProcessJob, "oTskProcessJob", (pfnTask)DUCTx_TskProcessJob, pThis, TSK_STACKSIZE_2048, STE_TASK_DEFAULT_PRI); #ifdef EVM_BOARD Gpo_Init(&Srio2TxLed, HEALTH_RED_LED); #endif Signal_Init(&pThis->oSigProcessJob, "oSigProcessJob"); Timer_Init(&pThis->oTmrProcessJob, CSL_TMR_3, PROCESS_JOB_TIMER_INVERAL, CSL_TMR_ENAMODE_CONT, (Intr_Handler)DUCTx_TmrProcessJob, pThis, INTR_ITEM_TIMER_3); }
int main(void) { int i; // uart initial fprintf(stderr, "This is a test for the Contex-A8...\n"); serial_initial("/dev/ttySAC1", &GsmDevice, 9600); AtTransmitInit(&GsmDevice); usleep(10000); SEQ_Init(); // GPS uart init GPS_Init(); // FIFO initial Open_ImageFIFO(ImageFIFO); #ifdef _EN_INITIAL_GSM_ // config the gprs network NetWork_Connection_Config(); #endif // printf the CSQ info GSM_GetPacketInfo(&unread_sum, &packet_sum); fprintf(stderr, "Unread packet sum = %d\n",unread_sum); fprintf(stderr, "total packet sum = %d\n",packet_sum); if(GSM_GetCSQ(&CSQ)!=ERR_NONE){ fprintf(stderr, "Can't get the CSQ...\n"); } else{ fprintf(stderr, "CSQ = %d\n",CSQ); } for(i=0;i<20;i++){ usleep(10000); } Login_Process(gRxBuff); fprintf(stderr, "========= start transmit =========\n"); for(i=0;i<100;i++){ usleep(10000); } // ===================================== GPS_Debug.lat = MSEC2NDeg( (double)81678360 ); GPS_Debug.lon = MSEC2NDeg( (double)409628128 ); GPS_Debug.speed = 60; GPS_InfoPrintf(&GPS_Debug); // ===================================== // image updata process //ImageTransmit_init("/home/plg/linux.jpg"); // packet process fprintf(stderr,"\r\n****************************\r\n"); PositionUpdateRule_Initial(&RuleList); InZoneCondition_Initial(&InZone_List); OutZoneCondition_Initial(&OutZone_List); TDSA_Condition_Initial(&TDSA_List); Interval_Locate_Init(); // initial the position update process ZoneInfo_Report_Init(); // initial the Zone information update process Speed_Report_Init(); // initial the speed information update process // task initial Task_Init(); SetTimeOut(_Task_Heartbeat_, 6); // execute every 60 seconds SetTimeOut(_Task_GPS_Display_, 6); // execute every 60 seconds SetTimeOut(_Task_RE_Login_, 15); // if we did not receive the heart beat ack in 150 seconds, re login... while(1){ GSM_GetPacketInfo(&unread_sum, &packet_sum); G_PacketType = TypeX; if(unread_sum>0){ memset(gRxBuff,'\0',1024); UDP_ReceivePacket(&link_num, &data_index, &data_len, gRxBuff); fprintf(stderr, "Receive Packet ...\n"); fprintf(stderr, "link num = %d\n",link_num); fprintf(stderr, "data index = %d\n",data_index); fprintf(stderr, "data length = %d\n",data_len); Packet.length = data_len; memcpy(&(Packet.Data[0]), gRxBuff, data_len); res = TLP_PacketDevide(&Packet, &APP_Packet, &G_PacketType); // A type input if((res == ERROR_NONE)&&(G_PacketType == TypeA)){ InputCommandHandle(&APP_Packet); ShowRules(&RuleList); ShowCondition(&InZone_List); ShowCondition(&OutZone_List); ShowSpeedCondition(&TDSA_List); } // B type input if(G_PacketType == TypeB){ ReportUpdata_Loop(0); } // D type input if(G_PacketType == TypeD){ ImageTransmit_loop(0); } } // check the fifo, if we got a new image, send it... DrowsyImage_Check(); DrowsyImage_Send(); // if the image transmit is in working, the other update mesage is delay if(Get_DT_State()==DT_Idle){ Interval_Locate_Check(&RuleList); // position update process Interval_Locate_Updata(&GPS_Msg); ZoneInfo_Condition_Check(&InZone_List, &OutZone_List, &GPS_Msg); // Zone information process ZoneInfo_Update(&GPS_Msg); Speed_Condition_Check(&TDSA_List,&GPS_Debug); SpeedReport_Update(&GPS_Debug); if( isTimeOut(_Task_Heartbeat_)==1 ){ HeartBeat_Request(NULL); ClearTimeOut(_Task_Heartbeat_); } if( isTimeOut(_Task_RE_Login_)==1 ){ // reconfig the network NetWork_Connection_Config(); Login_Process(gRxBuff); ClearTimeOut(_Task_RE_Login_); } } // GPS information GPS_Read(&GPS_Msg); if( isTimeOut(_Task_GPS_Display_)==1 ){ GPS_InfoPrintf(&GPS_Msg); ClearTimeOut(_Task_GPS_Display_); } usleep(500000); } GSM_CloseConnection(); for(i=0;i<100;i++){ usleep(20000); } GSM_Reset(); serial_close(&GsmDevice); return 0; }
//--------------------------------------------------------------------------- int main(void) { Task_Init(); // Initialize the RTOS //----------------------------------------------------------------------- // Create three application tasks at the same priority //----------------------------------------------------------------------- Task_CreateTask(&(stTask1.stTask), // Pointer to the task "RR Task1", // Task name (UCHAR*)(stTask1.ausStack), // Task stack pointer 64, // Task Size 1, // Task Priority (void*)Task1Func); // Task function pointer Task_CreateTask(&(stTask2.stTask), // Pointer to the task "RR Task2", // Task name (UCHAR*)(stTask2.ausStack), // Task stack pointer 64, // Task Size 1, // Task Priority (void*)Task2Func); // Task function pointer Task_CreateTask(&(stTask3.stTask), // Pointer to the task "RR Task3", // Task name (UCHAR*)(stTask3.ausStack), // Task stack pointer 64, // Task Size 1, // Task Priority (void*)Task3Func); // Task function pointer // Create the idle task - always need this Task_CreateTask(&(stIdleTask.stTask), "Idle Task", (UCHAR*)(stIdleTask.ausStack), 64, 0, // !! Task priority is 0 for idle task !! (void*)IdleTask); Task_Add((TASK_STRUCT*)&stTask1); // Add the tasks to the scheduler Task_Add((TASK_STRUCT*)&stTask2); // Add the tasks to the scheduler Task_Add((TASK_STRUCT*)&stTask3); // Add the tasks to the scheduler Task_Add((TASK_STRUCT*)&stIdleTask); //----------------------------------------------------------------------- // Set the time quantum for each task: // // Each task will get a fixed % of CPU time based on the quantum values // set here, assuming that tasks aren't sleeping or pending. // The portion of CPU time given to each task is the ratio of the task's // quantum over the sum of each task's quantum. // // In this example Task 1 will get 5/(5 + 10 + 20) = 5/35 = 14.28% CPU Time // Similarly, Task 2 will get 10/35 = 28.57%, and Task 3 will get 20/35 = // 57.14% CPU time. // // Note that these times do not take into account events like interrupts // or other IO operations that eat cycles or switch contexts outside of // the tasks. //----------------------------------------------------------------------- Task_SetQuantum((TASK_STRUCT)&stTask1, 5); // Execute continuously for 5 ticks Task_SetQuantum((TASK_STRUCT)&stTask2, 10); // Execute continuously for 10 ticks Task_SetQuantum((TASK_STRUCT)&stTask3, 20); // Execute continuously for 20 ticks Task_Start((TASK_STRUCT*)&stTask1); // Start the tasks Task_Start((TASK_STRUCT*)&stTask2); // Start the tasks Task_Start((TASK_STRUCT*)&stTask3); // Start the tasks Task_Start((TASK_STRUCT*)&stIdleTask); Task_StartTasks(); // Start the scheduler //-------------------------------------- // Scheduler takes over - never returns //-------------------------------------- return 0; }
int main() { /*----------------------------------------------------------------------------*/ /* SYSTEM INIT */ /*----------------------------------------------------------------------------*/ _SWDTEN = 0; // Disable WDT OSCCONbits.COSC = 0b11; OSCCONbits.NOSC = 0b11; OSCCONbits.CF = 0; while(OSCCONbits.LOCK!=1) {;}; // Wait for PLL to lock SET_CPU_IPL(0b111); // Force CPU interrupt priority to max.All user masked interrupts with ptiority from 0 to 7 are Disabled.(Safe version) delay_ms(5); /*----------------------------------------------------------------------------*/ /* MAIN PROGRAM */ /*----------------------------------------------------------------------------*/ /* INIT */ DSP_Engine_Init(); /* Parameters Read */ ee_param_act(1,1); // INIT and put in PARACT_PARAMS_READ_ALL state ee_param_act(0,0); // RUN read all parameters. NO NEED REINIT! /* HW Modules Init */ IF_DigitalIO_Init(); IF_PWM_Init(); IF_DigitalIO_Init(); IF_SysTmr1_Init(); IF_SysTmr2_Init(); IF_SysTmr3_Init(); IF_Uart_Init(38400); IF_ADC_INIT(); /* Software Modules Init */ Task_Init(); Task1_Stack_Usage_Calc(_get_sTimes(), 1); trace_init_first(); measure_init(); VF_ControlInit(); init_ramp1(0); init_ramp2(0); /* END INIT */ INTCON1bits.NSTDIS = 0; // Enable Nested Interrupts SET_CPU_IPL(0b000); // Force CPU interrupt priority to low. All user masked interrupts with ptiority from 0 to 7 are Enabled.(Safe version) ClrWdt(); // Clear WDT //_SWDTEN = 1; // Enable WDT while(1) { /* BACKGROUND LOOP. */ ee_param_act(0,0); // Online parameters actualization in background Sirem_Engine(); // Serial Communication run in background loop adc_par_convert(); TaskTimesCalc(_get_sTimes()); VF_Par_Convert(); } return(0); }
void UART_Init(uint8_t channel) { // use flag so init calls to Timing_Init and Task_Init get called only once static uint8_t init_flag = 0; rx_flags = 0; switch(channel){ #ifdef USE_UART0 case 0: hal_UART_Init(channel, UART0_BAUD); BufferInit(&rx0, &rx_buffer_array0[0], UART0_RX_BUFFER_LENGTH); BufferInit(&tx0, &tx_buffer_array0[0], UART0_TX_BUFFER_LENGTH); CharReceiverList_Init(&receiverList0, &receiver_array0[0], NUM_UART0_RECEIVERS); uart[0].rx = &rx0; uart[0].tx = &tx0; uart[0].receiverList = &receiverList0; break; #endif #ifdef USE_UART1 case 1: hal_UART_Init(channel, UART1_BAUD); BufferInit(&rx1, &rx_buffer_array1[0], UART1_RX_BUFFER_LENGTH); BufferInit(&tx1, &tx_buffer_array1[0], UART1_TX_BUFFER_LENGTH); CharReceiverList_Init(&receiverList1, &receiver_array1[0], NUM_UART1_RECEIVERS); uart[1].rx = &rx1; uart[1].tx = &tx1; uart[1].receiverList = &receiverList1; break; #endif #ifdef USE_UART2 case 2: hal_UART_Init(channel, UART2_BAUD); BufferInit(&rx2, &rx_buffer_array2[0], UART2_RX_BUFFER_LENGTH); BufferInit(&tx2, &tx_buffer_array2[0], UART2_TX_BUFFER_LENGTH); CharReceiverList_Init(&receiverList2, &receiver_array2[0], NUM_UART2_RECEIVERS); uart[2].rx = &rx2; uart[2].tx = &tx2; uart[2].receiverList = &receiverList2; break; #endif #ifdef USE_UART3 case 3: hal_UART_Init(channel, UART3_BAUD); BufferInit(&rx3, &rx_buffer_array3[0], UART3_RX_BUFFER_LENGTH); BufferInit(&tx3, &tx_buffer_array3[0], UART3_TX_BUFFER_LENGTH); CharReceiverList_Init(&receiverList3, &receiver_array3[0], NUM_UART3_RECEIVERS); uart[3].rx = &rx3; uart[3].tx = &tx3; uart[3].receiverList = &receiverList3; break; #endif #ifdef USE_UART4 case 4: hal_UART_Init(channel, UART4_BAUD); BufferInit(&rx4, &rx_buffer_array4[0], UART4_RX_BUFFER_LENGTH); BufferInit(&tx4, &tx_buffer_array4[0], UART4_TX_BUFFER_LENGTH); CharReceiverList_Init(&receiverList4, &receiver_array4[0], NUM_UART4_RECEIVERS); uart[4].rx = &rx4; uart[4].tx = &tx4; uart[4].receiverList = &receiverList4; break; #endif #ifdef USE_UART5 case 5: hal_UART_Init(channel, UART5_BAUD); BufferInit(&rx5, &rx_buffer_array5[0], UART5_RX_BUFFER_LENGTH); BufferInit(&tx5, &tx_buffer_array5[0], UART5_TX_BUFFER_LENGTH); CharReceiverList_Init(&receiverList5, &receiver_array5[0], NUM_UART5_RECEIVERS); uart[5].rx = &rx5; uart[5].tx = &tx5; uart[5].receiverList = &receiverList5; break; #endif #ifdef USE_UART6 case 6: hal_UART_Init(channel, UART6_BAUD); BufferInit(&rx6, &rx_buffer_array6[0], UART6_RX_BUFFER_LENGTH); BufferInit(&tx6, &tx_buffer_array6[0], UART6_TX_BUFFER_LENGTH); CharReceiverList_Init(&receiverList6, &receiver_array6[0], NUM_UART6_RECEIVERS); uart[6].rx = &rx6; uart[6].tx = &tx6; uart[6].receiverList = &receiverList6; break; #endif #ifdef USE_UART7 case 7: hal_UART_Init(channel, UART7_BAUD); BufferInit(&rx7, &rx_buffer_array7[0], UART7_RX_BUFFER_LENGTH); BufferInit(&tx7, &tx_buffer_array7[0], UART7_TX_BUFFER_LENGTH); CharReceiverList_Init(&receiverList7, &receiver_array7[0], NUM_UART7_RECEIVERS); uart[7].rx = &rx7; uart[7].tx = &tx7; uart[7].receiverList = &receiverList7; break; #endif } #ifdef _TASK_H_ #ifndef UART_TICK_OVERRIDE // if the Task Management Module is being used then schedule // the UART_Tick to happen every ms if(init_flag == 0) { // make sure the task manager is initialized Task_Init(); Task_Schedule(UART_Tick,0,1,1); } #endif #endif init_flag = 1; }