static portTASK_FUNCTION(MainTask, pvParameters) { (void)pvParameters; /* parameter not used */ TRACE_Init(); MMA1_Init(); /* enable accelerometer, if not already enabled */ SHELL_Init(); for(;;) { LED1_Neg(); FRTOS1_vTaskDelay(1000/portTICK_RATE_MS); } }
CTRACE::CTRACE(int toFile, int toConsol) { const char* ClassFileNaMe = "allegro.log"; m_FileIsOpen = 0; m_TraceToFile = toFile; m_TraceToCons = toConsol; m_FileNameF = new char[11]; sprintf(m_FileNameF, ClassFileNaMe); TRACE_Init(); }
CTRACE::CTRACE(int toFile, int toConsol, char* UserFileName) { const int nFNameLen = 20; m_FileIsOpen = 0; m_TraceToFile = toFile; m_TraceToCons = toConsol; m_FileNameF = new char[nFNameLen]; if (strlen(UserFileName) > nFNameLen ) { // UserFileName does not have any validation! const char* ClassFileNaMe = "allegro.log"; printf ("ATTN! Filename '%s' has more than %d characters.\n", UserFileName, nFNameLen); printf ("All TRACE will go to file 'allegro.log'\n") ; sprintf(m_FileNameF, ClassFileNaMe); } else { sprintf(m_FileNameF, UserFileName); } TRACE_Init(); }
// halInit is called on first initial boot, not on wakeup from sleep. void halInit(void) { #ifdef _EZR32_LEOPARD_FAMILY CHIP_Init(); halInternalInitButton(); halInternalInitLed(); halInternalInitRadioHoldOff(); halInternalInitVCPPins(); CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO); CMU_OscillatorEnable(cmuOsc_LFRCO, true, true); CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFRCO); CMU_ClockSelectSet(cmuClock_LFB, cmuSelect_LFRCO); RTCDRV_Init(); halInternalStartSymbolTimer(); // TODO: move to macInit or emRadioInit #endif /* Configure board. Select either EBI or SPI mode. */ #ifdef _EFR_DEVICE TRACE_Config_t traceConfig; traceConfig.setEventFuncPtr = NULL; CHIP_Init(); halInternalInitButton(); halInternalInitBoard(); CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO); CMU_OscillatorEnable(cmuOsc_LFRCO, true, true); CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFRCO); CMU_ClockSelectSet(cmuClock_LFB, cmuSelect_LFRCO); CMU_ClockEnable(cmuClock_CORELE, true); TRACE_Init(&traceConfig); RTCDRV_Init(); // GRAPHICS_Init(); // GRAPHICS_ShowStatus(); #ifndef DISABLE_WATCHDOG halInternalEnableWatchDog(); #endif #endif halInternalStartSystemTimer(); }
static portTASK_FUNCTION(MainTask, pvParameters) { unsigned char lcdBuf[sizeof("1234")]; uint16_t cntr; (void)pvParameters; /* parameter not used */ TRACE_Init(); MMA1_Init(); /* enable accelerometer, if not already enabled */ MAG1_Enable(); /* enable magnetometer */ SHELL_Init(); cntr = 0; for(;;) { UTIL1_Num16uToStrFormatted(lcdBuf, sizeof(lcdBuf), cntr, '0', 4); vfnLCD_Write_Msg(lcdBuf); cntr++; if (cntr>9999) { /* can only display 4 digits */ cntr = 0; } #if APP_USE_KEY_COMPONENT KEY1_ScanKeys(); /* using component in polling mode: poll keys, this will create events as needed. */ EVNT1_HandleEvent(); #else if (SW1_GetVal()==0) { /* button pressed */ FRTOS1_vTaskDelay(50/portTICK_RATE_MS); /* wait to debounce */ while (SW1_GetVal()==0) { /* still pressed? */ LED1_On(); } } if (SW3_GetVal()==0) { /* button pressed */ FRTOS1_vTaskDelay(50/portTICK_RATE_MS); /* wait to debounce */ while (SW3_GetVal()==0) { /* still pressed? */ LED2_On(); } } #endif LED1_Neg(); FRTOS1_vTaskDelay(50/portTICK_RATE_MS); } }