LM3S8962 Buton Kullanım Örneği
Buton.c dosyası içeriği
- Kütüphaneler dahil edililiyor
#include "inc/hw_gpio.h" #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "drivers/rit128x96x4.h"
- Kartın üzerindeki Select butonu için kesme tanımlanıyor
void
GPIOFIntHandler(void)
{
// Clear the GPIO interrupt.
GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);
RIT128x96x4StringDraw("SELECT", 48, 32, 15);
}
- Diğer butonlar(up,down,right,left) için kesme tanımlanıyor
void
GPIOEIntHandler(void)
{
// Clear the GPIO interrupt.
GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
if(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0) == 0)
RIT128x96x4StringDraw("UP ", 48, 32, 15);
if(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1) == 0)
RIT128x96x4StringDraw("DOWN ", 48, 32, 15);
if(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2) == 0)
RIT128x96x4StringDraw("LEFT ", 48, 32, 15);
if(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3) == 0)
RIT128x96x4StringDraw("RIGHT ", 48, 32, 15);
}
- Ana Fonksiyon saat ayarlamaları yapılıyor
int
main(void)
{
// Set the clocking to run directly from the crystal.
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
- Kullanılacak portlar aktif hale getiriliyor
// Enable the peripherals used by this application.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
- Butonlar giriş olarak ayarlanıyor. Butonların kesmelerinin düşen kenara göre ayarlanıyor. Kesme aktif hale getiriliyor.
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE);
GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1);
IntEnable(INT_GPIOF);
// E portu ayarlanıyor.
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0);
GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2
| GPIO_PIN_3, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2
| GPIO_PIN_3, GPIO_FALLING_EDGE);
GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
IntEnable(INT_GPIOE);
- OLED ayarlanıyor
RIT128x96x4Init(1000000);
RIT128x96x4StringDraw("But. Int Ex.", 30, 16, 15);
- Sonsuz Döngü
while(1)
{
}
}
startup_ccs.c
- startup_ccs.c dosyası içerisinde kesmeler tanımlanır.
extern void GPIOFIntHandler(void); extern void GPIOEIntHandler(void);
- Vektor tablosuna gerekli yerlere eklemeler yapılır. Burada ilgili kesmelere fonksiyonlar tanımlanır.
GPIOEIntHandler, // GPIO Port E
GPIOFIntHandler, // GPIO Port F
= Kaynaklar =
[1] Texas Instruments, gpio_jtag.c, GPIO JTAG Recovery Örneği
[2] http://www.ti.com/tool/ek-lm3s8962
[3] http://www.ti.com/tool/ccstudio?DCMP=dsp_ccs_v4&HQS=Other%252BOT%252Bccs