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

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.

I need to modify this uartecho code to solve these question. Turn on an LED when a user types ON into the console. Turn off the LED when a user types OFF into the console.

This is the code that needs to be modified

#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: "; 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); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To modify the provided code to implement a state machine that turns the LED on or off based on user input you must analyze the input and use GPIO oper... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!