/** @brief: save a msg into buffer using PushRingBuffer ****************************************************************/ void PushAMsgToTxRbuff(int8_t * buff, int32_t length) { PushRingBuffer(txDebugLengthRingBuffer, &length); while (length--) { //if has space in ring buffer REQUIRE(GetNumberByteLeftOfRBuffer(txDebugDataRingBuffer) != 0); PushRingBuffer(txDebugDataRingBuffer, buff); buff++; } }
void HAL_UARTDebug_RxCpltCallback(UART_HandleTypeDef *huart) { PushRingBuffer(rxDebugDataRingBuffer, (--(huart->pRxBuffPtr))); //rearm HAL_StatusTypeDef ret = HAL_UART_Receive_IT(huart, (uint8_t*) (huart->pRxBuffPtr), 1); if(ret != HAL_OK){ rearmUartReceiveIT = 1; } }
void USART6_IRQHandler(void) { char receivedBuff = '\0'; UartPort* prt = uartPort1; if (USART_GetITStatus(prt->thisUsart, USART_IT_RXNE) != RESET) { receivedBuff = USART_ReceiveData(prt->thisUsart); PushRingBuffer(prt->rxRingBuff, (void*) &receivedBuff); } else if (USART_GetITStatus(prt->thisUsart, USART_IT_ORE_RX) != RESET || USART_GetITStatus(prt->thisUsart, USART_IT_ORE_ER) != RESET || USART_GetITStatus(prt->thisUsart, USART_IT_NE) != RESET || USART_GetITStatus(prt->thisUsart, USART_IT_FE) != RESET || USART_GetITStatus(prt->thisUsart, USART_IT_PE) != RESET) { UartPrint("Uart got error on receive\r\n"); USART_ClearITPendingBit(prt->thisUsart, USART_IT_ORE_RX); USART_ClearITPendingBit(prt->thisUsart, USART_IT_ORE_ER); USART_ClearITPendingBit(prt->thisUsart, USART_IT_NE); USART_ClearITPendingBit(prt->thisUsart, USART_IT_FE); USART_ClearITPendingBit(prt->thisUsart, USART_IT_PE); } }
void HAL_UARTDebug_RxCpltCallback(UART_HandleTypeDef * huart) { PushRingBuffer(rxDebugDataRingBuffer, (--(huart->pRxBuffPtr))); HAL_UART_Receive_IT(huart, (uint8_t *) (huart->pRxBuffPtr), 1); }