File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -528,6 +528,31 @@ int uart_getc(serial_t *obj, unsigned char *c)
528528 return 0 ;
529529}
530530
531+ // PR180: HardwareSerial: use correct UART HW for TX
532+ /**
533+ * @brief Write byte to uart
534+ * @param obj : pointer to serial_t structure
535+ * @retval error status
536+ */
537+ int uart_putc (serial_t * obj , unsigned char c )
538+ {
539+ uint32_t tickstart = GetTick ();
540+
541+ if (obj == NULL ) {
542+ return -1 ;
543+ }
544+
545+ while (serial_tx_active (obj ))
546+ {
547+ if ((GetTick () - tickstart ) >= TX_TIMEOUT )
548+ {
549+ return 0 ; // 0 means no error? Should be timeout error?
550+ }
551+ }
552+
553+ USART_SendData (uart_handlers [obj -> index ]-> Instance , c );
554+ return 0 ; // 0 means no error
555+ }
531556
532557
533558
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ typedef struct __UART_HandleTypeDef
9090 void uart_deinit (serial_t * obj );
9191
9292 int uart_getc (serial_t * obj , unsigned char * c );
93+ int uart_putc (serial_t * obj , unsigned char c ); // PR180: HardwareSerial: use correct UART HW for TX
9394
9495 uint8_t serial_tx_active (serial_t * obj );
9596 uint8_t serial_rx_active (serial_t * obj );
You can’t perform that action at this time.
0 commit comments