Hi, Support Team,
Our product use CC3220SF SoC. SimpleLink-SDK version: simplelink_cc32xx_sdk_4_30_00_06.
In demo code “at_commands”(path: C:\ti\simplelink_cc32xx_sdk_4_30_00_06\examples\rtos\CC3220SF_LAUNCHXL\demos\at_commands\tirtos\ccs), use UART.h not UART2.h.
I use example code “uartecho” and modify "uartecho.c" code and run code in Launchpad.



My question:
- callback function is ISR(Interrupt Service Routine) ?
- Line 112, if no UART_read(uart, &input, 1), then callback function not working, why?
- I send “$4C$53$31$32$33$34$35$23” at the same time by Terminal v1.9v program, But I never get “RightMatch” message.
- Can not use readcallback function in UART.h ? Because I did not see any example or demo code use readcallback function with UART.h.
/*
* 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"
volatile char g_ucInput = 0;
volatile char g_ucRxDBuf[8] = {0};
volatile char g_ucTestLEDFlag = 0;
UART_Handle uart;
UART_Params uartParams;
void readcallback_LS (UART_Handle handle, void *buf, size_t count)
{
char i;
char i_input;
UART_read(uart, &i_input, 1);
g_ucInput = i_input;
for(i=7; i>=1; i--)
{
g_ucRxDBuf[i] = g_ucRxDBuf[i-1];
}
g_ucRxDBuf[0]=g_ucInput;
} // End void readcallback_LS (UART_Handle handle, void *buf, size_t count)
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
char input;
const char echoPrompt[] = "Echoing characters:\r\n";
const char RightMatch[] = "Match J-MEX command\r\n";
/* 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.readMode = UART_MODE_CALLBACK;
uartParams.writeMode = UART_MODE_BLOCKING;
uartParams.readCallback = readcallback_LS;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartParams.dataLength = UART_LEN_8;
uartParams.stopBits = UART_STOP_ONE;
uartParams.parityType = UART_PAR_NONE;
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));
UART_control(uart, UART_CMD_RXENABLE, NULL);
UART_read(uart, &input, 1);
/* Loop forever echoing */
while (1) {
// Lishen add[S]
if( (g_ucRxDBuf[7]==0x4C) && (g_ucRxDBuf[6]==0x53) && (g_ucRxDBuf[0]==0x23) )
{
UART_write(uart, RightMatch, sizeof(RightMatch));
GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
}
else
{
GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_OFF);
}
}
}
Thanks,
Lishen