-
Notifications
You must be signed in to change notification settings - Fork 29
/
UART_config.c
35 lines (30 loc) · 1.27 KB
/
UART_config.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*!
* @author Yash Bansod
* @date 29th September 2017
*
* @brief Source containing function definitions for UART configuration
* @file UART_config.c
*/
/* ----------------------- Include Files --------------------- */
#include "UART_config.h"
/* ----------------------- Function Definition --------------------- */
// Function for Initializing UART0 Peripheral
void UART0_init(void){
// Enable Clock to UART0 and GPIO PortA peripherals
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// Configure PA0 as UART0_Rx and PA1 as UART0_Tx
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// Configure the baud rate and data setup for the UART0
ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), UART0_BAUDRATE, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE );
// Configure and enable the interrupt for UART0
ROM_IntEnable(INT_UART0);
ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
}
// Function for Enabling UART0 Peripheral
void UART0_enable(void){
// Enable the UART0 peripheral
ROM_UARTEnable(UART0_BASE);
}