Exemple #1
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  bool vboost = false;

  /* Chip revision alignment and errata fixes */
  CHIP_Init();

  /* Initialize DVK board register access */
  BSP_Init(BSP_INIT_DEFAULT);

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Initialize board specific registers */
  VDDCHECK_Init();

  /* Check if voltage is below 3V, if so use voltage boost */
  if (VDDCHECK_LowVoltage(2.9))
    vboost = true;

  /* Disable Voltage Comparator */
  VDDCHECK_Disable();

  /* Run Energy Mode with LCD demo, see lcdtest.c */
  SegmentLCD_Init(vboost);
  /* Display a message if vboost is enabled */
  if ( vboost )
  {
    SegmentLCD_Write("vboost");
    RTCDRV_Delay(5000, false);
  }
  Test();

  return 0;
}
Exemple #2
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();
  
  /* Select clock source  */
  initClocks();
  
  /* Initialize EBI configuration for external RAM and display controller */
  BSP_Init(BSP_INIT_DK_EBI);
  
  /* Initialize emWin Library. Will call initDisplayController to initialize Direct Drive. */
  GUI_Init();
  
  
  /* Initialization done, enter drawing loop. 
   * More emWin examples can be viewed by copy pasting into this file and 
   * uncommenting the following line calling MainTask() instead of drawingLoop()
   * emWin examples can be found under reptile/emwin/examples
   */
  
  drawingLoop();
  
  //MainTask();
  
  return 0;
}
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
	CHIP_Init();

	enter_DefaultMode_from_RESET();

	setup_utilities(USART1);

	delay(100);

	I2C_Init_TypeDef i2cInit = I2C_INIT_DEFAULT;
	I2C_Init(I2C0, &i2cInit);

	// Offset zero is Device ID
	uint16_t value = i2c_read_register(0);

	// Set an LED on the Starter Kit if success
	if (value == DEVICE_ID)
	{
		set_led(1,1);
	}

	// Infinite loop
	while (1) {
  }
}
Exemple #4
0
/**
 * @brief Perform basic hardware initialization
 *
 * Initialize the interrupt controller device drivers.
 * Also initialize the timer device driver, if required.
 *
 * @return 0
 */
static int silabs_efm32wg_init(struct device *arg)
{
	ARG_UNUSED(arg);

	int oldLevel; /* old interrupt lock level */

	/* disable interrupts */
	oldLevel = irq_lock();

	/* handle chip errata */
	CHIP_Init();

	_ClearFaults();

	/* Initialize system clock according to CONFIG_CMU settings */
	clkInit();

	/*
	 * install default handler that simply resets the CPU
	 * if configured in the kernel, NOP otherwise
	 */
	NMI_INIT();

	/* restore interrupt state */
	irq_unlock(oldLevel);
	return 0;
}
Exemple #5
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Ensure core frequency has been updated */
  SystemCoreClockUpdate();

  /* Init LCD with no voltage boost */
  SegmentLCD_Init(oldBoost);

  /* Setup RTC to generate an interrupt every minute */
  rtcSetup();

  /* Setup GPIO with interrupts to serve the pushbuttons */
  gpioSetup();

  /* Main function loop */
  clockLoop();

  return 0;
}
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
    TEMPSENS_Temp_TypeDef temp;

    /* Chip revision alignment and errata fixes */
    CHIP_Init();

    /* Initialize LCD controller without boost */
    SegmentLCD_Init(false);

    I2C_Tempsens_Init();

    /* Main loop - just read temperature and update LCD */
    while (1)
    {
        if (TEMPSENS_TemperatureGet(I2C0,
                                    TEMPSENS_DVK_ADDR,
                                    &temp) < 0)
        {
            SegmentLCD_Write("ERROR");
            /* Enter EM2, no wakeup scheduled */
            EMU_EnterEM2(true);
        }

        /* Update LCD display */
        temperatureUpdateLCD(&temp);

        /* Read every 2 seconds which is more than it takes worstcase to */
        /* finish measurement inside sensor. */
        RTCDRV_Trigger(2000, NULL);
        EMU_EnterEM2(true);
    }
}
/**************************************************************************//**
 * @brief  Main function
 * Main is called from __iar_program_start, see assembly startup file
 *****************************************************************************/
