Back to posts Edit this post
Copy content

24 Jan 11:08

//***************************************************************************** // hello.c - Simple hello world example. // // Maciej Kucia July 2013 // // This is part of revision 1.0 of the EK-LM4F232 Firmware Package. //***************************************************************************** #include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "driverlib/fpu.h" #include "driverlib/sysctl.h" #include "driverlib/rom.h" #include "driverlib/pin_map.h" #include "driverlib/uart.h" #include "grlib/grlib.h" #include "drivers/ili9341_240x320x262K.h" #include "utils/uartstdio.h" #include "driverlib/gpio.h" #define GPIO_PINS_ALL GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7 //***************************************************************************** // // TI logo in array form (1 bit per pixel) // //***************************************************************************** const unsigned char TI_logo[(16*2)+5] = { IMAGE_FMT_1BPP_UNCOMP, 16,0, 16,0, 0x0f,0xff,0x0f,0xff,0x0f,0xf3,0x0f,0xfa,0x0f,0x8f,0x0f,0x89,0x81,0x99,0x81,0x19,0x03,0x09,0x07,0x89,0x07,0xdf,0x3f,0xee,0x7f,0xf0,0xff,0xf8,0xff,0xf9,0xff,0xfb}; // 1,1,1,1,0,0,0,0, 1,1,1,1,1,1,1,1, // 1,1,1,1,0,0,0,0, 1,1,1,1,1,1,1,1, // 1,1,1,1,0,0,0,0, 1,1,0,0,1,1,1,1, // 1,1,1,1,0,0,0,0, 0,1,0,1,1,1,1,1, // 1,1,1,1,0,0,0,0, 1,1,1,1,0,0,0,1, // 1,1,1,1,0,0,0,0, 1,0,0,1,0,0,0,1, // 1,0,0,0,0,0,0,1, 1,0,0,1,1,0,0,1, // 1,0,0,0,0,0,0,1, 1,0,0,1,1,0,0,0, // 1,1,0,0,0,0,0,0, 1,0,0,1,0,0,0,0, // 1,1,1,0,0,0,0,0, 1,0,0,1,0,0,0,1, // 1,1,1,0,0,0,0,0, 1,1,1,1,1,0,1,1, // 1,1,1,1,1,1,0,0, 0,1,1,1,0,1,1,1, // 1,1,1,1,1,1,1,0, 0,0,0,0,1,1,1,1, // 1,1,1,1,1,1,1,1, 0,0,0,1,1,1,1,1, // 1,1,1,1,1,1,1,1, 1,0,0,1,1,1,1,1, // 1,1,1,1,1,1,1,1, 1,1,0,1,1,1,1,1 //***************************************************************************** // // Print some text to the display. // //*********************************************** tContext sContext; tRectangle sRect; void refresh() { GrContextForegroundSet(&sContext, ClrWhite); GrContextBackgroundSet(&sContext, ClrWhite); GrRectFill(&sContext, &sRect); } void move(int xMin, int xMax, int yMin, int yMax) { refresh(); sRect.i16XMin = xMin; sRect.i16XMax = xMax; sRect.i16YMin = yMin; sRect.i16YMax = yMax; GrContextForegroundSet(&sContext, ClrRed); GrRectFill(&sContext, &sRect); } int main(void) { // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // ROM_FPULazyStackingEnable(); // // Set the clocking to run directly from the crystal. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); ILI9341_240x320x262K_Init(); // // Initialize the graphics context. // GrContextInit(&sContext, &g_sILI9341_240x320x262K); SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOK); // // Set all GPIOB pins as inputs // //!program! GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_7); GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0); GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_4); GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_5); GPIOPinTypeGPIOInput(GPIO_PORTK_BASE, GPIO_PIN_7); // zdefiniowanie polozenia poczatkowego int xMin = 110; int xMax = 130; int yMin = 150; int yMax = 170; sRect.i16XMin = xMin; sRect.i16YMin = yMin; sRect.i16XMax = xMax; sRect.i16YMax = yMax; GrContextBackgroundSet(&sContext, ClrWhite); GrContextForegroundSet(&sContext, ClrRed); GrRectFill(&sContext, &sRect); int step=10; for(;;) { if (GPIOPinRead(GPIO_PORTK_BASE,GPIO_PIN_7) == 0) { //lewo if((xMin-step)>=0) { xMin -= step; xMax -= step; move(xMin, xMax, yMin, yMax); } } if (GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_4) == 0) { //prawo if((xMin+step)<=300) { xMin += step; xMax += step; move(xMin, xMax, yMin, yMax); } } if (GPIOPinRead(GPIO_PORTB_BASE,GPIO_PIN_0) == 0) { //góra if((yMin-step)>=0) { yMin -= step; yMax -= step; move(xMin, xMax, yMin, yMax); } } if (GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_5) == 0) { //dół if((yMax+step)<=240) { yMin += step; yMax += step; move(xMin, xMax, yMin, yMax); } } SysCtlDelay(SysCtlClockGet() / 30); } }

No files