コード例 #1
0
ファイル: gpio_irq_api.c プロジェクト: JamesHinnant/osp
void gpio_irq_enable(gpio_irq_t *obj) {
    switch(obj->event){
        case IRQ_EDGE_RISE:
            Chip_PININT_SetPinModeEdge(LPC_PININT, obj->irq_index); /* edge sensitive */
            Chip_PININT_EnableIntHigh(LPC_PININT, obj->irq_index);  /* Rising edge interrupt */
            break;
        case IRQ_EDGE_FALL:
            Chip_PININT_SetPinModeEdge(LPC_PININT, obj->irq_index); /* Edge sensitive */
            Chip_PININT_EnableIntLow(LPC_PININT, obj->irq_index);   /* Falling edge interrupt */
            break;
        case IRQ_LEVEL_HIGH:
            Chip_PININT_SetPinModeLevel(LPC_PININT, obj->irq_index); /* Level sensitive */
            Chip_PININT_EnableIntHigh(LPC_PININT, obj->irq_index);   /* High level interrupt */
            break;
        case IRQ_LEVEL_LOW:
            Chip_PININT_SetPinModeLevel(LPC_PININT, obj->irq_index); /* Level sensitive */
            Chip_PININT_EnableIntLow(LPC_PININT, obj->irq_index);    /* Low level interrupt */
            break;
        default:
            D1_printf("GPIO_IRQ_ENABLE: Bad IRQ Mode: %d\r\n", obj->irq_index);
            while(1){};
    }        
}
コード例 #2
0
ファイル: ciaaIO_ISR.c プロジェクト: mdarino/LSE_SistOper2
   //BOTON 4
   // 0 Low - 1 High
   void ciaaIO_ISR_SetButton4(uint8_t LowOrHigh)
   {
      //Set GPIO1[9] 
      Chip_SCU_GPIOIntPinSel(3,1,9);
      Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT,PININTCH3); 
      if (LowOrHigh)
      {
         Chip_PININT_EnableIntHigh(LPC_GPIO_PIN_INT,PININTCH3);
      }
      else
      {
         Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT,PININTCH3);  
      }
      
      //habilitar la IRQ
      NVIC_EnableIRQ(PIN_INT3_IRQn);

   }   
コード例 #3
0
ファイル: ciaaIO_ISR.c プロジェクト: mdarino/LSE_SistOper2
   //BOTON 2
   // 0 Low - 1 High
   void ciaaIO_ISR_SetButton2(uint8_t LowOrHigh)
   {
      //Set GPIO0[8] 
      Chip_SCU_GPIOIntPinSel(1,0,8);
      Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT,PININTCH1); 
      if (LowOrHigh)
      {
         Chip_PININT_EnableIntHigh(LPC_GPIO_PIN_INT,PININTCH1);
      }
      else
      {
         Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT,PININTCH1);  
      }
      
      //habilitar la IRQ
      NVIC_EnableIRQ(PIN_INT1_IRQn);

   }