int main(void)
{  
  /* Initialize chip */
  CHIP_Init();
  
  /* Enable clock for GPIO module */
  CMU_ClockEnable(cmuClock_GPIO, true);

  /* Configure PD with alternate drive strength of 20mA */
  GPIO_DriveModeSet(gpioPortD, gpioDriveModeHigh);
  
  /* Configure PC12 as input with filter*/
  GPIO_PinModeSet(gpioPortC, 12, gpioModeInput, 0);
  
  /* Configure PD8 as push pull output */
  GPIO_PinModeSet(gpioPortD, 8, gpioModePushPullDrive, 0);
  
  while(1)
  {
    /* If PC12 is high, drive high PD8, else drive low */
    if(GPIO_PinInGet(gpioPortC, 12)) 
      GPIO_PinOutSet(gpioPortD, 8);   /* Drive high PD8 */ 
    else 
      GPIO_PinOutClear(gpioPortD, 8); /* Drive low PD8 */
  }
  
 
}
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Initialize chip */
  CHIP_Init();
  
  /* Enable Low energy clocking module clock. */
  CMU_ClockEnable(cmuClock_CORELE, true);

  /* Disable LFA and LFB clock domains to save power */
  CMU->LFCLKSEL = 0;
  
  /* Starting LFRCO and waiting until it is stable */
  CMU_OscillatorEnable(cmuOsc_LFRCO, true, true);

  /* Enable access to BURTC registers */
  RMU_ResetControl(rmuResetBU, false);

  /* Setting up burtc */
  setupBurtc();
  
  while (1)
  {
    /* Enter EM2. */
    EMU_EnterEM2(false);
  }
}
int main()
{
	CHIP_Init();
	TRACE_SWOSetup();
	ANTHRMSensor * hrm = ANTHRMSensor::getInstance();
	AlarmManager * alm = AlarmManager::getInstance();

	//USARTManager::getInstance()->getPort(USARTManagerPortLEUART0)->setSignalFrameHook(&frameHandler);
	//USARTManager::getInstance()->getPort(USARTManagerPortLEUART0)->setRxHook(&rxHook);

	bool OK = false; 
	
	SensorMessage * msg;
	HeartRateMessage * hrm_msg;
	uint16_t size;
		

	while(1)
	{
		alm->lowPowerDelay(900, sleepModeEM2);
		
		if(OK) {
			hrm->sampleSensorData();
			msg = (SensorMessage *) hrm->readSensorData(&size);
			hrm_msg = (HeartRateMessage *) msg->sensorMsgArray;
			printf("measured heart rate: %d bpm \n", hrm_msg->bpm);
		}
		else {
		  OK = hrm->initializeNetwork(true);			
		}
			
	}
}
/**************************************************************************//**
 * @brief Main function
 *****************************************************************************/
int main(void)
{  
  /* Chip revision alignment and errata fixes */
  CHIP_Init();
  
  /* Set system frequency to 1 MHz */
  CMU_HFRCOBandSet(cmuHFRCOBand_1MHz);
  
  /* Initialize LCD */
  SegmentLCD_Init(false); 

  /* Initialize TIMER0 */
  initTimer();
  
  /* Enable Sleep-om-Exit */
  SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
  
  /* Initialize interrupt count */
  interruptCount = 0;
  
  /* Enter EM1 until all TIMER0 interrupts are done
   * Notice that we only enter sleep once, as the MCU will fall asleep
   * immediately when the ISR is done without returning to main as long as
   * SLEEPONEXIT is set */
  EMU_EnterEM1();
  
  /* Signal that program is done */
  SegmentLCD_Write("DONE");
  while(1);
}
/**************************************************************************//**
 * @brief
 *   Main function is a CMSIS RTOS thread in itself
 *
 * @note
 *   This example uses threads, memory pool and message queue to demonstrate the
 *   usage of these CMSIS RTOS features. In this simple example, the same
 *   functionality could more easily be achieved by doing everything in the main
 *   loop.
 *****************************************************************************/
