协议栈:BLE-CC254x-1.4.2.2
---------------------------------------------------------------将默认的
INT_HEAP_LEN=3072
HALNODEBUG
OSAL_CBTIMER_NUM_TASKS=1
HAL_AES_DMA=TRUE
HAL_DMA=TRUE //默认使用的是DMA的查询方式。
POWER_SAVING
xPLUS_BROADCASTER
HAL_LCD=TRUE
HAL_LED=FALSE
HAL_KEY=TRUE
---------------------------------------------------------------改为
INT_HEAP_LEN=3072
HALNODEBUG
OSAL_CBTIMER_NUM_TASKS=1
HAL_AES_DMA=TRUE
HAL_DMA=TRUE
xPOWER_SAVING
HAL_UART_DMA=2 // UART1通道的DMA方式 (HAL_UART_ISR=2 UART1通道的中断方式)
HAL_UART=TRUE
DEBUG_PRINT
xPLUS_BROADCASTER
HAL_LCD=FALSE
HAL_LED=FALSE
HAL_KEY=FALSE
---------------------------------------------------------------关闭流控
#if !defined( NPI_UART_FC )
#define NPI_UART_FC FALSE // TRUE
#endif // !NPI_UART_FC
---------------------------------------------------------------添加printf()
#include "stdarg.h"
void printf(const char* fmt,...) // add
{
// 自定义了“DEBUG_PRINT”宏进行控制
#ifdef DEBUG_PRINT
va_list ap;
uint8 buffer[100];
uint16 len;
va_start(ap,fmt);
len = vsprintf((char *)buffer,fmt,ap);
va_end(ap);
NPI_WriteTransport(buffer,len);
#else
return;//屏蔽串口打印输出
#endif
}
---------------------------------------------------------------
static void NpiSerialCallback( uint8 port, uint8 events ) // add
{
(void)port;//加个 (void),是未了避免编译告警,明确告诉缓冲区不用理会这个变量
if (events & (HAL_UART_RX_TIMEOUT | HAL_UART_RX_FULL)) //串口有数据
{
uint8 numBytes = 0;
numBytes = NPI_RxBufLen(); //读出串口缓冲区有多少字节
if(numBytes == 0)
{
return;
}
else
{
//申请缓冲区buffer
uint8 *buffer = osal_mem_alloc(numBytes);
if(buffer)
{
//读取读取串口缓冲区数据,释放串口数据
NPI_ReadTransport(buffer,numBytes);
//把收到的数据发送到串口-实现回环
NPI_WriteTransport(buffer, numBytes);
//释放申请的缓冲区
osal_mem_free(buffer);
}
}
}
}
--------------------------------
--------------------------------