Exemple #1
0
static void ADC_PinMuxSetup(void)
{
#if defined(BOARD_NXP_LPCXPRESSO_54102)
	/* Enable PININT1, which will trigger SEQ_B */
	Chip_PININT_Init(LPC_PININT);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 24, IOCON_MODE_INACT | IOCON_FUNC0 | IOCON_DIGITAL_EN | IOCON_GPIO_MODE);
	Chip_GPIO_SetPinDIRInput(LPC_GPIO, 0, 24);
	LPC_INMUX->PINTSEL[PININTSELECT1] = 24;
	Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(PININTSELECT1));
	Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(PININTSELECT1));
	Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(PININTSELECT1));
	NVIC_ClearPendingIRQ(PIN_INT1_IRQn);
	NVIC_EnableIRQ(PIN_INT1_IRQn);

	/* All pins to inactive, neither pull-up nor pull-down. */
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 29, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 30, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 31, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 0, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 1, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 2, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 3, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 4, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 5, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 6, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 7, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 8, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);

#else
#warning "No ADC setup for this example"
#endif
}
Exemple #2
0
// Initialize the push button
void pb_init(void){
	// Set initial values
	pbState = READY;
	pbTenths = 0;
	pbLongPress = false;
	pbShortPress = false;

	// Set up timer interrupt
	Chip_MRT_IntClear(LPC_MRT_CH(0));
	Chip_MRT_SetEnabled(LPC_MRT_CH(0));

	// Set up pin interrupt
	Chip_PININT_Init(LPC_GPIO_PIN_INT);
	Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PININT);
	Chip_SYSCTL_PeriphReset(RESET_PININT);
	Chip_INMUX_PinIntSel(0, 0, PWR_PB_SENSE);
	Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, 1 << 0);
	Chip_PININT_SetPinModeLevel(LPC_GPIO_PIN_INT, 1 << 0);

	PININT_EnableLevelInt(LPC_GPIO_PIN_INT, 1 << 0);
	PININT_LowActive(LPC_GPIO_PIN_INT, 1 << 0); // Enable low first so that initial press is not detected

	NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
	NVIC_EnableIRQ(PIN_INT0_IRQn);
	NVIC_SetPriority(PIN_INT0_IRQn, 0x02); // Set higher than systick, but lower than sampling
}
Exemple #3
0
void App_Button_Init(void)
{
	ButtonWaiting = 0;

	//Initialize the timer for the debouncing, but don't start it
	Chip_TIMER_Init(DEBOUNCE_TIMER);
	Chip_TIMER_Reset(DEBOUNCE_TIMER);

	DEBOUNCE_TIMER->PR = 100;
	DEBOUNCE_TIMER->MCR = (1<<1)|(1<<0);		//Enable MR0 match interrupt, Reset TC on MR0 match
	DEBOUNCE_TIMER->MR[0]= 0xFFFF;				//MR0 match value

	//Enable the IRQ for the timer
	NVIC_EnableIRQ(DEBOUNCE_TIMER_NVIC_NAME);

	//Set all button pins to GPIO input with pullup
	Chip_IOCON_PinMuxSet(LPC_IOCON, BUTTON_1_PORT, BUTTON_1_PIN, (IOCON_FUNC0 | IOCON_MODE_PULLUP));
	Chip_IOCON_PinMuxSet(LPC_IOCON, BUTTON_2_PORT, BUTTON_2_PIN, (IOCON_FUNC0 | IOCON_MODE_PULLUP));
	Chip_IOCON_PinMuxSet(LPC_IOCON, BUTTON_3_PORT, BUTTON_3_PIN, (IOCON_FUNC0 | IOCON_MODE_PULLUP));
	Chip_IOCON_PinMuxSet(LPC_IOCON, BUTTON_4_PORT, BUTTON_4_PIN, (IOCON_FUNC0 | IOCON_MODE_PULLUP));
	Chip_IOCON_PinMuxSet(LPC_IOCON, BUTTON_5_PORT, BUTTON_5_PIN, (IOCON_FUNC0 | IOCON_MODE_PULLUP));

	Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_1_PORT, BUTTON_1_PIN);
	Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_2_PORT, BUTTON_2_PIN);
	Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_3_PORT, BUTTON_3_PIN);
	Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_4_PORT, BUTTON_4_PIN);
	Chip_GPIO_SetPinDIRInput(LPC_GPIO, BUTTON_5_PORT, BUTTON_5_PIN);


	//TODO: Probably put this in the main initalization...
	Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT);

	//Setup GPIO interrupts for each button

	/* Configure interrupt channel for the GPIO pin in SysCon block */
	Chip_SYSCTL_SetPinInterrupt(BUTTON_1_PININT_INDEX, BUTTON_1_PORT, BUTTON_1_PIN);
	Chip_SYSCTL_SetPinInterrupt(BUTTON_2_PININT_INDEX, BUTTON_2_PORT, BUTTON_2_PIN);
	Chip_SYSCTL_SetPinInterrupt(BUTTON_3_PININT_INDEX, BUTTON_3_PORT, BUTTON_3_PIN);
	Chip_SYSCTL_SetPinInterrupt(BUTTON_4_PININT_INDEX, BUTTON_4_PORT, BUTTON_4_PIN);
	Chip_SYSCTL_SetPinInterrupt(BUTTON_5_PININT_INDEX, BUTTON_5_PORT, BUTTON_5_PIN);

	/* Configure channel interrupt as edge sensitive and falling edge interrupt */
	Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(BUTTON_1_PININT_INDEX));
	Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(BUTTON_2_PININT_INDEX));
	Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(BUTTON_3_PININT_INDEX));
	Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(BUTTON_4_PININT_INDEX));
	Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(BUTTON_5_PININT_INDEX));
	Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(BUTTON_1_PININT_INDEX));
	Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(BUTTON_2_PININT_INDEX));
	Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(BUTTON_3_PININT_INDEX));
	Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(BUTTON_4_PININT_INDEX));
	Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(BUTTON_5_PININT_INDEX));

	Chip_PININT_ClearIntStatus(LPC_PININT, ((1 << BUTTON_1_PININT_INDEX)|(1<<BUTTON_2_PININT_INDEX)|(1<<BUTTON_3_PININT_INDEX)|(1<<BUTTON_4_PININT_INDEX)|(1<<BUTTON_5_PININT_INDEX)) );

	App_EnableButtons();

	return;
}
void PIN_INT0_IRQHandler(void)
{
    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(PININTSELECT0));
    bool PDMBit = Chip_GPIO_GetPinState(LPC_GPIO, 0, 9);
    if (AccumulatePCMData(PDMBit, &PCMValue)) {
        PCM_FIFO_PostValue(PCM_FIFO, PCMValue);
    }
}
Exemple #5
0
void Board_Buttons_Init(void)
{
	 buttonsData[0].callbackSw=NULL;
	 buttonsData[1].callbackSw=NULL;
	 buttonsData[2].callbackSw=NULL;
	 buttonsData[3].callbackSw=NULL;

	Chip_SCU_PinMuxSet(0x1, 0, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0));		// P1_0 as GPIO0[4]
	Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTONS_BUTTON1_GPIO_PORT_NUM, BUTTONS_BUTTON1_GPIO_BIT_NUM);	// input
	Chip_SCU_GPIOIntPinSel(0, 0, 4); // GPIO0[4] to INT0
	Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(0)); // INT0
        Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(0)); // INT0
        Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT, PININTCH(0));   // INT0
	NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
        NVIC_EnableIRQ(PIN_INT0_IRQn);


        Chip_SCU_PinMuxSet(0x1, 1, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0));         // P1_1 as GPIO0[8]
        Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTONS_BUTTON2_GPIO_PORT_NUM, BUTTONS_BUTTON2_GPIO_BIT_NUM);   // input
	Chip_SCU_GPIOIntPinSel(1, 0, 8); // GPIO0[8] to INT1
	Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(1)); // INT1
        Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(1)); // INT1
        Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT, PININTCH(1));   // INT1
	NVIC_ClearPendingIRQ(PIN_INT1_IRQn);
        NVIC_EnableIRQ(PIN_INT1_IRQn);


        Chip_SCU_PinMuxSet(0x1, 2, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0));         // P1_2 as GPIO0[9]
        Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTONS_BUTTON3_GPIO_PORT_NUM, BUTTONS_BUTTON3_GPIO_BIT_NUM);   // input
	Chip_SCU_GPIOIntPinSel(2, 0, 9); // GPIO0[9] to INT2
	Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(2)); // INT2
        Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(2)); // INT2
        Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT, PININTCH(2));   // INT2
        NVIC_ClearPendingIRQ(PIN_INT2_IRQn);
        NVIC_EnableIRQ(PIN_INT2_IRQn);


        Chip_SCU_PinMuxSet(0x1, 6, (SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0));         // P1_6 as GPIO1[9]
        Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, BUTTONS_BUTTON4_GPIO_PORT_NUM, BUTTONS_BUTTON4_GPIO_BIT_NUM);   // input
	Chip_SCU_GPIOIntPinSel(3, 1, 9); // GPIO1[9] to INT3
	Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(3)); // INT3
        Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(3)); // INT3
        Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT, PININTCH(3));   // INT3
        NVIC_ClearPendingIRQ(PIN_INT3_IRQn);
        NVIC_EnableIRQ(PIN_INT3_IRQn);
}
Exemple #6
0
void BUTTON_5_IRQ_HANDLER(void)
{
	DEBOUNCE_TIMER->PR = BUTTON_5_DEBOUNCE_TIME;
	App_DisableButtons();
	ButtonWaiting = BUTTON_5_PININT_INDEX;
	DEBOUNCE_TIMER->TCR = 0x01;
	Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(BUTTON_5_PININT_INDEX));
	return;
}
Exemple #7
0
/**
 * @brief Called upon waking from sleep to re-enable clocks, etc.
 */
