/**
 * Configures the EZRadio GPIO port and pins
 *
 * @param[in] ezradioIrqCallback EZRadio interrupt callback configuration
 * @param[in] enablePTI If true enables the radio PTI bridge in the controller.
 */
void ezradio_hal_GpioInit( GPIOINT_IrqCallbackPtr_t ezradioIrqCallback, bool enablePTI )
{
#if defined(_EZR32_HAPPY_FAMILY)
  (void)enablePTI;
#endif

#if !defined(EZRADIODRV_SPI_4WIRE_MODE)
   GPIO_PinModeSet( (GPIO_Port_TypeDef) RF_USARTRF_CS_PORT, RF_USARTRF_CS_PIN, gpioModePushPull, 1 );
#endif

   /* Setup enable and interrupt pins to radio */
   GPIO_PinModeSet( (GPIO_Port_TypeDef) RF_SDN_PORT, RF_SDN_PIN, gpioModePushPull,  0 );
   GPIO_PinModeSet( (GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, gpioModeInputPull, 1 );

   /* EZR32HG family uses hard wired PTI interface from the radio to the board controller */
#if ( !defined(_EZR32_HAPPY_FAMILY) && !defined(EZRADIODRV_DISABLE_PTI) )
   if (enablePTI)
   {
     /* Setup PRS for PTI pins */
     CMU_ClockEnable(cmuClock_PRS, true);

     /* Configure RF_GPIO0 and RF_GPIO1 to inputs. */
     GPIO_PinModeSet((GPIO_Port_TypeDef)RF_GPIO0_PORT, RF_GPIO0_PIN, gpioModeInput, 0);
     GPIO_PinModeSet((GPIO_Port_TypeDef)RF_GPIO1_PORT, RF_GPIO1_PIN, gpioModeInput, 0);

     /* Pin PA0 and PA1 output the GPIO0 and GPIO1 via PRS to PTI */
     GPIO_PinModeSet(gpioPortA, 0, gpioModePushPull, 0);
     GPIO_PinModeSet(gpioPortA, 1, gpioModePushPull, 0);

     /* Disable INT for PRS channels */
     GPIO_IntConfig((GPIO_Port_TypeDef)RF_GPIO0_PORT, RF_GPIO0_PIN, false, false, false);
     GPIO_IntConfig((GPIO_Port_TypeDef)RF_GPIO1_PORT, RF_GPIO1_PIN, false, false, false);

     /* Setup PRS for RF GPIO pins  */
     PRS_SourceAsyncSignalSet(0, PRS_CH_CTRL_SOURCESEL_GPIOH, PRS_CH_CTRL_SIGSEL_GPIOPIN15);
     PRS_SourceAsyncSignalSet(1, PRS_CH_CTRL_SOURCESEL_GPIOH, PRS_CH_CTRL_SIGSEL_GPIOPIN14);
     PRS->ROUTE = (PRS_ROUTE_CH0PEN | PRS_ROUTE_CH1PEN);

     /* Make sure PRS sensing is enabled (should be by default) */
     GPIO_InputSenseSet(GPIO_INSENSE_PRS, GPIO_INSENSE_PRS);
   }
#endif //#if !defined(_EZR32_HAPPY_FAMILY)

#if defined(EZRADIODRV_DISABLE_PTI) && defined(EZRADIODRV_COMM_USE_GPIO1_FOR_CTS)
   //Enable GPIO1 for CTS input
   GPIO_PinModeSet((GPIO_Port_TypeDef)RF_GPIO1_PORT, RF_GPIO1_PIN, gpioModeInput, 0);
#endif

   if (NULL != ezradioIrqCallback)
   {
       /* Register callback and enable interrupt */
       GPIOINT_CallbackRegister( RF_INT_PIN, ezradioIrqCallback );
       GPIO_IntConfig( (GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, false, true, true );
   }

}
/**************************************************************************//**
 * @brief Initialize Real Time Counter
 *****************************************************************************/
void initRTC()
{
  /* Starting LFXO and waiting until it is stable */
  CMU_OscillatorEnable(cmuOsc_LFXO, true, true);

  /* Routing the LFXO clock to the RTC */
  CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO);
  CMU_ClockEnable(cmuClock_RTC, true);

  /* Enabling clock to the interface of the low energy modules */
  CMU_ClockEnable(cmuClock_CORELE, true);

  const RTC_Init_TypeDef rtcInit =
  {
    .enable   = true,
    .debugRun = false,
    .comp0Top = true,
  };

  RTC_Init(&rtcInit);

  /* Set comapre value for compare register 0 */
  RTC_CompareSet(0, RTC_COUNT_BETWEEN_WAKEUP);

  /* Enable interrupt for compare register 0 */
  RTC_IntEnable(RTC_IFC_COMP0);

  /* Enabling Interrupt from RTC */
  NVIC_EnableIRQ(RTC_IRQn);

  RTC_Enable(false);
}

/**************************************************************************//**
 * @brief Initialize General Purpuse Input/Output
 *****************************************************************************/
void initGPIO()
{
  /* Enable clock for GPIO module */
  CMU_ClockEnable(cmuClock_GPIO, true);

  /* Configure pin PB9/PD8 (Push Button 1) and PB10/PB11 (Push Button 2) as an input,
   * so that we can read their values. */
  GPIO_PinModeSet(PB0_PORT, PB0_PIN, gpioModeInput, 1);
  GPIO_PinModeSet(PB1_PORT, PB1_PIN, gpioModeInput, 1);

  /* Enable GPIO_ODD and GPIO_EVEN interrupts in NVIC */
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);

  /* Configure interrupts on falling edge for pins B9/D8 (Push Button 1),
   * B10/B11 (Push Button 2) and D3 */
  GPIO_IntConfig(PB0_PORT, PB0_PIN, true, true, true);
  GPIO_IntConfig(PB1_PORT, PB1_PIN, true, true, true);
}
Beispiel #3
0
/*==============================================================================
  hal_extIntInit()
 =============================================================================*/
