@@ -83,8 +83,6 @@ static serial_t *rx_callback_obj[UART_NUM];
8383static int (* tx_callback [UART_NUM ])(serial_t * );
8484static serial_t * tx_callback_obj [UART_NUM ];
8585
86- static uint8_t rx_buffer [1 ] = {0 };
87-
8886/**
8987 * @brief Function called to initialize the uart interface
9088 * @param obj : pointer to serial_t structure
@@ -461,7 +459,7 @@ uint8_t serial_tx_active(serial_t *obj)
461459 * @param obj : pointer to serial_t structure
462460 * @retval last character received
463461 */
464- int uart_getc (serial_t * obj )
462+ int uart_getc (serial_t * obj , unsigned char * c )
465463{
466464 if (obj == NULL ) {
467465 return -1 ;
@@ -471,11 +469,12 @@ int uart_getc(serial_t *obj)
471469 return -1 ; // transaction ongoing
472470 }
473471
472+ * c = (unsigned char )(obj -> recv );
474473 // Restart RX irq
475474 UART_HandleTypeDef * huart = uart_handlers [obj -> index ];
476- HAL_UART_Receive_IT (huart , rx_buffer , 1 );
475+ HAL_UART_Receive_IT (huart , & ( obj -> recv ) , 1 );
477476
478- return rx_buffer [ 0 ] ;
477+ return 0 ;
479478}
480479
481480/**
@@ -502,7 +501,7 @@ void uart_attach_rx_callback(serial_t *obj, void (*callback)(serial_t*))
502501 HAL_NVIC_SetPriority (obj -> irq , 0 , 1 );
503502 HAL_NVIC_EnableIRQ (obj -> irq );
504503
505- if (HAL_UART_Receive_IT (uart_handlers [obj -> index ], rx_buffer , 1 ) != HAL_OK ) {
504+ if (HAL_UART_Receive_IT (uart_handlers [obj -> index ], & ( obj -> recv ) , 1 ) != HAL_OK ) {
506505 return ;
507506 }
508507}
0 commit comments