- since return value of close interface function is meaningless, return type is modified to void.
Change-Id: I3ef4298ac5a47db29697bdbbca97ecfbc0e20a57
Signed-off-by: Segwon <segwon.han@samsung.com>
#define GPIO_BUFFER_MAX 64
-int peripheral_interface_gpio_close(peripheral_gpio_h gpio);
+void peripheral_interface_gpio_close(peripheral_gpio_h gpio);
int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge);
int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction);
int peripheral_interface_gpio_write(peripheral_gpio_h gpio, uint32_t value);
union i2c_smbus_data *data;
};
-int peripheral_interface_i2c_close(peripheral_i2c_h i2c);
+void peripheral_interface_i2c_close(peripheral_i2c_h i2c);
int peripheral_interface_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length);
int peripheral_interface_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length);
int peripheral_interface_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data_out);
* @param[in] pin pwm pin number
* @return On success, 0 is returned. On failure, a negative value is returned.
*/
-int peripheral_interface_pwm_close(peripheral_pwm_h pwm);
+void peripheral_interface_pwm_close(peripheral_pwm_h pwm);
/**
* @brief pwm_set_period() sets the pwm period.
#include "peripheral_interface_common.h"
-int peripheral_interface_spi_close(peripheral_spi_h spi);
+void peripheral_interface_spi_close(peripheral_spi_h spi);
int peripheral_interface_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode);
int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order);
int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits);
* @param[in] file_hndl handle of uart_context
* @return On success, 0 is returned. On failure, a negative value is returned.
*/
-int peripheral_interface_uart_close(peripheral_uart_h uart);
+void peripheral_interface_uart_close(peripheral_uart_h uart);
/**
* @brief uart_flush() flushes uart buffer.
return PERIPHERAL_ERROR_NONE;
}
-int peripheral_interface_gpio_close(peripheral_gpio_h gpio)
+void peripheral_interface_gpio_close(peripheral_gpio_h gpio)
{
- int ret;
-
- ret = close(gpio->fd_direction);
- CHECK_ERROR(ret != 0);
-
- ret = close(gpio->fd_edge);
- CHECK_ERROR(ret != 0);
-
- ret = close(gpio->fd_value);
- CHECK_ERROR(ret != 0);
-
- return PERIPHERAL_ERROR_NONE;
+ close(gpio->fd_direction);
+ close(gpio->fd_edge);
+ close(gpio->fd_value);
}
int peripheral_interface_gpio_open_isr(peripheral_gpio_h gpio)
#include "peripheral_interface_i2c.h"
-int peripheral_interface_i2c_close(peripheral_i2c_h i2c)
+void peripheral_interface_i2c_close(peripheral_i2c_h i2c)
{
- int ret = close(i2c->fd);
- CHECK_ERROR(ret != 0);
-
- return PERIPHERAL_ERROR_NONE;
+ close(i2c->fd);
}
int peripheral_interface_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
#include "peripheral_interface_pwm.h"
-int peripheral_interface_pwm_close(peripheral_pwm_h pwm)
+void peripheral_interface_pwm_close(peripheral_pwm_h pwm)
{
- int ret;
-
- ret = close(pwm->fd_period);
- CHECK_ERROR(ret != 0);
-
- ret = close(pwm->fd_duty_cycle);
- CHECK_ERROR(ret != 0);
-
- ret = close(pwm->fd_polarity);
- CHECK_ERROR(ret != 0);
-
- ret = close(pwm->fd_enable);
- CHECK_ERROR(ret != 0);
-
- return PERIPHERAL_ERROR_NONE;
+ close(pwm->fd_period);
+ close(pwm->fd_duty_cycle);
+ close(pwm->fd_polarity);
+ close(pwm->fd_enable);
}
int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, uint32_t period)
#include "peripheral_interface_spi.h"
-int peripheral_interface_spi_close(peripheral_spi_h spi)
+void peripheral_interface_spi_close(peripheral_spi_h spi)
{
- int ret = close(spi->fd);
- CHECK_ERROR(ret != 0);
-
- return PERIPHERAL_ERROR_NONE;
+ close(spi->fd);
}
int peripheral_interface_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode)
static const int byteinfo[4] = {CS5, CS6, CS7, CS8};
-int peripheral_interface_uart_close(peripheral_uart_h uart)
+void peripheral_interface_uart_close(peripheral_uart_h uart)
{
- int ret;
-
peripheral_interface_uart_flush(uart);
-
- ret = close(uart->fd);
- CHECK_ERROR(ret != 0);
-
- return PERIPHERAL_ERROR_NONE;
+ close(uart->fd);
}
int peripheral_interface_uart_flush(peripheral_uart_h uart)
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_gdbus_gpio.h"
#include "peripheral_handle.h"
+#include "peripheral_gdbus_gpio.h"
+#include "peripheral_interface_gpio.h"
#include "peripheral_log.h"
#define PERIPHERAL_IO_GPIO_FEATURE "http://tizen.org/feature/peripheral_io.gpio"
/* call gpio_close */
ret = peripheral_gdbus_gpio_close();
- if (ret != PERIPHERAL_ERROR_NONE)
+ if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close the gpio pin, ret : %d", ret);
+ return ret;
+ }
+
+ peripheral_interface_gpio_close(gpio);
free(gpio);
gpio = NULL;
*/
int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF((direction < PERIPHERAL_GPIO_DIRECTION_IN) || (direction > PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid direction input");
- /* call gpio_set_direction */
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_gpio_set_direction(gpio, direction);
}
/**
*/
int peripheral_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF((edge < PERIPHERAL_GPIO_EDGE_NONE) || (edge > PERIPHERAL_GPIO_EDGE_BOTH), PERIPHERAL_ERROR_INVALID_PARAMETER, "edge input is invalid");
- /* call gpio_set_edge_mode */
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_gpio_set_edge_mode(gpio, edge);
}
/**
*/
int peripheral_gpio_read(peripheral_gpio_h gpio, uint32_t *value)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF(value == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio read value is invalid");
- /* call gpio_read */
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_gpio_read(gpio, value);
}
/**
*/
int peripheral_gpio_write(peripheral_gpio_h gpio, uint32_t value)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF((value != 0) && (value != 1), PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio value is invalid");
- /* call gpio_write */
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_gpio_write(gpio, value);
}
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_gdbus_i2c.h"
#include "peripheral_handle.h"
+#include "peripheral_gdbus_i2c.h"
+#include "peripheral_interface_i2c.h"
#include "peripheral_log.h"
#define PERIPHERAL_IO_I2C_FEATURE "http://tizen.org/feature/peripheral_io.i2c"
RETVM_IF(bus < 0 || address < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
handle = (peripheral_i2c_h)malloc(sizeof(struct _peripheral_i2c_s));
-
if (handle == NULL) {
_E("Failed to allocate peripheral_i2c_h");
return PERIPHERAL_ERROR_OUT_OF_MEMORY;
}
ret = peripheral_gdbus_i2c_open(handle, bus, address);
-
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open i2c communication, ret : %d", ret);
free(handle);
handle = NULL;
}
+
*i2c = handle;
return ret;
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
ret = peripheral_gdbus_i2c_close();
- if (ret != PERIPHERAL_ERROR_NONE)
+ if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close i2c communcation, ret : %d", ret);
+ return ret;
+ }
+
+ peripheral_interface_i2c_close(i2c);
free(i2c);
i2c = NULL;
int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_i2c_read(i2c, data, length);
}
int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_i2c_write(i2c, data, length);
}
int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_i2c_read_register_byte(i2c, reg, data);
}
int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_i2c_write_register_byte(i2c, reg, data);
}
int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_i2c_read_register_word(i2c, reg, data);
}
int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_i2c_write_register_word(i2c, reg, data);
}
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_gdbus_pwm.h"
#include "peripheral_handle.h"
+#include "peripheral_gdbus_pwm.h"
+#include "peripheral_interface_pwm.h"
#include "peripheral_log.h"
#define PERIPHERAL_IO_PWM_FEATURE "http://tizen.org/feature/peripheral_io.pwm"
/* Initialize */
handle = (peripheral_pwm_h)calloc(1, sizeof(struct _peripheral_pwm_s));
-
if (handle == NULL) {
_E("Failed to allocate peripheral_pwm_h");
return PERIPHERAL_ERROR_OUT_OF_MEMORY;
}
ret = peripheral_gdbus_pwm_open(handle, chip, pin);
-
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open PWM chip : %d, pin : %d", chip, pin);
free(handle);
handle = NULL;
}
+
*pwm = handle;
return ret;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- if ((ret = peripheral_gdbus_pwm_close()) < 0)
+ ret = peripheral_gdbus_pwm_close();
+ if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close PWM chip, continuing anyway, ret : %d", ret);
+ return ret;
+ }
+
+ peripheral_interface_pwm_close(pwm);
free(pwm);
+ pwm = NULL;
return ret;
}
int peripheral_pwm_set_period(peripheral_pwm_h pwm, uint32_t period_ns)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_pwm_set_period(pwm, period_ns);
}
int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle_ns)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_pwm_set_duty_cycle(pwm, duty_cycle_ns);
}
int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
RETVM_IF((polarity < PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH) || (polarity > PERIPHERAL_PWM_POLARITY_ACTIVE_LOW), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid polarity parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_pwm_set_polarity(pwm, polarity);
}
int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, bool enable)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_pwm_set_enable(pwm, enable);
}
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_gdbus_spi.h"
#include "peripheral_handle.h"
+#include "peripheral_gdbus_spi.h"
+#include "peripheral_interface_spi.h"
#include "peripheral_log.h"
#define PERIPHERAL_IO_SPI_FEATURE "http://tizen.org/feature/peripheral_io.spi"
/* Initialize */
handle = (peripheral_spi_h)calloc(1, sizeof(struct _peripheral_spi_s));
-
if (handle == NULL) {
_E("Failed to allocate peripheral_spi_h");
return PERIPHERAL_ERROR_OUT_OF_MEMORY;
}
ret = peripheral_gdbus_spi_open(handle, bus, cs);
-
if (ret != PERIPHERAL_ERROR_NONE) {
_E("SPI open error (%d, %d)", bus, cs);
free(handle);
handle = NULL;
}
+
*spi = handle;
return ret;
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
ret = peripheral_gdbus_spi_close();
- if (ret < PERIPHERAL_ERROR_NONE)
+ if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close SPI device, continuing anyway, ret : %d", ret);
+ return ret;
+ }
+
+ peripheral_interface_spi_close(spi);
free(spi);
+ spi = NULL;
return ret;
}
int peripheral_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF((mode < PERIPHERAL_SPI_MODE_0) || (mode > PERIPHERAL_SPI_MODE_3), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid spi mode parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_spi_set_mode(spi, mode);
}
int peripheral_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF((bit_order < PERIPHERAL_SPI_BIT_ORDER_MSB) || (bit_order > PERIPHERAL_SPI_BIT_ORDER_LSB), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid bit order parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_spi_set_bit_order(spi, bit_order);
}
int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_spi_set_bits_per_word(spi, bits);
}
int peripheral_spi_set_frequency(peripheral_spi_h spi, uint32_t freq_hz)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_spi_set_frequency(spi, freq_hz);
}
int peripheral_spi_read(peripheral_spi_h spi, uint8_t *data, uint32_t length)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_spi_read(spi, data, length);
}
int peripheral_spi_write(peripheral_spi_h spi, uint8_t *data, uint32_t length)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_spi_write(spi, data, length);
}
int peripheral_spi_transfer(peripheral_spi_h spi, uint8_t *txdata, uint8_t *rxdata, uint32_t length)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(txdata == NULL || rxdata == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_spi_transfer(spi, txdata, rxdata, length);
}
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_gdbus_uart.h"
#include "peripheral_handle.h"
+#include "peripheral_gdbus_uart.h"
+#include "peripheral_interface_uart.h"
#include "peripheral_log.h"
#define PERIPHERAL_IO_UART_FEATURE "http://tizen.org/feature/peripheral_io.uart"
RETVM_IF(port < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid port number");
handle = (peripheral_uart_h)calloc(1, sizeof(struct _peripheral_uart_s));
-
if (handle == NULL) {
_E("Failed to allocate peripheral_uart_h");
return PERIPHERAL_ERROR_OUT_OF_MEMORY;
}
ret = peripheral_gdbus_uart_open(handle, port);
-
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open uart port, ret : %d", ret);
free(handle);
handle = NULL;
}
+
*uart = handle;
return ret;
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
ret = peripheral_gdbus_uart_close();
- if (ret < PERIPHERAL_ERROR_NONE)
+ if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to close uart communication, continuing anyway, ret : %d", ret);
+ return ret;
+ }
+
+ peripheral_interface_uart_close(uart);
free(uart);
uart = NULL;
*/
int peripheral_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((baud < PERIPHERAL_UART_BAUD_RATE_0) || (baud > PERIPHERAL_UART_BAUD_RATE_230400), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid baud input");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_uart_set_baud_rate(uart, baud);
}
int peripheral_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((byte_size < PERIPHERAL_UART_BYTE_SIZE_5BIT) || (byte_size > PERIPHERAL_UART_BYTE_SIZE_8BIT), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_uart_set_byte_size(uart, byte_size);
}
int peripheral_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((parity < PERIPHERAL_UART_PARITY_NONE) || (parity > PERIPHERAL_UART_PARITY_ODD), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_uart_set_parity(uart, parity);
}
int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((stop_bits < PERIPHERAL_UART_STOP_BITS_1BIT) || (stop_bits > PERIPHERAL_UART_STOP_BITS_2BIT), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_uart_set_stop_bits(uart, stop_bits);
}
-
/**
* @brief Sets baudrate of the uart device.
*/
int peripheral_uart_set_flow_control(peripheral_uart_h uart, peripheral_uart_software_flow_control_e sw_flow_control, peripheral_uart_hardware_flow_control_e hw_flow_control)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((sw_flow_control < PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE) || (sw_flow_control > PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid sw_flow_control parameter");
RETVM_IF((hw_flow_control < PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE) || (hw_flow_control > PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid hw_flow_control parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_uart_set_flow_control(uart, sw_flow_control, hw_flow_control);
}
/**
*/
int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_uart_read(uart, data, length);
}
/**
*/
int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, uint32_t length)
{
- int ret = PERIPHERAL_ERROR_NONE;
-
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- // TODO : replace interface function
-
- return ret;
+ return peripheral_interface_uart_write(uart, data, length);
}