uint8_t hal_extIntInit(en_targetExtInt_t e_intSource, pfn_intCallb_t pfn_intCallback)
{
    int8_t    c_ret = 0;
    s_hal_gpio_pin_t* p_gpioPin = NULL;

    if( pfn_intCallback != NULL ) {

      /* Initialize GPIO interrupt dispatcher */
      GPIOINT_Init();

      switch( e_intSource ){
        case E_TARGET_RADIO_INT:

            pf_hal_radioCb = pfn_intCallback;

            p_gpioPin = &s_hal_gpio[e_hal_gpios_rf_irq];
            /* configure pin */
            GPIO_PinModeSet( p_gpioPin->port, p_gpioPin->pin, p_gpioPin->mode, p_gpioPin->val );
            /* Register callbacks before setting up and enabling pin interrupt. */
            GPIOINT_CallbackRegister( p_gpioPin->pin, _hal_radioCb );
            /* Set falling edge interrupt */
            GPIO_IntConfig( p_gpioPin->port, p_gpioPin->pin, true, false, true );
            c_ret = 1;
            break;

        case E_TARGET_USART_INT:
            break;

        default:
            break;
        }
    }
    return c_ret;
} /* hal_extIntInit() */
__LINK_C error_t hw_gpio_configure_interrupt(pin_id_t pin_id, gpio_inthandler_t callback, uint8_t event_mask)
{
    if(interrupts[pin_id.pin].interrupt_port != pin_id.port)
    	return EOFF;
    else if(callback == 0x0 || event_mask > (GPIO_RISING_EDGE | GPIO_FALLING_EDGE))
    	return EINVAL;

    error_t err;
    start_atomic();
	//do this check atomically: interrupts[..] callback is altered by this function
	//so the check belongs in the critical section as well
    if(interrupts[pin_id.pin].callback != 0x0 && interrupts[pin_id.pin].callback != callback)
	    err = EBUSY;
	else
	{
	    interrupts[pin_id.pin].callback = callback;
    	GPIOINT_CallbackRegister(pin_id.pin, &gpio_int_callback);
	    GPIO_IntConfig(pin_id.port, pin_id.pin, 
			!!(event_mask & GPIO_RISING_EDGE),
			!!(event_mask & GPIO_FALLING_EDGE),
			false);			
	    err = SUCCESS;
	}
    end_atomic();
    return err;
}
/*
 *  Interrupt GDO2 init
 */
