Skip to content

Instantly share code, notes, and snippets.

@tkmarsh
Created November 13, 2017 15:08
Show Gist options
  • Save tkmarsh/350ffc7dbee02800afa18c5423a0b13b to your computer and use it in GitHub Desktop.
Save tkmarsh/350ffc7dbee02800afa18c5423a0b13b to your computer and use it in GitHub Desktop.
#include "include/tm4c123gh6pm.h"
#include "include/delay.h"
#define RED (1U<<1)
#define BLUE (1U<<2)
#define GREEN (1U<<3)
int main(){
SYSCTL_RCGCGPIO_R=0x20U;
GPIO_PORTF_LOCK_R=0x4C4F434BU;
GPIO_PORTF_CR_R=0xFF;
GPIO_PORTF_DIR_R=RED|GREEN|BLUE;
GPIO_PORTF_PUR_R=0x11U;
GPIO_PORTF_DEN_R=0x1FU;
while(1){
GPIO_PORTF_DATA_R&=(~0x0EU);
switch(GPIO_PORTF_DATA_R & 0x11U){
case 0x00:
GPIO_PORTF_DATA_R |=RED;
break;
case 0x01:
GPIO_PORTF_DATA_R |=BLUE;
break;
case 0x10:
GPIO_PORTF_DATA_R |=GREEN;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment