Example #1
0
static uint32_t _WFE_PushButtons_Initialize( void )
{
    /* Configure PIO */
    PIO_Configure(&gPinButton1, 1);
    PIO_Configure(&gPinButton2, 1);
    
    /* Enable PIO interrupt */
    PIO_EnableIt(&gPinButton1);
    PIO_EnableIt(&gPinButton2);

    return SAMGUI_E_OK ;
}
Example #2
0
/**
 * @brief Configures the buttons to generate interrupts when pressed.
 */
void ConfigureButtons(void)
{
    // Configure PIO
    PIO_Configure(&pinPB1, 1);
    PIO_Configure(&pinPB2, 1);

    // Initialize interrupts
    PIO_InitializeInterrupts(AT91C_AIC_PRIOR_LOWEST);
    PIO_ConfigureIt(&pinPB1, (void (*)(const Pin *)) ISR_Bp1);
    PIO_ConfigureIt(&pinPB2, (void (*)(const Pin *)) ISR_Bp2);
    PIO_EnableIt(&pinPB1);
    PIO_EnableIt(&pinPB2);
}
Example #3
0
static void prvConfigureVBus( void )
{
const Pin xVBusPin = PIN_USB_VBUS;
const uint32_t ulPriority = 7; /* Highest. */

	/* Configure PIO to generate an interrupt on status change. */
    PIO_Configure( &xVBusPin, 1 );
    PIO_ConfigureIt( &xVBusPin );

	/* Ensure interrupt is disabled before setting the mode and installing the
	handler.  The priority of the tick interrupt should always be set to the
	lowest possible. */
	AIC->AIC_SSR  = ID_PIOE;
	AIC->AIC_IDCR = AIC_IDCR_INTD;
	AIC->AIC_SMR  = AIC_SMR_SRCTYPE_EXT_POSITIVE_EDGE | ulPriority;
	AIC->AIC_SVR = ( uint32_t ) prvVBusISRHandler;

	/* Start with the interrupt clear. */
	AIC->AIC_ICCR = AIC_ICCR_INTCLR;
	PIO_EnableIt( &xVBusPin );
    AIC_EnableIT( ID_PIOE );

	/* Check current level on VBus */
	if( PIO_Get( &xVBusPin ) != pdFALSE )
	{
		/* If VBUS present, force the connect */
		USBD_Connect();
	}
	else
	{
		USBD_Disconnect();
	}
}
Example #4
0
int main(void)
{
	/// Init DBGU
	TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK);
	printf("-- %s: blink-interrupt Project with at91lib v%s --\n\r", BOARD_NAME, SOFTPACK_VERSION);
	printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

	/// Init PIOA & PIOB interrupt
	PIO_InitializeInterrupts(0);

	/// Init LED
	PIO_Configure(&pinLed, 1);
	TRACE_INFO("LED:\n\r");

	/// Configure and enable the interrupt
	PIO_ConfigureIt(&pinButton, (void (*)(const Pin *)) User_InterruptHandler);
	PIO_EnableIt(&pinButton);

	while (1)
	{
		PIO_Set(&pinLed);
		delay(1000);

		PIO_Clear(&pinLed);
		delay(1000);
	}
}
Example #5
0
//------------------------------------------------------------------------------
/// Configures the wake-up pin to generate interrupts.
//------------------------------------------------------------------------------
static void ConfigureWakeUp(void)
{
    TRACE_INFO("Wake-up configuration\n\r");

    // Configure PIO
    PIO_Configure(&pinWakeUp, 1);
    PIO_ConfigureIt(&pinWakeUp, WakeUpHandler);
    PIO_EnableIt(&pinWakeUp);
}
Example #6
0
//Sets up pins for encoder 
void encoder_init(void){
    // Pio pins for encoder
    static const Pin encoder_pin_cw = ENCODER_CLOCKWISE;
    static const Pin encoder_pin_acw = ENCODER_ANTICLOCKWISE;


    //initilise pulse counter
    encoder_position_output = 0;
    
    //sets pins as inputs
    PIO_Configure(&encoder_pin_cw, 1);
    PIO_Configure(&encoder_pin_acw, 1);

    // Initialize interrupts
    PIO_ConfigureIt(&encoder_pin_cw, ENCODER_ISR_UP);
    PIO_ConfigureIt(&encoder_pin_acw, ENCODER_ISR_DOWN);
    PIO_EnableIt(&encoder_pin_cw);
    PIO_EnableIt(&encoder_pin_acw);
}
Example #7
0
//------------------------------------------------------------------------------
/// Configures the VBus pin to trigger an interrupt when the level on that pin
/// changes.
//------------------------------------------------------------------------------
static void VBus_Configure( void ) {
  // Configure PIO
  PIO_Configure(&pinVbus, 1);
  PIO_ConfigureIt(&pinVbus, ISR_Vbus);
  PIO_EnableIt(&pinVbus);

  // Check current level on VBus
  if (PIO_Get(&pinVbus))
    // if VBUS present, force the connect
    USBD_Connect();          
}
Example #8
0
/**
 *  \brief Configure the Pushbuttons
 *
 *  Configure the PIO as inputs and generate corresponding interrupt when
 *  pressed or released.
 */
