@@ -83,8 +83,6 @@ static serial_t *rx_callback_obj[UART_NUM];
83
83
static int (* tx_callback [UART_NUM ])(serial_t * );
84
84
static serial_t * tx_callback_obj [UART_NUM ];
85
85
86
- static uint8_t rx_buffer [1 ] = {0 };
87
-
88
86
/**
89
87
* @brief Function called to initialize the uart interface
90
88
* @param obj : pointer to serial_t structure
@@ -461,7 +459,7 @@ uint8_t serial_tx_active(serial_t *obj)
461
459
* @param obj : pointer to serial_t structure
462
460
* @retval last character received
463
461
*/
464
- int uart_getc (serial_t * obj )
462
+ int uart_getc (serial_t * obj , unsigned char * c )
465
463
{
466
464
if (obj == NULL ) {
467
465
return -1 ;
@@ -471,11 +469,12 @@ int uart_getc(serial_t *obj)
471
469
return -1 ; // transaction ongoing
472
470
}
473
471
472
+ * c = (unsigned char )(obj -> recv );
474
473
// Restart RX irq
475
474
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 );
477
476
478
- return rx_buffer [ 0 ] ;
477
+ return 0 ;
479
478
}
480
479
481
480
/**
@@ -502,7 +501,7 @@ void uart_attach_rx_callback(serial_t *obj, void (*callback)(serial_t*))
502
501
HAL_NVIC_SetPriority (obj -> irq , 0 , 1 );
503
502
HAL_NVIC_EnableIRQ (obj -> irq );
504
503
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 ) {
506
505
return ;
507
506
}
508
507
}
0 commit comments