コード例 #4
0
ファイル: board.c プロジェクト: ernesto-g/micropython
bool Board_GPIOs_enableIntCallback(int gpioNumber,void(*function)(void*),void* arg, uint8_t flagEdgeLevel, uint8_t flagHighLow)
{
	// check if gpio alerady has assigned int
	for(uint8_t i=0; i<4 ; i++)
        {
                if(extIntData[i].callback!=NULL && extIntData[i].gpioNumber==gpioNumber)
                    return 0;
	}

	// find free extInt callback
	for(uint8_t i=0; i<4 ; i++)
	{
		if(extIntData[i].callback==NULL)
		{
        		extIntData[i].callback = function;
        		extIntData[i].callbackArg = arg;
			extIntData[i].gpioNumber=gpioNumber;
			// Enable interrupt
			uint8_t intNumber = i + 4; // starts from INT4
			Chip_SCU_GPIOIntPinSel(intNumber, gpiosInfo[gpioNumber].gpio, gpiosInfo[gpioNumber].gpioBit);
        		Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(intNumber));

			if(flagEdgeLevel)
        			Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(intNumber));
			else
				Chip_PININT_SetPinModeLevel(LPC_GPIO_PIN_INT, PININTCH(intNumber));

			if(flagHighLow)
				Chip_PININT_EnableIntHigh(LPC_GPIO_PIN_INT, PININTCH(intNumber));
			else
        			Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT, PININTCH(intNumber));

			switch(intNumber) {
				case 4: NVIC_ClearPendingIRQ(PIN_INT4_IRQn); NVIC_EnableIRQ(PIN_INT4_IRQn); break;
				case 5: NVIC_ClearPendingIRQ(PIN_INT5_IRQn); NVIC_EnableIRQ(PIN_INT5_IRQn); break;
				case 6: NVIC_ClearPendingIRQ(PIN_INT6_IRQn); NVIC_EnableIRQ(PIN_INT6_IRQn); break;
				case 7: NVIC_ClearPendingIRQ(PIN_INT7_IRQn); NVIC_EnableIRQ(PIN_INT7_IRQn); break;
			}
			return 1;
		}
	}
	return 0;
}
int main(void)
{
#if defined (__USE_LPCOPEN)
    // Read clock settings and update SystemCoreClock variable
    SystemCoreClockUpdate();
#if !defined(NO_BOARD_LIB)
#if defined (__MULTICORE_MASTER) || defined (__MULTICORE_NONE)
    // Set up and initialize all required blocks and
    // functions related to the board hardware
    Board_Init();
#endif
    // Set the LED to the state of "On"
    Board_LED_Set(0, true);
#endif
#endif

#if defined (__MULTICORE_MASTER_SLAVE_M0SLAVE) || \
    defined (__MULTICORE_MASTER_SLAVE_M4SLAVE)
    boot_multicore_slave();
#endif

    // Get the address of the PCM value FIFO from the M4 master.
    PCM_FIFO = (PCM_FIFO_T *) Chip_MBOX_GetValue(LPC_MBOX, MAILBOX_CM0PLUS);

    // Map P0.21 as the CLKOUT pin.
    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 21,
                         (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGITAL_EN));

    // Route the main clock to the CLKOUT pin, for a 1 MHz signal.
    Chip_Clock_SetCLKOUTSource(SYSCON_CLKOUTSRC_MAINCLK, SystemCoreClock / 1000000);

    // Enable the GPIO and pin-interrupt sub-systems.
    Chip_GPIO_Init(LPC_GPIO);
    Chip_PININT_Init(LPC_PININT);

    // Map PIO0_9 as a GPIO input pin.  This is the data signal from the
    // microphone.
    Chip_GPIO_SetPinDIRInput(LPC_GPIO, 0, 9);
    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 9,
            (IOCON_FUNC0 | IOCON_DIGITAL_EN | IOCON_GPIO_MODE));

    // Map PIO0_11 as a GPIO input pin, triggering pin-interrupt 0.  This will
    // indicate that there is a sample ready from the microphone.
    Chip_GPIO_SetPinDIRInput(LPC_GPIO, 0, 11);
    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 11,
            (IOCON_FUNC0 | IOCON_DIGITAL_EN | IOCON_GPIO_MODE));
    Chip_INMUX_PinIntSel(PININTSELECT0, 0, 11);

    // Trigger the interrupt on the clock's rising edge.
    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(PININTSELECT0));
    Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(PININTSELECT0));
    Chip_PININT_EnableIntHigh(LPC_PININT, PININTCH(PININTSELECT0));

    // Enable the interrupt in the NVIC.
    NVIC_EnableIRQ(PIN_INT0_IRQn);

    // Spin while waiting for interrupts from the microphone.
    while (1) {
        __WFI();
    }
    return 0;
}
コード例 #6
0
void Board_Attach_Interrupt(uint32_t ulPin, void (*callback)(void), uint32_t mode)
{
    uint8_t port = 1;
    uint8_t pin = 24;
    uint8_t pinIntChannel = 0;
    LPC1347_IRQn_Type pinIntIRQ = PIN_INT0_IRQn;

    port = APIN_PORT(ulPin);
    pin = APIN_PIN(ulPin);

    pinIntChannel = APIN_INT(ulPin);

    if(pinIntChannel == EXT_INT_0)
    {
        pinIntIRQ = PIN_INT0_IRQn;
        callbackPinIntA = callback;
    }
    else if(pinIntChannel == EXT_INT_1)
    {
        pinIntIRQ = PIN_INT1_IRQn;
        callbackPinIntB = callback;
    }
    else if(pinIntChannel == EXT_INT_2)
    {
        pinIntIRQ = PIN_INT2_IRQn;
        callbackPinIntC = callback;
    }
    else if(pinIntChannel == EXT_INT_3)
    {
        pinIntIRQ = PIN_INT3_IRQn;
        callbackPinIntD = callback;
    }

    /* Configure GPIO pin as input */
    Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, port, pin);

    /* Configure pin as GPIO with pulldown */
    // All digital pins are selected such that GPIO is on IOCON_FUNC0
    Chip_IOCON_PinMuxSet(LPC_IOCON, port, pin, (IOCON_FUNC0 | IOCON_MODE_PULLDOWN));

    /* Enable PININT clock */
    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT);

    /* Configure interrupt channel for the GPIO pin in SysCon block */
    Chip_SYSCTL_SetPinInterrupt(pinIntChannel, port, pin);

    /* Configure channel interrupt as edge sensitive and falling edge interrupt */
    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(pinIntChannel));

    if(mode == HIGH)
    {
        Chip_PININT_SetPinModeLevel(LPC_PININT, PININTCH(pinIntChannel));
        Chip_PININT_EnableIntHigh(LPC_PININT, PININTCH(pinIntChannel));
    }
    else if(mode == LOW)
    {
        Chip_PININT_SetPinModeLevel(LPC_PININT, PININTCH(pinIntChannel));
        Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(pinIntChannel));
    }
    else if(mode == RISING)
    {
        Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(pinIntChannel));
        Chip_PININT_EnableIntHigh(LPC_PININT, PININTCH(pinIntChannel));
    }
    else if(mode == FALLING)
    {
        Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(pinIntChannel));
        Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(pinIntChannel));
    }
    else if(mode == CHANGE)
    {
        Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(pinIntChannel));
        Chip_PININT_EnableIntHigh(LPC_PININT, PININTCH(pinIntChannel));
        Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(pinIntChannel));
    }

    /* Enable interrupt in the NVIC */
    NVIC_ClearPendingIRQ(pinIntIRQ);
    NVIC_EnableIRQ(pinIntIRQ);
}