File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -523,13 +523,40 @@ int uart_getc(serial_t *obj, unsigned char *c)
523523 return -1 ;
524524 }
525525
526+ if (!USART_GetFlagStatus (uart_handlers [obj -> index ]-> Instance , USART_FLAG_RXNE )){
527+ return -1 ;
528+ }
526529 * c = (unsigned char )USART_ReceiveData (uart_handlers [obj -> index ]-> Instance );
527530
528531 return 0 ;
529532}
530533
531534
535+ /**
536+ * @brief Write byte to uart
537+ * @param obj : pointer to serial_t structure
538+ * @retval error status
539+ */
540+ int uart_putc (serial_t * obj , unsigned char c )
541+ {
542+ uint32_t tickstart = GetTick ();
543+
544+ if (obj == NULL ) {
545+ return -1 ;
546+ }
547+
548+ while (serial_tx_active (obj ))
549+ {
550+ if ((GetTick () - tickstart ) >= TX_TIMEOUT )
551+ {
552+ return 0 ;
553+ }
554+ }
555+
556+ USART_SendData (uart_handlers [obj -> index ]-> Instance , c );
532557
558+ return 0 ;
559+ }
533560
534561
535562
You can’t perform that action at this time.
0 commit comments