void CC1101_Radio::initializeRadioInterrupt2( bool rising, bool falling )
{
	GPIO_PinModeSet( _CC1101_INT_PIN_TWO, gpioModeInputPull, 1 );
	GPIO->IFC = ~0;
	GPIO_IntConfig( _CC1101_INT_PIN_TWO, rising, falling, true );
	NVIC_EnableIRQ( GPIO_EVEN_IRQn );
}
void setup_gpio_and_buttons()
{
	CMU_ClockEnable(cmuClock_GPIO, true);

	// Make sure the soleniod is off at startup
	GPIO_PinModeSet(SOLENOID_PORT, SOLENOID_PIN, gpioModePushPull, 0);

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

	set_button.short_press = false;
	set_button.long_press = false;
	set_button.pin = SET_BUTTON_PIN;

	adjust_button.short_press = false;
	adjust_button.long_press = false;
	adjust_button.pin = ADJUST_BUTTON_PIN;

	program_button.short_press = false;
	program_button.long_press = false;

	button_array[SET_BUTTON_INDEX] = &set_button;
	button_array[ADJUST_BUTTON_INDEX] = &adjust_button;
	button_array[PROGRAM_BUTTON_INDEX] = &program_button;

	// Enable GPIO_ODD interrupt vector in NVIC
	//NVIC_EnableIRQ(GPIO_ODD_IRQn);
	NVIC_EnableIRQ(GPIO_EVEN_IRQn);

	// Configure interrupt on falling edge of SET_BUTTON_PIN
	GPIO_IntConfig(BUTTON_PORT, SET_BUTTON_PIN, false, true, true);
}
Beispiel #7
0
int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
                  gpio_cb_t cb, void *arg)
{
    int result = gpio_init(pin, mode);

    if (result != 0) {
        return result;
    }

    /* just in case, disable the interrupt for this pin */
    GPIO_IntDisable(_pin_num(pin));

    /* store interrupt callback */
    isr_ctx[_pin_num(pin)].cb = cb;
    isr_ctx[_pin_num(pin)].arg = arg;

    /* enable interrupts */
    GPIO_IntConfig(_port_num(pin), _pin_num(pin),
                   flank & GPIO_RISING, flank & GPIO_FALLING, true);

    NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
    NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);

    NVIC_EnableIRQ(GPIO_EVEN_IRQn);
    NVIC_EnableIRQ(GPIO_ODD_IRQn);

    return 0;
}
Beispiel #8
0
void initGPIO()
{
	  CMU_ClockEnable(cmuClock_GPIO, true);                           // enable GPIO peripheral clock

	  GPIO_PinModeSet(GPS_PORT, FIX, gpioModeInput, 0);    // set FIX pin as input (no filter)
	  GPIO_PinModeSet(GPS_PORT, ENABLE, gpioModePushPull, 0);    // set ENABLE pin as output, initialize low

	  GPIO_PinModeSet(LED_PORT, LED0_PIN, gpioModePushPull, 0);       // configure LED0 pin as push-pull output with standard drive strength
	  GPIO_PinModeSet(LED_PORT, LED1_PIN, gpioModePushPull, 0);  // configure LED1 pin as push-pull output with alternate drive strength
	  GPIO_PinModeSet(EXT_LED, RED_LED, gpioModePushPull, 0);  // configure LED1 pin as push-pull output with alternate drive strength
	  GPIO_PinModeSet(EXT_LED, YEL_LED, gpioModePushPull, 0);  // configure LED1 pin as push-pull output with alternate drive strength
	  GPIO_PinModeSet(EXT_LED, GRE_LED, gpioModePushPull, 0);  // configure LED1 pin as push-pull output with alternate drive strength
	  GPIO_DriveModeSet(LED_PORT, gpioDriveModeLowest);               // set alternate drive strength to lowest setting (0.5mA)
	  GPIO_PinOutClear(LED_PORT, LED0_PIN);                             // turn on LED0
	  GPIO_PinOutSet(LED_PORT, LED1_PIN);                             // turn on LED1
	  GPIO_PinOutClear(EXT_LED, RED_LED);
	  GPIO_PinOutClear(EXT_LED, YEL_LED);                           // turn on LED1
	  GPIO_PinOutClear(EXT_LED, GRE_LED);

	  GPIO_PinModeSet(BUT_PORT, LEFT_BUT, gpioModeInputPull, 1);		//configure left button as input with pull-up enabled
	  GPIO_PinModeSet(BUT_PORT, RIGHT_BUT, gpioModeInputPull, 1);		//'' but with right button

	  NVIC_EnableIRQ(GPIO_ODD_IRQn);	//enable gpio_even interrupt vector in nvic
	  GPIO_IntConfig(GPS_PORT, FIX, true, false, true);		//configure FIX pin interrupt on rising
}
Beispiel #9
0
/*****************************************************************************
 * Waits in EM3 until the bootloader pin is pulled low. This saves power
 * while waiting to install firmware. 
 *****************************************************************************/