void wakeup(void) {
	Chip_SYSCTL_DisablePINTWakeup(SW_LEFT_PININT);
	Chip_SYSCTL_DisablePINTWakeup(SW_RIGHT_PININT);
	g_go_to_sleep = 0;

	Plot_Clear(&g_plot_temp);
	Plot_Clear(&g_plot_rh);

	Plot_Clear(&g_plot_mag);
	Plot_Clear(&g_plot_mag);

	SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |
	    		     SysTick_CTRL_TICKINT_Msk   |
	    		     SysTick_CTRL_ENABLE_Msk;


	g_sw_right_debouncing = 1;
	g_sw_left_debouncing = 1;
	g_sw_right_debounce_counter = 0;
	g_sw_left_debounce_counter = 0;


	NVIC_EnableIRQ(ADC_SEQA_IRQn);

	Chip_ADC_StartSequencer(LPC_ADC, ADC_SEQA_IDX);

	Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, LCD_BACKLIGHT, 0);

	Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, RANGE_POWER_PIN, 1);

	Chip_PININT_ClearIntStatus(LPC_PININT, SW_LEFT_PININTCH);
	Chip_PININT_ClearIntStatus(LPC_PININT, SW_RIGHT_PININTCH);

	NVIC_EnableIRQ(SW_LEFT_IRQn);
	NVIC_EnableIRQ(SW_RIGHT_IRQn);
}
Exemple #8
0
/**
 * @brief Interrupt initialization,
 */
