29 lines
841 B
C
29 lines
841 B
C
|
#include <stdint.h>
|
||
|
#include <stdbool.h>
|
||
|
#include "tm4c123gh6pm.h"
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
SYSCTL_RCGC2_R |= 0x00000020; /* enable clock to GPIOF */
|
||
|
GPIO_PORTF_LOCK_R = 0x4C4F434B; /* unlock commit register */
|
||
|
GPIO_PORTF_CR_R = 0x11; /* make PORTF0 PORTF4 CONFIGURABLE*/
|
||
|
GPIO_PORTF_DEN_R = 0x1F; /* set PORTF pins 5 pins*/
|
||
|
GPIO_PORTF_DIR_R = 0x0E; /* set PORTF0 PORTF4 pin as input user switch pin */
|
||
|
GPIO_PORTF_PUR_R = 0x11; /* PORTF4 PORT0 is pulled up */
|
||
|
GPIO_PORTF_IEV_R = 0x00; /*detects the falling edge of the switch*/
|
||
|
|
||
|
|
||
|
switch(z)
|
||
|
{
|
||
|
case 0: GPIO_PORTF_DATA_R = 0x02;
|
||
|
break;
|
||
|
|
||
|
case 1:GPIO_PORTF_DATA_R = 0x00;
|
||
|
break;
|
||
|
|
||
|
default:GPIO_PORTF_DATA_R = 0x04
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
}
|