void enterLowPowerWait(void)
{
  /* Enable interrupt on GPIO pin. Note that 
   * if the pin is changed to an odd pin number
   * the interrupt handler must also be changed */
  GPIO_IntConfig(BOOTLOADER_PIN, true, false, true);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
  
  /* Wait in EM3 until the pin is pulled low */
  while ( GPIO_PinInGet(BOOTLOADER_PIN) ) {
    EMU_EnterEM3(false);
  }
  
  /* Disable interrupts again */
  GPIO_IntConfig(BOOTLOADER_PIN, false, false, false);
  NVIC_DisableIRQ(GPIO_EVEN_IRQn);
}
Beispiel #10
0
static void Bitless_GpioSetup(void) {
    for (int i = 0; i < NUM_BUTTONS; i++) {
        /* Configure the five as input */
        GPIO_PinModeSet(BTNS[i].port, BTNS[i].pin, gpioModeInput, 0);
        /* Set falling edge interrupt for both ports */
        GPIO_IntConfig(BTNS[i].port, BTNS[i].pin, false, true, true);
    }
}
Beispiel #11
0
/** @brief Initialize External Device GPIOs
 * @param  deviceIntCB The callback routine for device general interrupt
 *                     (NULL to disable)
 * @param  deviceRdyCB The callback routine for device ready interrupt
 *                     (NULL to disable)
 * @return bitmask of configured features for this device
 * @note First initialization after bootup leaves the device powered down
 *       and unselected.  Subsequent inits don't touch the device powered
 *       or selected states and can be used to reconfigure callback(s),
 *       which always clears any stale/pending events.  For deviceRdyCB,
 *       its interrupt is enabled upon configuration; for deviceIntCB,
 *       halExtDeviceIntEnable() must subsequently be called to enable it.
 */
HalExtDeviceConfig halExtDeviceInit(HalExtDeviceIrqCB deviceIntCB,
                                    HalExtDeviceIrqCB deviceRdyCB)
{
  UNUSED_VAR(halExtDeviceRdyCB); // Work around potential compiler warnings
  UNUSED_VAR(halExtDeviceIntCB); // Work around potential compiler warnings
  halExtDeviceRdyCB = deviceRdyCB;
  halExtDeviceIntCB = deviceIntCB; 

  CMU_ClockEnable(cmuClock_PRS, true);

  /* Pin is configured to Push-pull: SDN */
  GPIO_PinModeSet((GPIO_Port_TypeDef) RF_SDN_PORT, RF_SDN_PIN, gpioModePushPull, 1u);

  /* Pin is configured to Push-pull: nSEL */
  GPIO_PinModeSet((GPIO_Port_TypeDef) RF_USARTRF_CS_PORT, RF_USARTRF_CS_PIN, gpioModePushPull, 1u);

  /* Pin PE13 is configured input: nIRQ */
  //GPIO_PinModeSet(RF_INT_PORT, RF_INT_PIN, gpioModeInput, 0u);

  /* Pin PA15 and PE14 are connected to GPIO0 and GPIO1 respectively. */
  GPIO_PinModeSet((GPIO_Port_TypeDef) RF_GPIO0_PORT, RF_GPIO0_PIN, gpioModeInput, 0);
  GPIO_PinModeSet((GPIO_Port_TypeDef) RF_GPIO1_PORT, RF_GPIO1_PIN, gpioModeInput, 0);

  /* Pin PA0 and PA1 are output the GPIO0 and GPIO1 via PRS */
  GPIO_PinModeSet(gpioPortA, 0, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortA, 1, gpioModePushPull, 0);

  /* Configure INT/PRS channels */
  GPIO_IntConfig((GPIO_Port_TypeDef) RF_GPIO0_PORT, RF_GPIO0_PIN, false, false, false);
  GPIO_IntConfig((GPIO_Port_TypeDef) RF_GPIO1_PORT, RF_GPIO1_PIN, false, false, false);

  /* Setup PRS */
  PRS_SourceAsyncSignalSet(0, PRS_CH_CTRL_SOURCESEL_GPIOH, PRS_CH_CTRL_SIGSEL_GPIOPIN15);
  PRS_SourceAsyncSignalSet(1, PRS_CH_CTRL_SOURCESEL_GPIOH, PRS_CH_CTRL_SIGSEL_GPIOPIN14);
  PRS->ROUTE = (PRS_ROUTE_CH0PEN | PRS_ROUTE_CH1PEN);

  /* Make sure PRS sensing is enabled (should be by default) */
  GPIO_InputSenseSet(GPIO_INSENSE_PRS, GPIO_INSENSE_PRS);

  /* TODO: Check whether the removed part is required 
     for the EZR32 implementation */
  halExtDeviceRdyCfgIrq();
  halExtDeviceIntCfgIrq();
  
  return 0;
}
Beispiel #12
0
/**********************************************************
 * Enable GPIO interrupts on both push buttons on the STK
 **********************************************************/
