/**************************************************************************//** * @brief Main function *****************************************************************************/ int main( void ) { /* Chip errata */ CHIP_Init(); /* Setup GPIO for pushbuttons. */ GpioSetup(); /* Initialize the display module. */ displayEnabled = true; DISPLAY_Init(); /* Retrieve the properties of the display. */ if ( DISPLAY_DeviceGet( 0, &displayDevice ) != DISPLAY_EMSTATUS_OK ) { /* Unable to get display handle. */ while( 1 ); } /* Retarget stdio to the display. */ if ( TEXTDISPLAY_EMSTATUS_OK != RETARGET_TextDisplayInit() ) { /* Text display initialization failed. */ while( 1 ); } /* Set PCNT to generate an interrupt every second. */ PcntInit(); printf( "\n\n Cycling through" "\n energy modes" "\n EM0-EM3" "\n\n Push PB0 to" "\n enter EM4\n\n\n\n" ); /* Turn on LFXO to be able to see the difference between EM2 and EM3. */ CMU_OscillatorEnable(cmuOsc_LFXO, true, false ); for (;;) { printf( "\r EM0" ); EnterEMode( 0, SLEEP_TIME ); CheckEM4Entry(); printf( "\r EM1" ); EnterEMode( 1, SLEEP_TIME ); CheckEM4Entry(); printf( "\r EM2" ); EnterEMode( 2, SLEEP_TIME ); CheckEM4Entry(); printf( "\r EM3" ); EnterEMode( 3, SLEEP_TIME ); CheckEM4Entry(); } }
/**************************************************************************//** * @brief Main function *****************************************************************************/ int main(void) { /* Setup SysTick Timer for 10 msec interrupts */ if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) { while (1) ; } /* Initialize the display module. */ DISPLAY_Init(); /* Retarget stdio to a text display. */ if (RETARGET_TextDisplayInit() != TEXTDISPLAY_EMSTATUS_OK) { while (1) ; } /* Output text on Memory LCD */ printf("Hello, EFM32 Zero Gecko world!"); Delay(2000); /* Clear screen */ printf("\f"); Setup_MPU6050(); MPU6050_Test_I2C(); MPU6050_Check_Registers(); Calibrate_Gyros(); Calibrate_Acc(); /* Update Memory LCD display forever */ while (1) { Get_Gyro_Rates(); Get_Accel_Values(); Delay(500); printf("\f"); } }
/**************************************************************************//** * @brief Main function *****************************************************************************/ int main(void) { int toggleLED = 0; int cnt, x, y; bool movedown, moveright; /* Use 48MHZ HFXO as core clock frequency */ CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO); /* Initialize DK board register access */ /* This demo currently only works in EBI mode */ BSP_Init(BSP_INIT_DEFAULT); BSP_LedsInit(); /* Setup SysTick Timer for 10 msec interrupts */ if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) { while (1) ; } /* Initialize the display module. */ DISPLAY_Init(); /* Retarget stdio to a text display. */ if (RETARGET_TextDisplayInit() != TEXTDISPLAY_EMSTATUS_OK) { while (1) ; } /* Output text on Memory LCD */ printf("Hello, EFM32 Zero Gecko world!"); Delay(2000); /* Clear screen */ printf("\f"); cnt = x = y = 0; movedown = moveright = true; /* Update Memory LCD display forever */ while (1) { printf("%d", cnt ); if (movedown) { y++; printf( TEXTDISPLAY_ESC_SEQ_CURSOR_DOWN_ONE_LINE ); } else { y--; printf( TEXTDISPLAY_ESC_SEQ_CURSOR_UP_ONE_LINE ); } if (y >= TEXTDISPLAY_DEVICE_0_LINES-1) movedown=false; if (y == 0) movedown=true; if (moveright) { x++; if (cnt >= 10) printf( TEXTDISPLAY_ESC_SEQ_CURSOR_LEFT_ONE_CHAR ); } else { x--; if (cnt > 10) { printf( TEXTDISPLAY_ESC_SEQ_CURSOR_LEFT_ONE_CHAR ); printf( TEXTDISPLAY_ESC_SEQ_CURSOR_LEFT_ONE_CHAR ); printf( TEXTDISPLAY_ESC_SEQ_CURSOR_LEFT_ONE_CHAR ); } else { printf( TEXTDISPLAY_ESC_SEQ_CURSOR_LEFT_ONE_CHAR ); printf( TEXTDISPLAY_ESC_SEQ_CURSOR_LEFT_ONE_CHAR ); } } if (x >= TEXTDISPLAY_DEVICE_0_COLUMNS-2) moveright=false; if (x == 0) moveright=true; /* Clear screen and reset counter when 100 is reached. */ if (++cnt == 100) { printf("\f"); cnt = x = y = 0; movedown = moveright = true; } /* Toggle led after each Memory LCD_displayUpdate iteration */ if (toggleLED) { BSP_LedsSet(0x0000); toggleLED = 0; } else { BSP_LedsSet(0x000f); toggleLED = 1; } Delay(100); } }