Esempio n. 1
0
void initLed(Button* but, Gpio* gpio, u8 port, u8 bit, u8 pressedState)
{
	initGpio(gpio, port, bit);
	but->gpio = gpio;
	but->pressedState = pressedState;
	
	ctlGpioIn(gpio);
}
Esempio n. 2
0
void init()
{
    Chip_SYSCTL_SetBODLevels(SYSCTL_BODRSTLVL_2_06V, SYSCTL_BODINTVAL_RESERVED1);
    Chip_SYSCTL_EnableBODReset();

    initWatchdog();
    initClock();
    initGpio();

    resetWatchdog();
}
Esempio n. 3
0
void _ma3_init()
{
  initGpio();
  initTimers();

  IC3ReadValue1 = 0;
  IC3ReadValue2 = 0;
  ma3_capture = 0;
  CaptureNumber = 0;
  dataCaptureReady = 0;
  ma3_capture_angle=0;
}
Esempio n. 4
0
int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;               // Stop WDT

    initGpio();                             // Configure GPIO

    // Initialize XT1 32kHz crystal
    P4SEL0 |= BIT1 | BIT2;                  // set XT1 pin as second function
    do
    {
        CSCTL7 &= ~(XT1OFFG | DCOFFG);      // Clear XT1 and DCO fault flag
        SFRIFG1 &= ~OFIFG;
    } while (SFRIFG1 & OFIFG);              // Test oscillator fault flag

    // First determine whether we are coming out of an LPMx.5 or a regular RESET.
    if (SYSRSTIV == SYSRSTIV_LPM5WU)        // When woken up from LPM3.5, reinit
    {
        // If MCU wakes up from LPM3.5, re-init and then return to LPM3.5 again.

        // Restore P1OUT value from backup RAM memory, keep P1OUT after LPMx.5 reset
        P1OUT = *(unsigned int *)BAK_RAM_BASE;

        __enable_interrupt();               // The RTC interrupt should trigger now...
    }
    else
    {
        // Device powered up from a cold start.
        // It configures the device and puts the device into LPM3.5

        // Configure backup memory
        *(unsigned int *)BAK_RAM_BASE = 0;

        // Initialize RTC
        // Interrupt and reset happen every 1024/32768 * 32 = 1 sec.
        RTCMOD = 32-1;
        RTCCTL = RTCSS__XT1CLK | RTCSR | RTCPS__1024 | RTCIE;

        // Store P1OUT value in backup memory register before enter LPM3.5
        *(unsigned int *)BAK_RAM_BASE = P1OUT;
    }

    // Enter LPM3.5 mode with interrupts enabled. Note that this operation does
    // not return. The LPM3.5 will exit through a RESET event, resulting in a
    // re-start of the code.
    PMMCTL0_H = PMMPW_H;                    // Open PMM Registers for write
    PMMCTL0_L |= PMMREGOFF;                 // and set PMMREGOFF
    __bis_SR_register(LPM3_bits | GIE);
    __no_operation();

    return 0;
}
Esempio n. 5
0
int main(void)
{
    
    initGpio();

    configurePins();
    
    while(1)
    {

    }

    return 0;
}
Esempio n. 6
0
int main() {
  trace_puts(">>> VfdClock main() init");
  initGpio();
  initRtc();
  initTimer();
  initUart();
  SysTick_Config(72000);  // 1kHz
  trace_puts("<<< VfdClock main() init");

  GPIO_WriteBit(LED_PORT, LED_PIN, RESET);

  // Disable buzzer.
  GPIO_WriteBit(BUZ_PORT, BUZ_PIN, RESET);
  TIM_Cmd(TIM3, DISABLE);

  backupLoad();

  uint8_t digits[6] = {
      DIGIT_BLANK, DIGIT_DASH, DIGIT_DASH, DIGIT_DASH, DIGIT_DASH, DIGIT_BLANK};
  setDisplay(digits);

  gSeconds = RTC_GetCounter();

  time_t localtime;
  struct tm *t = gmtime(&gSeconds);

  // Logic loop.
  while (1) {
    // Read GPS data, if it exists.
    if (strlen(gGpsLine) > 0) {
      handleGpsLine();
    } else if (gGpsNextPoll < gSeconds) {
      gpsSetPushFreq("ZDA", 2);
    }

    handleDigits(digits, t);
    handleButtonPress();

    if (gSecondFlag) {
      gSecondFlag = 0;
      localtime = gSeconds + gUtcOffset;
      t = gmtime(&localtime);
      handleDigits(digits, t);
      setDisplay(digits);
      // Blink decimal point.
      GPIO_WriteBit(DP_PORT, DP_PIN, SET);
      gDpTick = 500;
    }
  }
}
Esempio n. 7
0
int main(void) {
	double cpuTemp = getCpuTemp();
	printf("cpu temp: %.2f\n", cpuTemp);

	if (initGpio() == -1) {
		exit(1);
	}

	setLedFlash(0, 3);

	while (1) {
		int light = hasLight(7);
		int sound = hasSound(1);
		printf("has light: %d, has sound: %d\n", light, sound);

		delay(100);
	}

	return 0;
}
Esempio n. 8
0
/**
 ******************************************************************************
 ** \简  述  初始化MCU系统,包括看门狗、系统时钟、GPIO和各种需要的外设
 **
 ** \参  数  none
 ** \返回值  none
 ******************************************************************************/
