Tool/software: Starterware
Hey everyone,
i am trying to create an interrupt when pressing a switch connected to an input pin of my beaglebone white.
When this event occurs, i have created an isr which i want to turn off (an already on) led and turn on an other (currently off) led...
i don't know what is not working properly so i am giving you my code (actually a piece of it, which is responsible for enabling the pin, interrupt controller and the isr) in hope that someone can help..
IntMasterIRQEnable(); IntAINTCInit(); GPIO1ModuleClkConfig(); GpioModuleEnable(SOC_GPIO_1_REGS); GPIODirModeSet(SOC_GPIO_1_REGS, GPIO_INTER_INP, GPIO_DIR_INPUT); IntRegister(SYS_INT_GPIOINT1A, isr_buttonLed); IntPrioritySet(SYS_INT_GPIOINT1A, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_GPIOINT1A); GPIOIntTypeSet(SOC_GPIO_1_REGS,GPIO_INTER_INP,GPIO_INT_TYPE_LEVEL_HIGH); HWREG(SOC_GPIO_1_REGS + 0x34) = 0x10; HWREG(SOC_GPIO_1_REGS + 0x38) = 0x10; HWREG(SOC_GPIO_1_REGS + 0x44) = 0x10; // //------isr function // static void isr_buttonLed(void) { /* Clear interrupt */ HWREG(SOC_GPIO_1_REGS + 0x2C) = 0x10; HWREG(SOC_GPIO_1_REGS + 0x30) = 0x10; //turn off led that is already on GPIOPinWrite(SOC_GPIO_1_REGS, GPIO_LED_ON, GPIO_PIN_LOW); //turn on an other led GPIOPinWrite(SOC_GPIO_1_REGS, GPIO_LED_2, GPIO_PIN_HIGH); //again enable IRQ HWREG(SOC_GPIO_1_REGS + 0x34) = 0x10;//GPIO_IRQSTATUS_SET_0 HWREG(SOC_GPIO_1_REGS + 0x38) = 0x10;//GPIO_IRQSTATUS_SET_1 HWREG(SOC_GPIO_1_REGS + 0x44) = 0x10;//GPIO_IRQWAKEN_0 }
Do i have to enable something more? Are the above correct?
Also i am not pretty sure that i have understood how to choose the correct interrupt request line..any help is more than welcome...
Thanks in advance!