diff --git a/drivers/at/at.c b/drivers/at/at.c index 52646de19f..c6ecf493de 100644 --- a/drivers/at/at.c +++ b/drivers/at/at.c @@ -31,10 +31,9 @@ int at_dev_init(at_dev_t *dev, uart_t uart, uint32_t baudrate, char *buf, size_t { dev->uart = uart; isrpipe_init(&dev->isrpipe, buf, bufsize); - uart_init(uart, baudrate, _isrpipe_write_one_wrapper, - &dev->isrpipe); - return 0; + return uart_init(uart, baudrate, _isrpipe_write_one_wrapper, + &dev->isrpipe); } int at_expect_bytes(at_dev_t *dev, const char *bytes, uint32_t timeout) diff --git a/drivers/include/at.h b/drivers/include/at.h index a882b7cf73..42132ed5ff 100644 --- a/drivers/include/at.h +++ b/drivers/include/at.h @@ -124,8 +124,8 @@ typedef struct { * @param[in] buf input buffer * @param[in] bufsize size of @p buf * - * @returns 0 on success - * @returns <0 otherwise + * @returns success code UART_OK on success + * @returns error code UART_NODEV or UART_NOBAUD otherwise */ int at_dev_init(at_dev_t *dev, uart_t uart, uint32_t baudrate, char *buf, size_t bufsize); diff --git a/tests/driver_at/main.c b/tests/driver_at/main.c index 1aeb776765..2c0d62644a 100644 --- a/tests/driver_at/main.c +++ b/tests/driver_at/main.c @@ -47,9 +47,19 @@ static int init(int argc, char **argv) uint8_t uart = atoi(argv[1]); uint32_t baudrate = atoi(argv[2]); - at_dev_init(&at_dev, UART_DEV(uart), baudrate, buf, sizeof(buf)); + int res = at_dev_init(&at_dev, UART_DEV(uart), baudrate, buf, sizeof(buf)); - return 0; + /* check the UART initialization return value and respond as needed */ + if (res == UART_NODEV) { + puts("Invalid UART device given!"); + return 1; + } + else if (res == UART_NOBAUD) { + puts("Baudrate is not applicable!"); + return 1; + } + + return res; } static int send(int argc, char **argv)