/** ****************************************************************************** ** Main application to control the program flow *****************************************************************************/ void main(void) { // Initialize all interrupt levels of resources Vectors_InitIrqLevels(); // Allow all interrupt levels __set_il(7); // Enable interrupts __EI(); Flash_EnableWriting(); InitLCD(); #if ((SMC_TYPE != SMC_TYPE_R200) && (ZPD == ZPD_ENABLE)) ZPD_Init(); //ќжидание окончани¤ ZPD while (m_enSmcMode == Zpd) { WDTCP = 0x00; } #else m_enSmcMode = NormalDriving; #endif InitSMC(20); Timer_Init(); InitADC(); InitRTC(); // ≈сли двигатель R200 или ZPD не активно #if ((SMC_TYPE == SMC_TYPE_R200) || (ZPD == ZPD_DISABLE)) ZeroPosSMC(); Timer_Wait(TIMER_ID_MAIN, 2000, TRUE); #endif ClearPosSMC(); DriverInit(); InitFRTimer0(); InitExtInt0(); //test Init_4_imp(); InitBacklight(); Button_Init(ButtonCallback); CAN_Init(); J1939_init(); InitUsart0(); if (Button_GetCurrentButtonState(BUTTON_ID_B1) == StateLow) SetModePass(); while(1) { WDTCP_ = 0x00; Timer_Main(); } }
static void prvSetupHardware( void ) { /* Setup interrupt hardware - interrupts are kept disabled for now to prevent any interrupts attempting to cause a context switch before the scheduler has been started. */ InitIrqLevels(); portDISABLE_INTERRUPTS(); __set_il( 7 ); /* Set Port3 as output (7Segment Display). */ DDR03 = 0xff; /* Use Port 5 as I/O-Port. */ ADER1 = 0; PDR05 = 0x7f; /* Set Port5 as output (7Segment Display). */ DDR05 = 0xff; /* Disable inputs on the following ports. */ PIER02 = 0x00; PDR02 = 0x00; DDR02 = 0xff; PIER03 = 0x00; PDR03 = 0xff; PIER05 = 0x00; PDR05 = 0x00; PIER06 = 0x00; PDR06 = 0x00; DDR06 = 0xff; /* Enable P00_0/INT8 and P00_1/INT9 as input. */ PIER00 = 0x03; /* Enable external interrupt 8. */ PIER00_IE0 = 1; /* LB0, LA0 = 11 -> falling edge. */ ELVRL1_LB8 = 1; ELVRL1_LA8 = 1; /* Reset and enable the interrupt request. */ EIRR1_ER8 = 0; ENIR1_EN8 = 1; /* Enable external interrupt 9. */ PIER00_IE1 = 1; /* LB1, LA1 = 11 -> falling edge. */ ELVRL1_LB9 = 1; ELVRL1_LA9 = 1; /* Reset and enable the interrupt request. */ EIRR1_ER9 = 0; ENIR1_EN9 = 1; }
static void prvSetupHardware( void ) { /* Allow all interrupt levels. */ __set_il( mainINTERRUPT_LEVELS ); /* Initialise interrupts. */ InitIrqLevels(); /* Initialise the ports used by the LEDs. */ vParTestInitialise(); /* If we are going to use the watchdog, then initialise it now. */ #if WATCHDOG != WTC_NONE InitWatchdog(); #endif }
void main( void ) { InitIrqLevels(); /* Initialize interrupts */ __set_il( 7 ); /* Allow all levels */ prvSetupHardware(); #if WATCHDOG == WTC_IN_TASK vStartWatchdogTask( WTC_TASK_PRIORITY ); #endif /* Start the standard demo application tasks. */ vStartLEDFlashTasks( mainLED_TASK_PRIORITY ); vStartIntegerMathTasks( tskIDLE_PRIORITY ); vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); vStartBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY ); vStartDynamicPriorityTasks(); vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES ); vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY ); vCreateBlockTimeTasks(); /* The definition INCLUDE_TraceListTasks is set within FreeRTOSConfig.h. */ #if INCLUDE_TraceListTasks == 1 vUtilityStartTraceTask( TASK_UTILITY_PRIORITY ); #else vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED - 1 ); #endif /* Start the 'Check' task which is defined in this file. */ xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); /* The suicide tasks must be started last as they record the number of other tasks that exist within the system. The value is then used to ensure at run time the number of tasks that exists is within expected bounds. */ vCreateSuicidalTasks( mainDEATH_PRIORITY ); /* Now start the scheduler. Following this call the created tasks should be executing. */ vTaskStartScheduler( ); /* vTaskStartScheduler() will only return if an error occurs while the idle task is being created. */ for( ;; ); }
void main(void) { unsigned char t = 0; unsigned int i = 0; // unsigned int i; // unsigned char wdtc = *((__far unsigned char*)0x188); // name[2] = wdtc; // WDTC_WTE = 0; clear_CPU_operation_detection(); clear_CPU_operation_detection(); DDR8 = 0x00; PDR8 = 0x00; DDR8_D87 = 1; PDR8_P87 = 1; DDR0 = 0x00; DDR1 = 0x00; DDR3 = 0x00; DDR4 = 0x00; DDR5 = 0x00; DDR6 = 0x00; DDR7 = 0x00; DDR9 = 0x00; PDR0 = 0x00; PDR1 = 0x00; PDR3 = 0x00; PDR4 = 0x00; PDR5 = 0x00; PDR6 = 0x00; PDR7 = 0x00; PDR9 = 0x00; EIRR = 0; ADER = 0; PWC0_OE1 = 0; PWC0_OE2 = 0; PWC1_OE1 = 0; PWC1_OE2 = 0; PWC2_OE1 = 0; PWC2_OE2 = 0; PWC3_OE1 = 0; PWC3_OE2 = 0; InitTimer1(); driver_Init(); InitIrqLevels(); __set_il(7); /* allow all levels */ __EI(); /* globaly enable interrupts */ /* for (i=0; i<30000; i++) clear_CPU_operation_detection(); for (i=0; i<30000; i++) clear_CPU_operation_detection(); for (i=0; i<30000; i++) clear_CPU_operation_detection(); for (i=0; i<30000; i++) clear_CPU_operation_detection(); for (i=0; i<30000; i++) clear_CPU_operation_detection(); //*/ while(1) { driver_Update(); clear_CPU_operation_detection(); // if (t) // PDR8_P87 = 1; // else // PDR8_P87 = 0; // t=~t; // PDR8_P87 = ~PDR8_P87; } }
/*--------------------------------------------------------------------------- * main() *---------------------------------------------------------------------------*/ void main( void ) { InitIrqLevels(); /* Initialize interrupts */ __set_il( 7 ); /* Allow all levels */ prvSetupHardware(); #if WATCHDOG == WTC_IN_TASK vStartWatchdogTask( WTC_TASK_PRIORITY ); #endif /* Start the standard demo application tasks. */ #if ( INCLUDE_StartLEDFlashTasks == 1 ) vStartLEDFlashTasks( mainLED_TASK_PRIORITY ); #endif #if ( INCLUDE_StartIntegerMathTasks == 1 ) vStartIntegerMathTasks( tskIDLE_PRIORITY ); #endif #if ( INCLUDE_AltStartComTestTasks == 1 ) vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED - 1 ); #endif #if ( INCLUDE_StartPolledQueueTasks == 1 ) vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); #endif #if ( INCLUDE_StartSemaphoreTasks == 1 ) vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); #endif #if ( INCLUDE_StartBlockingQueueTasks == 1 ) vStartBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY ); #endif #if ( INCLUDE_StartDynamicPriorityTasks == 1 ) vStartDynamicPriorityTasks(); #endif #if ( INCLUDE_StartMathTasks == 1 ) vStartMathTasks( tskIDLE_PRIORITY ); #endif #if ( INCLUDE_StartFlashCoRoutines == 1 ) vStartFlashCoRoutines( ledNUMBER_OF_LEDS ); #endif #if ( INCLUDE_StartHookCoRoutines == 1 ) vStartHookCoRoutines(); #endif #if ( INCLUDE_StartGenericQueueTasks == 1 ) vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY ); #endif #if ( INCLUDE_StartQueuePeekTasks == 1 ) vStartQueuePeekTasks(); #endif #if ( INCLUDE_CreateBlockTimeTasks == 1 ) vCreateBlockTimeTasks(); #endif #if ( INCLUDE_CreateSuicidalTasks == 1 ) vCreateSuicidalTasks( mainDEATH_PRIORITY ); #endif #if ( INCLUDE_TraceListTasks == 1 ) vTraceListTasks( TASK_UTILITY_PRIORITY ); #endif /* Start the 'Check' task which is defined in this file. */ xTaskCreate( vErrorChecks, (signed portCHAR *) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); vTaskStartScheduler(); /* Should not reach here */ while( 1 ) { __asm( " NOP " ); /* // */ } }
void main(void) { #ifdef CAN_OPEN_ENABLE BYTE i; #endif //=================================== //#if ((BUFFER_LEN_UART>1000)||(COUNT_UART_BUF>4)) InitWatchDog(); //#endif I2C_Init(0); I2C_Init(1); InitUART(0); SetupTime(); InitReloadTimer0(); InitServiceUart0(); InitIrqLevels(); __set_il(7); /* allow all levels */ __EI(); /* globally enable interrupts */ //=================================== InitProgrammVar(); //=================================== if(INIT_BLOK!=NULL) INIT_BLOK(); //=================================== #ifdef CAN_OPEN_ENABLE setState(Initialisation); #else SetupCAN(SPEED_CAN_0, SPEED_CAN_1, SPEED_CAN_2); #endif //=================================== #ifdef EN_SR_ZN_CYKL add_timer(&TimerSrZnC); #endif #ifdef CASH_PDO_DATA add_timer(&TimerCashCan); #endif puts((BYTE *)"===============================================================================\r\n"); puts((BYTE *)" Terminal Fujitsu MB96F338 \r\n"); puts((BYTE *)"===============================================================================\r\n$>"); while(1) { //======================================== clrwdt; // обнуление WatchDog таймера //======================================== CyclicModules(); // цикличные операции выполняемые в каждом блоке //======================================== if(DRIVER_BLOK!=NULL) // Функционал конкретного блока DRIVER_BLOK(); //======================================== #ifdef CAN_OPEN_ENABLE receiveMsgHandler(0); receiveMsgHandler(1); receiveMsgHandler(2); DriverCanOpen(); #ifdef CASH_PDO_DATA if(getTimer(&TimerCashCan)==0) { setTimer(&TimerCashCan, 30); // обновляем данные в объектном словаре 1 раз в 30 мс for(i=0;i<30;i++) buildPDO_CASH(0x1800+i); if(program.Cnt1WareDev == 0) GetDataWare(0); } #endif #endif //======================================== #ifdef TERMINAL_EN Terminal(); #endif //======================================== // подсчёт среднего времени цикла в мкс #ifdef EN_SR_ZN_CYKL program.CountCikl_1s++; if(getTimer(&TimerSrZnC)==0) { program.SrCikl_mks = 1000000/program.CountCikl_1s; // среднее значение цикла в мкс program.CountCikl_1s = 0; setTimer(&TimerSrZnC, 1000); } #endif //======================================== } }