ee690_tasks/main.c

51 lines
1.1 KiB
C

#include <stdint.h>
#include <stdbool.h>
#include "tm4c123gh6pm.h"
void Systick_Handler(void);
void systickInit(void);
int main(void)
{
SYSCTL_RCGC2_R |= 0x00000020; /* enable clock to GPIOF */
GPIO_PORTF_LOCK_R = 0x4C4F434B; /* unlock commit register */
GPIO_PORTF_CR_R = 0x1F; /* make PORTF0 configurable */
GPIO_PORTF_DEN_R = 0x1E; /* set PORTF pins 4 pin */
GPIO_PORTF_DIR_R = 0x0E; /* set PORTF4 pin as input user switch pin */
GPIO_PORTF_PUR_R = 0x10; /* PORTF4 is pulled up */
GPIO_PORTF_IS_R = (~(1<<4));
GPIO_PORTF_IBE_R = (~(1<<4));
GPIO_PORTF_IEV_R = (~(1<<4));
GPIO_PORTF_IM_R = (1<<4);
NVIC_EN0_R |= (1<<30);
while(1)
{
}
}
void systickInit()
{
NVIC_ST_CURRENT_R = 0;
NVIC_ST_CTRL_R = 0x07;
NVIC_ST_RELOAD_R = 8000000;
}
void Systick_Handler()
{
systickInit();
if (GPIO_PORTF_DATA_R & 0x04) {
GPIO_PORTF_DATA_R &= ~0x04;
}
else {
GPIO_PORTF_DATA_R |= 0x04;
}
systickInit();
}