问题遇到的现象和发生背景
我想通过消息队列传递该结构体,curbuf 是通过pvMalloc
typedef struct
{
uint16_t maxLen; //当前数组 数据的最大长度
uint16_t len; //当前数组已接收数据的长度
uint8_t *curbuf; //当前数组
} UART_Data_t;
但是传递指针一直是同一个地址,也就是说我Send多次结构体 curbuf的值一直是同一个,就会导致数据被覆盖
代码
void USART2_IRQHandler(void)
{
static uint16_t RevLen = 0;
static BaseType_t xHigherPriorityTaskWoken = pdFALSE;
uint8_t res;
if (USART_GetIntStatus(USART2, USART_INT_IDLEF) != RESET)
{
/* Read data len from the receive data register */
RevLen = BT_UART_RECV_BUF_LMT - DMA_GetCurrDataCounter(USART_BLE_Rx_DMA_Channel);
if ((RevLen > 0) && (BLE_UART_Rx.curbuf[0] == BLE_ACK_HEAD_FIRST) && (BLE_UART_Rx.curbuf[2] != sendData))
{
BLE_UART_Rx.len = RevLen;
if(pdPASS == xQueueSendToBackFromISR(xQueue_BLERecv, (void *)&BLE_UART_Rx, &xHigherPriorityTaskWoken)) //把数据放到队列当中
{
}else{
YJ_LOG_WARNING("Ble uart Queue is full \r\n");
}
}
DMA_EnableChannel(USART_BLE_Rx_DMA_Channel, DISABLE);
DMA_SetCurrDataCounter(USART_BLE_Rx_DMA_Channel, BLE_UART_Rx.maxLen);
DMA_EnableChannel(USART_BLE_Rx_DMA_Channel, ENABLE);
res = USART_BLE->STS;
res = USART_BLE->DAT;
}
}
我是在中断里面存数据,另外的地方读取 如何保证该指针相互独立