void interruptInit(void) {
	Chip_SYSCTL_SetPinInterrupt(0, SW_LEFT);
	Chip_SYSCTL_SetPinInterrupt(1, SW_RIGHT);

	Chip_PININT_SetPinModeEdge(LPC_PININT,
			SW_LEFT_PININTCH | SW_RIGHT_PININTCH);
	Chip_PININT_EnableIntLow(LPC_PININT,
			SW_LEFT_PININTCH | SW_RIGHT_PININTCH);

	Chip_PININT_ClearIntStatus(LPC_PININT,
			SW_RIGHT_PININTCH | SW_LEFT_PININTCH);

	NVIC_EnableIRQ(SW_LEFT_IRQn);
	NVIC_EnableIRQ(SW_RIGHT_IRQn);
}
Exemple #9
0
void SW_RIGHT_IRQHandler(void) {
	Chip_PININT_ClearIntStatus(LPC_PININT, SW_RIGHT_PININTCH);

	if (g_ignore_switches) return;

	if (!g_sw_right_debouncing) {
		g_right_display = (g_right_display + 1) % N_DISPLAYS;

		// Don't allow same display on both sides:
		if (g_left_display == g_right_display) {
			g_right_display = (g_right_display + 1) % N_DISPLAYS;
		}
		g_sw_right_debouncing = 1;
	}
}
Exemple #10
0
void GPIO1_IRQHandler()
{

   portBASE_TYPE xSwitchRequired1;
   
   if (Chip_PININT_GetFallStates(LPC_GPIO_PIN_INT)&PININTCH1)
    { 
      Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT,PININTCH1);   
      uint8_t aux=1;
      xQueueSendFromISR( xQueue1, ( void * ) &aux, &xSwitchRequired1);
      //xSemaphoreGiveFromISR(xSemaphore,&xSwitchRequired1);
      //NO USAR - xSemaphoreGive(xSemaphore);
    }
   portEND_SWITCHING_ISR(xSwitchRequired1);

}
Exemple #11
0
void App_EnableButtons(void)
{
	Chip_PININT_ClearIntStatus(LPC_PININT, ((1 << BUTTON_1_PININT_INDEX)|(1<<BUTTON_2_PININT_INDEX)|(1<<BUTTON_3_PININT_INDEX)|(1<<BUTTON_4_PININT_INDEX)|(1<<BUTTON_5_PININT_INDEX)) );

	NVIC_ClearPendingIRQ(BUTTON_1_NVIC_NAME);
	NVIC_ClearPendingIRQ(BUTTON_2_NVIC_NAME);
	NVIC_ClearPendingIRQ(BUTTON_3_NVIC_NAME);
	NVIC_ClearPendingIRQ(BUTTON_4_NVIC_NAME);
	NVIC_ClearPendingIRQ(BUTTON_5_NVIC_NAME);

	NVIC_EnableIRQ(BUTTON_1_NVIC_NAME);
	NVIC_EnableIRQ(BUTTON_2_NVIC_NAME);
	NVIC_EnableIRQ(BUTTON_3_NVIC_NAME);
	NVIC_EnableIRQ(BUTTON_4_NVIC_NAME);
	NVIC_EnableIRQ(BUTTON_5_NVIC_NAME);
	return;
}
Exemple #12
0
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;
}
Exemple #13
0
void GPIO7_IRQHandler(void)
{
        Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(7));
        if(extIntData[3].callback!=NULL)
                extIntData[3].callback( extIntData[3].callbackArg);
}
Exemple #14
0
void GPIO3_IRQHandler(void)
{
        Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(3));
	if(buttonsData[3].callbackSw!=NULL)
		buttonsData[3].callbackSw( buttonsData[3].callbackSwArg);
}
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;
}
void PIN_INT1_IRQHandler(void)
{
    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(1));
    if(callbackPinIntB) callbackPinIntB();
}
Exemple #17
0
/**
 * @brief	Main program body
 * @return	Does not return
 */
