void APP_Run(void) { appState = APP_STATE_INIT; MOT_Init(); SHELL_Init(); #if PL_HAS_LINE_SENSOR REF_Init(); LF_Init(); TURN_Init(); #endif #if PL_HAS_ULTRASONIC US_Init(); #endif #if PL_HAS_BUZZER BUZ_Init(); #endif #if PL_HAS_EVENTS EVNT_Init(); #endif #if PL_HAS_RADIO RADIO_Init(); #endif #if PL_HAS_REMOTE REMOTE_Init(); #endif #if PL_HAS_QUEUE QUEUE_Init(); #endif if (FRTOS1_xTaskCreate(MainTask, (signed portCHAR *)"Main", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } FRTOS1_vTaskStartScheduler(); }
/*lint -save -e970 Disable MISRA rule (6.3) checking. */ int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { /* Write your local variable definition here */ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ RADIO_Init(); /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
void Debug_Init() { if (debug_status) { return; } #if DEBUG_MODE_UART UART_InitType UART_InitStruct; UART_InitStruct.rts_pin_number = 8; // pin 0.8 UART_InitStruct.txd_pin_number = 9; // pin 0.9 UART_InitStruct.hwfc = UART_CONFIG_HWFC_Enabled; UART_InitStruct.cts_pin_number = 10; // pin 0.10 UART_InitStruct.rxd_pin_number = 11; // pin 0.11 UART_InitStruct.baudrate = UART_BAUDRATE_BAUDRATE_Baud230400; UART_InitStruct.parity = UART_CONFIG_PARITY_Excluded; // no parity UART_Init(&UART_InitStruct); #endif /* DEBUG_MODE_UART */ #if DEBUG_MODE_RADIO /* Start 16 MHz crystal oscillator */ NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1; /* Wait for the external oscillator to start up */ while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) { } RADIO_Init(); #endif /* DEBUG_MODE_RADIO */ #if DEBUG_MODE_FLASH currentFLASHWriteAddress = ADDRESS_LOG_END; MX25L4006E_Init(); MX25L4006E_WakeUp(); bool isFound = false; for (int i = SECTOR_LOG_BEGIN; i < SECTOR_LOG_END; i++) { if (isFound) { break; } uint8_t byte; uint32_t address = FLASH_SECTOR_SIZE * i; MX25L4006E_Read(address, &byte, sizeof(byte), 10); if (byte != 0xFF) { uint8_t buf[FLASH_PAGE_SIZE]; for (uint32_t j = 0; j < FLASH_SECTOR_SIZE; j += sizeof(buf)) { if (isFound) { break; } MX25L4006E_Read(address + j, buf, sizeof(buf), 10); for (int k = 0; k < sizeof(buf); k++) { if (buf[k] == 0xFF) { currentFLASHWriteAddress = address + j + k; isFound = true; break; } } } } else { if (address == ADDRESS_LOG_BEGIN) { currentFLASHWriteAddress = ADDRESS_LOG_BEGIN; } } } fifoFLASH = LX_FIFOCreate(FLASH_FIFO_SIZE); #endif /* DEBUG_MODE_FLASH */ }
int main() { unsigned int nextState; unsigned int actualStateButton = 0; //Define a a data e hora que o sistema vai ter inicialmente //RTC_SetTime(00,00,00); ti.tm_hour = 00; ti.tm_min = 00; ti.tm_sec = 00; //RTC_SetDate(8,11,2013); ti.tm_mday = 8; ti.tm_mon = 11; ti.tm_year = 2013; //RTC_SetDays(5 ,365); ti.tm_wday = 5; ti.tm_yday = 365; //System init SYSCLK_Init(1000); /* Acertar o clock do TIMER*/ RTC_Init(&ti); /* Iniciar o RTC com a data e hora definida inifialmente*/ LCD_Init(); LCD_Clear(); I2C_Init(); RADIO_Init(); RADIO_SetFreq(89.9); WriteData(); while(1) { actualStateButton = Button_Read(); nextState = decodeButtons(actualStateButton); switch(nextState) { case CHANGE_HOURS: changeHours(&ti); break; case CHANGE_RADIO: changeRadio(&tea); LCD_Clear(); break; //Tambem devia de escrever a freq do radio case SHOW: RTC_GetValue(&ti); LCD_Goto(4,0); strftime(buffer,16,"%T",&ti); LCD_WriteString(buffer); ReadData(&tea); float fm = RADIO_GetFreq(&tea); int level = RADIO_Station_Level(&tea); int parteDecimal = (int)(fm*10)%10; sprintf(buffer, "%d.%dMHz L:%d",(int)fm,parteDecimal, level); LCD_Goto(0,1); LCD_WriteString(buffer); break; default: break; } } return 0; }