I need to create code (state machine) that when the user types on or off the LED on the board turns on or off. This is for a texas instruments CC3220s board. Now it is time to modify uartecho. Your code will need to accomplish the following: • Use only one byte of RAM for the serial buffer ( char input; ). • Use only one byte of RAM for the state ( unsigned char state; ). • Receive only one character at a time from the UART and it is not buffered. • Turn on an LED when a user types ON into the console. • Turn off the LED when a user types OFF into the console. #include #include /* Driver Header files */ #include #include /* Driver configuration */ #include "ti_drivers_config.h" /* * ======== mainThread ======== */ void *mainThread(void *arg0) {     char        input;     const char echoPrompt[] = "Echoing characters:\r\n";     UART_Handle uart;     UART_Params uartParams;     /* Call driver init functions */     GPIO_init();     UART_init();     /* Configure the LED pin */     GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);     /* Create a UART with data processing off. */     UART_Params_init(&uartParams);     uartParams.writeDataMode = UART_DATA_BINARY;     uartParams.readDataMode = UART_DATA_BINARY;     uartParams.readReturnMode = UART_RETURN_FULL;     uartParams.baudRate = 115200;     uart = UART_open(CONFIG_UART_0, &uartParams);     if (uart == NULL) {         /* UART_open() failed */         while (1);     }     /* Turn on user LED to indicate successful initialization */     GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);     UART_write(uart, echoPrompt, sizeof(echoPrompt));     /* Loop forever echoing */     while (1) {         UART_read(uart, &input, 1);         //Insert State Machine Here          UART_write(uart, &input, 1);     } }.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

I need to create code (state machine) that when the user types on or off the LED on the board turns on or off. This is for a texas instruments CC3220s board.

Now it is time to modify uartecho. Your code will need to accomplish the following:
• Use only one byte of RAM for the serial buffer ( char input; ).
• Use only one byte of RAM for the state ( unsigned char state; ).
• Receive only one character at a time from the UART and it is not buffered.
• Turn on an LED when a user types ON into the console.
• Turn off the LED when a user types OFF into the console.

#include <stdint.h>
#include <stddef.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>

/* Driver configuration */
#include "ti_drivers_config.h"

/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
    char        input;
    const char echoPrompt[] = "Echoing characters:\r\n";
    UART_Handle uart;
    UART_Params uartParams;

    /* Call driver init functions */
    GPIO_init();
    UART_init();

    /* Configure the LED pin */
    GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    /* Create a UART with data processing off. */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.baudRate = 115200;

    uart = UART_open(CONFIG_UART_0, &uartParams);

    if (uart == NULL) {
        /* UART_open() failed */
        while (1);
    }

    /* Turn on user LED to indicate successful initialization */
    GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);

    UART_write(uart, echoPrompt, sizeof(echoPrompt));

    /* Loop forever echoing */
    while (1) {
        UART_read(uart, &input, 1);

        //Insert State Machine Here    

     UART_write(uart, &input, 1);
    }
}.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education