int main(void)
{
	/* Generic Initialization */
	SystemCoreClockUpdate();

	/* Board_Init calls Chip_GPIO_Init and enables GPIO clock if needed,
	   Chip_GPIO_Init is not called again */
	Board_Init();
	Board_LED_Set(0, false);

	Chip_PININT_Init(LPC_PININT);

	/* Configure GPIO pin as input */
	Chip_GPIO_SetPinDIRInput(LPC_GPIO, GPIO_PININT_PORT, GPIO_PININT_PIN);

	/* Configure pin as GPIO */
	Chip_IOCON_PinMuxSet(LPC_IOCON, GPIO_PININT_PORT, GPIO_PININT_PIN,
						 (IOCON_FUNC0 | IOCON_DIGITAL_EN  | IOCON_GPIO_MODE));

	/* Configure pin interrupt selection for the GPIO pin in Input Mux Block */
	Chip_INMUX_PinIntSel(GPIO_PININT_INDEX, GPIO_PININT_PORT, GPIO_PININT_PIN);

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

	/* Enable interrupt in the NVIC */
	NVIC_EnableIRQ(PININT_NVIC_NAME);

	/* Enable wakeup for PININT0 */
	Chip_SYSCON_EnableWakeup(SYSCON_STARTER_PINT0);

	/* save the clock source, power down the PLL */
	saved_clksrc = Chip_Clock_GetMainClockSource();

	/* Go to sleep mode - LED will toggle on each wakeup event */
	while (1) {
		/* Go to sleep state - will wake up automatically on interrupt */
		/* Disable PLL, if previously enabled, prior to sleep */
		if (saved_clksrc == SYSCON_MAINCLKSRC_PLLOUT) {
			Chip_Clock_SetMainClockSource(SYSCON_MAINCLKSRC_IRC);
			Chip_SYSCON_PowerDown(SYSCON_PDRUNCFG_PD_SYS_PLL);
		}

		/* Lower system voltages to current lock (likely IRC) */
		Chip_POWER_SetVoltage(POWER_LOW_POWER_MODE, Chip_Clock_GetMainClockRate());

		/* Go to sleep leaving SRAM powered during sleep. Use lower
		    voltage during sleep. */
		Chip_POWER_EnterPowerMode(PDOWNMODE,
								  (SYSCON_PDRUNCFG_PD_SRAM0A | SYSCON_PDRUNCFG_PD_SRAM0B));

		/* On wakeup, restore PLL power if needed */
		if (saved_clksrc == SYSCON_MAINCLKSRC_PLLOUT) {
			Chip_SYSCON_PowerUp(SYSCON_PDRUNCFG_PD_SYS_PLL);

			/* Wait for PLL lock */
			while (!Chip_Clock_IsSystemPLLLocked()) {}

			Chip_POWER_SetVoltage(POWER_LOW_POWER_MODE, Chip_Clock_GetSystemPLLOutClockRate(false));

			/* Use PLL for system clock */
			Chip_Clock_SetMainClockSource(SYSCON_MAINCLKSRC_PLLOUT);
		}
	}

	return 0;
}
Exemple #18
0
void PININT3_IRQHandler(void) {

  Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(IR_IRQ));
}
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);
}
void PIN_INT3_IRQHandler(void)
{
    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(3));
    if(callbackPinIntD) callbackPinIntD();
}
void PIN_INT2_IRQHandler(void)
{
    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(2));
    if(callbackPinIntC) callbackPinIntC();
}
Exemple #22
0
/**
 * @brief	Handle interrupt from GPIO pin or GPIO pin mapped to PININT
 * @return	Nothing
 */
void PININT_IRQ_HANDLER(void)
{
	Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
	Board_LED_Toggle(0);
}
Exemple #23
0
void gpio_irq_disable(gpio_irq_t *obj) {
	Chip_PININT_ClearIntStatus(LPC_PININT, obj->irq_index);
}
Exemple #24
0
void FLEX_INT1_IRQHandler(void)
{
	Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(1));
	osSignalSet(get_temperature_id, OS_DRDY1);
}
/**
 * @brief   Handle interrupt from GPIO pin or GPIO pin mapped to PININT
 * @return  Nothing
 */
void PIN_INT0_IRQHandler(void)
{
    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(0));
    if(callbackPinIntA) callbackPinIntA();
}