Initialized PORT E and also added code for LED control

This commit is contained in:
Rajput R Vikramsingh Vikramsingh 2024-10-29 00:59:51 +05:30
parent 3ab1c54fad
commit 5b4d235ad8
1 changed files with 30 additions and 3 deletions

33
main.c
View File

@ -67,9 +67,36 @@ void UART0_Write(char data)
} }
void PortF_Init(void)
{
SYSCTL_RCGCGPIO_R |= 0x20; // Enable clock to Port F
GPIO_PORTF_LOCK_R = 0x4C4F434B; // Unlock Port F for commit
GPIO_PORTF_CR_R |= 0x0E; // Allow changes to PF1, PF2, PF3 (RGB LEDs)
GPIO_PORTF_DIR_R |= 0x0E; // Set PF1, PF2, PF3 as outputs
GPIO_PORTF_DEN_R |= 0x0E; // Enable digital on PF1, PF2, PF3
}
void LED_Control(char receivedChar)
{
switch(receivedChar)
{
case 'R':
GPIO_PORTF_DATA_R = 0x02; // Turn on RED LED (PF1)
break;
case 'B':
GPIO_PORTF_DATA_R = 0x04; // Turn on BLUE LED (PF2)
break;
case 'G':
GPIO_PORTF_DATA_R = 0x08; // Turn on GREEN LED (PF3)
break;
default:
GPIO_PORTF_DATA_R = 0x00; // Turn off all LEDs
break;
}
}