您好、支持团队、
我们的产品使用 CC3220SF SoC。 SimpleLink-SDK 版本:simplelink_cc32xx_sdk_4_30_00_06。
在演示代码"AT_commands"(路径:C:\ti\simplelink_cc32xx_sdk_4_30_00_06\examples\rtos\CC3220SF_LAUNCHXL_demos\at_commands\tirtos\ccs)中,使用 UART.h 而不是 UART2.h
我使用示例代码“uartecho”并修改"uartecho.c"代码,然后在 Launchpad 中运行代码。



我的问题:
- 回调函数是 ISR (中断服务例程)?
- 第112行、如果没有 UART_READ (UART、INPUT、1)、则回调函数不起作用、为什么?
- 我同时通过 Terminal v1.9v 程序发送“$4C$53$31$32$33$34$35$23”,但我从未收到“RightMatch”消息。
- 无法在 UART.h 中使用 readcallback 函数? 因为我没有看到任何示例或演示代码将 readcallback 函数与 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);
}
}
}
谢谢、
Lishen