From: Segwon Date: Thu, 16 Nov 2017 09:09:07 +0000 (+0900) Subject: error: return a recongnizable error value X-Git-Tag: accepted/tizen/unified/20171221.071344~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F160489%2F1;p=platform%2Fcore%2Fapi%2Fperipheral-io.git error: return a recongnizable error value - unclear PERIPHERAL_ERROR_UNKNOWN error is returning too much - change linux error type usage to error value defined by peripheral_io Signed-off-by: Segwon Change-Id: I3196ed16afafa3a83ba5362287d7281dcd255192 --- diff --git a/include/interface/peripheral_interface_common.h b/include/interface/peripheral_interface_common.h index b7047e4..f51a4c2 100644 --- a/include/interface/peripheral_interface_common.h +++ b/include/interface/peripheral_interface_common.h @@ -31,11 +31,11 @@ do { \ if (expr) { \ if (errno == EAGAIN) \ - return -EAGAIN; \ + return PERIPHERAL_ERROR_TRY_AGAIN; \ char errmsg[MAX_ERR_LEN]; \ strerror_r(errno, errmsg, sizeof(errmsg)); \ _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \ - return -EIO; \ + return PERIPHERAL_ERROR_IO_ERROR; \ } \ } while (0) diff --git a/src/gdbus/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c index 2f2ead6..43ee5b7 100644 --- a/src/gdbus/peripheral_gdbus_gpio.c +++ b/src/gdbus/peripheral_gdbus_gpio.c @@ -43,7 +43,7 @@ static int __gpio_proxy_init(void) if (gpio_proxy == NULL) { _E("Failed to create gpio proxy : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } return PERIPHERAL_ERROR_NONE; @@ -53,7 +53,7 @@ static int __gpio_proxy_deinit(void) { if (gpio_proxy == NULL) { _E("Gpio proxy is NULL"); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(gpio_proxy); @@ -84,7 +84,7 @@ int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio) &error) == FALSE) { _E("Failed to request daemon to gpio open : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. @@ -95,21 +95,21 @@ int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio) if (gpio->fd_direction < 0) { _E("Failed to get fd for gpio direction : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } gpio->fd_edge = g_unix_fd_list_get(fd_list, GPIO_FD_INDEX_EDGE, &error); if (gpio->fd_edge < 0) { _E("Failed to get fd for gpio edge : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } gpio->fd_value = g_unix_fd_list_get(fd_list, GPIO_FD_INDEX_VALUE, &error); if (gpio->fd_value < 0) { _E("Failed to get fd for gpio value : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(fd_list); diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c index 0300fb8..e85f21b 100644 --- a/src/gdbus/peripheral_gdbus_i2c.c +++ b/src/gdbus/peripheral_gdbus_i2c.c @@ -41,7 +41,7 @@ static int __i2c_proxy_init(void) if (i2c_proxy == NULL) { _E("Failed to create i2c proxy : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } return PERIPHERAL_ERROR_NONE; @@ -51,7 +51,7 @@ static int __i2c_proxy_deinit(void) { if (i2c_proxy == NULL) { _E("I2c proxy is NULL"); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(i2c_proxy); @@ -83,7 +83,7 @@ int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) &error) == FALSE) { _E("Failed to request daemon to i2c open : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. @@ -94,6 +94,7 @@ int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) if (i2c->fd < 0) { _E("Failed to get fd for i2c : %s", error->message); g_error_free(error); + ret = PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(fd_list); diff --git a/src/gdbus/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c index 1274744..4b76866 100644 --- a/src/gdbus/peripheral_gdbus_pwm.c +++ b/src/gdbus/peripheral_gdbus_pwm.c @@ -44,7 +44,7 @@ static int __pwm_proxy_init(void) if (pwm_proxy == NULL) { _E("Failed to create pwm proxy : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } return PERIPHERAL_ERROR_NONE; @@ -54,7 +54,7 @@ static int __pwm_proxy_deinit(void) { if (pwm_proxy == NULL) { _E("Pwm proxy is NULL"); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(pwm_proxy); @@ -86,7 +86,7 @@ int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) &error) == FALSE) { _E("Failed to request daemon to pwm open : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. @@ -97,28 +97,28 @@ int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) if (pwm->fd_period < 0) { _E("Failed to get fd for pwm period : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } pwm->fd_duty_cycle = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_DUTY_CYCLE, &error); if (pwm->fd_duty_cycle < 0) { _E("Failed to get fd for pwm duty cycle : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } pwm->fd_polarity = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_POLARITY, &error); if (pwm->fd_polarity < 0) { _E("Failed to get fd for pwm polarity : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } pwm->fd_enable = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_ENABLE, &error); if (pwm->fd_enable < 0) { _E("Failed to get fd for pwm enable : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(fd_list); diff --git a/src/gdbus/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c index 9cdb0e8..d518d85 100644 --- a/src/gdbus/peripheral_gdbus_spi.c +++ b/src/gdbus/peripheral_gdbus_spi.c @@ -41,7 +41,7 @@ static int __spi_proxy_init(void) if (spi_proxy == NULL) { _E("Failed to create spi proxy : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } return PERIPHERAL_ERROR_NONE; @@ -51,7 +51,7 @@ static int __spi_proxy_deinit(void) { if (spi_proxy == NULL) { _E("Spi proxy is NULL"); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(spi_proxy); @@ -83,7 +83,7 @@ int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) &error) == FALSE) { _E("Failed to request daemon to spi open : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. @@ -94,7 +94,7 @@ int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) if (spi->fd < 0) { _E("Failed to get fd for spi : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(fd_list); diff --git a/src/gdbus/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c index 539ccf6..671f7da 100644 --- a/src/gdbus/peripheral_gdbus_uart.c +++ b/src/gdbus/peripheral_gdbus_uart.c @@ -41,7 +41,7 @@ static int __uart_proxy_init(void) if (uart_proxy == NULL) { _E("Failed to create uart proxy : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } return PERIPHERAL_ERROR_NONE; @@ -51,7 +51,7 @@ static int __uart_proxy_deinit(void) { if (uart_proxy == NULL) { _E("Uart proxy is NULL"); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(uart_proxy); @@ -82,7 +82,7 @@ int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port) &error) == FALSE) { _E("Failed to request daemon to uart open : %s", error->message); g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; + return PERIPHERAL_ERROR_IO_ERROR; } // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. @@ -93,7 +93,7 @@ int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port) if (uart->fd < 0) { _E("Failed to get fd for uart : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; + ret = PERIPHERAL_ERROR_IO_ERROR; } g_object_unref(fd_list); diff --git a/src/interface/peripheral_interface_gpio.c b/src/interface/peripheral_interface_gpio.c index 3084350..fc677b6 100644 --- a/src/interface/peripheral_interface_gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -27,7 +27,7 @@ int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, peripheral_g int ret = write(gpio->fd_direction, types[direction].type, types[direction].len); CHECK_ERROR(ret != types[direction].len); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge) @@ -42,7 +42,7 @@ int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_g int ret = write(gpio->fd_edge, types[edge].type, types[edge].len); CHECK_ERROR(ret != types[edge].len); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_gpio_write(peripheral_gpio_h gpio, uint32_t value) @@ -55,7 +55,7 @@ int peripheral_interface_gpio_write(peripheral_gpio_h gpio, uint32_t value) int ret = write(gpio->fd_value, types[value].type, types[value].len); CHECK_ERROR(ret != types[value].len); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_gpio_read(peripheral_gpio_h gpio, uint32_t *value) @@ -67,15 +67,16 @@ int peripheral_interface_gpio_read(peripheral_gpio_h gpio, uint32_t *value) ret = read(gpio->fd_value, &gpio_buf, length); CHECK_ERROR(ret != length); - if (gpio_buf[0] == '0') + if (gpio_buf[0] == '0') { *value = 0; - else if (gpio_buf[0] == '1') + } else if (gpio_buf[0] == '1') { *value = 1; - else + } else { _E("Error: gpio value is error \n"); - return -EIO; + return PERIPHERAL_ERROR_IO_ERROR; + } - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_gpio_close(peripheral_gpio_h gpio) @@ -91,19 +92,19 @@ int peripheral_interface_gpio_close(peripheral_gpio_h gpio) ret = close(gpio->fd_value); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_gpio_open_isr(peripheral_gpio_h gpio) { // TODO: set interrupted callback function - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_gpio_close_isr(peripheral_gpio_h gpio) { // TODO: unset interrupted callback function - return 0; + return PERIPHERAL_ERROR_NONE; } \ No newline at end of file diff --git a/src/interface/peripheral_interface_i2c.c b/src/interface/peripheral_interface_i2c.c index ef4c944..b90ee4d 100644 --- a/src/interface/peripheral_interface_i2c.c +++ b/src/interface/peripheral_interface_i2c.c @@ -23,7 +23,7 @@ int peripheral_interface_i2c_close(peripheral_i2c_h i2c) int ret = close(i2c->fd); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length) @@ -31,7 +31,7 @@ int peripheral_interface_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t int ret = read(i2c->fd, data, length); CHECK_ERROR(ret != length); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length) @@ -39,7 +39,7 @@ int peripheral_interface_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t int ret = write(i2c->fd, data, length); CHECK_ERROR(ret != length); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data_out) @@ -61,7 +61,7 @@ int peripheral_interface_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t re *data_out = data.byte; - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data_in) @@ -83,7 +83,7 @@ int peripheral_interface_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t r ret = ioctl(i2c->fd, I2C_SMBUS, &data_arg); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data_out) @@ -105,7 +105,7 @@ int peripheral_interface_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t re *data_out = data.word; - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data_in) @@ -127,5 +127,5 @@ int peripheral_interface_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t r ret = ioctl(i2c->fd, I2C_SMBUS, &data_arg); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } \ No newline at end of file diff --git a/src/interface/peripheral_interface_pwm.c b/src/interface/peripheral_interface_pwm.c index a56a701..96d3dce 100644 --- a/src/interface/peripheral_interface_pwm.c +++ b/src/interface/peripheral_interface_pwm.c @@ -32,7 +32,7 @@ int peripheral_interface_pwm_close(peripheral_pwm_h pwm) ret = close(pwm->fd_enable); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, uint32_t period) @@ -45,7 +45,7 @@ int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, uint32_t period) ret = write(pwm->fd_period, pwm_buf, length); CHECK_ERROR(ret != length); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle) @@ -58,7 +58,7 @@ int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_ ret = write(pwm->fd_duty_cycle, pwm_buf, length); CHECK_ERROR(ret != length); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity) @@ -71,7 +71,7 @@ int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_p int ret = write(pwm->fd_polarity, types[polarity].type, types[polarity].len); CHECK_ERROR(ret != types[polarity].len); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_pwm_set_enable(peripheral_pwm_h pwm, bool enable) @@ -84,5 +84,5 @@ int peripheral_interface_pwm_set_enable(peripheral_pwm_h pwm, bool enable) int ret = write(pwm->fd_enable, types[enable].type, types[enable].len); CHECK_ERROR(ret != types[enable].len); - return 0; + return PERIPHERAL_ERROR_NONE; } diff --git a/src/interface/peripheral_interface_spi.c b/src/interface/peripheral_interface_spi.c index b3b8fc1..d59f45e 100644 --- a/src/interface/peripheral_interface_spi.c +++ b/src/interface/peripheral_interface_spi.c @@ -24,7 +24,7 @@ int peripheral_interface_spi_close(peripheral_spi_h spi) int ret = close(spi->fd); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode) @@ -32,7 +32,7 @@ int peripheral_interface_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_ int ret = ioctl(spi->fd, SPI_IOC_WR_MODE, &mode); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order) @@ -40,7 +40,7 @@ int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_ int ret = ioctl(spi->fd, SPI_IOC_WR_LSB_FIRST, &bit_order); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits) @@ -48,7 +48,7 @@ int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bit int ret = ioctl(spi->fd, SPI_IOC_WR_BITS_PER_WORD, &bits); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, uint32_t freq) @@ -56,7 +56,7 @@ int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, uint32_t freq) int ret = ioctl(spi->fd, SPI_IOC_WR_MAX_SPEED_HZ, &freq); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_spi_read(peripheral_spi_h spi, uint8_t *rxbuf, uint32_t length) @@ -71,7 +71,7 @@ int peripheral_interface_spi_read(peripheral_spi_h spi, uint8_t *rxbuf, uint32_t ret = ioctl(spi->fd, SPI_IOC_MESSAGE(1), &xfer); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_spi_write(peripheral_spi_h spi, uint8_t *txbuf, uint32_t length) @@ -86,7 +86,7 @@ int peripheral_interface_spi_write(peripheral_spi_h spi, uint8_t *txbuf, uint32_ ret = ioctl(spi->fd, SPI_IOC_MESSAGE(1), &xfer); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_spi_transfer(peripheral_spi_h spi, uint8_t *txbuf, uint8_t *rxbuf, uint32_t length) @@ -94,7 +94,7 @@ int peripheral_interface_spi_transfer(peripheral_spi_h spi, uint8_t *txbuf, uint int ret; struct spi_ioc_transfer xfer; - if (!txbuf || !rxbuf) return -EINVAL; + if (!txbuf || !rxbuf) return PERIPHERAL_ERROR_INVALID_PARAMETER; memset(&xfer, 0, sizeof(xfer)); xfer.tx_buf = (unsigned long)txbuf; @@ -104,5 +104,5 @@ int peripheral_interface_spi_transfer(peripheral_spi_h spi, uint8_t *txbuf, uint ret = ioctl(spi->fd, SPI_IOC_MESSAGE(1), &xfer); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c index ca37ec4..e3f1814 100644 --- a/src/interface/peripheral_interface_uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -38,7 +38,7 @@ int peripheral_interface_uart_close(peripheral_uart_h uart) ret = close(uart->fd); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_uart_flush(peripheral_uart_h uart) @@ -46,7 +46,7 @@ int peripheral_interface_uart_flush(peripheral_uart_h uart) int ret = tcflush(uart->fd, TCIOFLUSH); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud) @@ -68,7 +68,7 @@ int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, peripheral_u ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size) @@ -88,7 +88,7 @@ int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, peripheral_u ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity) @@ -120,7 +120,7 @@ int peripheral_interface_uart_set_parity(peripheral_uart_h uart, peripheral_uart ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits) @@ -141,14 +141,14 @@ int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, peripheral_u break; default: _E("Invalid parameter stop_bits"); - return -EINVAL; + return PERIPHERAL_ERROR_INVALID_PARAMETER; } peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, peripheral_uart_software_flow_control_e xonxoff, peripheral_uart_hardware_flow_control_e rtscts) @@ -164,19 +164,19 @@ int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, periphera else if (rtscts == PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE) tio.c_cflag &= ~CRTSCTS; else - return -EINVAL; + return PERIPHERAL_ERROR_INVALID_PARAMETER; if (xonxoff == PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF) tio.c_iflag |= (IXON | IXOFF | IXANY); else if (xonxoff == PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE) tio.c_iflag &= ~(IXON | IXOFF | IXANY); else - return -EINVAL; + return PERIPHERAL_ERROR_INVALID_PARAMETER; ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); - return 0; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, uint32_t length) @@ -184,7 +184,7 @@ int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, uint32_ int ret = read(uart->fd, (void *)buf, length); CHECK_ERROR(ret != length); - return ret; + return PERIPHERAL_ERROR_NONE; } int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, uint32_t length) @@ -192,5 +192,5 @@ int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, uint32 int ret = write(uart->fd, buf, length); CHECK_ERROR(ret != length); - return ret; + return PERIPHERAL_ERROR_NONE; } diff --git a/test/peripheral-io-test.c b/test/peripheral-io-test.c index 21062a1..d8a103b 100644 --- a/test/peripheral-io-test.c +++ b/test/peripheral-io-test.c @@ -52,9 +52,9 @@ static int __get_model_name(char **model_name) ret = system_info_get_platform_string(KEY_SYSTEM_MODEL_NAME, model_name); if (ret != SYSTEM_INFO_ERROR_NONE) { printf("[Message] Failed to get model name.\n\n"); - return -1; + return PERIPHERAL_ERROR_NOT_SUPPORTED; } - return 0; + return PERIPHERAL_ERROR_NONE; } static int __get_feature(const char *key, bool *feature) @@ -63,45 +63,56 @@ static int __get_feature(const char *key, bool *feature) ret = system_info_get_platform_bool(key, feature); if (ret != SYSTEM_INFO_ERROR_NONE) { printf("[Message] Failed to feature (%s).\n\n", key); - return -1; + return PERIPHERAL_ERROR_NOT_SUPPORTED; } - return 0; + return PERIPHERAL_ERROR_NONE; } static int __test_peripheral_init() { - int ret = 0; + int ret = PERIPHERAL_ERROR_NONE; char *model_name = NULL; bool feature = false; ret = __get_model_name(&model_name); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = __get_feature(KEY_FEATURE_PERIPHERAL_IO_GPIO, &feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = test_peripheral_io_gpio_initialize(model_name, feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = __get_feature(KEY_FEATURE_PERIPHERAL_IO_I2C, &feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = test_peripheral_io_i2c_initialize(model_name, feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = __get_feature(KEY_FEATURE_PERIPHERAL_IO_PWM, &feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = test_peripheral_io_pwm_initialize(model_name, feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = __get_feature(KEY_FEATURE_PERIPHERAL_IO_UART, &feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = test_peripheral_io_uart_initialize(model_name, feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = __get_feature(KEY_FEATURE_PERIPHERAL_IO_SPI, &feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = test_peripheral_io_spi_initialize(model_name, feature); - if (ret != 0) return ret; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; return ret; } @@ -485,7 +496,7 @@ int main(int argc, char **argv) pass_count = 0; ret = __test_peripheral_init(); - if (ret != 0) { + if (ret != PERIPHERAL_ERROR_NONE) { printf("[Message] Failed test init...\n\n"); return -1; } diff --git a/test/src/test_peripheral_gpio.c b/test/src/test_peripheral_gpio.c index 9c594ff..70b139d 100644 --- a/test/src/test_peripheral_gpio.c +++ b/test/src/test_peripheral_gpio.c @@ -35,8 +35,8 @@ int test_peripheral_io_gpio_initialize(char *model, bool feature) else if (!strcmp(model, "artik")) pin = GPIO_PIN_ARTIK530; else - return -1; - return 0; + return PERIPHERAL_ERROR_NO_DEVICE; + return PERIPHERAL_ERROR_NONE; } int test_peripheral_io_gpio_peripheral_gpio_open_p(void) @@ -47,14 +47,17 @@ int test_peripheral_io_gpio_peripheral_gpio_open_p(void) if (g_feature == false) { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -66,11 +69,13 @@ int test_peripheral_io_gpio_peripheral_gpio_open_n1(void) if (g_feature == false) { ret = peripheral_gpio_open(pin, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -84,11 +89,13 @@ int test_peripheral_io_gpio_peripheral_gpio_open_n2(void) if (g_feature == false) { ret = peripheral_gpio_open(GPIO_PIN_INVALID, &gpio_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(GPIO_PIN_INVALID, &gpio_h); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -102,14 +109,17 @@ int test_peripheral_io_gpio_peripheral_gpio_close_p(void) if (g_feature == false) { ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -121,11 +131,13 @@ int test_peripheral_io_gpio_peripheral_gpio_close_n(void) if (g_feature == false) { ret = peripheral_gpio_close(NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_close(NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -139,20 +151,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_direction_p1(void) if (g_feature == false) { ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -166,20 +181,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_direction_p2(void) if (g_feature == false) { ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -193,20 +211,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_direction_p3(void) if (g_feature == false) { ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -218,11 +239,13 @@ int test_peripheral_io_gpio_peripheral_gpio_set_direction_n1(void) if (g_feature == false) { ret = peripheral_gpio_set_direction(NULL, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_set_direction(NULL, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -236,20 +259,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_direction_n2(void) if (g_feature == false) { ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -263,20 +289,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_direction_n3(void) if (g_feature == false) { ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -290,26 +319,29 @@ int test_peripheral_io_gpio_peripheral_gpio_set_edge_mode_p1(void) if (g_feature == false) { ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_NONE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_NONE); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -323,26 +355,29 @@ int test_peripheral_io_gpio_peripheral_gpio_set_edge_mode_p2(void) if (g_feature == false) { ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_RISING); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_RISING); if (ret != PERIPHERAL_ERROR_NONE && ret != PERIPHERAL_ERROR_TRY_AGAIN) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -356,26 +391,29 @@ int test_peripheral_io_gpio_peripheral_gpio_set_edge_mode_p3(void) if (g_feature == false) { ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_FALLING); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_FALLING); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -389,20 +427,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_edge_mode_p4(void) if (g_feature == false) { ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_BOTH); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_BOTH); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -414,11 +455,13 @@ int test_peripheral_io_gpio_peripheral_gpio_set_edge_mode_n1(void) if (g_feature == false) { ret = peripheral_gpio_set_edge_mode(NULL, PERIPHERAL_GPIO_EDGE_RISING); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_set_edge_mode(NULL, PERIPHERAL_GPIO_EDGE_RISING); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -432,20 +475,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_edge_mode_n2(void) if (g_feature == false) { ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_NONE - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_NONE - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -459,20 +505,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_edge_mode_n3(void) if (g_feature == false) { ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_BOTH + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_BOTH + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -493,38 +542,41 @@ int test_peripheral_io_gpio_peripheral_gpio_set_interrupted_cb_p(void) if (g_feature == false) { ret = peripheral_gpio_set_interrupted_cb(gpio_h, gpio_interrupted_cb, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_set_edge_mode(gpio_h, PERIPHERAL_GPIO_EDGE_RISING); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_set_interrupted_cb(gpio_h, gpio_interrupted_cb, NULL); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_unset_interrupted_cb(gpio_h); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -536,11 +588,13 @@ int test_peripheral_io_gpio_peripheral_gpio_set_interrupted_cb_n1(void) if (g_feature == false) { ret = peripheral_gpio_set_interrupted_cb(NULL, gpio_interrupted_cb, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_set_interrupted_cb(NULL, gpio_interrupted_cb, NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -554,20 +608,23 @@ int test_peripheral_io_gpio_peripheral_gpio_set_interrupted_cb_n2(void) if (g_feature == false) { ret = peripheral_gpio_set_interrupted_cb(gpio_h, NULL, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_interrupted_cb(gpio_h, NULL, NULL); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -581,26 +638,29 @@ int test_peripheral_io_gpio_peripheral_gpio_unset_interrupted_cb_p1(void) if (g_feature == false) { ret = peripheral_gpio_unset_interrupted_cb(gpio_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_interrupted_cb(gpio_h, gpio_interrupted_cb, NULL); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_unset_interrupted_cb(gpio_h); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -614,20 +674,23 @@ int test_peripheral_io_gpio_peripheral_gpio_unset_interrupted_cb_p2(void) if (g_feature == false) { ret = peripheral_gpio_unset_interrupted_cb(gpio_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_unset_interrupted_cb(gpio_h); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -639,11 +702,13 @@ int test_peripheral_io_gpio_peripheral_gpio_unset_interrupted_cb_n(void) if (g_feature == false) { ret = peripheral_gpio_unset_interrupted_cb(NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_unset_interrupted_cb(NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -659,26 +724,29 @@ int test_peripheral_io_gpio_peripheral_gpio_read_p(void) if (g_feature == false) { ret = peripheral_gpio_read(gpio_h, &value); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_read(gpio_h, &value); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -692,11 +760,13 @@ int test_peripheral_io_gpio_peripheral_gpio_read_n1(void) if (g_feature == false) { ret = peripheral_gpio_read(NULL, &value); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_read(NULL, &value); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -710,26 +780,29 @@ int test_peripheral_io_gpio_peripheral_gpio_read_n2(void) if (g_feature == false) { ret = peripheral_gpio_read(gpio_h, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_IN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_read(gpio_h, NULL); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -745,26 +818,29 @@ int test_peripheral_io_gpio_peripheral_gpio_write_p(void) if (g_feature == false) { ret = peripheral_gpio_write(gpio_h, value); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_write(gpio_h, value); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -778,11 +854,13 @@ int test_peripheral_io_gpio_peripheral_gpio_write_n1(void) if (g_feature == false) { ret = peripheral_gpio_write(NULL, value); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_write(NULL, value); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -798,26 +876,29 @@ int test_peripheral_io_gpio_peripheral_gpio_write_n2(void) if (g_feature == false) { ret = peripheral_gpio_write(gpio_h, value); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_gpio_open(pin, &gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_gpio_set_direction(gpio_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_write(gpio_h, value); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_gpio_close(gpio_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_gpio_close(gpio_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; diff --git a/test/src/test_peripheral_i2c.c b/test/src/test_peripheral_i2c.c index a9a81ee..bb1de7f 100644 --- a/test/src/test_peripheral_i2c.c +++ b/test/src/test_peripheral_i2c.c @@ -38,11 +38,11 @@ int test_peripheral_io_i2c_initialize(char *model, bool feature) if ((!strcmp(model, "rpi3")) || (!strcmp(model, "artik"))) bus = I2C_BUS; else - return -1; + return PERIPHERAL_ERROR_NO_DEVICE; address = I2C_ADDRESS; - return 0; + return PERIPHERAL_ERROR_NONE; } int test_peripheral_io_i2c_peripheral_i2c_open_p(void) @@ -53,14 +53,17 @@ int test_peripheral_io_i2c_peripheral_i2c_open_p(void) if (g_feature == false) { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -72,11 +75,13 @@ int test_peripheral_io_i2c_peripheral_i2c_open_n1(void) if (g_feature == false) { ret = peripheral_i2c_open(bus, address, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -90,11 +95,13 @@ int test_peripheral_io_i2c_peripheral_i2c_open_n2(void) if (g_feature == false) { ret = peripheral_i2c_open(I2C_BUS_INVALID, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(I2C_BUS_INVALID, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -108,11 +115,13 @@ int test_peripheral_io_i2c_peripheral_i2c_open_n3(void) if (g_feature == false) { ret = peripheral_i2c_open(bus, I2C_ADDRESS_INVALID, &i2c_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, I2C_ADDRESS_INVALID, &i2c_h); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -126,14 +135,17 @@ int test_peripheral_io_i2c_peripheral_i2c_close_p(void) if (g_feature == false) { ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -145,11 +157,13 @@ int test_peripheral_io_i2c_peripheral_i2c_close_n(void) if (g_feature == false) { ret = peripheral_i2c_close(NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_close(NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -165,20 +179,23 @@ int test_peripheral_io_i2c_peripheral_i2c_read_p(void) if (g_feature == false) { ret = peripheral_i2c_read(i2c_h, buf, I2C_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_read(i2c_h, buf, I2C_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -192,11 +209,13 @@ int test_peripheral_io_i2c_peripheral_i2c_read_n1(void) if (g_feature == false) { ret = peripheral_i2c_read(NULL, buf, I2C_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_read(NULL, buf, I2C_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -210,20 +229,23 @@ int test_peripheral_io_i2c_peripheral_i2c_read_n2(void) if (g_feature == false) { ret = peripheral_i2c_read(i2c_h, NULL, I2C_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_read(i2c_h, NULL, I2C_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -239,20 +261,23 @@ int test_peripheral_io_i2c_peripheral_i2c_write_p(void) if (g_feature == false) { ret = peripheral_i2c_write(i2c_h, buf, I2C_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_write(i2c_h, buf, I2C_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -266,11 +291,13 @@ int test_peripheral_io_i2c_peripheral_i2c_write_n1(void) if (g_feature == false) { ret = peripheral_i2c_write(NULL, buf, I2C_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_write(NULL, buf, I2C_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -284,20 +311,23 @@ int test_peripheral_io_i2c_peripheral_i2c_write_n2(void) if (g_feature == false) { ret = peripheral_i2c_write(i2c_h, NULL, I2C_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_write(i2c_h, NULL, I2C_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -313,20 +343,23 @@ int test_peripheral_io_i2c_peripheral_i2c_read_register_byte_p(void) if (g_feature == false) { ret = peripheral_i2c_read_register_byte(i2c_h, I2C_REGISTER, &data); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_read_register_byte(i2c_h, I2C_REGISTER, &data); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -340,11 +373,13 @@ int test_peripheral_io_i2c_peripheral_i2c_read_register_byte_n1(void) if (g_feature == false) { ret = peripheral_i2c_read_register_byte(NULL, I2C_REGISTER, &data); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_read_register_byte(NULL, I2C_REGISTER, &data); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -359,20 +394,23 @@ int test_peripheral_io_i2c_peripheral_i2c_read_register_byte_n2(void) if (g_feature == false) { ret = peripheral_i2c_read_register_byte(i2c_h, I2C_REGISTER, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_read_register_byte(i2c_h, I2C_REGISTER, NULL); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -386,20 +424,23 @@ int test_peripheral_io_i2c_peripheral_i2c_write_register_byte_p(void) if (g_feature == false) { ret = peripheral_i2c_write_register_byte(i2c_h, I2C_REGISTER, I2C_BUFFER_VALUE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_write_register_byte(i2c_h, I2C_REGISTER, I2C_BUFFER_VALUE); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -411,11 +452,13 @@ int test_peripheral_io_i2c_peripheral_i2c_write_register_byte_n(void) if (g_feature == false) { ret = peripheral_i2c_write_register_byte(NULL, I2C_REGISTER, I2C_BUFFER_VALUE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_write_register_byte(NULL, I2C_REGISTER, I2C_BUFFER_VALUE); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -431,20 +474,23 @@ int test_peripheral_io_i2c_peripheral_i2c_read_register_word_p(void) if (g_feature == false) { ret = peripheral_i2c_read_register_word(i2c_h, I2C_REGISTER, &data); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_read_register_word(i2c_h, I2C_REGISTER, &data); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -458,11 +504,13 @@ int test_peripheral_io_i2c_peripheral_i2c_read_register_word_n1(void) if (g_feature == false) { ret = peripheral_i2c_read_register_word(NULL, I2C_REGISTER, &data); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_read_register_word(NULL, I2C_REGISTER, &data); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -477,20 +525,23 @@ int test_peripheral_io_i2c_peripheral_i2c_read_register_word_n2(void) if (g_feature == false) { ret = peripheral_i2c_read_register_word(i2c_h, I2C_REGISTER, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_read_register_word(i2c_h, I2C_REGISTER, NULL); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -505,20 +556,23 @@ int test_peripheral_io_i2c_peripheral_i2c_write_register_word_p(void) if (g_feature == false) { ret = peripheral_i2c_write_register_word(i2c_h, I2C_REGISTER, I2C_BUFFER_VALUE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_open(bus, address, &i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_i2c_write_register_word(i2c_h, I2C_REGISTER, I2C_BUFFER_VALUE); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_i2c_close(i2c_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_i2c_close(i2c_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -530,11 +584,13 @@ int test_peripheral_io_i2c_peripheral_i2c_write_register_word_n(void) if (g_feature == false) { ret = peripheral_i2c_write_register_word(NULL, I2C_REGISTER, I2C_BUFFER_VALUE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_i2c_write_register_word(NULL, I2C_REGISTER, I2C_BUFFER_VALUE); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; diff --git a/test/src/test_peripheral_pwm.c b/test/src/test_peripheral_pwm.c index 7b88d5e..32dd422 100644 --- a/test/src/test_peripheral_pwm.c +++ b/test/src/test_peripheral_pwm.c @@ -38,9 +38,9 @@ int test_peripheral_io_pwm_initialize(char *model, bool feature) chip = PWM_CHIP; pin = PWM_PIN; } else { - return -1; + return PERIPHERAL_ERROR_NO_DEVICE; } - return 0; + return PERIPHERAL_ERROR_NONE; } int test_peripheral_io_pwm_peripheral_pwm_open_p(void) @@ -51,14 +51,17 @@ int test_peripheral_io_pwm_peripheral_pwm_open_p(void) if (g_feature == false) { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -72,11 +75,13 @@ int test_peripheral_io_pwm_peripheral_pwm_open_n1(void) if (g_feature == false) { ret = peripheral_pwm_open(PWM_CHIP_INVALID, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(PWM_CHIP_INVALID, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -90,11 +95,13 @@ int test_peripheral_io_pwm_peripheral_pwm_open_n2(void) if (g_feature == false) { ret = peripheral_pwm_open(chip, PWM_PIN_INVALID, &pwm_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, PWM_PIN_INVALID, &pwm_h); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -106,11 +113,13 @@ int test_peripheral_io_pwm_peripheral_pwm_open_n3(void) if (g_feature == false) { ret = peripheral_pwm_open(chip, pin, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -124,14 +133,17 @@ int test_peripheral_io_pwm_peripheral_pwm_close_p(void) if (g_feature == false) { ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -143,11 +155,13 @@ int test_peripheral_io_pwm_peripheral_pwm_close_n(void) if (g_feature == false) { ret = peripheral_pwm_close(NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_close(NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -161,20 +175,23 @@ int test_peripheral_io_pwm_peripheral_pwm_set_period_p(void) if (g_feature == false) { ret = peripheral_pwm_set_period(pwm_h, PWM_PERIOD); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_set_period(pwm_h, PWM_PERIOD); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_pwm_close(pwm_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -186,11 +203,13 @@ int test_peripheral_io_pwm_peripheral_pwm_set_period_n(void) if (g_feature == false) { ret = peripheral_pwm_set_period(NULL, PWM_PERIOD); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_set_period(NULL, PWM_PERIOD); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -204,20 +223,23 @@ int test_peripheral_io_pwm_peripheral_pwm_set_duty_cycle_p(void) if (g_feature == false) { ret = peripheral_pwm_set_duty_cycle(pwm_h, PWM_DUTY_CYCLE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_set_duty_cycle(pwm_h, PWM_DUTY_CYCLE); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_pwm_close(pwm_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -229,11 +251,13 @@ int test_peripheral_io_pwm_peripheral_pwm_set_duty_cycle_n(void) if (g_feature == false) { ret = peripheral_pwm_set_duty_cycle(NULL, PWM_DUTY_CYCLE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_set_duty_cycle(NULL, PWM_DUTY_CYCLE); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -247,20 +271,23 @@ int test_peripheral_io_pwm_peripheral_pwm_set_polarity_p1(void) if (g_feature == false) { ret = peripheral_pwm_set_polarity(pwm_h, PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_set_polarity(pwm_h, PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_pwm_close(pwm_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -274,20 +301,23 @@ int test_peripheral_io_pwm_peripheral_pwm_set_polarity_p2(void) if (g_feature == false) { ret = peripheral_pwm_set_polarity(pwm_h, PERIPHERAL_PWM_POLARITY_ACTIVE_LOW); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_set_polarity(pwm_h, PERIPHERAL_PWM_POLARITY_ACTIVE_LOW); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_pwm_close(pwm_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -299,11 +329,13 @@ int test_peripheral_io_pwm_peripheral_pwm_set_polarity_n1(void) if (g_feature == false) { ret = peripheral_pwm_set_polarity(NULL, PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_set_polarity(NULL, PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -317,20 +349,23 @@ int test_peripheral_io_pwm_peripheral_pwm_set_polarity_n2(void) if (g_feature == false) { ret = peripheral_pwm_set_polarity(pwm_h, PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_set_polarity(pwm_h, PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_pwm_close(pwm_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -344,20 +379,23 @@ int test_peripheral_io_pwm_peripheral_pwm_set_polarity_n3(void) if (g_feature == false) { ret = peripheral_pwm_set_polarity(pwm_h, PERIPHERAL_PWM_POLARITY_ACTIVE_LOW + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_set_polarity(pwm_h, PERIPHERAL_PWM_POLARITY_ACTIVE_LOW + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_pwm_close(pwm_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -373,20 +411,23 @@ int test_peripheral_io_pwm_peripheral_pwm_set_enabled_p1(void) if (g_feature == false) { ret = peripheral_pwm_set_enabled(pwm_h, enable); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_set_enabled(pwm_h, enable); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_pwm_close(pwm_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -402,20 +443,23 @@ int test_peripheral_io_pwm_peripheral_pwm_set_enabled_p2(void) if (g_feature == false) { ret = peripheral_pwm_set_enabled(pwm_h, enable); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_open(chip, pin, &pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_pwm_set_enabled(pwm_h, enable); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_pwm_close(pwm_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_pwm_close(pwm_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -429,11 +473,13 @@ int test_peripheral_io_pwm_peripheral_pwm_set_enabled_n(void) if (g_feature == false) { ret = peripheral_pwm_set_enabled(NULL, enable); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_pwm_set_enabled(NULL, enable); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; diff --git a/test/src/test_peripheral_spi.c b/test/src/test_peripheral_spi.c index 41576c2..1969138 100644 --- a/test/src/test_peripheral_spi.c +++ b/test/src/test_peripheral_spi.c @@ -43,11 +43,11 @@ int test_peripheral_io_spi_initialize(char *model, bool feature) else if (!strcmp(model, "artik")) bus = SPI_BUS_ARTIK530; else - return -1; + return PERIPHERAL_ERROR_NO_DEVICE; cs = SPI_CS; - return 0; + return PERIPHERAL_ERROR_NONE; } int test_peripheral_io_spi_peripheral_spi_open_p(void) @@ -58,14 +58,17 @@ int test_peripheral_io_spi_peripheral_spi_open_p(void) if (g_feature == false) { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -79,11 +82,13 @@ int test_peripheral_io_spi_peripheral_spi_open_n1(void) if (g_feature == false) { ret = peripheral_spi_open(SPI_BUS_INVALID, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(SPI_BUS_INVALID, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -97,11 +102,13 @@ int test_peripheral_io_spi_peripheral_spi_open_n2(void) if (g_feature == false) { ret = peripheral_spi_open(bus, SPI_CS_INVALID, &spi_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, SPI_CS_INVALID, &spi_h); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -113,11 +120,13 @@ int test_peripheral_io_spi_peripheral_spi_open_n3(void) if (g_feature == false) { ret = peripheral_spi_open(bus, cs, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -131,14 +140,17 @@ int test_peripheral_io_spi_peripheral_spi_close_p(void) if (g_feature == false) { ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -150,11 +162,13 @@ int test_peripheral_io_spi_peripheral_spi_close_n(void) if (g_feature == false) { ret = peripheral_spi_close(NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_close(NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -168,20 +182,23 @@ int test_peripheral_io_spi_peripheral_spi_set_mode_p1(void) if (g_feature == false) { ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_0); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_0); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -195,20 +212,23 @@ int test_peripheral_io_spi_peripheral_spi_set_mode_p2(void) if (g_feature == false) { ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_1); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -222,20 +242,23 @@ int test_peripheral_io_spi_peripheral_spi_set_mode_p3(void) if (g_feature == false) { ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_2); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_2); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -249,20 +272,23 @@ int test_peripheral_io_spi_peripheral_spi_set_mode_p4(void) if (g_feature == false) { ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_3); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_3); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -276,20 +302,23 @@ int test_peripheral_io_spi_peripheral_spi_set_mode_n1(void) if (g_feature == false) { ret = peripheral_spi_set_mode(NULL, PERIPHERAL_SPI_MODE_0); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_mode(NULL, PERIPHERAL_SPI_MODE_0); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -303,20 +332,23 @@ int test_peripheral_io_spi_peripheral_spi_set_mode_n2(void) if (g_feature == false) { ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_0 - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_0 - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -330,20 +362,23 @@ int test_peripheral_io_spi_peripheral_spi_set_mode_n3(void) if (g_feature == false) { ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_3 + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_3 + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -357,20 +392,23 @@ int test_peripheral_io_spi_peripheral_spi_set_bit_order_p1(void) if (g_feature == false) { ret = peripheral_spi_set_bit_order(spi_h, PERIPHERAL_SPI_BIT_ORDER_MSB); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_bit_order(spi_h, PERIPHERAL_SPI_BIT_ORDER_MSB); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -384,20 +422,23 @@ int test_peripheral_io_spi_peripheral_spi_set_bit_order_p2(void) if (g_feature == false) { ret = peripheral_spi_set_bit_order(spi_h, PERIPHERAL_SPI_BIT_ORDER_LSB); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_bit_order(spi_h, PERIPHERAL_SPI_BIT_ORDER_LSB); if (ret != PERIPHERAL_ERROR_IO_ERROR) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -409,11 +450,13 @@ int test_peripheral_io_spi_peripheral_spi_set_bit_order_n1(void) if (g_feature == false) { ret = peripheral_spi_set_bit_order(NULL, PERIPHERAL_SPI_BIT_ORDER_MSB); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_set_bit_order(NULL, PERIPHERAL_SPI_BIT_ORDER_MSB); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -427,20 +470,23 @@ int test_peripheral_io_spi_peripheral_spi_set_bit_order_n2(void) if (g_feature == false) { ret = peripheral_spi_set_bit_order(spi_h, PERIPHERAL_SPI_BIT_ORDER_MSB - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_bit_order(spi_h, PERIPHERAL_SPI_BIT_ORDER_MSB - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -454,20 +500,23 @@ int test_peripheral_io_spi_peripheral_spi_set_bit_order_n3(void) if (g_feature == false) { ret = peripheral_spi_set_bit_order(spi_h, PERIPHERAL_SPI_BIT_ORDER_LSB + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_bit_order(spi_h, PERIPHERAL_SPI_BIT_ORDER_LSB + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -481,20 +530,23 @@ int test_peripheral_io_spi_peripheral_spi_set_bits_per_word_p(void) if (g_feature == false) { ret = peripheral_spi_set_bits_per_word(spi_h, SPI_BITS_PER_WORD); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_bits_per_word(spi_h, SPI_BITS_PER_WORD); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -506,11 +558,13 @@ int test_peripheral_io_spi_peripheral_spi_set_bits_per_word_n1(void) if (g_feature == false) { ret = peripheral_spi_set_bits_per_word(NULL, SPI_BITS_PER_WORD); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_set_bits_per_word(NULL, SPI_BITS_PER_WORD); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -524,20 +578,23 @@ int test_peripheral_io_spi_peripheral_spi_set_bits_per_word_n2(void) if (g_feature == false) { ret = peripheral_spi_set_bits_per_word(spi_h, SPI_BITS_PER_WORD_INVALID); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_bits_per_word(spi_h, SPI_BITS_PER_WORD_INVALID); if (ret != PERIPHERAL_ERROR_IO_ERROR) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -551,32 +608,35 @@ int test_peripheral_io_spi_peripheral_spi_set_frequency_p(void) if (g_feature == false) { ret = peripheral_spi_set_frequency(spi_h, SPI_FREQUENCY); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_set_mode(spi_h, PERIPHERAL_SPI_MODE_0); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_set_bits_per_word(spi_h, SPI_BITS_PER_WORD); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_set_frequency(spi_h, SPI_FREQUENCY); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -588,11 +648,13 @@ int test_peripheral_io_spi_peripheral_spi_set_frequency_n(void) if (g_feature == false) { ret = peripheral_spi_set_frequency(NULL, SPI_FREQUENCY); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_set_frequency(NULL, SPI_FREQUENCY); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -608,20 +670,23 @@ int test_peripheral_io_spi_peripheral_spi_read_p(void) if (g_feature == false) { ret = peripheral_spi_read(spi_h, &data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_read(spi_h, &data, SPI_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -635,11 +700,13 @@ int test_peripheral_io_spi_peripheral_spi_read_n1(void) if (g_feature == false) { ret = peripheral_spi_read(NULL, &data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_read(NULL, &data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -653,20 +720,23 @@ int test_peripheral_io_spi_peripheral_spi_read_n2(void) if (g_feature == false) { ret = peripheral_spi_read(spi_h, NULL, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_read(spi_h, NULL, SPI_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -682,20 +752,23 @@ int test_peripheral_io_spi_peripheral_spi_write_p(void) if (g_feature == false) { ret = peripheral_spi_write(spi_h, &data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_write(spi_h, &data, SPI_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -709,11 +782,13 @@ int test_peripheral_io_spi_peripheral_spi_write_n1(void) if (g_feature == false) { ret = peripheral_spi_write(NULL, &data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_write(NULL, &data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -728,20 +803,23 @@ int test_peripheral_io_spi_peripheral_spi_write_n2(void) if (g_feature == false) { ret = peripheral_spi_write(spi_h, NULL, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_write(spi_h, NULL, SPI_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -758,20 +836,23 @@ int test_peripheral_io_spi_peripheral_spi_transfer_p(void) if (g_feature == false) { ret = peripheral_spi_transfer(spi_h, &tx_data, &rx_data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_transfer(spi_h, &tx_data, &rx_data, SPI_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -786,11 +867,13 @@ int test_peripheral_io_spi_peripheral_spi_transfer_n1(void) if (g_feature == false) { ret = peripheral_spi_transfer(NULL, &tx_data, &rx_data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_transfer(NULL, &tx_data, &rx_data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -806,20 +889,23 @@ int test_peripheral_io_spi_peripheral_spi_transfer_n2(void) if (g_feature == false) { ret = peripheral_spi_transfer(spi_h, NULL, &rx_data, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_transfer(spi_h, NULL, &rx_data, SPI_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -835,20 +921,23 @@ int test_peripheral_io_spi_peripheral_spi_transfer_n3(void) if (g_feature == false) { ret = peripheral_spi_transfer(spi_h, &tx_data, NULL, SPI_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_spi_open(bus, cs, &spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_spi_transfer(spi_h, &tx_data, NULL, SPI_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_spi_close(spi_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_spi_close(spi_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; diff --git a/test/src/test_peripheral_uart.c b/test/src/test_peripheral_uart.c index 442961a..801afb8 100644 --- a/test/src/test_peripheral_uart.c +++ b/test/src/test_peripheral_uart.c @@ -37,9 +37,9 @@ int test_peripheral_io_uart_initialize(char *model, bool feature) else if (!strcmp(model, "artik")) port = UART_PORT_ARTIK530; else - return -1; + return PERIPHERAL_ERROR_NO_DEVICE; - return 0; + return PERIPHERAL_ERROR_NONE; } int test_peripheral_io_uart_peripheral_uart_open_p(void) @@ -50,14 +50,17 @@ int test_peripheral_io_uart_peripheral_uart_open_p(void) if (g_feature == false) { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -71,11 +74,13 @@ int test_peripheral_io_uart_peripheral_uart_open_n1(void) if (g_feature == false) { ret = peripheral_uart_open(UART_PORT_INVALID, &uart_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(UART_PORT_INVALID, &uart_h); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -87,11 +92,13 @@ int test_peripheral_io_uart_peripheral_uart_open_n2(void) if (g_feature == false) { ret = peripheral_uart_open(port, NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -105,14 +112,17 @@ int test_peripheral_io_uart_peripheral_uart_close_p(void) if (g_feature == false) { ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -124,11 +134,13 @@ int test_peripheral_io_uart_peripheral_uart_close_n(void) if (g_feature == false) { ret = peripheral_uart_close(NULL); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_close(NULL); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -142,20 +154,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p1(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_0); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_0); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -169,20 +184,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p2(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_50); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_50); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -196,20 +214,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p3(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_110); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_110); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -223,20 +244,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p4(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_134); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_134); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -250,20 +274,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p5(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_150); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_150); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -277,20 +304,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p6(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_200); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_200); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -304,20 +334,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p7(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_300); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_300); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -331,20 +364,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p8(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_600); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_600); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -358,20 +394,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p9(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_1200); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_1200); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -385,20 +424,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p10(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_1800); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_1800); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -412,20 +454,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p11(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_2400); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_2400); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -439,20 +484,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p12(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_4800); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_4800); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -466,20 +514,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p13(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_9600); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_9600); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -493,20 +544,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p14(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_19200); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_19200); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -520,20 +574,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p15(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_38400); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_38400); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -547,20 +604,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p16(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_57600); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_57600); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -574,20 +634,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p17(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_115200); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_115200); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -601,20 +664,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_p18(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_230400); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_230400); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -626,11 +692,13 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_n1(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(NULL, PERIPHERAL_UART_BAUD_RATE_1200); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_set_baud_rate(NULL, PERIPHERAL_UART_BAUD_RATE_1200); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -644,20 +712,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_n2(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_0 - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_0 - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -671,20 +742,23 @@ int test_peripheral_io_uart_peripheral_uart_set_baud_rate_n3(void) if (g_feature == false) { ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_230400 + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_baud_rate(uart_h, PERIPHERAL_UART_BAUD_RATE_230400 + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -698,20 +772,23 @@ int test_peripheral_io_uart_peripheral_uart_set_byte_size_p1(void) if (g_feature == false) { ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_5BIT); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_5BIT); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -725,20 +802,23 @@ int test_peripheral_io_uart_peripheral_uart_set_byte_size_p2(void) if (g_feature == false) { ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_6BIT); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_6BIT); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -752,20 +832,23 @@ int test_peripheral_io_uart_peripheral_uart_set_byte_size_p3(void) if (g_feature == false) { ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_7BIT); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_7BIT); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -779,20 +862,23 @@ int test_peripheral_io_uart_peripheral_uart_set_byte_size_p4(void) if (g_feature == false) { ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_8BIT); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_8BIT); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -804,11 +890,13 @@ int test_peripheral_io_uart_peripheral_uart_set_byte_size_n1(void) if (g_feature == false) { ret = peripheral_uart_set_byte_size(NULL, PERIPHERAL_UART_BYTE_SIZE_5BIT); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_set_byte_size(NULL, PERIPHERAL_UART_BYTE_SIZE_5BIT); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -822,20 +910,23 @@ int test_peripheral_io_uart_peripheral_uart_set_byte_size_n2(void) if (g_feature == false) { ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_5BIT - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_5BIT - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -849,20 +940,23 @@ int test_peripheral_io_uart_peripheral_uart_set_byte_size_n3(void) if (g_feature == false) { ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_8BIT + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_byte_size(uart_h, PERIPHERAL_UART_BYTE_SIZE_8BIT + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -876,20 +970,23 @@ int test_peripheral_io_uart_peripheral_uart_set_parity_p1(void) if (g_feature == false) { ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_NONE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_NONE); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -903,20 +1000,23 @@ int test_peripheral_io_uart_peripheral_uart_set_parity_p2(void) if (g_feature == false) { ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_EVEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_EVEN); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -930,20 +1030,23 @@ int test_peripheral_io_uart_peripheral_uart_set_parity_p3(void) if (g_feature == false) { ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_ODD); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_ODD); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -955,11 +1058,13 @@ int test_peripheral_io_uart_peripheral_uart_set_parity_n1(void) if (g_feature == false) { ret = peripheral_uart_set_parity(NULL, PERIPHERAL_UART_PARITY_NONE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_set_parity(NULL, PERIPHERAL_UART_PARITY_NONE); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -973,20 +1078,23 @@ int test_peripheral_io_uart_peripheral_uart_set_parity_n2(void) if (g_feature == false) { ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_NONE - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_NONE - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1000,20 +1108,23 @@ int test_peripheral_io_uart_peripheral_uart_set_parity_n3(void) if (g_feature == false) { ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_ODD + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_parity(uart_h, PERIPHERAL_UART_PARITY_ODD + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1027,20 +1138,23 @@ int test_peripheral_io_uart_peripheral_uart_set_stop_bits_p1(void) if (g_feature == false) { ret = peripheral_uart_set_stop_bits(uart_h, PERIPHERAL_UART_STOP_BITS_1BIT); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_stop_bits(uart_h, PERIPHERAL_UART_STOP_BITS_1BIT); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1054,20 +1168,23 @@ int test_peripheral_io_uart_peripheral_uart_set_stop_bits_p2(void) if (g_feature == false) { ret = peripheral_uart_set_stop_bits(uart_h, PERIPHERAL_UART_STOP_BITS_2BIT); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_stop_bits(uart_h, PERIPHERAL_UART_STOP_BITS_2BIT); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1079,11 +1196,13 @@ int test_peripheral_io_uart_peripheral_uart_set_stop_bits_n1(void) if (g_feature == false) { ret = peripheral_uart_set_stop_bits(NULL, PERIPHERAL_UART_STOP_BITS_1BIT); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_set_stop_bits(NULL, PERIPHERAL_UART_STOP_BITS_1BIT); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1097,20 +1216,23 @@ int test_peripheral_io_uart_peripheral_uart_set_stop_bits_n2(void) if (g_feature == false) { ret = peripheral_uart_set_stop_bits(uart_h, PERIPHERAL_UART_STOP_BITS_1BIT - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_stop_bits(uart_h, PERIPHERAL_UART_STOP_BITS_1BIT - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1124,20 +1246,23 @@ int test_peripheral_io_uart_peripheral_uart_set_stop_bits_n3(void) if (g_feature == false) { ret = peripheral_uart_set_stop_bits(uart_h, PERIPHERAL_UART_STOP_BITS_2BIT + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_stop_bits(uart_h, PERIPHERAL_UART_STOP_BITS_2BIT + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1151,20 +1276,23 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_p1(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1178,20 +1306,23 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_p2(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1205,20 +1336,23 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_p3(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1232,20 +1366,23 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_p4(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS); if (ret != PERIPHERAL_ERROR_NONE) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1257,11 +1394,13 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_n1(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(NULL, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_set_flow_control(NULL, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1275,20 +1414,23 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_n2(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE - 1, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE - 1, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1302,20 +1444,23 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_n3(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF + 1, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF + 1, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1329,20 +1474,23 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_n4(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE - 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF, PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE - 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1356,20 +1504,23 @@ int test_peripheral_io_uart_peripheral_uart_set_flow_control_n5(void) if (g_feature == false) { ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF + 1); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_set_flow_control(uart_h, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE, PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF + 1); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1385,20 +1536,23 @@ int test_peripheral_io_uart_peripheral_uart_read_p(void) if (g_feature == false) { ret = peripheral_uart_read(uart_h, data, UART_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_read(uart_h, data, UART_BUFFER_LEN); if (ret <= 0 && ret != PERIPHERAL_ERROR_TRY_AGAIN) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1412,11 +1566,13 @@ int test_peripheral_io_uart_peripheral_uart_read_n1(void) if (g_feature == false) { ret = peripheral_uart_read(NULL, data, UART_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_read(NULL, data, UART_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1430,20 +1586,23 @@ int test_peripheral_io_uart_peripheral_uart_read_n2(void) if (g_feature == false) { ret = peripheral_uart_read(uart_h, NULL, UART_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_read(uart_h, NULL, UART_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1459,20 +1618,23 @@ int test_peripheral_io_uart_peripheral_uart_write_p(void) if (g_feature == false) { ret = peripheral_uart_write(uart_h, data, UART_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_write(uart_h, data, UART_BUFFER_LEN); if (ret <= 0 && ret != PERIPHERAL_ERROR_TRY_AGAIN) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1486,11 +1648,13 @@ int test_peripheral_io_uart_peripheral_uart_write_n1(void) if (g_feature == false) { ret = peripheral_uart_write(NULL, data, UART_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_write(NULL, data, UART_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) + return ret; } return PERIPHERAL_ERROR_NONE; @@ -1505,20 +1669,23 @@ int test_peripheral_io_uart_peripheral_uart_write_n2(void) if (g_feature == false) { ret = peripheral_uart_write(uart_h, NULL, UART_BUFFER_LEN); - if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED) + return ret; } else { ret = peripheral_uart_open(port, &uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; ret = peripheral_uart_write(uart_h, NULL, UART_BUFFER_LEN); if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) { peripheral_uart_close(uart_h); - return PERIPHERAL_ERROR_UNKNOWN; + return ret; } ret = peripheral_uart_close(uart_h); - if (ret != PERIPHERAL_ERROR_NONE) return PERIPHERAL_ERROR_UNKNOWN; + if (ret != PERIPHERAL_ERROR_NONE) + return ret; } return PERIPHERAL_ERROR_NONE;