Description
Need following code edited to do the following. This is using Code Composer Studio for the CS3220s Launchpad. I just need the requirements listed below to be completed. Please message if more info is needed.
-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.
Code:
/*
* Copyright (c) 2015-2020, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== uartecho.c ========
*/
#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);
UART_write(uart, &input, 1);
}
}
Explanation & Answer
View attached explanation and answer. Let me know if you have any questions.Hi bro, I tried several attempts to solve the problem (#include "uart_term.h") but I didn't find a solution, try downloading this library to your computer, I apologize for the late reply and if you have any questions please feel free to contact us. 💗
Need following code edited to do the following. This is using Code Composer Studio for the
CS3220s Launchpad. just need the requirements listed below to be completed
-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.
Code:
/*
* Copyright (c) 2015-2020, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyrig...