pls tell me where to study about uart functions to write a code i am using ccs5.5, tivaware 1.1, tiva123gh6pm.if possible give me a code for glowing led by recieving data from sensor. i wrote the code upto here
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
void setupClocks() {
//this line of code sets system clock to 40 MHz
SysCtlClockSet(
SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
| SYSCTL_XTAL_16MHZ);
// this line will enables clock to UART0
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
// this line will enables clock to PORT_A
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
}
void setupPortsIO() {
//sets PA0 as data transmitting pin and PA1 as Data Receiving pin
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
//sets PD1 as output to buzzer
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0);
}
//Initialises UART
void setupUart() {
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
}
int main(void) {
setupClocks(); // clocks are enabled
setupPortsIO(); // all i/o ports are configured
setupUart(); // uart is started
while(1){
//here i have to write code to recieve serial data from xbee and glow the led in tiva launchpad and i know the code in arduino this is the code how to do it in tiva c launchpad
int read=0;
if(serial.available>21){
if(serial.read()==0x7E){
for(int i=0;i<19;i++){
byte discard=serial.read()}
read value=serial.read();
}
}
if(read=0){
serial.println("on");
}
else{
serial.println("off");
}