8000 return 0 in getc when the transfer errors · sparkfun/mbed-os-ambiq-apollo3@8046172 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8046172

Browse files
committed
return 0 in getc when the transfer errors
1 parent 5ab9977 commit 8046172

File tree

1 file changed

+5
-1
lines changed
  • targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device

1 file changed

+5
-1
lines changed

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/serial_api.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ int serial_getc(serial_t *obj) {
264264
};
265265

266266
do {
267-
am_hal_uart_transfer(obj->serial.uart_control->handle, &am_hal_uart_xfer_read_single);
267+
uint32_t status = am_hal_uart_transfer(obj->serial.uart_control->handle, &am_hal_uart_xfer_read_single);
268+
if(status != AM_HAL_STATUS_SUCCESS)
269+
{
270+
return 0;
271+
}
268272
} while (bytes_read == 0);
269273

270274
return (int)rx_c;

0 commit comments

Comments
 (0)
0