int main(void)
{
  int count = 0;

  /* Chip errata */
  CHIP_Init();

  /* Initialize CMSIS RTOS structures */
  /* create memory pool */
  mpool = osPoolCreate(osPool(mpool));
  /* create msg queue */
  msgBox = osMessageCreate(osMessageQ(msgBox), NULL);
  /* create thread 1 */
  osThreadCreate(osThread(PrintLcdThread), NULL);

  /* Infinite loop */
  while (1)
  {
    count = (count + 1) & 0xF;

    /* Send message to PrintLcdThread */
    /* Allocate memory for the message */
    lcdText_t *mptr = osPoolAlloc(mpool);
    /* Set the message content */
    (*mptr)[0] = count >= 10 ? '1' : '0';
    (*mptr)[1] = count % 10 + '0';
    (*mptr)[2] = '\0';
    /* Send message */
    osMessagePut(msgBox, (uint32_t) mptr, osWaitForever);

    /* Wait now for half a second */
    osDelay(500);
  }
}
Exemple #12
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip revision alignment and errata fixes */
  CHIP_Init();

  /* Initialize DK board register access */
  BSP_Init(BSP_INIT_DEFAULT);

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000))
  {
    while (1) ;
  }

  /* Blink forever */
  while (1)
  {
    /* Blink user leds on DVK board */
    BSP_LedsSet(0x00ff);
    Delay(200);

    /* Blink user leds on DVK board */
    BSP_LedsSet(0xff00);
    Delay(200);
  }
}
Exemple #13
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Initialize SLEEP driver, no calbacks are used */
  SLEEP_Init(NULL, NULL);
#if (configSLEEP_MODE < 3)
  /* do not let to sleep deeper than define */
  SLEEP_SleepBlockBegin((SLEEP_EnergyMode_t)(configSLEEP_MODE+1));
#endif

  /* Initialize the LCD driver */
  SegmentLCD_Init(false);

  /* Create standard binary semaphore */
  vSemaphoreCreateBinary(sem);

  /* Create two task to show numbers from 0 to 15 */
  xTaskCreate(Count, (const signed char *) "Count", STACK_SIZE_FOR_TASK, NULL, TASK_PRIORITY, NULL);
  xTaskCreate(LcdPrint, (const signed char *) "LcdPrint", STACK_SIZE_FOR_TASK, NULL, TASK_PRIORITY, NULL);

  /* Start FreeRTOS Scheduler */
  vTaskStartScheduler();

  return 0;
}
/******************************************************************************
 * @brief  
 *   Main function
 *****************************************************************************/
int main(void)
{
  /* Initialize chip - handle erratas */
  CHIP_Init();

  /* Setup RTC for periodic wake-ups */
  startRTCTick();

  /* Start LFXO. Do not wait until it is stable */
  CMU_OscillatorEnable(cmuOsc_LFXO, true, false);

  /* Wait in EM2 until LFXO is ready */
  while (!(CMU->STATUS & CMU_STATUS_LFXORDY))
  {
    EMU_EnterEM2(false);
  }
  /* Stop the RTC */
  stopRTCTick();

  while (1)
  {
    /* Go to sleep */
    EMU_EnterEM1();
  }
}
Exemple #15
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
	// Chip errata
	CHIP_Init();

	setup_utilities();

	CMU_ClockEnable(cmuClock_GPIO, true);

	// Set up the user interface buttons
	GPIO_PinModeSet(BUTTON_PORT, SET_BUTTON_PIN, gpioModeInput,  0);

	while (1)
	{
		if (get_button())
		{
			set_led(0, 1);
			delay(DELAY_VALUE);
			set_led(1, 1);
		}
		else
		{
			set_led(0, 0);
			set_led(1, 0);
		}
	}
}
Exemple #16
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();

  enter_DefaultMode_from_RESET();


  Imu_Initialize();
  //Imu_Initialize_OneShot();
  Mag_Initialize_OneShot();
  Cli_Initialize_Cli();
  Time_Initilize_TimeStamp();
  Sch_Initilize_Scheduler();
  /* Infinite loop */
  Sch_Run_Scheduler();




  while(1)
  {
	  //Temporary while loop
	  //Imu_TestFunction();
	  //Imu_Read();
	  Imu_WriteStreamFifo();
  }

}
Exemple #17
0
int main()
{
	
	// Chip errata
	CHIP_Init();
	
	// ensure core frequency has been updated
	SystemCoreClockUpdate();
	
	// start clocks
	initClocks();
		
	// init LEDs
	LED_Init();
	
	// init scheduler
	SCHEDULER_Init();
	
	// enable timers
	enableTimers();
	
	// enable interrupts
	enableInterrupts();
	
	// init tasks
	SCHEDULER_TaskInit(&radio_task, radio_task_entrypoint);
	
	// run
	SCHEDULER_Run();
	
}
Exemple #18
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();
  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Initialize LED driver */
  BSP_LedsInit();
  /* Setting state of leds*/
  BSP_LedSet(0);
  BSP_LedSet(1);

  /* Initialize SLEEP driver, no calbacks are used */
  SLEEP_Init(NULL, NULL);