void ConfigureButtons(void)
{
    /* Configure pios as inputs. */
    PIO_Configure(&pinPB1, 1);
    PIO_Configure(&pinPB2, 1);

    /* Adjust pio debounce filter patameters, uses 10 Hz filter. */
    PIO_SetDebounceFilter(&pinPB1, 10);
    PIO_SetDebounceFilter(&pinPB1, 10);

    /* Initialize pios interrupt handlers, see PIO definition in board.h. */
    PIO_ConfigureIt(&pinPB1, Button1_Handler); /* Interrupt on rising edge  */
    PIO_ConfigureIt(&pinPB2, Button2_Handler); /* Interrupt on falling edge */

    /* Enable PIO controller IRQs. */
    NVIC_EnableIRQ((IRQn_Type)pinPB1.id);
    NVIC_EnableIRQ((IRQn_Type)pinPB2.id);

    /* Enable PIO line interrupts. */
    PIO_EnableIt(&pinPB1);
    PIO_EnableIt(&pinPB2);
}
Example #9
0
/**
 *  Configures the VBus pin to trigger an interrupt when the level on that pin
 *  changes.
 */
static void VBus_Configure( void )
{
    /* Configure PIO */
    PIO_Configure(&pinVbus, 1);
    PIO_ConfigureIt(&pinVbus, ISR_Vbus);
    PIO_EnableIt(&pinVbus);

    /* Check current level on VBus */
    if (PIO_Get(&pinVbus)) {

        /* if VBUS present, force the connect */
        USBD_Connect();
    }
    else {
        TRACE_INFO("discon\n\r");
        USBD_Disconnect();
    }
}
Example #10
0
//Sets up pin and buffer for speed sensor
void speed_init(void){

    //initilize buffer
    for(int i = 0; i < SPEED_BUFFER_SIZE; i++){
        speed_buffer[i] = 0;
    }

    //sets inital speed to 0
    speed_output = 0;

    //sets pins as inputs
    PIO_Configure(&speed_pin, 1);

    // Initialize interrupts
    PIO_ConfigureIt(&speed_pin, (void (*)(const Pin *)) SPEED_ISR);
    PIO_EnableIt(&speed_pin);

    TRACE_INFO("Speed sensor initilazaton complete\n\r");
}
Example #11
0
//------------------------------------------------------------------------------
/// Configures the VBus pin to trigger an interrupt when the level on that pin
/// changes.
//------------------------------------------------------------------------------
static void VBus_Configure( void )
{
    TRACE_INFO("VBus configuration\n\r");

    // Configure PIO
    PIO_Configure(&pinVbus, 1);
    PIO_ConfigureIt(&pinVbus, ISR_VBus);
    PIO_EnableIt(&pinVbus);

    // Check current level on VBus
    if (PIO_Get(&pinVbus)) {

        // if VBUS present, force the connect
        TRACE_INFO("VBUS conn\n\r");
        USBD_Connect();
    }
    else {
        USBD_Disconnect();
    }           
}
Example #12
0
static void prvConfigureVBus( void )
{
const Pin xVBusPin = PIN_USB_VBUS;

	/* Configure PIO to generate an interrupt on status change. */
	PIO_Configure( &xVBusPin, 1 );
	PIO_ConfigureIt( &xVBusPin, prvVBusISRHandler );
	PIO_EnableIt( &xVBusPin );

	/* Check current level on VBus */
	if( PIO_Get( &xVBusPin ) != pdFALSE )
	{
		/* if VBUS present, force the connect */
		USBD_Connect();
	}
	else
	{
		USBD_Disconnect();
	}
}
Example #13
0
File: main.c Project: gstroe/Arm
/**
 * Configures the smartcard detection pin to trigger an interrupt.
 */
static void ConfigureCardDetection(void)
{
	PIO_Configure(&pinSmartCard, 1);
	PIO_ConfigureIt(&pinSmartCard, ISR_PioSmartCard);
	PIO_EnableIt(&pinSmartCard);
}
Example #14
0
void usb_detect_configure(void) {
    // Configure PIO
    PIO_Configure(&pin_usb_detect, 1);
    PIO_ConfigureIt(&pin_usb_detect, usb_isr_vbus);
    PIO_EnableIt(&pin_usb_detect);
}