Skip to content
Snippets Groups Projects
Commit fc91de93 authored by Leonardo Martinez Hornak's avatar Leonardo Martinez Hornak
Browse files

Button press ISR working

parent 79213e35
Branches
Tags
No related merge requests found
......@@ -5,6 +5,7 @@
/**
* main.c
*/
void main(void)
{
volatile int i;
......@@ -12,11 +13,12 @@ void main(void)
initializeGPIOModule();
__enable_interrupt();
while(1)
{
turnOnAlarmLED();
turnOffAlarmLED();
//turnOnAlarmLED();
//turnOffAlarmLED();
}
}
#include "msp.h"
#include "gpio.h"
volatile int prueba;
void initializeGPIOModule(void)
{
//Configures Port1 pins according to SLAU597F (MSP432 Launchpad User Guide)
P1DIR = 0b11101001;
P1SEL1 = 0b0000000;
P1SEL0 = 0b1110110;
P1OUT = 0;
P1DIR = 0xE9;
P1SEL1 = 0;
P1SEL0 = 0xE6;
P2OUT = 0;
P2DIR = 0xFF;
P2SEL1 = 0;
P2SEL0 = 0xF0;
//Configure Interrupt for P1.4
P1IFG = 0;
P1IES = 0; //Low to high transition for the ISR
P1IE |= BIT4; //Enable interrupt
//Enable Pull-Up for P1.4
P1OUT |= BIT4; //Enable interrupt
P1REN |= BIT4; //Enable interrupt
P2DIR = 0b11111111;
P2SEL1 = 0b00000000;
P2SEL0 = 0b11110000;
NVIC_SetPriority(PORT1_IRQn,3);
NVIC_EnableIRQ(PORT1_IRQn); // Enable PORT1 Interrupt
//TODO Configure other ports
}
......@@ -56,6 +72,25 @@ void turnOffLED(int identifier)
void setBluetoothButtonISRCallbackFunction(void *callback_function)
{}
void PORT1_IRQHandler(void)
{
if(P1IFG & BIT4){
if(prueba == 0)
{
turnOnLED(LED_BLUE);
prueba = 1;
}
else
{
turnOffLED(LED_BLUE);
prueba = 0;
}
P1IFG &= ~BIT4;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment