Tiva Programa Con Teclado
Tiva Programa Con Teclado
*
* 4x4 Keypad Detection
*
**/
#include <stdint.h>
#include "inc/tm4c123gh6pm.h"
void keypad_init(void);
unsigned char keypad_kbhit(void);
unsigned char keypad_getkey(void);
void gpio_led_init(void);
void gpio_toggle_led(uint8_t led);
void delayMs(int n);
void delayUs(int n);
int main(void)
{
unsigned char key;
keypad_init();
{
// LCD_command(0x80); /* LCD cursor location */
void gpio_led_init(void)
{
/* enable clock to GPIO PORTF at clock gating control register */
SYSCTL_RCGC2_R |= 0x00000020;
/* enable the GPIO pins for the LED (PF3, 2, 1) as output */
GPIO_PORTF_DIR_R = 0x0E;
/* enable the GPIO pins for digital function */
GPIO_PORTF_DEN_R = 0x0E;
}
row = 1;
GPIO_PORTE_DATA_R = 0x0D; /* enable row 1 */
delayUs(2); /* wait for signal to settle */
col = GPIO_PORTC_DATA_R & 0xF0;
if (col != 0xF0) break;
row = 2;
GPIO_PORTE_DATA_R = 0x0B; /* enable row 2 */
delayUs(2); /* wait for signal to settle */
col = GPIO_PORTC_DATA_R & 0xF0;
if (col != 0xF0) break;
row = 3;
GPIO_PORTE_DATA_R = 0x07; /* enable row 3 */
delayUs(2); /* wait for signal to settle */
col = GPIO_PORTC_DATA_R & 0xF0;
if (col != 0xF0) break;
void delayUs(int n)
{
int i, j;
for(i = 0 ; i < n; i++)
for(j = 0; j < 3; j++)
{} /* do nothing for 1 us */
}