void gpioInit(void)
{
  /* Enable clock to GPIO */
  CMU_ClockEnable(cmuClock_GPIO, true);
   
  /* Enable interrupt on push button 0 */
  GPIO_PinModeSet(gpioPortB, 9, gpioModeInput, 0);
  GPIO_IntConfig(gpioPortB, 9, false, true, true);
  NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
  
  /* Enable interrupt on push button 1 */
  GPIO_PinModeSet(gpioPortB, 10, gpioModeInput, 0);
  GPIO_IntConfig(gpioPortB, 10, false, true, true);
  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}   
Beispiel #13
0
/**************************************************************************//**
 * @brief Setup GPIO interrupt to set the time
 *****************************************************************************/
void gpioSetup(void)
{
  /* Configure PB10 as input */
  GPIO_PinModeSet(gpioPortB, 10, gpioModeInput, 0);

  /* Set falling edge interrupt */
  GPIO_IntConfig(gpioPortB, 10, false, true, true);
  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);

  /* Configure PB9 as input */
  GPIO_PinModeSet(gpioPortB, 9, gpioModeInput, 0);

  /* Set falling edge interrupt */
  GPIO_IntConfig(gpioPortB, 9, false, true, true);
  NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
}
Beispiel #14
0
/**************************************************************************//**
 * @brief Setup GPIO interrupt to change demo mode
 *****************************************************************************/
void gpioSetup(void)
{
  /* Enable GPIO clock */
  CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;

  /* Configure PB10 as input and enable interrupt  */
  GPIO_PinModeSet(gpioPortB, 10, gpioModeInputPull, 1);
  GPIO_IntConfig(gpioPortB, 10, false, true, true);

  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);

  /* Configure PB9 as input and enable interrupt */
  GPIO_PinModeSet(gpioPortB, 9, gpioModeInputPull, 1);
  GPIO_IntConfig(gpioPortB, 9, false, true, true);

  NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
}
Beispiel #15
0
/**************************************************************************//**
 * @brief Setup GPIO interrupt for pushbuttons.
 *****************************************************************************/
static void gpioSetup(void)
{
  /* Enable GPIO clock */
  CMU_ClockEnable(cmuClock_GPIO, true);

  /* Configure PC8 as input and enable interrupt  */
  GPIO_PinModeSet(gpioPortC, 8, gpioModeInputPull, 1);
  GPIO_IntConfig(gpioPortC, 8, false, true, true);

  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);

  /* Configure PC9 as input and enable interrupt */
  GPIO_PinModeSet(gpioPortC, 9, gpioModeInputPull, 1);
  GPIO_IntConfig(gpioPortC, 9, false, true, true);

  NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
}
Beispiel #16
0
/**************************************************************************//**
 * @brief  Setup the GPIO
 *****************************************************************************/
void setupGPIO(void)
{
  /* Configure measuring pin as push pull */
  GPIO_PinModeSet(LCSENSE_SENSOR_PORT, LCSENSE_SENSOR_PIN, gpioModePushPull, 0);
  /* Enable push button 0 pin as input. */
  GPIO_PinModeSet(LCSENSE_BUTTON_PORT, LCSENSE_BUTTON_PIN, gpioModeInput, 0);
  /* Enable interrupts for that pin. */
  GPIO_IntConfig(LCSENSE_BUTTON_PORT, LCSENSE_BUTTON_PIN, false, true, true);
  /* Enable GPIO_EVEN interrupt vector in NVIC. */
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
Beispiel #17
0
/**************************************************************************//**
 * @brief Setup GPIO interrupt to set the time
 *****************************************************************************/
void gpioSetup(void)
{
  /* Enable GPIO in CMU */
  CMU_ClockEnable(cmuClock_GPIO, true);

  /* Configure PB9 and PB10 as input */
  GPIO_PinModeSet(gpioPortB, 9, gpioModeInput, 0);
  GPIO_PinModeSet(gpioPortB, 10, gpioModeInput, 0);

  /* Set falling edge interrupt for both ports */
  GPIO_IntConfig(gpioPortB, 9, false, true, true);
  GPIO_IntConfig(gpioPortB, 10, false, true, true);

  /* Enable interrupt in core for even and odd gpio interrupts */
  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);

  NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
}
Beispiel #18
0
/**************************************************************************//**
 * @brief Initialize GPIO interrupt for joystick (ie FPGA signal)
 *****************************************************************************/
