#include <stdint.h> #include "C:\ti\TivaWare_C_Series-2.1.4.178\inc\tm4c123gh6pm.h" /** * main.c */ void delayMS(int n); /*function prototype for delay*/ int main(void) { unsigned int value; SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_R5; GPIO_PORTF_LOCK_R = 0x4C4F434B; GPIO_PORTF_CR_R = 0x01; GPIO_PORTF_DIR_R = 0x0a; //PF3, PF1 as output PF4, PF0 as input GPIO_PORTF_DEN_R = 0x1b;//PF4, PF3, PF1, PF0 as digital pins GPIO_PORTF_PUR_R = 0x11; //Enable pull up for PF0,PF1 while(1) { value = GPIO_PORTF_DATA_R; //read data from PORTF value = ~value; //switch is low active; LED is high active if (value & 0x10) { //SW1 GPIO_PORTF_DATA_R = 0x08; //put it on the green LED } else if(value & 0x01) { //SW2 GPIO_PORTF_DATA_R = 0x02; //put it on the RED LED }else { GPIO_PORTF_DATA_R = 0x00; } } return 0; } void SystemInit(void) { NVIC_CPAC_R |= 0x00F00000; }