#if (configSLEEP_MODE < 3)
  /* do not let to sleep deeper than define */
  SLEEP_SleepBlockBegin((SLEEP_EnergyMode_t)(configSLEEP_MODE+1));
#endif

  /* Parameters value for taks*/
  static TaskParams_t parametersToTask1 = { pdMS_TO_TICKS(1000), 0 };
  static TaskParams_t parametersToTask2 = { pdMS_TO_TICKS(500), 1 };

  /*Create two task for blinking leds*/
  xTaskCreate( LedBlink, (const char *) "LedBlink1", STACK_SIZE_FOR_TASK, &parametersToTask1, TASK_PRIORITY, NULL);
  xTaskCreate( LedBlink, (const char *) "LedBlink2", STACK_SIZE_FOR_TASK, &parametersToTask2, TASK_PRIORITY, NULL);

  /*Start FreeRTOS Scheduler*/
  vTaskStartScheduler();

  return 0;
}
/******************************************************************************
 * @brief  Main function
 * Main is called from _program_start, see assembly startup file
 *****************************************************************************/
int main(void)
{

  /* Initialize chip */
  //eADesigner_Init();
  /* Initialize chip */
  CHIP_Init();

  /* Initalizing */
  init();

  GPIO_PortOutSetVal(gpioPortD, 1<<3, 1<<3);
  GPIO_PortOutSetVal(gpioPortF, 1<<6, 1<<6);
  GPIO_PortOutSetVal(gpioPortB, 1<<12, 1<<12);
  GPIO_PortOutSetVal(LED_PORT, 1<<LED_PIN, 1<<LED_PIN);
  while(1){
	  /* Data transmission to slave */
	  /* ************************** */
	  /* Setting up RX interrupt for master */
	  SPI1_setupRXInt(receiveBuffer, BUFFERSIZE);
	  GPIO_PortOutSetVal(LED_PORT, 0<<LED_PIN, 1<<LED_PIN);
	  /* Transmitting data */
	  USART1_sendBuffer(transmitBuffer, BUFFERSIZE);
	  GPIO_PortOutSetVal(LED_PORT, 1<<LED_PIN, 1<<LED_PIN);
  }

}
/******************************************************************************
 * @brief  Main function
 * The main file starts a timer and uses PRS to trigger an ADC conversion.
 * It waits in EM1 until the ADC conversion is complete, then prints the
 * result on the lcd.
 *****************************************************************************/
int main(void)
{
  /* Initialize chip */
  CHIP_Init();
  
  SegmentLCD_Init(false);

  /* Enable clocks required */
  CMU_ClockEnable(cmuClock_ADC0, true);
  CMU_ClockEnable(cmuClock_PRS, true);
  CMU_ClockEnable(cmuClock_TIMER0, true);

  /* Select TIMER0 as source and TIMER0OF (Timer0 overflow) as signal (rising edge) */
  PRS_SourceSignalSet(0, PRS_CH_CTRL_SOURCESEL_TIMER0, PRS_CH_CTRL_SIGSEL_TIMER0OF, prsEdgePos);

  ADCConfig();
  TimerConfig();

  /* Stay in this loop forever */
  while (1)
  {
    /* Enter EM1 and wait for timer triggered adc conversion */
    EMU_EnterEM1();

    /* Write result to LCD */
    SegmentLCD_Number(adcResult);

    /* Do other stuff */
    int i;
    for (i = 0; i < 10000; i++) ;
  }
}
Exemple #21
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();

  /* Enable clock for GPIO */
  CMU_ClockEnable(cmuClock_GPIO, true);

  /* Configure LED_PORT pin LED_PIN (User LED) as push/pull outputs */
  GPIO_PinModeSet(LED_PORT,         /* Port */
                  LED_PIN,          /* Pin */
                  gpioModePushPull, /* Mode */
                  0 );              /* Output value */

  /* Initialize SLEEP driver, no calbacks are used */
  SLEEP_Init(NULL, NULL);
#if (configSLEEP_MODE < 3)
  /* do not let to sleep deeper than define */
  SLEEP_SleepBlockBegin((SLEEP_EnergyMode_t)(configSLEEP_MODE+1));
