summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthread-liu <[email protected]>2021-01-21 09:46:00 +0800
committerthread-liu <[email protected]>2021-01-21 09:46:35 +0800
commitc8ac5c748a14123967dcbebf264e8dbe355a1e75 (patch)
tree74078f5d58182302b9483f14ca8db26948dcef2c
parentf691db99b51ddddfefbc36a1b3211ee13f63e603 (diff)
[update] return value judgment.
-rw-r--r--bsp/stm32/stm32mp157a-st-ev1/board/ports/dma_sample.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/bsp/stm32/stm32mp157a-st-ev1/board/ports/dma_sample.c b/bsp/stm32/stm32mp157a-st-ev1/board/ports/dma_sample.c
index 6fd88fe0fb..23cc195046 100644
--- a/bsp/stm32/stm32mp157a-st-ev1/board/ports/dma_sample.c
+++ b/bsp/stm32/stm32mp157a-st-ev1/board/ports/dma_sample.c
@@ -88,8 +88,20 @@ static int uart_dma_sample(int argc, char *argv[])
sizeof(msg_pool),
RT_IPC_FLAG_FIFO);
- rt_device_open(serial, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_DMA_RX);
- rt_device_set_rx_indicate(serial, uart_input);
+ ret = rt_device_open(serial, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_DMA_RX);
+ if (ret != RT_EOK)
+ {
+ rt_kprintf("serial device open fail!.\n");
+ return -RT_ERROR;
+ }
+
+ ret = rt_device_set_rx_indicate(serial, uart_input);
+ if (ret != RT_EOK)
+ {
+ rt_kprintf("set rx indicate fail!.\n");
+ return -RT_ERROR;
+ }
+
rt_device_write(serial, 0, str, (sizeof(str) - 1));
rt_thread_t thread = rt_thread_create("serial", serial_thread_entry, RT_NULL, 1024, 25, 10);