AnsweredAssumed Answered

Set a RTOS Uart queue with the HAL librarie

Question asked by alexandre.dauphi.001 on May 2, 2016
Latest reply on May 3, 2016 by alexandre.dauphi.001

Hi everyone,

I would like to include in my project  FreeRTOS a uart queue.
I have already  done this with the StdPeriph lib but I'm facing difficulties to migrate from StdPriph to HAL.

My previous project was build like this :
A simple usart task :

void vUSARTTask( void *pvParameters )


  portTickType xLastWakeTime;

  const portTickType xFrequency = 50;


  char ch;


  RxQueue = xQueueCreate( configCOM0_RX_BUFFER_LENGTH, sizeof( portCHAR ) );

  TxQueue = xQueueCreate( configCOM0_TX_BUFFER_LENGTH, sizeof( portCHAR ) );


  USART1PutString(pcUsartTaskStartMsg,strlen( pcUsartTaskStartMsg ));

  for( ;; )


      //Echo back


      if(xQueueReceive( RxQueue, ch, 0 ) == pdPASS)


                if( xQueueSend( TxQueue, &ch, 10 ) == pdPASS )


                          USART_ITConfig(USART1, USART_IT_TXE, ENABLE);






And the Usart handler :

void USART1_IRQHandler(void)


  long xHigherPriorityTaskWoken = pdFALSE;

  uint8_t ch;

  //if Receive interrupt




      xQueueSendToBackFromISR( RxQueue, &ch, &xHigherPriorityTaskWoken );





      if( xQueueReceiveFromISR( TxQueue, &ch, &xHigherPriorityTaskWoken ) )


          USART_SendData(USART1, ch);


           //disable Transmit Data Register empty interrupt




  portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );


I used UART_Receive_IT() and  UART_Transmit_IT() in order to remplace Uart_ReceiceDATA and Uart_TransmitDATA

My main problem is to find the equivalent of the Usart_GetITStatus() function in the HAL lib
In order to differentiate the Tx of the Rx interrupt

Is there an example of a Rtos queue integrate with a periphic handler of the HAL lib ?

Can you help me to use the function UART_Receive() with queue and IT ?

Thanks a lot