#endif

  /*Create two task for blinking leds*/
  xTaskCreate( LedBlink, (const char *) "LedBlink", STACK_SIZE_FOR_TASK,  NULL, TASK_PRIORITY, NULL);

  /* Start FreeRTOS Scheduler */
  vTaskStartScheduler();

  return 0;
}
/**************************************************************************//**
 * @brief  Main function
 * Main is called from __iar_program_start, see assembly startup file
 *****************************************************************************/
int main(void)
{  
  /* Align different chip revisions */
  CHIP_Init();
    
  /* Enable clock for PRS */
  CMU_ClockEnable(cmuClock_PRS, true);

  /* Initialize DAC */
  DAC_setup();

  /* Calculate output to 0.5 V. */
  uint32_t dacValue;
  dacValue = (uint32_t)((0.5 * 4096) / 3.3);
  
  /* Write the new value to DAC register
     This value will not be output immediately, 
     only when the PRS pulse is generated by
     software */
  DAC_WriteData(DAC0, dacValue, 0);
  
  /* Generate PRS pulse on channel 5 
     by writing 1 to bit 5 (0x20) in
     PRS_SWPULSE register 
     This will trigger the DAC conversion
     and 0.5V can be probed on PB11 */
  PRS_PulseTrigger(0x20);
  
  while(1)
  {
    /* Enter EM1 */ 
    EMU_EnterEM1();
  }
}
Exemple #23
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();

  /* Ensure core frequency has been updated */
  SystemCoreClockUpdate();

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Init LCD with no voltage boost */
  SegmentLCD_Init(oldBoost);

  /* Setup RTC to generate an interrupt every minute */
  rtcSetup();

  /* Enable GPIO clock */
  CMU_ClockEnable(cmuClock_GPIO, true);

  /* Setup GPIO interrupt to set the time */
  gpioSetup();

  /* Main function loop */
  //clockLoop();

  main_loop();

  return 0;
}
Exemple #24
0
void KP_Init()
{
	CHIP_Init();
	PORTC &= 0x3F;
    DDRC |= 0xC0;
	PORTB = 0xFF;
    DDRB = 0x00;
}
Exemple #25
0
/**************************************************************************//**
 * @brief  Main function of clock example.
 *
 *****************************************************************************/
int main(void)
{  
  EMSTATUS status;
  bool redraw;
  ClockMode_t prevClockMode = CLOCK_MODE_DIGITAL;
  
  /* Chip errata */
  CHIP_Init();

  /* Use the 21 MHz band in order to decrease time spent awake.
     Note that 21 MHz is the highest HFRCO band on ZG. */
  CMU_ClockSelectSet( cmuClock_HF, cmuSelect_HFRCO  );
  CMU_HFRCOBandSet( cmuHFRCOBand_21MHz );

  /* Setup GPIO for pushbuttons. */
  gpioSetup();

  /* Initialize display module */    
  status = DISPLAY_Init();
  if (DISPLAY_EMSTATUS_OK != status)
    while (true)
      ;

  /* Initialize the DMD module for the DISPLAY device driver. */
  status = DMD_init(0);
  if (DMD_OK != status)
    while (true)
      ;

  status = GLIB_contextInit(&gc);
  if (GLIB_OK != status)
    while (true)
      ;
  
  /* Set PCNT to generate interrupt every second */
  pcntInit();
  
  /* Pre-compte positions for the analog graphics */
  analogClockInitGraphics();

  /* Enter infinite loop that switches between analog and digitcal clock
   * modes, toggled by pressing the button PB0. */
  while (true)
  {    
    redraw = (prevClockMode != clockMode);
    prevClockMode = clockMode;
    if (CLOCK_MODE_ANALOG == clockMode)
    {
      analogClockShow(redraw);
    }
    else
    {
      digitalClockShow(redraw);
    }
    /* Sleep between each frame update */
    EMU_EnterEM2(false);
  }
}
Exemple #26
0
int main(int argc, char **argv)
{
/*
 * Initalize chip.
 */
  CHIP_Init();

/* 
 * Use XT oscillator, disable internal RC osc.
 */
  CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);
  CMU_OscillatorEnable(cmuOsc_HFRCO, false, false);
  SystemCoreClockUpdate();

