Hi ,
I was trying out the code given below with IAR 6.60 and Tiva C eval board .
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
void onButtonDown(void);
void onButtonUp(void);
void onButtonDown(void) {
if (GPIOIntStatus(GPIO_PORTF_BASE, false) & GPIO_PIN_4) {
// PF4 was interrupt cause
printf("Button Down\n");
GPIOIntRegister(GPIO_PORTF_BASE, onButtonUp); // Register our handler function for port F
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4,
GPIO_RISING_EDGE); // Configure PF4 for rising edge trigger
GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_4); // Clear interrupt flag
}
}
void onButtonUp(void) {
if (GPIOIntStatus(GPIO_PORTF_BASE, false) & GPIO_PIN_4) {
// PF4 was interrupt cause
printf("Button Up\n");
GPIOIntRegister(GPIO_PORTF_BASE, onButtonDown); // Register our handler function for port F
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4,
GPIO_FALLING_EDGE); // Configure PF4 for falling edge trigger
GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_4); // Clear interrupt flag
}
}
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_2_5| SYSCTL_USE_PLL | SYSCTL_OSC_INT | SYSCTL_XTAL_16MHZ);
// Pin F4 setup
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable port F
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4); // Init PF4 as input
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4,
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Enable weak pullup resistor for PF4
// Interrupt setuü
GPIOIntDisable(GPIO_PORTF_BASE, GPIO_PIN_4); // Disable interrupt for PF4 (in case it was enabled)
GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_4); // Clear pending interrupts for PF4
GPIOIntRegister(GPIO_PORTF_BASE, onButtonDown); // Register our handler function for port F
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4,
GPIO_FALLING_EDGE); // Configure PF4 for falling edge trigger
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4); // Enable interrupt for PF4
while(1);
}
__
The compiler works fine with it (0 errors); the linker gives me following errors ..
Building configuration: Button_Intr - Debug
Updating build tree...
Button_2.c
Linking
Error[Li005]: no definition for "SysCtlClockSet" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "SysCtlPeripheralEnable" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "GPIOPinTypeGPIOInput" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "GPIOPadConfigSet" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "GPIOIntDisable" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "GPIOIntClear" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "GPIOIntRegister" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "GPIOIntTypeSet" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "GPIOIntEnable" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error[Li005]: no definition for "GPIOIntStatus" [referenced from D:\WorkSpace\DIY\LED_Button_Interrupt\Debug\Obj\Button_2.o]
Error while running Linker
Total number of errors: 10
Total number of warnings: 0
I have added libraries in Project > Options > C/ C++ Compiler > Preprocessor .
Any thing more I need to do ? I'm bit new to this .
Thanks !