void initMCU(void)
{
    initGpio(); 
    
    LED1 = LED_ON;
    LED2 = LED_ON;
    LED3 = LED_ON;
    LEDRED = LED_ON;
    LEDGRN = LED_ON;
    delay100ms(2);
    LED1 = LED_OFF;
    LED2 = LED_OFF;
    LED3 = LED_OFF;
    LEDRED = LED_OFF;
    LEDGRN = LED_OFF;
    initUart();
    initSPI();
    initButton();
    UsbConfig_UsbInit();
    UsbDeviceCdcCom_SetSeparator('\r');     // there is the possibility to set end of buffer by a seperator
    UsbDeviceCdcCom_SetEchomode(TRUE);      // all input shall be echoed
    UsbConfig_SwitchMode(); 
    __enable_interrupt();
}
Esempio n. 9
0
void init(void) {
	sysclk_init();
	board_init();
	initGpio();
}
Esempio n. 10
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
#ifdef GG_STK
  uint32_t mode = 0;
#else
  /* Initialize DK board register access, necessary if run on DK */
  BSP_Init(BSP_INIT_DEFAULT);
  BSP_PeripheralAccess(BSP_AUDIO_OUT, true);
#endif
  
  /* Initialize peripherals */
  initClock();
  initDma();
  initDac();
  initDacDma();
  initTimer();
#ifdef GG_STK
  initGpio();
#endif

  while(1)
  {
/*** Operation for EFM32GG-DK3750 ***/    
#ifndef GG_STK
    /* Wait key press */
    while(!BSP_PushButtonsGet())
      ;
    if (BSP_PushButtonsGet() == BC_UIF_PB1)
    {
      BSP_LedsSet(0x0001);
      /* Wait key release */
      while(BSP_PushButtonsGet()!=0);
      /* Start play files */      
      playList[0].frameStart = (char *)voice8k;
      playList[1].frameStart = NULL;
      playList[0].frameNum = sizeof(voice8k)/FRAME_SIZE_8K;
      speexPlayBack(0, NARROWBAND, FRAME_SIZE_8K, &playList[0]);
      BSP_LedsSet(0x0000);
    }
    if (BSP_PushButtonsGet() == BC_UIF_PB2)
    {    
      BSP_LedsSet(0x0002);
      /* Wait key release */
      while(BSP_PushButtonsGet()!=0);
      /* Start play files */      
      playList[0].frameStart = (char *)voice11k;
      playList[1].frameStart = NULL;
      playList[0].frameNum = sizeof(voice11k)/FRAME_SIZE_11K;
      speexPlayBack(0, NARROWBAND, FRAME_SIZE_11K, &playList[0]);
      BSP_LedsSet(0x0000);
    }
    if (BSP_PushButtonsGet() == BC_UIF_PB3)
    {
      BSP_LedsSet(0x0004);
      /* Wait key release */
      while(BSP_PushButtonsGet()!=0);
      /* Start play files */      
      playList[0].frameStart = (char *)voice15k;
      playList[1].frameStart = NULL;
      playList[0].frameNum = sizeof(voice15k)/FRAME_SIZE_15K;
      speexPlayBack(0, NARROWBAND, FRAME_SIZE_15K, &playList[0]);
      BSP_LedsSet(0x0000);
    }
    if (BSP_PushButtonsGet() == BC_UIF_PB4)
    {    
      BSP_LedsSet(0x0008);
      /* Wait key release */
      while(BSP_PushButtonsGet()!=0);
      /* Start play files */      
      playList[0].frameStart = (char *)voice18k2;
      playList[1].frameStart = NULL;
      playList[0].frameNum = sizeof(voice18k2)/FRAME_SIZE_18K2;
      speexPlayBack(0, NARROWBAND, FRAME_SIZE_18K2, &playList[0]);
      BSP_LedsSet(0x0000);
    }

/*** Operation for EFM32GG-STK3750 ***/        
#else
    /* Wait key press */
    EMU_EnterEM1();

    switch (keyCheck())
    {
    case 1:
      mode++;
      if (mode == 4)
      {
        mode = 0;
      }
      GPIO_PortOutSetVal(gpioPortE, (mode << 2), 0x000c);
      break;
      
    case 2:
      if (mode == 0x00)
      {
        /* Start play files */      
        playList[0].frameStart = (char *)voice8k;
        playList[1].frameStart = NULL;
        playList[0].frameNum = sizeof(voice8k)/FRAME_SIZE_8K;
        speexPlayBack(0, NARROWBAND, FRAME_SIZE_8K, &playList[0]);
      }
      else if (mode == 0x01)
      {
        /* Start play files */      
        playList[0].frameStart = (char *)voice11k;
        playList[1].frameStart = NULL;
        playList[0].frameNum = sizeof(voice11k)/FRAME_SIZE_11K;
        speexPlayBack(0, NARROWBAND, FRAME_SIZE_11K, &playList[0]);
      }
      else if (mode == 0x02)
      {
        /* Start play files */      
        playList[0].frameStart = (char *)voice15k;
        playList[1].frameStart = NULL;
        playList[0].frameNum = sizeof(voice15k)/FRAME_SIZE_15K;
        speexPlayBack(0, NARROWBAND, FRAME_SIZE_15K, &playList[0]);
      }
      else
      {
        /* Start play files */      
        playList[0].frameStart = (char *)voice18k2;
        playList[1].frameStart = NULL;
        playList[0].frameNum = sizeof(voice18k2)/FRAME_SIZE_18K2;
        speexPlayBack(0, NARROWBAND, FRAME_SIZE_18K2, &playList[0]);
      }
      break;
      
    default:
      break;
    }    
#endif
  }
}