The code below must be edited to apply these functions #include #include /* Driver Header files */
Posted: Mon Jun 06, 2022 6:07 pm
The code below must be edited to apply these functions
#include <stdint.h>
#include <stddef.h>
/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART2.h>
/* Driver configuration */
#include "ti_drivers_config.h"
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
char input;
const char echoPrompt[] = "Echoing
characters:\r\n";
UART2_Handle uart;
UART2_Params uartParams;
size_t bytesRead;
size_t bytesWritten = 0;
uint32_t status =
UART2_STATUS_SUCCESS;
/* Call driver init functions */
GPIO_init();
/* Configure the LED pin */
GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD |
GPIO_CFG_OUT_LOW);
/* Create a UART where the default read and write
mode is BLOCKING */
UART2_Params_init(&uartParams);
uartParams.baudRate = 115200;
uart = UART2_open(CONFIG_UART2_0,
&uartParams);
if (uart == NULL) {
/* UART2_open() failed */
while (1);
}
/* Turn on user LED to indicate successful
initialization */
GPIO_write(CONFIG_GPIO_LED_0,
CONFIG_GPIO_LED_ON);
UART2_write(uart, echoPrompt, sizeof(echoPrompt),
&bytesWritten);
/* Loop forever echoing */
while (1) {
bytesRead = 0;
while (bytesRead == 0) {
status = UART2_read(uart,
&input, 1, &bytesRead);
if (status !=
UART2_STATUS_SUCCESS) {
/*
UART2_read() failed */
while
(1);
}
}
bytesWritten = 0;
while (bytesWritten == 0) {
status =
UART2_write(uart, &input, 1, &bytesWritten);
if (status !=
UART2_STATUS_SUCCESS) {
/*
UART2_write() failed */
while
(1);
}
}
}
}
#include <stdint.h>
#include <stddef.h>
/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART2.h>
/* Driver configuration */
#include "ti_drivers_config.h"
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
char input;
const char echoPrompt[] = "Echoing
characters:\r\n";
UART2_Handle uart;
UART2_Params uartParams;
size_t bytesRead;
size_t bytesWritten = 0;
uint32_t status =
UART2_STATUS_SUCCESS;
/* Call driver init functions */
GPIO_init();
/* Configure the LED pin */
GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD |
GPIO_CFG_OUT_LOW);
/* Create a UART where the default read and write
mode is BLOCKING */
UART2_Params_init(&uartParams);
uartParams.baudRate = 115200;
uart = UART2_open(CONFIG_UART2_0,
&uartParams);
if (uart == NULL) {
/* UART2_open() failed */
while (1);
}
/* Turn on user LED to indicate successful
initialization */
GPIO_write(CONFIG_GPIO_LED_0,
CONFIG_GPIO_LED_ON);
UART2_write(uart, echoPrompt, sizeof(echoPrompt),
&bytesWritten);
/* Loop forever echoing */
while (1) {
bytesRead = 0;
while (bytesRead == 0) {
status = UART2_read(uart,
&input, 1, &bytesRead);
if (status !=
UART2_STATUS_SUCCESS) {
/*
UART2_read() failed */
while
(1);
}
}
bytesWritten = 0;
while (bytesWritten == 0) {
status =
UART2_write(uart, &input, 1, &bytesWritten);
if (status !=
UART2_STATUS_SUCCESS) {
/*
UART2_write() failed */
while
(1);
}
}
}
}