The code below must be edited to apply these functions #include #include /* Driver Header files */

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

The code below must be edited to apply these functions #include #include /* Driver Header files */

Post by answerhappygod »

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);
}
}
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply