工程文件夹
EasyDebug 文件夹目录
编译器添加全局宏 ‘EDEBUG’
修改文件:source\ti\display\Display.h
// 在IDE中添加全局宏
#if EDEBUG
#include "edebug.h"
# define Display_printf LOG_TI
#else
# define Display_printf Display_doPrintf
#endif
#include "edebug.h"
int main()
{
*** ***
edebug_init(); // debug初始化
/* enable interrupts and start SYS/BIOS */
BIOS_start();
}
edebug_cc26xx.c – 82行 – 波特率115200 – 默认开启空闲接收中断回调(uart_read_callback)
/* Call driver init functions */
UART_init();
UART_Params params;
/* Create a UART with data processing off. */
UART_Params_init(¶ms);
params.writeMode = UART_MODE_BLOCKING;
params.writeDataMode = UART_DATA_BINARY;
params.readMode = UART_MODE_CALLBACK;
params.readDataMode = UART_DATA_BINARY;
params.readCallback = uart_read_callback;
params.baudRate = 115200;
// Open the UART and initiate the first read
uart_handle = UART_open(CONFIG_UART_0, ¶ms);
if (!uart_handle) while(1);
UART_control(uart_handle, UARTCC26XX_CMD_RX_FIFO_FLUSH,NULL); // 清空接收缓存区
UART_control(uart_handle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL); // 开启空闲接收回调
#if ATCMD_EN
UART_read(uart_handle, g_rx_buff, RX_MAX_LEN);
#endif
#if ATCMD_EN
// 在功能模块中定义一个标准函数
static int test(atcmd_pack_t *pack) {
uint8_t buff[20] = "test\r\n";
strcat((char*)buff, AT_OK);
pack->reply(buff, strlen((char*)buff));
return 0;
}
static int test2(atcmd_pack_t *pack) {
if (pack->argc != 2) return -1;
uint8_t buff[20] = "";
uint32_t num = 0, num1 = 0;
sscanf((char*)(pack->data), "%d,%d", &num, &num1);
snprintf((char*)buff, 20, "%d,%d"AT_OK, num, num1);
pack->reply(buff, strlen((char*)buff));
return 1;
}
// 注册AT指令,传入标准函数
ATCMD_INIT("AT^TEST?", test);
ATCMD_INIT("AT^TEST=", test2);
#endif
/********************************************************************************
* @file edebug_cc26xx.h
* @author jianqiang.xue
* @version V1.0.0
* @date 2022-09-13
* @brief 移植RTT并替换TI自带LOG -- JLINK(RTT)-- XDS110(UART),添加ATCMD,快速实现单例测试
********************************************************************************/
#ifndef __EDEBUG_H__
#define __EDEBUG_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include
#include
#include
#include
#include "SEGGER_RTT.h"
/*------------【RTT_OUT / UART_OUT】 只能选取一个,注释另一个-------------------*/
// #define RTT_OUT
#define UART_OUT
#if defined(RTT_OUT) && defined(UART_OUT)
#error "禁止开启两个!!!"
#endif
#define ATCMD_EN 1 // 目前只有UART有效,后期增加RTT
#define RX_MAX_LEN 256 // AT指令最大接收长度
/* Private Define ------------------------------------------------------------*/
#ifdef RTT_OUT
#define LOG_PROTO(type, color, format, ...) { \
SEGGER_RTT_printf(0, "\r\r" color "%s[%s.c:%d]" format "\r\n", type, \
__func__, __LINE__, \
##__VA_ARGS__); \
}
/* 无颜色日志输出 */
#define LOG(format, ...) LOG_PROTO("", "", format, ##__VA_ARGS__)
/* 有颜色格式日志输出 */
#define LOGI(format, ...) LOG_PROTO("I: ", RTT_CTRL_TEXT_BRIGHT_GREEN, format, ##__VA_ARGS__)
#define LOGW(format, ...) LOG_PROTO("W: ", RTT_CTRL_TEXT_BRIGHT_YELLOW, format, ##__VA_ARGS__)
#define LOGE(format, ...) LOG_PROTO("E: ", RTT_CTRL_TEXT_BRIGHT_RED, format, ##__VA_ARGS__)
#define LOGD(format, ...) LOG_PROTO("D: ", RTT_CTRL_TEXT_BRIGHT_WHITE, format, ##__VA_ARGS__)
#else // uart0,这里在SEGGER_RTT_printf内部做了处理
#define LOG_PROTO(type, format, ...) { \
SEGGER_RTT_printf(0, "%s[%s.c:%d]" format "\r\n", type, \
__func__, __LINE__, \
##__VA_ARGS__); \
}
#define LOG(format, ...) LOG_PROTO("", format, ##__VA_ARGS__)
#define LOGI(format, ...) LOG_PROTO("I: ", format, ##__VA_ARGS__)
#define LOGW(format, ...) LOG_PROTO("W: ", format, ##__VA_ARGS__)
#define LOGE(format, ...) LOG_PROTO("E: ", format, ##__VA_ARGS__)
#define LOGD(format, ...) LOG_PROTO("D: ", format, ##__VA_ARGS__)
#endif
// TI log替换
#define LOG_TI(handle, line, column, format, ...) LOGI(format, ##__VA_ARGS__)
/* Public Function Prototypes ------------------------------------------------*/
void edebug_init(void);
#if ATCMD_EN
void edebug_send(uint8_t* data, uint16_t len);
#endif
#ifdef __cplusplus
}
#endif
#endif