#if PORTCFG_CON_USART == 0
  // Allow deep sleep. Doesn't work well with uart console currently.
  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
#endif

#if PORTCFG_CONOUT_ITM == 1
#ifdef _DBG
  if (DBG_Connected()) {

    CMU_ClockEnable(cmuClock_GPIO, true);
    DBG_SWOEnable(0);

    /* Enable trace in core debug, taken from Energy Aware Commander */
    CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
    ITM->LAR  = 0xC5ACCE55;
    ITM->TER  = 0x0;
    ITM->TCR  = 0x0;
    TPI->SPPR = 2;
    TPI->ACPR = 0xf;
    ITM->TPR  = 0x0;
    DWT->CTRL = 0x400003FE;
    ITM->TCR  = 0x0001000D;
    TPI->FFCR = 0x00000100;
    ITM->TER  = 0x1;

  }
#endif
#endif

#if PORTCFG_CON_USART == 1

  // Configure usart pins.

  CMU_ClockEnable(cmuClock_GPIO, true);

  GPIO_PinModeSet(gpioPortC, 0, gpioModePushPull, 1);
  GPIO_PinModeSet(gpioPortC, 1, gpioModeInput, 0);

#endif

  testStart();
  return 0;
}
Exemple #27
0
/**************************************************************************//**
 * @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)
{
  /* Initialize chip */
  CHIP_Init();
  
  /* Enable code view */
  setupSWO();

  /* Initialize LCD */
  SegmentLCD_Init(false);

  /* Enable the HFPER clock */
  CMU_ClockEnable(cmuClock_HFPER, true);

  /* Configure RTC and GPIO */
  rtc_setup();
  gpio_setup();

  /* Stay in this loop forever */
  while (1)
  {
    /* Wait for Push Button 1 to be pressed */
    while (GPIO_PinInGet(PB0_PORT, PB0_PIN)) ;
    /* and released, so that we do not exit the while loop below immediately */
    while (!GPIO_PinInGet(PB0_PORT, PB0_PIN)) ;

    /* Reset time */
    time = 0;

    /* Disable LCD */
    LCD_Enable(true);

    /* Update time until Push Button 1 is pressed again */
    while (1)
    {
      if (RTC_CounterGet() == 0)
      {
        SegmentLCD_Number(++time);
      }

      if (!GPIO_PinInGet(PB0_PORT, PB0_PIN))
        break;
    }

    /* Delay while showing the result on the LCD */
    for (uint32_t delay = 0; delay < 30; delay++)
    {
      /* Wait for the RTC to overflow once */
      while (RTC_CounterGet() != 0) ;
      while (RTC_CounterGet() == 0) ;
    }

    /* Disable LCD */
    LCD_Enable(false);
  }
}
Exemple #29
0
int main(void) 
{
	
	CHIP_Init();

	if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;

  BSP_Init(BSP_INIT_DEFAULT);
	BSP_LedsSet(0);

  BSP_PeripheralAccess(BSP_AUDIO_IN, true);
  BSP_PeripheralAccess(BSP_AUDIO_OUT, true);

  RTCDRV_Trigger(1000, NULL);
  EMU_EnterEM2(true);

  initSource();

	setupCMU();
  setupDMA();
  
  //setupADC();
  //setupDAC();

  //setupDMAInput();
  //setupDMAOutput();

	//setupDMASplit();
	//setupDMAMerge();

  ADCConfig();
  DACConfig();

  TIMER_Init_TypeDef timerInit = TIMER_INIT_DEFAULT;
  TIMER_TopSet(TIMER0, CMU_ClockFreqGet(cmuClock_HFPER) / SAMPLE_RATE);
  TIMER_Init(TIMER0, &timerInit);

	Delay(100);
	BSP_LedsSet(3);
	Delay(500);
	BSP_LedsSet(0);
	Delay(100);

	while(1) {
		volatile bool result = test();
		if (result) {
			BSP_LedsSet(0x00FF);
		} else {
			BSP_LedsSet(0xFF00);			
		}
		Delay(1000);
    BSP_LedsSet(0x0);    
    Delay(1000);
	}

}
Exemple #30
0
/******************************************************************************
 * @brief  Main function
 * Main is called from _program_start, see assembly startup file
 *****************************************************************************/
int main(void)
{  
  /* Initialize chip */
  CHIP_Init();  
  
  /* ENTER YOUR CODE HERE */

  while(1);
  
}