void eepromtestIRQInit(void)
{
  /* Configure interrupt pin as input with pull-up */
  GPIO_PinModeSet(GPIO_INT_PORT, GPIO_INT_PIN, gpioModeInputPull, 2);

  /* Set falling edge interrupt and clear/enable it */
  GPIO_IntConfig(GPIO_INT_PORT, GPIO_INT_PIN, false, true, true);

  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
Beispiel #19
0
/**************************************************************************//**
 * @brief Initialize GPIO interrupt for joystick (ie FPGA signal)
 *****************************************************************************/
void temperatureIRQInit(void)
{
  /* Configure interrupt pin as input with pull-up */
  GPIO_PinModeSet(gpioPortC, GPIO_INT_PIN, gpioModeInputPull, 1);

  /* Set falling edge interrupt and clear/enable it */
  GPIO_IntConfig(gpioPortC, GPIO_INT_PIN, false, true, true);

  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
Beispiel #20
0
/* functions */
void RADIO_Init()
{
	
	// usart 0 location 2
	
	// enable pins
	GPIO_PinModeSet(NRF_CE_PORT, NRF_CE_PIN, gpioModePushPull, 0);
	GPIO_PinModeSet(NRF_CSN_PORT, NRF_CSN_PIN, gpioModePushPull, 1);
	GPIO_PinModeSet(NRF_INT_PORT, NRF_INT_PIN, gpioModeInput, 0);
	GPIO_PinModeSet(NRF_RXEN_PORT, NRF_RXEN_PIN, gpioModePushPull, 0);
	
	GPIO_PinModeSet(gpioPortC, 11, gpioModePushPull, 1);
	GPIO_PinModeSet(gpioPortC, 10, gpioModeInput, 0);
	GPIO_PinModeSet(gpioPortC, 9, gpioModePushPull, 0);
	
	USART_InitSync_TypeDef usartInit = USART_INITSYNC_DEFAULT;
	
	usartInit.msbf = true;
	usartInit.clockMode = usartClockMode0;
	usartInit.baudrate = 1000000;
	USART_InitSync(NRF_USART, &usartInit);
	NRF_USART->ROUTE = (NRF_USART->ROUTE & ~_USART_ROUTE_LOCATION_MASK) | USART_ROUTE_LOCATION_LOC2;
	NRF_USART->ROUTE |= USART_ROUTE_TXPEN | USART_ROUTE_RXPEN | USART_ROUTE_CLKPEN;
	
	// configure gpio interrupt
	GPIO_IntClear(1 << 0);
	writeRegister(NRF_STATUS,0x70);
	GPIO_IntConfig(NRF_INT_PORT,NRF_INT_PIN,false,true,true);
	
	// initial config
	writeRegister(NRF_EN_AA,0x00);
	writeRegister(NRF_EN_RXADDR,0x3F);
	writeRegister(NRF_SETUP_AW,0x03);
	writeRegister(NRF_SETUP_RETR,0x00);
	writeRegister(NRF_RF_CH,NODE_CH);
	writeRegister(NRF_RF_SETUP,0x0F);
	
	uint8_t addr_array[5];
	
	addr_array[0] = 0xE7;
	addr_array[1] = 0xE7;
	addr_array[2] = 0xE7;
	addr_array[3] = 0xE7;
	addr_array[4] = 0xE7;
	
	writeRegisterMulti(NRF_TX_ADDR, addr_array, 5);
	
	writeRegisterMulti(NRF_RX_ADDR_P0, addr_array, 5);
	writeRegister(NRF_RX_PW_P0,0x20);
	
	writeRegister(NRF_DYNPD, 0x00);
	writeRegister(NRF_FEATURE, 0x00);
	
}
Beispiel #21
0
/**************************************************************************//**
 * @brief  Gpio setup. Setup button pins to trigger falling edge interrupts.
 *  Register callbacks for that interrupts.
 *****************************************************************************/
void gpioSetup(void)
{
  /* Enable GPIO in CMU */
  CMU_ClockEnable(cmuClock_GPIO, true);

  /* Initialize GPIO interrupt dispatcher */
  GPIOINT_Init();
  
  /* Configure PB9 and PB10 as input */
  GPIO_PinModeSet(gpioPortB, 9, gpioModeInput, 0);
  GPIO_PinModeSet(gpioPortB, 10, gpioModeInput, 0);

  /* Register callbacks before setting up and enabling pin interrupt. */
  GPIOINT_CallbackRegister(9, gpioCallback);
  GPIOINT_CallbackRegister(10, gpioCallback);

  /* Set falling edge interrupt for both ports */
  GPIO_IntConfig(gpioPortB, 9, false, true, true);
  GPIO_IntConfig(gpioPortB, 10, false, true, true);
}
Beispiel #22
0
/**************************************************************************//**
 * @brief Initialize GPIO interrupt on PC14
 *****************************************************************************/
void GPIO_IRQInit(void)
{
  /* Configure PC14 as input pull, drive high */
  GPIO_PinModeSet(gpioPortC, 14, gpioModeInputPull, 1);

  /* Set and enable falling edge interrupt */
  GPIO_IntConfig(gpioPortC, 14, false, true, true);

  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
Beispiel #23
0
/**************************************************************************//**
 * @brief Initialize GPIO interrupt on PC14
 *****************************************************************************/
static void GpioIrqInit(void)
{
    /* Configure interrupt pin as input with pull-up */
    GPIO_PinModeSet(gpioPortE, 2, gpioModeInputPull, 1);

    /* Set falling edge interrupt and clear/enable it */
    GPIO_IntConfig(gpioPortE, 2, false, true, true);

    NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
    NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
Beispiel #24
0
/**************************************************************************//**
 * @brief Setup GPIO interrupt to set the time
 *****************************************************************************/
void gpioSetup(void)
{
  /* Enable GPIO in CMU */
  CMU_ClockEnable(cmuClock_GPIO, true);

  /* Configure PD8 as input */
  GPIO_PinModeSet(gpioPortD, 8, gpioModeInput, 0);

  /* Set falling edge interrupt */
  GPIO_IntConfig(gpioPortD, 8, false, true, true);
  NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);

  /* Configure PB11 as input */
  GPIO_PinModeSet(gpioPortB, 11, gpioModeInput, 0);

  /* Set falling edge interrupt */
  GPIO_IntConfig(gpioPortB, 11, false, true, true);
  NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
}
Beispiel #25
0
/**************************************************************************//**
 * @brief Initialize GPIO interrupt on PE0 and PE1
 *****************************************************************************/
void GPIO_IRQInit(void)
{
	// enable clock for GPIO module
  CMU_ClockEnable(cmuClock_GPIO, true);

	// Init the Button BUT1 located on PIN PE0
	GPIO_PinModeSet(gpioPortE,0,gpioModeInputPullFilter,1);

	// Init the Button BUT2 located on PIN PE1
	GPIO_PinModeSet(gpioPortE,1,gpioModeInputPullFilter,1);

  /* Enable GPIO_ODD interrupt vector in NVIC */
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
	/* Enable GPIO_EVEN interrupt vector in NVIC */
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);

  /* Configure PE0 interrupt on falling edge */
  GPIO_IntConfig(gpioPortE, 0, false, true, true);

	  /* Configure PE1 interrupt on falling edge */
  GPIO_IntConfig(gpioPortE, 1, false, true, true);
}
Beispiel #26
0
void qk_gpio_interrupt_set(qk_gpio_pin pin, uint32_t flags)
{
	bool risingEdge = false, fallingEdge = false;
	if(flags & QK_GPIO_FLAG_FALL)
		fallingEdge = true;
	if(flags & QK_GPIO_FLAG_RISE)
		risingEdge = true;

	GPIO_IntConfig((GPIO_Port_TypeDef) _QK_GPIO_PORT(pin),
			       (unsigned int) _QK_GPIO_BIT(pin),
	               risingEdge,
	               fallingEdge,
	               true);
}
Beispiel #27
0
/** @brief Configure and enable/disable the device interrupt IRQ
 */
static void halExtDeviceIntCfgIrq(void)
{
    /* Configure nIRQ signal to trigger Port Pin ISR */
    GPIO_PinModeSet((GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, gpioModeInput, 1u);
    GPIO_InputSenseSet(GPIO_INSENSE_INT, GPIO_INSENSE_INT);
    GPIOINT_CallbackRegister(RF_INT_PIN, halIrqxIsr);
    GPIO_IntConfig((GPIO_Port_TypeDef) RF_INT_PORT, RF_INT_PIN, false, true, true);

    if (halExtDeviceIntCB == NULL) {
      halExtDeviceIntLevel = EXT_DEVICE_INT_UNCONFIGURED;
    } else {
      halExtDeviceIntLevel = EXT_DEVICE_INT_LEVEL_OFF;
      // Callers need to use halExtDeviceIntEnable() to enable top level
    }
}
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Initialize chip */
  CHIP_Init();
  
  setupSWO();

  BSP_LedsInit();

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

  /* Configure interrupt for Push Button 0 */
  GPIO_PinModeSet(PB0_PORT, PB0_PIN, gpioModeInput, 1);
#if defined(_EFM32_GIANT_FAMILY)
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
#else
  NVIC_EnableIRQ(GPIO_EVEN_IRQn);
#endif
  GPIO_IntConfig(PB0_PORT, PB0_PIN, false, true, true);

  /* By turning on retention in EM4, the state of the GPIO pins
   * can be retained in all energy modes */
  GPIO->CTRL = GPIO_CTRL_EM4RET;

  /* Uncomment to drive LED in all energy modes */
  /* BSP_LedSet(0);*/

  while (1)
  {
    switch (STATE)
    {
    case EM0:
      break;
    case EM1:
      EMU_EnterEM1();
      break;
    case EM2:
      EMU_EnterEM2(true);
      break;
    case EM3:
      EMU_EnterEM3(true);
    case EM4:
      EMU_EnterEM4();
      break;
    }
  }
}
Beispiel #29
0
/**************************************************************************//**
 * @brief  Setup the GPIO
 *****************************************************************************/
void setupGPIO(void)
{
  /* Configure the drive strength of the ports for the light sensor. */
  GPIO_DriveModeSet(LIGHTSENSE_EXCITE_PORT, gpioDriveModeStandard);
  GPIO_DriveModeSet(LIGHTSENSE_SENSOR_PORT, gpioDriveModeStandard);

  /* Initialize the 2 GPIO pins of the light sensor setup. */
  GPIO_PinModeSet(LIGHTSENSE_EXCITE_PORT, LIGHTSENSE_EXCITE_PIN, gpioModePushPull, 0);
  GPIO_PinModeSet(LIGHTSENSE_SENSOR_PORT, LIGHTSENSE_SENSOR_PIN, gpioModeDisabled, 0);

  /* Enable push button 0 pin as input. */
  GPIO_PinModeSet(LIGHTSENSE_BUTTON0_PORT, LIGHTSENSE_BUTTON0_PIN,  gpioModeInput, 0);
  /* Enable interrupts for that pin. */
  GPIO_IntConfig(LIGHTSENSE_BUTTON0_PORT, LIGHTSENSE_BUTTON0_PIN, false, true, true);
  /* Enable GPIO_EVEN interrupt vector in NVIC. */
  NVIC_EnableIRQ(GPIO_ODD_IRQn);
}
Beispiel #30
0
/**
 * Initializes the SPI pins, frequency, and SPI mode configuration.
 */
void enc28j60_spi_init(void)
{
  /*
   * UEXT connections with STM32-P152:
   * 1 +3.3V
   * 2 GND
   * 3 LEDA = TX_US1
   * 4 WOL  = RX_US1
   * 5 INT  = PD7
   * 6 RST  = PD6
   * 7 MISO = PE11
   * 8 MOSI = PE10
   * 9 SCK  = PE12
   * 10 CS  = PE13
   */

  // Enable clocks.
  CMU_ClockEnable(cmuClock_GPIO, true);
  CMU_ClockEnable(cmuClock_USART0, true);

  // Configure GPIO pins.
  // Set CS to 1 (inactive)
  GPIO_PinModeSet(gpioPortE, 13, gpioModePushPull, 1);
  GPIO_PinModeSet(gpioPortE, 10, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 12, gpioModePushPull, 0);
  GPIO_PinModeSet(gpioPortE, 11, gpioModeInput, 0);

  // Configure SPI.
  USART_Reset(USART0);
  USART_InitSync(USART0, &spiConfig);

  USART0->ROUTE = USART_ROUTE_TXPEN | USART_ROUTE_RXPEN | USART_ROUTE_CLKPEN | USART_ROUTE_LOCATION_LOC0;

#ifdef ENC28J60_USE_INTERRUPTS

  // Configure UEXT enc28j60 interrupt line.

   CMU_ClockEnable(cmuClock_GPIO, true);
   GPIO_PinModeSet(gpioPortD, 7, gpioModeInputPullFilter, 1);
   GPIO_IntConfig(gpioPortD, 7, false, true, true);

   NVIC_EnableIRQ(GPIO_ODD_IRQn);
   NVIC_SetPriority(GPIO_ODD_IRQn, PORT_PENDSV_PRI - 1);

#endif
}