From 8c6dae8d1ae8a7e9741603539f30b99cdf0b2670 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 12:26:22 +0900 Subject: [PATCH 01/16] interface: add prefix 'peripheral_interface' to file and function name. Change-Id: I23b6fe4aa850e4a713aa6e419ab334681e596d39 Signed-off-by: Segwon --- CMakeLists.txt | 10 +++--- .../{gpio.h => peripheral_interface_gpio.h} | 21 ++++++------ .../{i2c.h => peripheral_interface_i2c.h} | 16 +++++----- .../{pwm.h => peripheral_interface_pwm.h} | 16 +++++----- include/interface/peripheral_interface_spi.h | 31 ++++++++++++++++++ .../{uart.h => peripheral_interface_uart.h} | 26 +++++++-------- include/interface/spi.h | 31 ------------------ .../{gpio.c => peripheral_interface_gpio.c} | 37 ++++++---------------- .../{i2c.c => peripheral_interface_i2c.c} | 12 +++---- .../{pwm.c => peripheral_interface_pwm.c} | 12 +++---- .../{spi.c => peripheral_interface_spi.c} | 18 +++++------ .../{uart.c => peripheral_interface_uart.c} | 34 ++++++++++---------- 12 files changed, 124 insertions(+), 140 deletions(-) rename include/interface/{gpio.h => peripheral_interface_gpio.h} (60%) rename include/interface/{i2c.h => peripheral_interface_i2c.h} (74%) rename include/interface/{pwm.h => peripheral_interface_pwm.h} (79%) create mode 100644 include/interface/peripheral_interface_spi.h rename include/interface/{uart.h => peripheral_interface_uart.h} (79%) delete mode 100644 include/interface/spi.h rename src/interface/{gpio.c => peripheral_interface_gpio.c} (77%) rename src/interface/{i2c.c => peripheral_interface_i2c.c} (84%) rename src/interface/{pwm.c => peripheral_interface_pwm.c} (86%) rename src/interface/{spi.c => peripheral_interface_spi.c} (85%) rename src/interface/{uart.c => peripheral_interface_uart.c} (87%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 714f3d0..335e42a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,11 +48,11 @@ SET(SOURCES src/peripheral_gpio.c src/peripheral_pwm.c src/peripheral_uart.c src/peripheral_spi.c - src/interface/gpio.c - src/interface/i2c.c - src/interface/pwm.c - src/interface/spi.c - src/interface/uart.c + src/interface/peripheral_interface_gpio.c + src/interface/peripheral_interface_i2c.c + src/interface/peripheral_interface_pwm.c + src/interface/peripheral_interface_spi.c + src/interface/peripheral_interface_uart.c src/peripheral_gdbus_gpio.c src/peripheral_gdbus_i2c.c src/peripheral_gdbus_pwm.c diff --git a/include/interface/gpio.h b/include/interface/peripheral_interface_gpio.h similarity index 60% rename from include/interface/gpio.h rename to include/interface/peripheral_interface_gpio.h index b4d6ccc..cf5d76c 100644 --- a/include/interface/gpio.h +++ b/include/interface/peripheral_interface_gpio.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __GPIO_H__ -#define __GPIO_H__ +#ifndef __PERIPHERAL_INTERFACE_GPIO_H__ +#define __PERIPHERAL_INTERFACE_GPIO_H__ #include "peripheral_io.h" @@ -35,12 +35,13 @@ typedef enum { GPIO_EDGE_BOTH = 3, } gpio_edge_e; -int gpio_close(peripheral_gpio_h gpio); -int gpio_set_edge_mode(peripheral_gpio_h gpio, gpio_edge_e edge); -int gpio_set_direction(peripheral_gpio_h gpio, gpio_direction_e dir); -int gpio_write(peripheral_gpio_h gpio, int value); -int gpio_read(peripheral_gpio_h gpio, int *value); +int peripheral_interface_gpio_close(peripheral_gpio_h gpio); +int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, gpio_edge_e edge); +int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, gpio_direction_e dir); +int peripheral_interface_gpio_write(peripheral_gpio_h gpio, int value); +int peripheral_interface_gpio_read(peripheral_gpio_h gpio, int *value); -int gpio_open_isr(peripheral_gpio_h gpio); -int gpio_close_isr(peripheral_gpio_h gpio); -#endif/*__GPIO_H__*/ +int peripheral_interface_gpio_open_isr(peripheral_gpio_h gpio); +int peripheral_interface_gpio_close_isr(peripheral_gpio_h gpio); + +#endif/*__PERIPHERAL_INTERFACE_GPIO_H__*/ \ No newline at end of file diff --git a/include/interface/i2c.h b/include/interface/peripheral_interface_i2c.h similarity index 74% rename from include/interface/i2c.h rename to include/interface/peripheral_interface_i2c.h index 6846649..b41c555 100644 --- a/include/interface/i2c.h +++ b/include/interface/peripheral_interface_i2c.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __I2C_H__ -#define __I2C_H__ +#ifndef __PERIPHERAL_INTERFACE_I2C_H__ +#define __PERIPHERAL_INTERFACE_I2C_H__ #include @@ -57,10 +57,10 @@ struct i2c_smbus_ioctl_data { union i2c_smbus_data *data; }; -int i2c_close(peripheral_i2c_h i2c); -int i2c_set_address(peripheral_i2c_h i2c, int address); -int i2c_read(peripheral_i2c_h i2c, unsigned char *data, int length); -int i2c_write(peripheral_i2c_h i2c, const unsigned char *data, int length); -int i2c_smbus_ioctl(peripheral_i2c_h i2c, struct i2c_smbus_ioctl_data *data); +int peripheral_interface_i2c_close(peripheral_i2c_h i2c); +int peripheral_interface_i2c_set_address(peripheral_i2c_h i2c, int address); +int peripheral_interface_i2c_read(peripheral_i2c_h i2c, unsigned char *data, int length); +int peripheral_interface_i2c_write(peripheral_i2c_h i2c, const unsigned char *data, int length); +int peripheral_interface_i2c_smbus_ioctl(peripheral_i2c_h i2c, struct i2c_smbus_ioctl_data *data); -#endif/* __I2C_H__ */ +#endif/* __PERIPHERAL_INTERFACE_I2C_H__ */ diff --git a/include/interface/pwm.h b/include/interface/peripheral_interface_pwm.h similarity index 79% rename from include/interface/pwm.h rename to include/interface/peripheral_interface_pwm.h index 7a9f0d0..833de2b 100644 --- a/include/interface/pwm.h +++ b/include/interface/peripheral_interface_pwm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __PWM_H__ -#define __PWM_H__ +#ifndef __PERIPHERAL_INTERFACE_PWM_H__ +#define __PERIPHERAL_INTERFACE_PWM_H__ #include "peripheral_io.h" @@ -35,7 +35,7 @@ typedef enum { * @param[in] pin pwm pin number * @return On success, 0 is returned. On failure, a negative value is returned. */ -int pwm_close(peripheral_pwm_h pwm); +int peripheral_interface_pwm_close(peripheral_pwm_h pwm); /** * @brief pwm_set_period() sets the pwm period. @@ -45,7 +45,7 @@ int pwm_close(peripheral_pwm_h pwm); * @param[in] period pwm period * @return On success, 0 is returned. On failure, a negative value is returned. */ -int pwm_set_period(peripheral_pwm_h pwm, int period); +int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, int period); /** * @brief pwm_set_duty_cycle() sets the pwm duty cycle. @@ -55,7 +55,7 @@ int pwm_set_period(peripheral_pwm_h pwm, int period); * @param[in] duty_cycle pwm duty cycle * @return On success, 0 is returned. On failure, a negative value is returned. */ -int pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle); +int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle); /** * @brief pwm_set_polarity() sets the pwm polarity. @@ -65,7 +65,7 @@ int pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle); * @param[in] polarity pwm polarity * @return On success, 0 is returned. On failure, a negative value is returned. */ -int pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity); +int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity); /** * @brief pwm_set_enable() sets the pwm state. @@ -75,6 +75,6 @@ int pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity); * @param[in] enable pwm enable/disabled state value * @return On success, 0 is returned. On failure, a negative value is returned. */ -int pwm_set_enable(peripheral_pwm_h pwm, bool enable); +int peripheral_interface_pwm_set_enable(peripheral_pwm_h pwm, bool enable); -#endif /* __PWM_H__ */ +#endif /* __PERIPHERAL_INTERFACE_PWM_H__ */ diff --git a/include/interface/peripheral_interface_spi.h b/include/interface/peripheral_interface_spi.h new file mode 100644 index 0000000..937caa7 --- /dev/null +++ b/include/interface/peripheral_interface_spi.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __PERIPHERAL_INTERFACE_SPI_H__ +#define __PERIPHERAL_INTERFACE_SPI_H__ + +#include "peripheral_io.h" + +int peripheral_interface_spi_close(peripheral_spi_h spi); +int peripheral_interface_spi_set_mode(peripheral_spi_h spi, unsigned char mode); +int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, unsigned char lsb); +int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits); +int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, unsigned int freq); +int peripheral_interface_spi_read(peripheral_spi_h spi, unsigned char *rxbuf, int length); +int peripheral_interface_spi_write(peripheral_spi_h spi, unsigned char *txbuf, int length); +int peripheral_interface_spi_transfer(peripheral_spi_h spi, unsigned char *txbuf, unsigned char *rxbuf, int length); + +#endif /* __PERIPHERAL_INTERFACE_SPI_H__ */ diff --git a/include/interface/uart.h b/include/interface/peripheral_interface_uart.h similarity index 79% rename from include/interface/uart.h rename to include/interface/peripheral_interface_uart.h index a0505ee..f5273fe 100644 --- a/include/interface/uart.h +++ b/include/interface/peripheral_interface_uart.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __UART_H__ -#define __UART_H__ +#ifndef __PERIPHERAL_INTERFACE_UART_H__ +#define __PERIPHERAL_INTERFACE_UART_H__ #include "peripheral_io.h" @@ -79,7 +79,7 @@ typedef enum { * @param[in] file_hndl handle of uart_context * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_close(peripheral_uart_h uart); +int peripheral_interface_uart_close(peripheral_uart_h uart); /** * @brief uart_flush() flushes uart buffer. @@ -87,7 +87,7 @@ int uart_close(peripheral_uart_h uart); * @param[in] file_hndl handle of uart_context * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_flush(peripheral_uart_h uart); +int peripheral_interface_uart_flush(peripheral_uart_h uart); /** * @brief uart_set_baudrate() sets uart baud rate. @@ -96,7 +96,7 @@ int uart_flush(peripheral_uart_h uart); * @param[in] baud uart baud rate * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud); +int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud); /** * @brief uart_set_mode() sets byte size, parity bit and stop bits. @@ -107,7 +107,7 @@ int uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud); * @param[in] stop_bits uart stop bits * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parity_e parity, uart_stop_bits_e stop_bits); +int peripheral_interface_uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parity_e parity, uart_stop_bits_e stop_bits); /** * @brief peripheral_bus_uart_set_byte_size() set byte size. @@ -116,7 +116,7 @@ int uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parit * @param[in] byte_size uart byte size * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size); +int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size); /** * @brief peripheral_bus_uart_set_parity() set parity bit. @@ -125,7 +125,7 @@ int uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size); * @param[in] parity uart parity type (even/odd/none) * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_set_parity(peripheral_uart_h uart, uart_parity_e parity); +int peripheral_interface_uart_set_parity(peripheral_uart_h uart, uart_parity_e parity); /** * @brief peripheral_bus_uart_set_stop_bits() set stop bits. @@ -134,7 +134,7 @@ int uart_set_parity(peripheral_uart_h uart, uart_parity_e parity); * @param[in] stop_bits uart stop bits * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits); +int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits); /** * @brief uart_set_flow_control() set flow control settings. @@ -144,7 +144,7 @@ int uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits); * @param[in] rtscts rts/cts * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts); +int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts); /** * @brief uart_read() reads data over uart bus. @@ -154,7 +154,7 @@ int uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts); * @param[in] length size to read * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_read(peripheral_uart_h uart, uint8_t *buf, unsigned int length); +int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, unsigned int length); /** * @brief uart_write() writes data over uart bus. @@ -164,7 +164,7 @@ int uart_read(peripheral_uart_h uart, uint8_t *buf, unsigned int length); * @param[in] length size to write * @return On success, 0 is returned. On failure, a negative value is returned. */ -int uart_write(peripheral_uart_h uart, uint8_t *buf, unsigned int length); +int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, unsigned int length); -#endif /* __UART_H__ */ +#endif /* __PERIPHERAL_INTERFACE_UART_H__ */ diff --git a/include/interface/spi.h b/include/interface/spi.h deleted file mode 100644 index 3708363..0000000 --- a/include/interface/spi.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __SPI_H__ -#define __SPI_H__ - -#include "peripheral_io.h" - -int spi_close(peripheral_spi_h spi); -int spi_set_mode(peripheral_spi_h spi, unsigned char mode); -int spi_set_bit_order(peripheral_spi_h spi, unsigned char lsb); -int spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits); -int spi_set_frequency(peripheral_spi_h spi, unsigned int freq); -int spi_read(peripheral_spi_h spi, unsigned char *rxbuf, int length); -int spi_write(peripheral_spi_h spi, unsigned char *txbuf, int length); -int spi_transfer(peripheral_spi_h spi, unsigned char *txbuf, unsigned char *rxbuf, int length); - -#endif /* __SPI_H__ */ diff --git a/src/interface/gpio.c b/src/interface/peripheral_interface_gpio.c similarity index 77% rename from src/interface/gpio.c rename to src/interface/peripheral_interface_gpio.c index 352e8c9..e4620ca 100644 --- a/src/interface/gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -22,13 +22,13 @@ #include #include -#include "gpio.h" +#include "peripheral_interface_gpio.h" #include "peripheral_common.h" #include "peripheral_internal.h" #define MAX_ERR_LEN 255 -int gpio_set_direction(peripheral_gpio_h gpio, gpio_direction_e dir) +int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, gpio_direction_e dir) { int status; @@ -51,7 +51,7 @@ int gpio_set_direction(peripheral_gpio_h gpio, gpio_direction_e dir) return 0; } -int gpio_set_edge_mode(peripheral_gpio_h gpio, gpio_edge_e edge) +int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, gpio_edge_e edge) { int status; @@ -76,7 +76,7 @@ int gpio_set_edge_mode(peripheral_gpio_h gpio, gpio_edge_e edge) return 0; } -int gpio_write(peripheral_gpio_h gpio, int value) +int peripheral_interface_gpio_write(peripheral_gpio_h gpio, int value) { int status; @@ -97,7 +97,7 @@ int gpio_write(peripheral_gpio_h gpio, int value) return 0; } -int gpio_read(peripheral_gpio_h gpio, int *value) +int peripheral_interface_gpio_read(peripheral_gpio_h gpio, int *value) { int len; char gpio_buf[GPIO_BUFFER_MAX] = {0, }; @@ -120,7 +120,7 @@ int gpio_read(peripheral_gpio_h gpio, int *value) return 0; } -int gpio_close(peripheral_gpio_h gpio) +int peripheral_interface_gpio_close(peripheral_gpio_h gpio) { int status; @@ -145,33 +145,16 @@ int gpio_close(peripheral_gpio_h gpio) return 0; } -int gpio_open_isr(peripheral_gpio_h gpio) +int peripheral_interface_gpio_open_isr(peripheral_gpio_h gpio) { - // int fd; - // char gpio_dev[GPIO_BUFFER_MAX] = {0, }; - - // snprintf(gpio_dev, sizeof(gpio_dev)-1, SYSFS_GPIO_DIR"/gpio%d/value", gpiopin); - - // _D("open isr string [%s]", gpio_dev); - - // fd = open(gpio_dev, O_RDONLY); - // if (fd < 0) { - // char errmsg[MAX_ERR_LEN]; - // strerror_r(errno, errmsg, MAX_ERR_LEN); - // _E("Can't Open /sys/class/gpio/gpio%d pin value: %s\n", gpiopin, errmsg); - // return -ENXIO; - // } - - // return fd; + // TODO: set interrupted callback function return 0; } -int gpio_close_isr(peripheral_gpio_h gpio) +int peripheral_interface_gpio_close_isr(peripheral_gpio_h gpio) { -// if (fd <= 0) return -EINVAL; - -// close(fd); + // TODO: unset interrupted callback function return 0; } \ No newline at end of file diff --git a/src/interface/i2c.c b/src/interface/peripheral_interface_i2c.c similarity index 84% rename from src/interface/i2c.c rename to src/interface/peripheral_interface_i2c.c index fec6ea2..9da17bd 100644 --- a/src/interface/i2c.c +++ b/src/interface/peripheral_interface_i2c.c @@ -22,13 +22,13 @@ #include #include -#include "i2c.h" +#include "peripheral_interface_i2c.h" #include "peripheral_common.h" #include "peripheral_internal.h" #define MAX_ERR_LEN 255 -int i2c_close(peripheral_i2c_h i2c) +int peripheral_interface_i2c_close(peripheral_i2c_h i2c) { int status; @@ -46,7 +46,7 @@ int i2c_close(peripheral_i2c_h i2c) return 0; } -int i2c_set_address(peripheral_i2c_h i2c, int address) +int peripheral_interface_i2c_set_address(peripheral_i2c_h i2c, int address) { int status; @@ -64,7 +64,7 @@ int i2c_set_address(peripheral_i2c_h i2c, int address) return 0; } -int i2c_read(peripheral_i2c_h i2c, unsigned char *data, int length) +int peripheral_interface_i2c_read(peripheral_i2c_h i2c, unsigned char *data, int length) { int status; @@ -81,7 +81,7 @@ int i2c_read(peripheral_i2c_h i2c, unsigned char *data, int length) return 0; } -int i2c_write(peripheral_i2c_h i2c, const unsigned char *data, int length) +int peripheral_interface_i2c_write(peripheral_i2c_h i2c, const unsigned char *data, int length) { int status; @@ -98,7 +98,7 @@ int i2c_write(peripheral_i2c_h i2c, const unsigned char *data, int length) return 0; } -int i2c_smbus_ioctl(peripheral_i2c_h i2c, struct i2c_smbus_ioctl_data *data) +int peripheral_interface_i2c_smbus_ioctl(peripheral_i2c_h i2c, struct i2c_smbus_ioctl_data *data) { int status; diff --git a/src/interface/pwm.c b/src/interface/peripheral_interface_pwm.c similarity index 86% rename from src/interface/pwm.c rename to src/interface/peripheral_interface_pwm.c index 2d34ec7..a5cae4d 100644 --- a/src/interface/pwm.c +++ b/src/interface/peripheral_interface_pwm.c @@ -22,7 +22,7 @@ #include #include -#include "pwm.h" +#include "peripheral_interface_pwm.h" #include "peripheral_common.h" #include "peripheral_internal.h" @@ -32,7 +32,7 @@ #define PWM_BUF_MAX 16 #define MAX_ERR_LEN 255 -int pwm_close(peripheral_pwm_h pwm) +int peripheral_interface_pwm_close(peripheral_pwm_h pwm) { int status; @@ -63,7 +63,7 @@ int pwm_close(peripheral_pwm_h pwm) return 0; } -int pwm_set_period(peripheral_pwm_h pwm, int period) +int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, int period) { int len, status; char pwm_buf[PWM_BUF_MAX] = {0}; @@ -78,7 +78,7 @@ int pwm_set_period(peripheral_pwm_h pwm, int period) return 0; } -int pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle) +int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle) { int len, status; char pwm_buf[PWM_BUF_MAX] = {0}; @@ -93,7 +93,7 @@ int pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle) return 0; } -int pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity) +int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity) { int status; @@ -114,7 +114,7 @@ int pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity) return 0; } -int pwm_set_enable(peripheral_pwm_h pwm, bool enable) +int peripheral_interface_pwm_set_enable(peripheral_pwm_h pwm, bool enable) { int len, status; char pwm_buf[PWM_BUF_MAX] = {0}; diff --git a/src/interface/spi.c b/src/interface/peripheral_interface_spi.c similarity index 85% rename from src/interface/spi.c rename to src/interface/peripheral_interface_spi.c index c212792..1296d9f 100644 --- a/src/interface/spi.c +++ b/src/interface/peripheral_interface_spi.c @@ -23,7 +23,7 @@ #include #include -#include "spi.h" +#include "peripheral_interface_spi.h" #include "peripheral_common.h" #include "peripheral_internal.h" @@ -32,7 +32,7 @@ #define SPI_BUFFER_MAX 64 #define MAX_ERR_LEN 255 -int spi_close(peripheral_spi_h spi) +int peripheral_interface_spi_close(peripheral_spi_h spi) { int status; @@ -50,7 +50,7 @@ int spi_close(peripheral_spi_h spi) return 0; } -int spi_set_mode(peripheral_spi_h spi, unsigned char mode) +int peripheral_interface_spi_set_mode(peripheral_spi_h spi, unsigned char mode) { int status; @@ -68,7 +68,7 @@ int spi_set_mode(peripheral_spi_h spi, unsigned char mode) return 0; } -int spi_set_bit_order(peripheral_spi_h spi, unsigned char lsb) +int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, unsigned char lsb) { int status; @@ -86,7 +86,7 @@ int spi_set_bit_order(peripheral_spi_h spi, unsigned char lsb) return 0; } -int spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits) +int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits) { int status; @@ -104,7 +104,7 @@ int spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits) return 0; } -int spi_set_frequency(peripheral_spi_h spi, unsigned int freq) +int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, unsigned int freq) { int status; @@ -122,7 +122,7 @@ int spi_set_frequency(peripheral_spi_h spi, unsigned int freq) return 0; } -int spi_read(peripheral_spi_h spi, unsigned char *rxbuf, int length) +int peripheral_interface_spi_read(peripheral_spi_h spi, unsigned char *rxbuf, int length) { int status; struct spi_ioc_transfer xfer; @@ -144,7 +144,7 @@ int spi_read(peripheral_spi_h spi, unsigned char *rxbuf, int length) return 0; } -int spi_write(peripheral_spi_h spi, unsigned char *txbuf, int length) +int peripheral_interface_spi_write(peripheral_spi_h spi, unsigned char *txbuf, int length) { int status; struct spi_ioc_transfer xfer; @@ -166,7 +166,7 @@ int spi_write(peripheral_spi_h spi, unsigned char *txbuf, int length) return 0; } -int spi_transfer(peripheral_spi_h spi, unsigned char *txbuf, unsigned char *rxbuf, int length) +int peripheral_interface_spi_transfer(peripheral_spi_h spi, unsigned char *txbuf, unsigned char *rxbuf, int length) { int status; struct spi_ioc_transfer xfer; diff --git a/src/interface/uart.c b/src/interface/peripheral_interface_uart.c similarity index 87% rename from src/interface/uart.c rename to src/interface/peripheral_interface_uart.c index fcddde9..92fffce 100644 --- a/src/interface/uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -24,7 +24,7 @@ #include #include -#include "uart.h" +#include "peripheral_interface_uart.h" #include "peripheral_common.h" #include "peripheral_internal.h" @@ -53,7 +53,7 @@ static const int peripheral_uart_br[UART_BAUDRATE_SIZE] = { static const int byteinfo[4] = {CS5, CS6, CS7, CS8}; -int uart_close(peripheral_uart_h uart) +int peripheral_interface_uart_close(peripheral_uart_h uart) { int status; @@ -64,7 +64,7 @@ int uart_close(peripheral_uart_h uart) return -EINVAL; } - status = uart_flush(uart); + status = peripheral_interface_uart_flush(uart); if (status < 0) { char errmsg[MAX_ERR_LEN]; strerror_r(errno, errmsg, MAX_ERR_LEN); @@ -83,7 +83,7 @@ int uart_close(peripheral_uart_h uart) return 0; } -int uart_flush(peripheral_uart_h uart) +int peripheral_interface_uart_flush(peripheral_uart_h uart) { int ret; @@ -103,7 +103,7 @@ int uart_flush(peripheral_uart_h uart) return 0; } -int uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud) +int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud) { int ret; struct termios tio; @@ -135,7 +135,7 @@ int uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud) tio.c_cc[VMIN] = 1; tio.c_cc[VTIME] = 0; - uart_flush(uart); + peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); if (ret) { char errmsg[MAX_ERR_LEN]; @@ -147,7 +147,7 @@ int uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud) return 0; } -int uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parity_e parity, uart_stop_bits_e stop_bits) +int peripheral_interface_uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parity_e parity, uart_stop_bits_e stop_bits) { int ret; struct termios tio; @@ -207,7 +207,7 @@ int uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parit return -EINVAL; } - uart_flush(uart); + peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); if (ret) { char errmsg[MAX_ERR_LEN]; @@ -219,7 +219,7 @@ int uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parit return 0; } -int uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size) +int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size) { int ret; struct termios tio; @@ -249,7 +249,7 @@ int uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size) tio.c_cflag |= byteinfo[byte_size]; tio.c_cflag |= (CLOCAL | CREAD); - uart_flush(uart); + peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); if (ret) { char errmsg[MAX_ERR_LEN]; @@ -261,7 +261,7 @@ int uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size) return 0; } -int uart_set_parity(peripheral_uart_h uart, uart_parity_e parity) +int peripheral_interface_uart_set_parity(peripheral_uart_h uart, uart_parity_e parity) { int ret; struct termios tio; @@ -298,7 +298,7 @@ int uart_set_parity(peripheral_uart_h uart, uart_parity_e parity) break; } - uart_flush(uart); + peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); if (ret) { char errmsg[MAX_ERR_LEN]; @@ -310,7 +310,7 @@ int uart_set_parity(peripheral_uart_h uart, uart_parity_e parity) return 0; } -int uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits) +int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits) { int ret; struct termios tio; @@ -343,7 +343,7 @@ int uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits) return -EINVAL; } - uart_flush(uart); + peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); if (ret) { char errmsg[MAX_ERR_LEN]; @@ -355,7 +355,7 @@ int uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits) return 0; } -int uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts) +int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts) { int ret; struct termios tio; @@ -398,7 +398,7 @@ int uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts) return 0; } -int uart_read(peripheral_uart_h uart, uint8_t *buf, unsigned int length) +int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, unsigned int length) { int ret; @@ -420,7 +420,7 @@ int uart_read(peripheral_uart_h uart, uint8_t *buf, unsigned int length) return ret; } -int uart_write(peripheral_uart_h uart, uint8_t *buf, unsigned int length) +int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, unsigned int length) { int ret; -- 2.7.4 From 51613a796376575bd56788548453136486d7c1c5 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 12:43:07 +0900 Subject: [PATCH 02/16] uart: remove unused interface function that peripheral_interface_uart_set_mode(). Change-Id: I9e1c5a7326d65598e2ce326162abd9c5c0b4806e Signed-off-by: Segwon --- include/interface/peripheral_interface_uart.h | 11 ---- src/interface/peripheral_interface_uart.c | 72 --------------------------- 2 files changed, 83 deletions(-) diff --git a/include/interface/peripheral_interface_uart.h b/include/interface/peripheral_interface_uart.h index f5273fe..c9a8c30 100644 --- a/include/interface/peripheral_interface_uart.h +++ b/include/interface/peripheral_interface_uart.h @@ -99,17 +99,6 @@ int peripheral_interface_uart_flush(peripheral_uart_h uart); int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud); /** -* @brief uart_set_mode() sets byte size, parity bit and stop bits. -* -* @param[in] file_hndl handle of uart_context -* @param[in] byte_size uart byte size -* @param[in] parity uart parity type (even/odd/none) -* @param[in] stop_bits uart stop bits -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int peripheral_interface_uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parity_e parity, uart_stop_bits_e stop_bits); - -/** * @brief peripheral_bus_uart_set_byte_size() set byte size. * * @param[in] file_hndl handle of uart_context diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c index 92fffce..c563fc6 100644 --- a/src/interface/peripheral_interface_uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -147,78 +147,6 @@ int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_ra return 0; } -int peripheral_interface_uart_set_mode(peripheral_uart_h uart, uart_byte_size_e byte_size, uart_parity_e parity, uart_stop_bits_e stop_bits) -{ - int ret; - struct termios tio; - - _D("file_hndl : %d, bytesize : %d, parity : %d, stopbits : %d", uart->fd, byte_size, parity, stop_bits); - - if (!uart->fd) { - _E("Invalid NULL parameter"); - return -EINVAL; - } - - if (byte_size > UART_BYTE_SIZE_8BIT) { - _E("Invalid bytesize parameter"); - return -EINVAL; - } - - ret = tcgetattr(uart->fd, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcgetattr failed, errmsg: %s", errmsg); - return -1; - } - - /* set byte size */ - tio.c_cflag &= ~CSIZE; - tio.c_cflag |= byteinfo[byte_size]; - tio.c_cflag |= (CLOCAL | CREAD); - - /* set parity info */ - switch (parity) { - case UART_PARITY_EVEN: - tio.c_cflag |= PARENB; - tio.c_cflag &= ~PARODD; - break; - case UART_PARITY_ODD: - tio.c_cflag |= PARENB; - tio.c_cflag |= PARODD; - break; - case UART_PARITY_NONE: - default: - tio.c_cflag &= ~PARENB; - tio.c_cflag &= ~PARODD; - break; - } - - /* set stop bit */ - switch (stop_bits) { - case UART_STOP_BITS_1BIT: - tio.c_cflag &= ~CSTOPB; - break; - case UART_STOP_BITS_2BIT: - tio.c_cflag |= CSTOPB; - break; - default: - _E("Invalid parameter stop_bits"); - return -EINVAL; - } - - peripheral_interface_uart_flush(uart); - ret = tcsetattr(uart->fd, TCSANOW, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcsetattr failed, errmsg : %s", errmsg); - return -1; - } - - return 0; -} - int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size) { int ret; -- 2.7.4 From 625deea325617c6597ccbd4221b7c8db519a0203 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 12:55:52 +0900 Subject: [PATCH 03/16] interface: unuse the enum types defined in the interface - replace with enum types provided by the API - remove enum list 1) gpio_direction_e 2) gpio_edge_e 3) pwm_polarity_e 4) uart_baud_rate_e 5) uart_byte_size_e 6) uart_parity_e 7) uart_stop_bits_e Change-Id: Id70350fabf29b18c7b440be8bbfdd4b99ed3b98d Signed-off-by: Segwon --- include/interface/peripheral_interface_gpio.h | 17 +------- include/interface/peripheral_interface_pwm.h | 11 +---- include/interface/peripheral_interface_spi.h | 4 +- include/interface/peripheral_interface_uart.h | 62 +++------------------------ src/interface/peripheral_interface_gpio.c | 18 ++++---- src/interface/peripheral_interface_pwm.c | 6 +-- src/interface/peripheral_interface_spi.c | 10 ++--- src/interface/peripheral_interface_uart.c | 38 ++++++++-------- 8 files changed, 47 insertions(+), 119 deletions(-) diff --git a/include/interface/peripheral_interface_gpio.h b/include/interface/peripheral_interface_gpio.h index cf5d76c..9792a1c 100644 --- a/include/interface/peripheral_interface_gpio.h +++ b/include/interface/peripheral_interface_gpio.h @@ -22,22 +22,9 @@ #define SYSFS_GPIO_DIR "/sys/class/gpio" #define GPIO_BUFFER_MAX 64 -typedef enum { - GPIO_DIRECTION_IN = 0, - GPIO_DIRECTION_OUT_HIGH = 1, - GPIO_DIRECTION_OUT_LOW = 2, -} gpio_direction_e; - -typedef enum { - GPIO_EDGE_NONE = 0, - GPIO_EDGE_RISING = 1, - GPIO_EDGE_FALLING = 2, - GPIO_EDGE_BOTH = 3, -} gpio_edge_e; - int peripheral_interface_gpio_close(peripheral_gpio_h gpio); -int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, gpio_edge_e edge); -int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, gpio_direction_e dir); +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, int value); int peripheral_interface_gpio_read(peripheral_gpio_h gpio, int *value); diff --git a/include/interface/peripheral_interface_pwm.h b/include/interface/peripheral_interface_pwm.h index 833de2b..e45c2d6 100644 --- a/include/interface/peripheral_interface_pwm.h +++ b/include/interface/peripheral_interface_pwm.h @@ -20,15 +20,6 @@ #include "peripheral_io.h" /** - * @brief Enumeration for Polarity - */ -typedef enum { - PWM_POLARITY_NORMAL = 0, - PWM_POLARITY_INVERSED, -} pwm_polarity_e; - - -/** * @brief pwm_close() deinit pwm pin. * * @param[in] chip pwm chip number @@ -65,7 +56,7 @@ int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle * @param[in] polarity pwm polarity * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity); +int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity); /** * @brief pwm_set_enable() sets the pwm state. diff --git a/include/interface/peripheral_interface_spi.h b/include/interface/peripheral_interface_spi.h index 937caa7..2cee142 100644 --- a/include/interface/peripheral_interface_spi.h +++ b/include/interface/peripheral_interface_spi.h @@ -20,8 +20,8 @@ #include "peripheral_io.h" int peripheral_interface_spi_close(peripheral_spi_h spi); -int peripheral_interface_spi_set_mode(peripheral_spi_h spi, unsigned char mode); -int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, unsigned char lsb); +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, unsigned char bits); int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, unsigned int freq); int peripheral_interface_spi_read(peripheral_spi_h spi, unsigned char *rxbuf, int length); diff --git a/include/interface/peripheral_interface_uart.h b/include/interface/peripheral_interface_uart.h index c9a8c30..5541618 100644 --- a/include/interface/peripheral_interface_uart.h +++ b/include/interface/peripheral_interface_uart.h @@ -22,58 +22,6 @@ #include /** - * @brief Enumeration for Baud Rate - */ -typedef enum { - UART_BAUD_RATE_0 = 0, - UART_BAUD_RATE_50, - UART_BAUD_RATE_75, - UART_BAUD_RATE_110, - UART_BAUD_RATE_134, - UART_BAUD_RATE_150, - UART_BAUD_RATE_200, - UART_BAUD_RATE_300, - UART_BAUD_RATE_600, - UART_BAUD_RATE_1200, - UART_BAUD_RATE_1800, - UART_BAUD_RATE_2400, - UART_BAUD_RATE_4800, - UART_BAUD_RATE_9600, - UART_BAUD_RATE_19200, - UART_BAUD_RATE_38400, - UART_BAUD_RATE_57600, - UART_BAUD_RATE_115200, - UART_BAUD_RATE_230400 -} uart_baud_rate_e; - -/** - * @brief Enumeration for Byte Size - */ -typedef enum { - UART_BYTE_SIZE_5BIT = 0, - UART_BYTE_SIZE_6BIT, - UART_BYTE_SIZE_7BIT, - UART_BYTE_SIZE_8BIT -} uart_byte_size_e; - -/** - * @brief Enumeration of Parity Bit - */ -typedef enum { - UART_PARITY_NONE = 0, - UART_PARITY_EVEN, - UART_PARITY_ODD -} uart_parity_e; - -/** - * @brief Enumeration for Stop Bits - */ -typedef enum { - UART_STOP_BITS_1BIT = 0, - UART_STOP_BITS_2BIT -} uart_stop_bits_e; - -/** * @brief uart_close() closes uart port. * * @param[in] file_hndl handle of uart_context @@ -96,7 +44,7 @@ int peripheral_interface_uart_flush(peripheral_uart_h uart); * @param[in] baud uart baud rate * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud); +int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud); /** * @brief peripheral_bus_uart_set_byte_size() set byte size. @@ -105,7 +53,7 @@ int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_ra * @param[in] byte_size uart byte size * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size); +int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size); /** * @brief peripheral_bus_uart_set_parity() set parity bit. @@ -114,7 +62,7 @@ int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, uart_byte_si * @param[in] parity uart parity type (even/odd/none) * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_uart_set_parity(peripheral_uart_h uart, uart_parity_e parity); +int peripheral_interface_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity); /** * @brief peripheral_bus_uart_set_stop_bits() set stop bits. @@ -123,7 +71,7 @@ int peripheral_interface_uart_set_parity(peripheral_uart_h uart, uart_parity_e p * @param[in] stop_bits uart stop bits * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits); +int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits); /** * @brief uart_set_flow_control() set flow control settings. @@ -133,7 +81,7 @@ int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bi * @param[in] rtscts rts/cts * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts); +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); /** * @brief uart_read() reads data over uart bus. diff --git a/src/interface/peripheral_interface_gpio.c b/src/interface/peripheral_interface_gpio.c index e4620ca..24c1837 100644 --- a/src/interface/peripheral_interface_gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -28,15 +28,15 @@ #define MAX_ERR_LEN 255 -int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, gpio_direction_e dir) +int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction) { int status; - if (dir == GPIO_DIRECTION_IN) + if (direction == PERIPHERAL_GPIO_DIRECTION_IN) status = write(gpio->fd_direction, "in", strlen("in")+1); - else if (dir == GPIO_DIRECTION_OUT_HIGH) + else if (direction == PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH) status = write(gpio->fd_direction, "high", strlen("high")+1); - else if (dir == GPIO_DIRECTION_OUT_LOW) + else if (direction == PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW) status = write(gpio->fd_direction, "low", strlen("low")+1); else { _E("Error: gpio direction is wrong\n"); @@ -51,17 +51,17 @@ int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, gpio_directi return 0; } -int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, gpio_edge_e edge) +int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge) { int status; - if (edge == GPIO_EDGE_NONE) + if (edge == PERIPHERAL_GPIO_EDGE_NONE) status = write(gpio->fd_edge, "none", strlen("none")+1); - else if (edge == GPIO_EDGE_RISING) + else if (edge == PERIPHERAL_GPIO_EDGE_RISING) status = write(gpio->fd_edge, "rising", strlen("rising")+1); - else if (edge == GPIO_EDGE_FALLING) + else if (edge == PERIPHERAL_GPIO_EDGE_FALLING) status = write(gpio->fd_edge, "falling", strlen("falling")+1); - else if (edge == GPIO_EDGE_BOTH) + else if (edge == PERIPHERAL_GPIO_EDGE_BOTH) status = write(gpio->fd_edge, "both", strlen("both")+1); else { _E("Error: gpio edge is wrong\n"); diff --git a/src/interface/peripheral_interface_pwm.c b/src/interface/peripheral_interface_pwm.c index a5cae4d..da6cbca 100644 --- a/src/interface/peripheral_interface_pwm.c +++ b/src/interface/peripheral_interface_pwm.c @@ -93,13 +93,13 @@ int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle return 0; } -int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, pwm_polarity_e polarity) +int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity) { int status; - if (polarity == PWM_POLARITY_NORMAL) + if (polarity == PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH) status = write(pwm->fd_polarity, "normal", strlen("normal")+1); - else if (polarity == PWM_POLARITY_INVERSED) + else if (polarity == PERIPHERAL_PWM_POLARITY_ACTIVE_LOW) status = write(pwm->fd_polarity, "inversed", strlen("inversed")+1); else { _E("Invalid pwm polarity : %d", polarity); diff --git a/src/interface/peripheral_interface_spi.c b/src/interface/peripheral_interface_spi.c index 1296d9f..1ea88de 100644 --- a/src/interface/peripheral_interface_spi.c +++ b/src/interface/peripheral_interface_spi.c @@ -50,7 +50,7 @@ int peripheral_interface_spi_close(peripheral_spi_h spi) return 0; } -int peripheral_interface_spi_set_mode(peripheral_spi_h spi, unsigned char mode) +int peripheral_interface_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode) { int status; @@ -68,18 +68,18 @@ int peripheral_interface_spi_set_mode(peripheral_spi_h spi, unsigned char mode) return 0; } -int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, unsigned char lsb) +int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order) { int status; - _D("fd : %d, lsb : %d", spi->fd, lsb); + _D("fd : %d, lsb : %d", spi->fd, bit_order); RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd"); - status = ioctl(spi->fd, SPI_IOC_WR_LSB_FIRST, &lsb); + status = ioctl(spi->fd, SPI_IOC_WR_LSB_FIRST, &bit_order); if (status < 0) { char errmsg[MAX_ERR_LEN]; strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to set lsb first(%d), fd : %d, errmsg : %s", lsb, spi->fd, errmsg); + _E("Failed to set lsb first(%d), fd : %d, errmsg : %s", bit_order, spi->fd, errmsg); return -EIO; } diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c index c563fc6..49f9346 100644 --- a/src/interface/peripheral_interface_uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -103,7 +103,7 @@ int peripheral_interface_uart_flush(peripheral_uart_h uart) return 0; } -int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_rate_e baud) +int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud) { int ret; struct termios tio; @@ -116,7 +116,7 @@ int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_ra return -EINVAL; } - if (baud > UART_BAUD_RATE_230400) { + if (baud > PERIPHERAL_UART_BAUD_RATE_230400) { _E("Invalid parameter"); return -EINVAL; } @@ -147,7 +147,7 @@ int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, uart_baud_ra return 0; } -int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, uart_byte_size_e byte_size) +int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size) { int ret; struct termios tio; @@ -159,7 +159,7 @@ int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, uart_byte_si return -EINVAL; } - if (byte_size > UART_BYTE_SIZE_8BIT) { + if (byte_size > PERIPHERAL_UART_BYTE_SIZE_8BIT) { _E("Invalid bytesize parameter"); return -EINVAL; } @@ -189,7 +189,7 @@ int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, uart_byte_si return 0; } -int peripheral_interface_uart_set_parity(peripheral_uart_h uart, uart_parity_e parity) +int peripheral_interface_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity) { int ret; struct termios tio; @@ -211,15 +211,15 @@ int peripheral_interface_uart_set_parity(peripheral_uart_h uart, uart_parity_e p /* set parity info */ switch (parity) { - case UART_PARITY_EVEN: + case PERIPHERAL_UART_PARITY_EVEN: tio.c_cflag |= PARENB; tio.c_cflag &= ~PARODD; break; - case UART_PARITY_ODD: + case PERIPHERAL_UART_PARITY_ODD: tio.c_cflag |= PARENB; tio.c_cflag |= PARODD; break; - case UART_PARITY_NONE: + case PERIPHERAL_UART_PARITY_NONE: default: tio.c_cflag &= ~PARENB; tio.c_cflag &= ~PARODD; @@ -238,7 +238,7 @@ int peripheral_interface_uart_set_parity(peripheral_uart_h uart, uart_parity_e p return 0; } -int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bits_e stop_bits) +int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits) { int ret; struct termios tio; @@ -260,10 +260,10 @@ int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bi /* set stop bit */ switch (stop_bits) { - case UART_STOP_BITS_1BIT: + case PERIPHERAL_UART_STOP_BITS_1BIT: tio.c_cflag &= ~CSTOPB; break; - case UART_STOP_BITS_2BIT: + case PERIPHERAL_UART_STOP_BITS_2BIT: tio.c_cflag |= CSTOPB; break; default: @@ -283,7 +283,7 @@ int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, uart_stop_bi return 0; } -int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts) +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) { int ret; struct termios tio; @@ -303,17 +303,19 @@ int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, bool xonx return -1; } - /* rtscts => 1: rts/cts on, 0: off */ - if (rtscts) + if (rtscts == PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS) tio.c_cflag |= CRTSCTS; - else + else if (rtscts == PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE) tio.c_cflag &= ~CRTSCTS; + else + return -EINVAL; - /* xonxoff => 1: xon/xoff on, 0: off */ - if (xonxoff) + if (xonxoff == PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF) tio.c_iflag |= (IXON | IXOFF | IXANY); - else + else if (xonxoff == PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE) tio.c_iflag &= ~(IXON | IXOFF | IXANY); + else + return -EINVAL; ret = tcsetattr(uart->fd, TCSANOW, &tio); if (ret) { -- 2.7.4 From 7e9d52a11322171f21a19d17244b72d7d81a040f Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 13:19:48 +0900 Subject: [PATCH 04/16] interface: change the type of parameters in interface functions. - it matches the parameter type of the API Change-Id: I79d7b66fb917affd4398c1609b367859bc5da3bc Signed-off-by: Segwon --- include/interface/peripheral_interface_gpio.h | 4 ++-- include/interface/peripheral_interface_i2c.h | 4 ++-- include/interface/peripheral_interface_pwm.h | 4 ++-- include/interface/peripheral_interface_spi.h | 10 +++++----- include/interface/peripheral_interface_uart.h | 4 ++-- src/interface/peripheral_interface_gpio.c | 4 ++-- src/interface/peripheral_interface_i2c.c | 4 ++-- src/interface/peripheral_interface_pwm.c | 4 ++-- src/interface/peripheral_interface_spi.c | 12 ++++++------ src/interface/peripheral_interface_uart.c | 4 ++-- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/interface/peripheral_interface_gpio.h b/include/interface/peripheral_interface_gpio.h index 9792a1c..cc68e92 100644 --- a/include/interface/peripheral_interface_gpio.h +++ b/include/interface/peripheral_interface_gpio.h @@ -25,8 +25,8 @@ int 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, int value); -int peripheral_interface_gpio_read(peripheral_gpio_h gpio, int *value); +int peripheral_interface_gpio_write(peripheral_gpio_h gpio, uint32_t value); +int peripheral_interface_gpio_read(peripheral_gpio_h gpio, uint32_t *value); int peripheral_interface_gpio_open_isr(peripheral_gpio_h gpio); int peripheral_interface_gpio_close_isr(peripheral_gpio_h gpio); diff --git a/include/interface/peripheral_interface_i2c.h b/include/interface/peripheral_interface_i2c.h index b41c555..67c7019 100644 --- a/include/interface/peripheral_interface_i2c.h +++ b/include/interface/peripheral_interface_i2c.h @@ -59,8 +59,8 @@ struct i2c_smbus_ioctl_data { int peripheral_interface_i2c_close(peripheral_i2c_h i2c); int peripheral_interface_i2c_set_address(peripheral_i2c_h i2c, int address); -int peripheral_interface_i2c_read(peripheral_i2c_h i2c, unsigned char *data, int length); -int peripheral_interface_i2c_write(peripheral_i2c_h i2c, const unsigned char *data, int length); +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_smbus_ioctl(peripheral_i2c_h i2c, struct i2c_smbus_ioctl_data *data); #endif/* __PERIPHERAL_INTERFACE_I2C_H__ */ diff --git a/include/interface/peripheral_interface_pwm.h b/include/interface/peripheral_interface_pwm.h index e45c2d6..0867663 100644 --- a/include/interface/peripheral_interface_pwm.h +++ b/include/interface/peripheral_interface_pwm.h @@ -36,7 +36,7 @@ int peripheral_interface_pwm_close(peripheral_pwm_h pwm); * @param[in] period pwm period * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, int period); +int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, uint32_t period); /** * @brief pwm_set_duty_cycle() sets the pwm duty cycle. @@ -46,7 +46,7 @@ int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, int period); * @param[in] duty_cycle pwm duty cycle * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle); +int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle); /** * @brief pwm_set_polarity() sets the pwm polarity. diff --git a/include/interface/peripheral_interface_spi.h b/include/interface/peripheral_interface_spi.h index 2cee142..d7a471d 100644 --- a/include/interface/peripheral_interface_spi.h +++ b/include/interface/peripheral_interface_spi.h @@ -22,10 +22,10 @@ int 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, unsigned char bits); -int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, unsigned int freq); -int peripheral_interface_spi_read(peripheral_spi_h spi, unsigned char *rxbuf, int length); -int peripheral_interface_spi_write(peripheral_spi_h spi, unsigned char *txbuf, int length); -int peripheral_interface_spi_transfer(peripheral_spi_h spi, unsigned char *txbuf, unsigned char *rxbuf, int length); +int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits); +int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, uint32_t freq); +int peripheral_interface_spi_read(peripheral_spi_h spi, uint8_t *rxbuf, uint32_t length); +int peripheral_interface_spi_write(peripheral_spi_h spi, uint8_t *txbuf, uint32_t length); +int peripheral_interface_spi_transfer(peripheral_spi_h spi, uint8_t *txbuf, uint8_t *rxbuf, uint32_t length); #endif /* __PERIPHERAL_INTERFACE_SPI_H__ */ diff --git a/include/interface/peripheral_interface_uart.h b/include/interface/peripheral_interface_uart.h index 5541618..4648ae1 100644 --- a/include/interface/peripheral_interface_uart.h +++ b/include/interface/peripheral_interface_uart.h @@ -91,7 +91,7 @@ int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, periphera * @param[in] length size to read * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, unsigned int length); +int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, uint32_t length); /** * @brief uart_write() writes data over uart bus. @@ -101,7 +101,7 @@ int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, unsigne * @param[in] length size to write * @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, unsigned int length); +int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, uint32_t length); #endif /* __PERIPHERAL_INTERFACE_UART_H__ */ diff --git a/src/interface/peripheral_interface_gpio.c b/src/interface/peripheral_interface_gpio.c index 24c1837..e2ce235 100644 --- a/src/interface/peripheral_interface_gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -76,7 +76,7 @@ int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_g return 0; } -int peripheral_interface_gpio_write(peripheral_gpio_h gpio, int value) +int peripheral_interface_gpio_write(peripheral_gpio_h gpio, uint32_t value) { int status; @@ -97,7 +97,7 @@ int peripheral_interface_gpio_write(peripheral_gpio_h gpio, int value) return 0; } -int peripheral_interface_gpio_read(peripheral_gpio_h gpio, int *value) +int peripheral_interface_gpio_read(peripheral_gpio_h gpio, uint32_t *value) { int len; char gpio_buf[GPIO_BUFFER_MAX] = {0, }; diff --git a/src/interface/peripheral_interface_i2c.c b/src/interface/peripheral_interface_i2c.c index 9da17bd..cc703fe 100644 --- a/src/interface/peripheral_interface_i2c.c +++ b/src/interface/peripheral_interface_i2c.c @@ -64,7 +64,7 @@ int peripheral_interface_i2c_set_address(peripheral_i2c_h i2c, int address) return 0; } -int peripheral_interface_i2c_read(peripheral_i2c_h i2c, unsigned char *data, int length) +int peripheral_interface_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length) { int status; @@ -81,7 +81,7 @@ int peripheral_interface_i2c_read(peripheral_i2c_h i2c, unsigned char *data, int return 0; } -int peripheral_interface_i2c_write(peripheral_i2c_h i2c, const unsigned char *data, int length) +int peripheral_interface_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length) { int status; diff --git a/src/interface/peripheral_interface_pwm.c b/src/interface/peripheral_interface_pwm.c index da6cbca..822332b 100644 --- a/src/interface/peripheral_interface_pwm.c +++ b/src/interface/peripheral_interface_pwm.c @@ -63,7 +63,7 @@ int peripheral_interface_pwm_close(peripheral_pwm_h pwm) return 0; } -int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, int period) +int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, uint32_t period) { int len, status; char pwm_buf[PWM_BUF_MAX] = {0}; @@ -78,7 +78,7 @@ int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, int period) return 0; } -int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle) +int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle) { int len, status; char pwm_buf[PWM_BUF_MAX] = {0}; diff --git a/src/interface/peripheral_interface_spi.c b/src/interface/peripheral_interface_spi.c index 1ea88de..ddc643c 100644 --- a/src/interface/peripheral_interface_spi.c +++ b/src/interface/peripheral_interface_spi.c @@ -86,7 +86,7 @@ int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_ return 0; } -int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits) +int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits) { int status; @@ -104,7 +104,7 @@ int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, unsigned ch return 0; } -int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, unsigned int freq) +int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, uint32_t freq) { int status; @@ -122,7 +122,7 @@ int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, unsigned int fr return 0; } -int peripheral_interface_spi_read(peripheral_spi_h spi, unsigned char *rxbuf, int length) +int peripheral_interface_spi_read(peripheral_spi_h spi, uint8_t *rxbuf, uint32_t length) { int status; struct spi_ioc_transfer xfer; @@ -144,7 +144,7 @@ int peripheral_interface_spi_read(peripheral_spi_h spi, unsigned char *rxbuf, in return 0; } -int peripheral_interface_spi_write(peripheral_spi_h spi, unsigned char *txbuf, int length) +int peripheral_interface_spi_write(peripheral_spi_h spi, uint8_t *txbuf, uint32_t length) { int status; struct spi_ioc_transfer xfer; @@ -166,14 +166,14 @@ int peripheral_interface_spi_write(peripheral_spi_h spi, unsigned char *txbuf, i return 0; } -int peripheral_interface_spi_transfer(peripheral_spi_h spi, unsigned char *txbuf, unsigned char *rxbuf, int length) +int peripheral_interface_spi_transfer(peripheral_spi_h spi, uint8_t *txbuf, uint8_t *rxbuf, uint32_t length) { int status; struct spi_ioc_transfer xfer; RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd : %d", spi->fd); - if (!txbuf || !rxbuf || length < 0) return -EINVAL; + if (!txbuf || !rxbuf) return -EINVAL; memset(&xfer, 0, sizeof(xfer)); xfer.tx_buf = (unsigned long)txbuf; diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c index 49f9346..4933ab4 100644 --- a/src/interface/peripheral_interface_uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -328,7 +328,7 @@ int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, periphera return 0; } -int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, unsigned int length) +int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, uint32_t length) { int ret; @@ -350,7 +350,7 @@ int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, unsigne return ret; } -int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, unsigned int length) +int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, uint32_t length) { int ret; -- 2.7.4 From 503baca692cf21f5f652d9418b2efce068fc45a5 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 13:24:37 +0900 Subject: [PATCH 05/16] i2c: remove unused interface function that peripheral_interface_i2c_set_address() Change-Id: I277e99134c27a411614aac9502c700ab83f04c3e Signed-off-by: Segwon --- include/interface/peripheral_interface_i2c.h | 1 - src/interface/peripheral_interface_i2c.c | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/include/interface/peripheral_interface_i2c.h b/include/interface/peripheral_interface_i2c.h index 67c7019..41326d6 100644 --- a/include/interface/peripheral_interface_i2c.h +++ b/include/interface/peripheral_interface_i2c.h @@ -58,7 +58,6 @@ struct i2c_smbus_ioctl_data { }; int peripheral_interface_i2c_close(peripheral_i2c_h i2c); -int peripheral_interface_i2c_set_address(peripheral_i2c_h i2c, int address); 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_smbus_ioctl(peripheral_i2c_h i2c, struct i2c_smbus_ioctl_data *data); diff --git a/src/interface/peripheral_interface_i2c.c b/src/interface/peripheral_interface_i2c.c index cc703fe..6b235ff 100644 --- a/src/interface/peripheral_interface_i2c.c +++ b/src/interface/peripheral_interface_i2c.c @@ -46,24 +46,6 @@ int peripheral_interface_i2c_close(peripheral_i2c_h i2c) return 0; } -int peripheral_interface_i2c_set_address(peripheral_i2c_h i2c, int address) -{ - int status; - - _D("fd : %d, slave address : 0x%x", i2c->fd, address); - RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd"); - - status = ioctl(i2c->fd, I2C_SLAVE, address); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to set slave address(%x), fd : %d, errmsg : %s", address, i2c->fd, errmsg); - return status; - } - - return 0; -} - int peripheral_interface_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length) { int status; -- 2.7.4 From 91cec9be39189285a4532ee6e1f9a36187b46e45 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 15:55:58 +0900 Subject: [PATCH 06/16] interface: use the CHECK_ERROR macro for error set by system call - created a peripheral_interface_common.h file and implemented error macro - macro name : CHECK_ERROR Signed-off-by: Segwon Change-Id: I5d1167ab2d7aa3e5e3b22ef2192efbd68b1f17bc --- include/interface/peripheral_interface_common.h | 32 +++++++ src/interface/peripheral_interface_gpio.c | 36 ++------ src/interface/peripheral_interface_i2c.c | 29 ++---- src/interface/peripheral_interface_pwm.c | 41 ++------- src/interface/peripheral_interface_spi.c | 57 ++---------- src/interface/peripheral_interface_uart.c | 112 ++++-------------------- 6 files changed, 81 insertions(+), 226 deletions(-) create mode 100644 include/interface/peripheral_interface_common.h diff --git a/include/interface/peripheral_interface_common.h b/include/interface/peripheral_interface_common.h new file mode 100644 index 0000000..33a8d39 --- /dev/null +++ b/include/interface/peripheral_interface_common.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __PERIPHERAL_INTERFACE_COMMON_H__ +#define __PERIPHERAL_INTERFACE_COMMON_H__ + +#define CHECK_ERROR(val) \ + do { \ + if (val < 0) { \ + if (errno == EAGAIN) \ + return -EAGAIN; \ + char errmsg[255]; \ + strerror_r(errno, errmsg, sizeof(errmsg)); \ + _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \ + return -EIO; \ + } \ + } while (0) + +#endif /*__PERIPHERAL_INTERFACE_COMMON_H__*/ \ No newline at end of file diff --git a/src/interface/peripheral_interface_gpio.c b/src/interface/peripheral_interface_gpio.c index e2ce235..7d4ef2f 100644 --- a/src/interface/peripheral_interface_gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -22,6 +22,7 @@ #include #include +#include "peripheral_interface_common.h" #include "peripheral_interface_gpio.h" #include "peripheral_common.h" #include "peripheral_internal.h" @@ -43,10 +44,7 @@ int peripheral_interface_gpio_set_direction(peripheral_gpio_h gpio, peripheral_g return -EIO; } - if (status <= 0) { - _E("Error: gpio direction set error\n"); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -68,10 +66,7 @@ int peripheral_interface_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_g return -EIO; } - if (status <= 0) { - _E("Error: gpio edge set error\n"); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -89,10 +84,7 @@ int peripheral_interface_gpio_write(peripheral_gpio_h gpio, uint32_t value) return -EIO; } - if (status <= 0) { - _E("Error: gpio write error\n"); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -103,10 +95,7 @@ int peripheral_interface_gpio_read(peripheral_gpio_h gpio, uint32_t *value) char gpio_buf[GPIO_BUFFER_MAX] = {0, }; len = read(gpio->fd_value, &gpio_buf, 1); - if (len <= 0) { - _E("Error: gpio read error \n"); - return -EIO; - } + CHECK_ERROR(len); if (0 == strncmp(gpio_buf, "1", strlen("1"))) *value = 1; @@ -125,22 +114,13 @@ int peripheral_interface_gpio_close(peripheral_gpio_h gpio) int status; status = close(gpio->fd_direction); - if (status < 0) { - _E("Error: gpio direction fd close error \n"); - return -EIO; - } + CHECK_ERROR(status); status = close(gpio->fd_edge); - if (status < 0) { - _E("Error: gpio edge fd close error \n"); - return -EIO; - } + CHECK_ERROR(status); status = close(gpio->fd_value); - if (status < 0) { - _E("Error: gpio value fd close error \n"); - return -EIO; - } + CHECK_ERROR(status); return 0; } diff --git a/src/interface/peripheral_interface_i2c.c b/src/interface/peripheral_interface_i2c.c index 6b235ff..fadbf63 100644 --- a/src/interface/peripheral_interface_i2c.c +++ b/src/interface/peripheral_interface_i2c.c @@ -22,6 +22,7 @@ #include #include +#include "peripheral_interface_common.h" #include "peripheral_interface_i2c.h" #include "peripheral_common.h" #include "peripheral_internal.h" @@ -36,12 +37,7 @@ int peripheral_interface_i2c_close(peripheral_i2c_h i2c) RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd"); status = close(i2c->fd); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to close fd : %d", i2c->fd); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -53,12 +49,7 @@ int peripheral_interface_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd : %d", i2c->fd); status = read(i2c->fd, data, length); - if (status != length) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("i2c read failed, fd : %d, errmsg : %s", i2c->fd, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -70,12 +61,7 @@ int peripheral_interface_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd : %d", i2c->fd); status = write(i2c->fd, data, length); - if (status != length) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("i2c write failed fd : %d, errmsg : %s", i2c->fd, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -87,12 +73,7 @@ int peripheral_interface_i2c_smbus_ioctl(peripheral_i2c_h i2c, struct i2c_smbus_ RETVM_IF(i2c->fd < 0, -EINVAL, "Invalid fd : %d", i2c->fd); status = ioctl(i2c->fd, I2C_SMBUS, data); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("i2c transaction failed fd : %d, errmsg : %s", i2c->fd, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } diff --git a/src/interface/peripheral_interface_pwm.c b/src/interface/peripheral_interface_pwm.c index 822332b..faefc1a 100644 --- a/src/interface/peripheral_interface_pwm.c +++ b/src/interface/peripheral_interface_pwm.c @@ -22,6 +22,7 @@ #include #include +#include "peripheral_interface_common.h" #include "peripheral_interface_pwm.h" #include "peripheral_common.h" #include "peripheral_internal.h" @@ -37,28 +38,16 @@ int peripheral_interface_pwm_close(peripheral_pwm_h pwm) int status; status = close(pwm->fd_period); - if (status < 0) { - _E("Error: pwm period fd close error \n"); - return -EIO; - } + CHECK_ERROR(status); status = close(pwm->fd_duty_cycle); - if (status < 0) { - _E("Error: pwm duty cycle fd close error \n"); - return -EIO; - } + CHECK_ERROR(status); status = close(pwm->fd_polarity); - if (status < 0) { - _E("Error: pwm polarity fd close error \n"); - return -EIO; - } + CHECK_ERROR(status); status = close(pwm->fd_enable); - if (status < 0) { - _E("Error: pwm enable fd close error \n"); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -70,10 +59,7 @@ int peripheral_interface_pwm_set_period(peripheral_pwm_h pwm, uint32_t period) len = snprintf(pwm_buf, sizeof(pwm_buf), "%d", period); status = write(pwm->fd_period, pwm_buf, len); - if (status < 0) { - _E("Failed to set period"); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -85,10 +71,7 @@ int peripheral_interface_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_ len = snprintf(pwm_buf, sizeof(pwm_buf), "%d", duty_cycle); status = write(pwm->fd_duty_cycle, pwm_buf, len); - if (status < 0) { - _E("Failed to set duty cycle"); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -106,10 +89,7 @@ int peripheral_interface_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_p return -EINVAL; } - if (status <= 0) { - _E("Failed to set polarity"); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -121,10 +101,7 @@ int peripheral_interface_pwm_set_enable(peripheral_pwm_h pwm, bool enable) len = snprintf(pwm_buf, sizeof(pwm_buf), "%d", enable); status = write(pwm->fd_enable, pwm_buf, len); - if (status < 0) { - _E("Failed to set enable"); - return -EIO; - } + CHECK_ERROR(status); return 0; } diff --git a/src/interface/peripheral_interface_spi.c b/src/interface/peripheral_interface_spi.c index ddc643c..1c83726 100644 --- a/src/interface/peripheral_interface_spi.c +++ b/src/interface/peripheral_interface_spi.c @@ -23,6 +23,7 @@ #include #include +#include "peripheral_interface_common.h" #include "peripheral_interface_spi.h" #include "peripheral_common.h" #include "peripheral_internal.h" @@ -40,12 +41,7 @@ int peripheral_interface_spi_close(peripheral_spi_h spi) RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd"); status = close(spi->fd); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to close fd : %d", spi->fd); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -58,12 +54,7 @@ int peripheral_interface_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_ RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd"); status = ioctl(spi->fd, SPI_IOC_WR_MODE, &mode); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to set mode(%d) : %s", mode, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -76,12 +67,7 @@ int peripheral_interface_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_ RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd"); status = ioctl(spi->fd, SPI_IOC_WR_LSB_FIRST, &bit_order); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to set lsb first(%d), fd : %d, errmsg : %s", bit_order, spi->fd, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -94,12 +80,7 @@ int peripheral_interface_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bit RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd"); status = ioctl(spi->fd, SPI_IOC_WR_BITS_PER_WORD, &bits); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to set bits(%d), fd : %d, errmsg : %s", bits, spi->fd, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -112,12 +93,7 @@ int peripheral_interface_spi_set_frequency(peripheral_spi_h spi, uint32_t freq) RETVM_IF(spi->fd < 0, -EINVAL, "Invalid fd"); status = ioctl(spi->fd, SPI_IOC_WR_MAX_SPEED_HZ, &freq); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to set frequency(%d), fd : %d, errmsg : %s", freq, spi->fd, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -134,12 +110,7 @@ int peripheral_interface_spi_read(peripheral_spi_h spi, uint8_t *rxbuf, uint32_t xfer.len = length; status = ioctl(spi->fd, SPI_IOC_MESSAGE(1), &xfer); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to read data, fd : %d, length : %d, errmsg : %s", spi->fd, length, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -156,12 +127,7 @@ int peripheral_interface_spi_write(peripheral_spi_h spi, uint8_t *txbuf, uint32_ xfer.len = length; status = ioctl(spi->fd, SPI_IOC_MESSAGE(1), &xfer); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to write data(%d) : %s", length, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -181,12 +147,7 @@ int peripheral_interface_spi_transfer(peripheral_spi_h spi, uint8_t *txbuf, uint xfer.len = length; status = ioctl(spi->fd, SPI_IOC_MESSAGE(1), &xfer); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to exchange data(%d) : %s", length, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c index 4933ab4..a0f9637 100644 --- a/src/interface/peripheral_interface_uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -24,6 +24,7 @@ #include #include +#include "peripheral_interface_common.h" #include "peripheral_interface_uart.h" #include "peripheral_common.h" #include "peripheral_internal.h" @@ -65,20 +66,10 @@ int peripheral_interface_uart_close(peripheral_uart_h uart) } status = peripheral_interface_uart_flush(uart); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to close fd : %d, errmsg : %s", uart->fd, errmsg); - return -EIO; - } + CHECK_ERROR(status); status = close(uart->fd); - if (status < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("Failed to close fd : %d, errmsg : %s", uart->fd, errmsg); - return -EIO; - } + CHECK_ERROR(status); return 0; } @@ -93,12 +84,7 @@ int peripheral_interface_uart_flush(peripheral_uart_h uart) } ret = tcflush(uart->fd, TCIOFLUSH); - if (ret < 0) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcflush failed, errmsg : %s", errmsg); - return -1; - } + CHECK_ERROR(ret); return 0; } @@ -122,12 +108,8 @@ int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, peripheral_u } ret = tcgetattr(uart->fd, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcgetattr failed, errmsg : %s", errmsg); - return -1; - } + CHECK_ERROR(ret); + tio.c_cflag = peripheral_uart_br[baud]; tio.c_iflag = IGNPAR; tio.c_oflag = 0; @@ -137,12 +119,7 @@ int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, peripheral_u peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcsetattr failed, errmsg: %s", errmsg); - return -1; - } + CHECK_ERROR(ret); return 0; } @@ -165,12 +142,8 @@ int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, peripheral_u } ret = tcgetattr(uart->fd, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcgetattr failed, errmsg: %s", errmsg); - return -1; - } + CHECK_ERROR(ret); + /* set byte size */ tio.c_cflag &= ~CSIZE; @@ -179,12 +152,7 @@ int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, peripheral_u peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcsetattr failed, errmsg : %s", errmsg); - return -1; - } + CHECK_ERROR(ret); return 0; } @@ -202,12 +170,7 @@ int peripheral_interface_uart_set_parity(peripheral_uart_h uart, peripheral_uart } ret = tcgetattr(uart->fd, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcgetattr failed, errmsg: %s", errmsg); - return -1; - } + CHECK_ERROR(ret); /* set parity info */ switch (parity) { @@ -228,12 +191,7 @@ int peripheral_interface_uart_set_parity(peripheral_uart_h uart, peripheral_uart peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcsetattr failed, errmsg : %s", errmsg); - return -1; - } + CHECK_ERROR(ret); return 0; } @@ -251,12 +209,7 @@ int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, peripheral_u } ret = tcgetattr(uart->fd, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcgetattr failed, errmsg: %s", errmsg); - return -1; - } + CHECK_ERROR(ret); /* set stop bit */ switch (stop_bits) { @@ -273,12 +226,7 @@ int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, peripheral_u peripheral_interface_uart_flush(uart); ret = tcsetattr(uart->fd, TCSANOW, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcsetattr failed, errmsg : %s", errmsg); - return -1; - } + CHECK_ERROR(ret); return 0; } @@ -296,12 +244,7 @@ int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, periphera } ret = tcgetattr(uart->fd, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcgetattr failed, errmsg : %s", errmsg); - return -1; - } + CHECK_ERROR(ret); if (rtscts == PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS) tio.c_cflag |= CRTSCTS; @@ -318,12 +261,7 @@ int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, periphera return -EINVAL; ret = tcsetattr(uart->fd, TCSANOW, &tio); - if (ret) { - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("tcsetattr failed, errmsg : %s", errmsg); - return -1; - } + CHECK_ERROR(ret); return 0; } @@ -338,14 +276,7 @@ int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, uint32_ } ret = read(uart->fd, (void *)buf, length); - if (ret <= 0) { - if (errno == EAGAIN) - return -EAGAIN; - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("read failed, errmsg : %s", errmsg); - return -EIO; - } + CHECK_ERROR(ret); return ret; } @@ -360,14 +291,7 @@ int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, uint32 } ret = write(uart->fd, buf, length); - if (ret <= 0) { - if (errno == EAGAIN) - return -EAGAIN; - char errmsg[MAX_ERR_LEN]; - strerror_r(errno, errmsg, MAX_ERR_LEN); - _E("write failed, errmsg : %s", errmsg); - return -EIO; - } + CHECK_ERROR(ret); return ret; } -- 2.7.4 From 04503068e5448f9b551778212a58302087e53fe8 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 17:54:05 +0900 Subject: [PATCH 07/16] gdbus: move gdbus files to top level gdbus folder Change-Id: If08e00e576cb8bdb099a740768870a6bdcf41d8b Signed-off-by: Segwon --- CMakeLists.txt | 17 +++++++++-------- include/{ => gdbus}/peripheral_gdbus.h | 0 include/{ => gdbus}/peripheral_gdbus_gpio.h | 0 include/{ => gdbus}/peripheral_gdbus_i2c.h | 0 include/{ => gdbus}/peripheral_gdbus_pwm.h | 0 include/{ => gdbus}/peripheral_gdbus_spi.h | 0 include/{ => gdbus}/peripheral_gdbus_uart.h | 0 src/{ => gdbus}/peripheral_gdbus_gpio.c | 0 src/{ => gdbus}/peripheral_gdbus_i2c.c | 0 src/{ => gdbus}/peripheral_gdbus_pwm.c | 0 src/{ => gdbus}/peripheral_gdbus_spi.c | 0 src/{ => gdbus}/peripheral_gdbus_uart.c | 0 src/{ => gdbus}/peripheral_io.xml | 0 src/peripheral_gpio.c | 2 +- 14 files changed, 10 insertions(+), 9 deletions(-) rename include/{ => gdbus}/peripheral_gdbus.h (100%) rename include/{ => gdbus}/peripheral_gdbus_gpio.h (100%) rename include/{ => gdbus}/peripheral_gdbus_i2c.h (100%) rename include/{ => gdbus}/peripheral_gdbus_pwm.h (100%) rename include/{ => gdbus}/peripheral_gdbus_spi.h (100%) rename include/{ => gdbus}/peripheral_gdbus_uart.h (100%) rename src/{ => gdbus}/peripheral_gdbus_gpio.c (100%) rename src/{ => gdbus}/peripheral_gdbus_i2c.c (100%) rename src/{ => gdbus}/peripheral_gdbus_pwm.c (100%) rename src/{ => gdbus}/peripheral_gdbus_spi.c (100%) rename src/{ => gdbus}/peripheral_gdbus_uart.c (100%) rename src/{ => gdbus}/peripheral_io.xml (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 335e42a..9b17fa7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,14 +19,15 @@ SET(VERSION ${version}) FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen) EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS " \\ - --generate-c-code ${CMAKE_SOURCE_DIR}/src/peripheral_io_gdbus \\ + --generate-c-code ${CMAKE_SOURCE_DIR}/src/gdbus/peripheral_io_gdbus \\ --c-namespace PeripheralIoGdbus \\ --interface-prefix org.tizen.peripheral_io. \\ - ${CMAKE_SOURCE_DIR}/src/peripheral_io.xml \\ + ${CMAKE_SOURCE_DIR}/src/gdbus/peripheral_io.xml \\ ") SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) +INCLUDE_DIRECTORIES(${INC_DIR}/gdbus) INCLUDE_DIRECTORIES(${INC_DIR}/interface) INCLUDE(FindPkgConfig) @@ -53,12 +54,12 @@ SET(SOURCES src/peripheral_gpio.c src/interface/peripheral_interface_pwm.c src/interface/peripheral_interface_spi.c src/interface/peripheral_interface_uart.c - src/peripheral_gdbus_gpio.c - src/peripheral_gdbus_i2c.c - src/peripheral_gdbus_pwm.c - src/peripheral_gdbus_uart.c - src/peripheral_gdbus_spi.c - src/peripheral_io_gdbus.c) + src/gdbus/peripheral_gdbus_gpio.c + src/gdbus/peripheral_gdbus_i2c.c + src/gdbus/peripheral_gdbus_pwm.c + src/gdbus/peripheral_gdbus_uart.c + src/gdbus/peripheral_gdbus_spi.c + src/gdbus/peripheral_io_gdbus.c) ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) diff --git a/include/peripheral_gdbus.h b/include/gdbus/peripheral_gdbus.h similarity index 100% rename from include/peripheral_gdbus.h rename to include/gdbus/peripheral_gdbus.h diff --git a/include/peripheral_gdbus_gpio.h b/include/gdbus/peripheral_gdbus_gpio.h similarity index 100% rename from include/peripheral_gdbus_gpio.h rename to include/gdbus/peripheral_gdbus_gpio.h diff --git a/include/peripheral_gdbus_i2c.h b/include/gdbus/peripheral_gdbus_i2c.h similarity index 100% rename from include/peripheral_gdbus_i2c.h rename to include/gdbus/peripheral_gdbus_i2c.h diff --git a/include/peripheral_gdbus_pwm.h b/include/gdbus/peripheral_gdbus_pwm.h similarity index 100% rename from include/peripheral_gdbus_pwm.h rename to include/gdbus/peripheral_gdbus_pwm.h diff --git a/include/peripheral_gdbus_spi.h b/include/gdbus/peripheral_gdbus_spi.h similarity index 100% rename from include/peripheral_gdbus_spi.h rename to include/gdbus/peripheral_gdbus_spi.h diff --git a/include/peripheral_gdbus_uart.h b/include/gdbus/peripheral_gdbus_uart.h similarity index 100% rename from include/peripheral_gdbus_uart.h rename to include/gdbus/peripheral_gdbus_uart.h diff --git a/src/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c similarity index 100% rename from src/peripheral_gdbus_gpio.c rename to src/gdbus/peripheral_gdbus_gpio.c diff --git a/src/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c similarity index 100% rename from src/peripheral_gdbus_i2c.c rename to src/gdbus/peripheral_gdbus_i2c.c diff --git a/src/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c similarity index 100% rename from src/peripheral_gdbus_pwm.c rename to src/gdbus/peripheral_gdbus_pwm.c diff --git a/src/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c similarity index 100% rename from src/peripheral_gdbus_spi.c rename to src/gdbus/peripheral_gdbus_spi.c diff --git a/src/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c similarity index 100% rename from src/peripheral_gdbus_uart.c rename to src/gdbus/peripheral_gdbus_uart.c diff --git a/src/peripheral_io.xml b/src/gdbus/peripheral_io.xml similarity index 100% rename from src/peripheral_io.xml rename to src/gdbus/peripheral_io.xml diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index 408ed0a..c80e9c9 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -19,12 +19,12 @@ #include #include #include +#include #include "peripheral_io.h" #include "peripheral_gdbus_gpio.h" #include "peripheral_common.h" #include "peripheral_internal.h" -#include "peripheral_io_gdbus.h" #define PERIPHERAL_IO_GPIO_FEATURE "http://tizen.org/feature/peripheral_io.gpio" -- 2.7.4 From 3f5e52ec5533ad263a83eb43f87f0d93904a71e3 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 19:58:32 +0900 Subject: [PATCH 08/16] [4/6] fd passing: get file descriptor list from daemon through gdbus - save the received fds to handle. - it only receive fds when the open function is run. Change-Id: Iaa3c87adaab0254c519b2f695068ae79850e3a23 Signed-off-by: Segwon --- src/gdbus/peripheral_gdbus_gpio.c | 31 +++++++++++++++++++++++++++++++ src/gdbus/peripheral_gdbus_i2c.c | 15 +++++++++++++++ src/gdbus/peripheral_gdbus_pwm.c | 39 +++++++++++++++++++++++++++++++++++++++ src/gdbus/peripheral_gdbus_spi.c | 15 +++++++++++++++ src/gdbus/peripheral_gdbus_uart.c | 15 +++++++++++++++ src/gdbus/peripheral_io.xml | 5 +++++ 6 files changed, 120 insertions(+) diff --git a/src/gdbus/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c index 42025de..52fce3e 100644 --- a/src/gdbus/peripheral_gdbus_gpio.c +++ b/src/gdbus/peripheral_gdbus_gpio.c @@ -16,6 +16,7 @@ #include #include +#include #include "peripheral_io.h" #include "peripheral_gdbus.h" @@ -23,6 +24,10 @@ #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" +#define GPIO_FD_INDEX_DIRECTION 0 +#define GPIO_FD_INDEX_EDGE 1 +#define GPIO_FD_INDEX_VALUE 2 + extern int peripheral_gpio_interrupted_cb_handler(int pin, int value, unsigned long long timestamp, int err); static PeripheralIoGdbusGpio *gpio_proxy = NULL; @@ -77,14 +82,17 @@ int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio) { GError *error = NULL; gint32 ret = PERIPHERAL_ERROR_NONE; + GUnixFDList *fd_list = NULL; if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; if (peripheral_io_gdbus_gpio_call_open_sync( gpio_proxy, gpio->pin, + NULL, &gpio->handle, &ret, + &fd_list, NULL, &error) == FALSE) { _E("Error in %s() : %s", __func__, error->message); @@ -92,6 +100,29 @@ int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio) return PERIPHERAL_ERROR_UNKNOWN; } + gpio->fd_direction = g_unix_fd_list_get(fd_list, GPIO_FD_INDEX_DIRECTION, &error); + if (gpio->fd_direction < 0) { + _E("Failed to get fd for gpio direction : %s", error->message); + g_error_free(error); + ret = PERIPHERAL_ERROR_UNKNOWN; + } + + 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; + } + + 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; + } + + g_object_unref(fd_list); + return ret; } diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c index e0a39ac..a3290ab 100644 --- a/src/gdbus/peripheral_gdbus_i2c.c +++ b/src/gdbus/peripheral_gdbus_i2c.c @@ -16,6 +16,7 @@ #include #include +#include #include "peripheral_io.h" #include "peripheral_gdbus.h" @@ -23,6 +24,8 @@ #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" +#define I2C_FD_INDEX 0 + static PeripheralIoGdbusI2c *i2c_proxy = NULL; void i2c_proxy_init(void) @@ -56,6 +59,7 @@ int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) { GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; + GUnixFDList *fd_list = NULL; if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; @@ -63,8 +67,10 @@ int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) i2c_proxy, bus, address, + NULL, &i2c->handle, &ret, + &fd_list, NULL, &error) == FALSE) { _E("Error in %s() : %s", __func__, error->message); @@ -72,6 +78,15 @@ int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) return PERIPHERAL_ERROR_UNKNOWN; } + i2c->fd = g_unix_fd_list_get(fd_list, I2C_FD_INDEX, &error); + if (i2c->fd < 0) { + _E("Failed to get fd for i2c : %s", error->message); + g_error_free(error); + ret = PERIPHERAL_ERROR_UNKNOWN; + } + + g_object_unref(fd_list); + return ret; } diff --git a/src/gdbus/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c index e1fdae9..1eb3435 100644 --- a/src/gdbus/peripheral_gdbus_pwm.c +++ b/src/gdbus/peripheral_gdbus_pwm.c @@ -16,6 +16,7 @@ #include #include +#include #include "peripheral_io.h" #include "peripheral_gdbus.h" @@ -23,6 +24,11 @@ #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" +#define PWM_FD_INDEX_PERIOD 0 +#define PWM_FD_INDEX_DUTY_CYCLE 1 +#define PWM_FD_INDEX_POLARITY 2 +#define PWM_FD_INDEX_ENABLE 3 + static PeripheralIoGdbusPwm *pwm_proxy = NULL; void pwm_proxy_init(void) @@ -56,6 +62,7 @@ int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) { GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; + GUnixFDList *fd_list = NULL; if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; @@ -63,8 +70,10 @@ int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) pwm_proxy, chip, pin, + NULL, &pwm->handle, &ret, + &fd_list, NULL, &error) == FALSE) { _E("%s", error->message); @@ -72,6 +81,36 @@ int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) return PERIPHERAL_ERROR_UNKNOWN; } + pwm->fd_period = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_PERIOD, &error); + if (pwm->fd_period < 0) { + _E("Failed to get fd for pwm period : %s", error->message); + g_error_free(error); + ret = PERIPHERAL_ERROR_UNKNOWN; + } + + 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; + } + + 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; + } + + 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; + } + + g_object_unref(fd_list); + return ret; } diff --git a/src/gdbus/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c index cc7a8a5..2959835 100644 --- a/src/gdbus/peripheral_gdbus_spi.c +++ b/src/gdbus/peripheral_gdbus_spi.c @@ -16,6 +16,7 @@ #include #include +#include #include "peripheral_io.h" #include "peripheral_gdbus.h" @@ -23,6 +24,8 @@ #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" +#define SPI_FD_INDEX 0 + static PeripheralIoGdbusSpi *spi_proxy = NULL; void spi_proxy_init(void) @@ -56,6 +59,7 @@ int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) { GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; + GUnixFDList *fd_list = NULL; if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; @@ -63,8 +67,10 @@ int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) spi_proxy, bus, cs, + NULL, &spi->handle, &ret, + &fd_list, NULL, &error) == FALSE) { _E("%s", error->message); @@ -72,6 +78,15 @@ int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) return PERIPHERAL_ERROR_UNKNOWN; } + spi->fd = g_unix_fd_list_get(fd_list, SPI_FD_INDEX, &error); + if (spi->fd < 0) { + _E("Failed to get fd for spi : %s", error->message); + g_error_free(error); + ret = PERIPHERAL_ERROR_UNKNOWN; + } + + g_object_unref(fd_list); + return ret; } diff --git a/src/gdbus/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c index 78bc0c0..e7e57b6 100644 --- a/src/gdbus/peripheral_gdbus_uart.c +++ b/src/gdbus/peripheral_gdbus_uart.c @@ -16,6 +16,7 @@ #include #include +#include #include "peripheral_io.h" #include "peripheral_gdbus.h" @@ -23,6 +24,8 @@ #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" +#define UART_FD_INDEX 0 + static PeripheralIoGdbusUart *uart_proxy = NULL; void uart_proxy_init(void) @@ -56,14 +59,17 @@ int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port) { GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; + GUnixFDList *fd_list = NULL; if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; if (peripheral_io_gdbus_uart_call_open_sync( uart_proxy, port, + NULL, &uart->handle, &ret, + &fd_list, NULL, &error) == FALSE) { _E("Error in %s() : %s", __func__, error->message); @@ -71,6 +77,15 @@ int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port) return PERIPHERAL_ERROR_UNKNOWN; } + uart->fd = g_unix_fd_list_get(fd_list, UART_FD_INDEX, &error); + if (uart->fd < 0) { + _E("Failed to get fd for uart : %s", error->message); + g_error_free(error); + ret = PERIPHERAL_ERROR_UNKNOWN; + } + + g_object_unref(fd_list); + return ret; } diff --git a/src/gdbus/peripheral_io.xml b/src/gdbus/peripheral_io.xml index 466efac..30ceaa6 100644 --- a/src/gdbus/peripheral_io.xml +++ b/src/gdbus/peripheral_io.xml @@ -2,6 +2,7 @@ + @@ -46,6 +47,7 @@ + @@ -83,6 +85,7 @@ + @@ -115,6 +118,7 @@ + @@ -168,6 +172,7 @@ + -- 2.7.4 From bbbec795a3b6a1def61758f532a3f3133d32a116 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 20:22:09 +0900 Subject: [PATCH 09/16] [5/6] fd passing: remove unnecessary gdbus functions. Change-Id: Ic2c0ae84608851344191606101dcef82df3786de Signed-off-by: Segwon --- include/gdbus/peripheral_gdbus_gpio.h | 6 - include/gdbus/peripheral_gdbus_i2c.h | 3 - include/gdbus/peripheral_gdbus_pwm.h | 4 - include/gdbus/peripheral_gdbus_spi.h | 7 -- include/gdbus/peripheral_gdbus_uart.h | 7 -- src/gdbus/peripheral_gdbus_gpio.c | 148 +----------------------- src/gdbus/peripheral_gdbus_i2c.c | 98 +--------------- src/gdbus/peripheral_gdbus_pwm.c | 90 +-------------- src/gdbus/peripheral_gdbus_spi.c | 208 +--------------------------------- src/gdbus/peripheral_gdbus_uart.c | 183 +----------------------------- src/gdbus/peripheral_io.xml | 167 --------------------------- src/peripheral_gpio.c | 118 +------------------ src/peripheral_i2c.c | 46 +++----- src/peripheral_pwm.c | 24 ++-- src/peripheral_spi.c | 43 +++---- src/peripheral_uart.c | 49 +++----- 16 files changed, 62 insertions(+), 1139 deletions(-) diff --git a/include/gdbus/peripheral_gdbus_gpio.h b/include/gdbus/peripheral_gdbus_gpio.h index 39c67c5..f9e35e6 100644 --- a/include/gdbus/peripheral_gdbus_gpio.h +++ b/include/gdbus/peripheral_gdbus_gpio.h @@ -22,11 +22,5 @@ void gpio_proxy_deinit(void); int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio); int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio); -int peripheral_gdbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction); -int peripheral_gdbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge); -int peripheral_gdbus_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data); -int peripheral_gdbus_gpio_unset_interrupted_cb(peripheral_gpio_h gpio); -int peripheral_gdbus_gpio_read(peripheral_gpio_h gpio, int *value); -int peripheral_gdbus_gpio_write(peripheral_gpio_h gpio, int value); #endif /* __PERIPHERAL_GDBUS_GPIO_H__ */ diff --git a/include/gdbus/peripheral_gdbus_i2c.h b/include/gdbus/peripheral_gdbus_i2c.h index 7b2b899..30604c7 100644 --- a/include/gdbus/peripheral_gdbus_i2c.h +++ b/include/gdbus/peripheral_gdbus_i2c.h @@ -22,8 +22,5 @@ void i2c_proxy_deinit(void); int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address); int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c); -int peripheral_gdbus_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length); -int peripheral_gdbus_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length); -int peripheral_gdbus_i2c_smbus_ioctl(peripheral_i2c_h i2c, uint8_t read_write, uint8_t command, uint32_t size, uint16_t data_in, uint16_t *data_out); #endif /* __PERIPHERAL_GDBUS_I2C_H__ */ diff --git a/include/gdbus/peripheral_gdbus_pwm.h b/include/gdbus/peripheral_gdbus_pwm.h index f6d4c1c..0ce6159 100644 --- a/include/gdbus/peripheral_gdbus_pwm.h +++ b/include/gdbus/peripheral_gdbus_pwm.h @@ -22,9 +22,5 @@ void pwm_proxy_deinit(void); int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin); int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm); -int peripheral_gdbus_pwm_set_period(peripheral_pwm_h pwm, int period); -int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle_ns); -int peripheral_gdbus_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity); -int peripheral_gdbus_pwm_set_enable(peripheral_pwm_h pwm, bool enable); #endif /* __PERIPHERAL_GDBUS_PWM_H__ */ diff --git a/include/gdbus/peripheral_gdbus_spi.h b/include/gdbus/peripheral_gdbus_spi.h index 7ab743a..d6be9b5 100644 --- a/include/gdbus/peripheral_gdbus_spi.h +++ b/include/gdbus/peripheral_gdbus_spi.h @@ -21,12 +21,5 @@ void spi_proxy_deinit(); int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs); int peripheral_gdbus_spi_close(peripheral_spi_h spi); -int peripheral_gdbus_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode); -int peripheral_gdbus_spi_set_bit_order(peripheral_spi_h spi, bool lsb); -int peripheral_gdbus_spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits); -int peripheral_gdbus_spi_set_frequency(peripheral_spi_h spi, unsigned int freq_hz); -int peripheral_gdbus_spi_read(peripheral_spi_h spi, unsigned char *data, int length); -int peripheral_gdbus_spi_write(peripheral_spi_h spi, unsigned char *data, int length); -int peripheral_gdbus_spi_transfer(peripheral_spi_h spi, unsigned char *tx_data, unsigned char *rx_data, int length); #endif /* __PERIPHERAL_GDBUS_SPI_H_ */ diff --git a/include/gdbus/peripheral_gdbus_uart.h b/include/gdbus/peripheral_gdbus_uart.h index 15b5d06..d19440c 100644 --- a/include/gdbus/peripheral_gdbus_uart.h +++ b/include/gdbus/peripheral_gdbus_uart.h @@ -21,12 +21,5 @@ void uart_proxy_deinit(); int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port); int peripheral_gdbus_uart_close(peripheral_uart_h uart); -int peripheral_gdbus_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud); -int peripheral_gdbus_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size); -int peripheral_gdbus_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity); -int peripheral_gdbus_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits); -int peripheral_gdbus_uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts); -int peripheral_gdbus_uart_read(peripheral_uart_h uart, uint8_t *data, int length); -int peripheral_gdbus_uart_write(peripheral_uart_h uart, uint8_t *data, int length); #endif /* __PERIPHERAL_GDBUS_UART_H_ */ diff --git a/src/gdbus/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c index 52fce3e..17a7f2f 100644 --- a/src/gdbus/peripheral_gdbus_gpio.c +++ b/src/gdbus/peripheral_gdbus_gpio.c @@ -28,19 +28,8 @@ #define GPIO_FD_INDEX_EDGE 1 #define GPIO_FD_INDEX_VALUE 2 -extern int peripheral_gpio_interrupted_cb_handler(int pin, int value, unsigned long long timestamp, int err); - static PeripheralIoGdbusGpio *gpio_proxy = NULL; -static void __peripheral_gpio_interrupted_cb(PeripheralIoGdbusGpio *gpio, gint pin, gint value, guint64 timestamp, gpointer user_data) -{ - int err = PERIPHERAL_ERROR_NONE; - if (!gpio) - err = PERIPHERAL_ERROR_IO_ERROR; - - peripheral_gpio_interrupted_cb_handler(pin, value, timestamp, err); -} - void gpio_proxy_init(void) { GError *error = NULL; @@ -62,11 +51,6 @@ void gpio_proxy_init(void) g_error_free(error); return; } - - g_signal_connect(gpio_proxy, - "interrupted-cb", - G_CALLBACK(__peripheral_gpio_interrupted_cb), - NULL); } void gpio_proxy_deinit() @@ -145,134 +129,4 @@ int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio) } return ret; -} - -int peripheral_gdbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_gpio_call_set_direction_sync( - gpio_proxy, - gpio->handle, - direction, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_gpio_call_set_edge_mode_sync( - gpio_proxy, - gpio->handle, - edge, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_gpio_call_set_interrupted_cb_sync( - gpio_proxy, - gpio->handle, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_gpio_unset_interrupted_cb(peripheral_gpio_h gpio) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_gpio_call_unset_interrupted_cb_sync( - gpio_proxy, - gpio->handle, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_gpio_read(peripheral_gpio_h gpio, int *value) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_gpio_call_read_sync( - gpio_proxy, - gpio->handle, - value, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_gpio_write(peripheral_gpio_h gpio, int value) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_gpio_call_write_sync( - gpio_proxy, - gpio->handle, - value, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} +} \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c index a3290ab..63fda68 100644 --- a/src/gdbus/peripheral_gdbus_i2c.c +++ b/src/gdbus/peripheral_gdbus_i2c.c @@ -109,100 +109,4 @@ int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c) } return ret; -} - -int peripheral_gdbus_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - GVariant *data_array; - GVariantIter *iter; - guint8 str; - int i = 0; - - if (i2c_proxy == NULL || data == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_i2c_call_read_sync( - i2c_proxy, - i2c->handle, - length, - &data_array, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - g_variant_get(data_array, "a(y)", &iter); - while (g_variant_iter_loop(iter, "(y)", &str)) { - data[i] = str; - if (i++ == length) break; - } - g_variant_iter_free(iter); - g_variant_unref(data_array); - - return ret; -} - -int peripheral_gdbus_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - GVariantBuilder *builder; - GVariant *g_data; - int i = 0; - - if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - - for (i = 0; i < length; i++) - g_variant_builder_add(builder, "(y)", data[i]); - g_variant_builder_add(builder, "(y)", 0x00); - - g_data = g_variant_new("a(y)", builder); - g_variant_builder_unref(builder); - - if (peripheral_io_gdbus_i2c_call_write_sync( - i2c_proxy, - i2c->handle, - length, - g_data, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_i2c_smbus_ioctl(peripheral_i2c_h i2c, uint8_t read_write, uint8_t command, uint32_t size, uint16_t data_in, uint16_t *data_out) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_i2c_call_smbus_ioctl_sync( - i2c_proxy, - i2c->handle, - read_write, - command, - size, - data_in, - data_out, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} +} \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c index 1eb3435..f512e2c 100644 --- a/src/gdbus/peripheral_gdbus_pwm.c +++ b/src/gdbus/peripheral_gdbus_pwm.c @@ -133,92 +133,4 @@ int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm) } return ret; -} - -int peripheral_gdbus_pwm_set_period(peripheral_pwm_h pwm, int period) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_pwm_call_set_period_sync( - pwm_proxy, - pwm->handle, - period, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle_ns) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_pwm_call_set_duty_cycle_sync( - pwm_proxy, - pwm->handle, - duty_cycle_ns, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_pwm_call_set_polarity_sync( - pwm_proxy, - pwm->handle, - polarity, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_pwm_set_enable(peripheral_pwm_h pwm, bool enable) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_pwm_call_set_enable_sync( - pwm_proxy, - pwm->handle, - enable, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} +} \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c index 2959835..e286f40 100644 --- a/src/gdbus/peripheral_gdbus_spi.c +++ b/src/gdbus/peripheral_gdbus_spi.c @@ -109,210 +109,4 @@ int peripheral_gdbus_spi_close(peripheral_spi_h spi) } return ret; -} - -int peripheral_gdbus_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_spi_call_set_mode_sync( - spi_proxy, - spi->handle, - (guchar)mode, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_spi_set_bit_order(peripheral_spi_h spi, bool lsb) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_spi_call_set_bit_order_sync( - spi_proxy, - spi->handle, - lsb, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_spi_call_set_bits_per_word_sync( - spi_proxy, - spi->handle, - bits, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_spi_set_frequency(peripheral_spi_h spi, unsigned int freq_hz) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - - if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_spi_call_set_frequency_sync( - spi_proxy, - spi->handle, - freq_hz, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_spi_read(peripheral_spi_h spi, unsigned char *data, int length) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - GVariant *data_array; - GVariantIter *iter; - guint8 str; - int i = 0; - - if (spi_proxy == NULL || data == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_spi_call_read_sync( - spi_proxy, - spi->handle, - length, - &data_array, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - g_variant_get(data_array, "a(y)", &iter); - while (g_variant_iter_loop(iter, "(y)", &str)) { - data[i] = str; - if (i++ == length) break; - } - g_variant_iter_free(iter); - g_variant_unref(data_array); - - return ret; -} - -int peripheral_gdbus_spi_write(peripheral_spi_h spi, unsigned char *data, int length) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - GVariantBuilder *builder; - GVariant *data_array; - int i = 0; - - if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - - for (i = 0; i < length; i++) - g_variant_builder_add(builder, "(y)", data[i]); - g_variant_builder_add(builder, "(y)", 0x00); - - data_array = g_variant_new("a(y)", builder); - g_variant_builder_unref(builder); - - if (peripheral_io_gdbus_spi_call_write_sync( - spi_proxy, - spi->handle, - length, - data_array, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_spi_transfer(peripheral_spi_h spi, unsigned char *tx_data, unsigned char *rx_data, int length) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - GVariantBuilder *builder; - GVariant *rx_data_array; - GVariant *tx_data_array; - GVariantIter *iter; - guint8 str; - int i = 0; - - if (spi_proxy == NULL || !rx_data || !tx_data) return PERIPHERAL_ERROR_UNKNOWN; - - builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - - for (i = 0; i < length; i++) - g_variant_builder_add(builder, "(y)", tx_data[i]); - g_variant_builder_add(builder, "(y)", 0x00); - - tx_data_array = g_variant_new("a(y)", builder); - g_variant_builder_unref(builder); - - if (peripheral_io_gdbus_spi_call_transfer_sync( - spi_proxy, - spi->handle, - length, - tx_data_array, - &rx_data_array, - &ret, - NULL, - &error) == FALSE) { - _E("%s", error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - i = 0; - g_variant_get(rx_data_array, "a(y)", &iter); - while (g_variant_iter_loop(iter, "(y)", &str)) { - rx_data[i] = str; - if (i++ == length) break; - } - g_variant_iter_free(iter); - g_variant_unref(rx_data_array); - - return ret; -} +} \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c index e7e57b6..16111dd 100644 --- a/src/gdbus/peripheral_gdbus_uart.c +++ b/src/gdbus/peripheral_gdbus_uart.c @@ -108,185 +108,4 @@ int peripheral_gdbus_uart_close(peripheral_uart_h uart) } return ret; -} - -int peripheral_gdbus_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud) -{ - GError *error = NULL; - gint32 ret = PERIPHERAL_ERROR_NONE; - - if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_uart_call_set_baud_rate_sync( - uart_proxy, - uart->handle, - baud, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size) -{ - GError *error = NULL; - gint32 ret = PERIPHERAL_ERROR_NONE; - - if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_uart_call_set_byte_size_sync( - uart_proxy, - uart->handle, - byte_size, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity) -{ - GError *error = NULL; - gint32 ret = PERIPHERAL_ERROR_NONE; - - if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_uart_call_set_parity_sync( - uart_proxy, - uart->handle, - parity, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits) -{ - GError *error = NULL; - gint32 ret = PERIPHERAL_ERROR_NONE; - - if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_uart_call_set_stop_bits_sync( - uart_proxy, - uart->handle, - stop_bits, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts) -{ - GError *error = NULL; - gint32 ret = PERIPHERAL_ERROR_NONE; - - if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_uart_call_set_flow_control_sync( - uart_proxy, - uart->handle, - xonxoff, - rtscts, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} - -int peripheral_gdbus_uart_read(peripheral_uart_h uart, uint8_t *data, int length) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - GVariant *data_array; - GVariantIter *iter; - guint8 str; - int i = 0; - - if (uart_proxy == NULL || data == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - if (peripheral_io_gdbus_uart_call_read_sync( - uart_proxy, - uart->handle, - length, - &data_array, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - g_variant_get(data_array, "a(y)", &iter); - while (g_variant_iter_loop(iter, "(y)", &str)) { - data[i] = str; - if (i++ == length) break; - } - g_variant_iter_free(iter); - g_variant_unref(data_array); - - return ret; -} - -int peripheral_gdbus_uart_write(peripheral_uart_h uart, uint8_t *data, int length) -{ - GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - GVariantBuilder *builder; - GVariant *g_data; - int i = 0; - - if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - - builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - - for (i = 0; i < length; i++) - g_variant_builder_add(builder, "(y)", data[i]); - g_variant_builder_add(builder, "(y)", 0x00); - - g_data = g_variant_new("a(y)", builder); - g_variant_builder_unref(builder); - - if (peripheral_io_gdbus_uart_call_write_sync( - uart_proxy, - uart->handle, - length, - g_data, - &ret, - NULL, - &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); - g_error_free(error); - return PERIPHERAL_ERROR_UNKNOWN; - } - - return ret; -} +} \ No newline at end of file diff --git a/src/gdbus/peripheral_io.xml b/src/gdbus/peripheral_io.xml index 30ceaa6..00c49e7 100644 --- a/src/gdbus/peripheral_io.xml +++ b/src/gdbus/peripheral_io.xml @@ -11,39 +11,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -57,31 +24,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -95,26 +37,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -127,48 +49,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -182,52 +62,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index c80e9c9..a66cbaa 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -48,87 +48,6 @@ static bool __is_feature_supported() return (gpio_feature == GPIO_FEATURE_TRUE ? true : false); } -typedef struct { - peripheral_gpio_h handle; - peripheral_gpio_interrupted_cb callback; - void *user_data; -} interrupted_cb_info_s; - -static GList *interrupted_cb_info_list = NULL; - -int peripheral_gpio_interrupted_cb_handler(int pin, int value, unsigned long long timestamp, int error) -{ - GList *link; - interrupted_cb_info_s *cb_info; - - link = interrupted_cb_info_list; - while (link) { - cb_info = (interrupted_cb_info_s*)link->data; - if (cb_info->handle->pin == pin) { - if (cb_info->callback) - cb_info->callback(cb_info->handle, error, cb_info->user_data); - return PERIPHERAL_ERROR_NONE; - } - link = g_list_next(link); - } - - return PERIPHERAL_ERROR_NONE; -} - -static int __interrupted_cb_info_list_append(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data) -{ - GList *link; - interrupted_cb_info_s *cb_info = NULL; - - link = interrupted_cb_info_list; - while (link) { - interrupted_cb_info_s *tmp; - tmp = (interrupted_cb_info_s*)link->data; - if (tmp->handle == gpio) { - cb_info = tmp; - break; - } - link = g_list_next(link); - } - - if (cb_info == NULL) { - cb_info = (interrupted_cb_info_s*)calloc(1, sizeof(interrupted_cb_info_s)); - if (cb_info == NULL) { - _E("failed to allocate interrupted_cb_info_s"); - return PERIPHERAL_ERROR_OUT_OF_MEMORY; - } - - interrupted_cb_info_list = g_list_append(interrupted_cb_info_list, cb_info); - } - - cb_info->handle = gpio; - cb_info->callback = callback; - cb_info->user_data = user_data; - - return PERIPHERAL_ERROR_NONE; -} - -static int __interrupted_cb_info_list_remove(peripheral_gpio_h gpio) -{ - GList *link; - interrupted_cb_info_s *cb_info; - - link = interrupted_cb_info_list; - while (link) { - cb_info = (interrupted_cb_info_s*)link->data; - - if (cb_info->handle == gpio) { - interrupted_cb_info_list = g_list_remove_link(interrupted_cb_info_list, link); - free(link->data); - g_list_free(link); - break; - } - link = g_list_next(link); - } - - return PERIPHERAL_ERROR_NONE; -} - /** * @brief Initializes(export) gpio pin and creates gpio handle. */ @@ -200,9 +119,7 @@ int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direct 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 */ - ret = peripheral_gdbus_gpio_set_direction(gpio, direction); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set gpio direction, ret : %d", ret); + // TODO : replace interface function return ret; } @@ -220,9 +137,7 @@ int peripheral_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e 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 */ - ret = peripheral_gdbus_gpio_set_edge_mode(gpio, edge); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set edge mode of the gpio pin, ret : %d", ret); + // TODO : replace interface function return ret; } @@ -238,16 +153,7 @@ int peripheral_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_i RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL"); RETVM_IF(callback == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio interrupted callback is NULL"); - ret = peripheral_gdbus_gpio_set_interrupted_cb(gpio, callback, user_data); - if (ret != PERIPHERAL_ERROR_NONE) { - _E("Failed to set gpio interrupted cb, ret : %d", ret); - return ret; - } - - /* set isr */ - ret = __interrupted_cb_info_list_append(gpio, callback, user_data); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to append gpio interrupt callback info, ret : %d", ret); + // TODO : replace interface function return ret; } @@ -262,15 +168,7 @@ int peripheral_gpio_unset_interrupted_cb(peripheral_gpio_h gpio) 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"); - ret = peripheral_gdbus_gpio_unset_interrupted_cb(gpio); - if (ret != PERIPHERAL_ERROR_NONE) { - _E("Failed to unset gpio interrupt callback, ret : %d", ret); - return ret; - } - - ret = __interrupted_cb_info_list_remove(gpio); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to remove gpio interrupt callback info, ret : %d", ret); + // TODO : replace interface function return ret; } @@ -287,9 +185,7 @@ int peripheral_gpio_read(peripheral_gpio_h gpio, uint32_t *value) RETVM_IF(value == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio read value is invalid"); /* call gpio_read */ - ret = peripheral_gdbus_gpio_read(gpio, (int *)value); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to read value of the gpio pin, ret : %d", ret); + // TODO : replace interface function return ret; } @@ -306,9 +202,7 @@ int peripheral_gpio_write(peripheral_gpio_h gpio, uint32_t value) RETVM_IF((value != 0) && (value != 1), PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio value is invalid"); /* call gpio_write */ - ret = peripheral_gdbus_gpio_write(gpio, (int)value); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to write to the gpio pin, ret : %d", ret); + // TODO : replace interface function return ret; } diff --git a/src/peripheral_i2c.c b/src/peripheral_i2c.c index 5d32bf3..60e0c59 100644 --- a/src/peripheral_i2c.c +++ b/src/peripheral_i2c.c @@ -90,7 +90,7 @@ int peripheral_i2c_open(int bus, int address, peripheral_i2c_h *i2c) int peripheral_i2c_close(peripheral_i2c_h i2c) { - int ret; + 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"); @@ -108,96 +108,76 @@ int peripheral_i2c_close(peripheral_i2c_h i2c) int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length) { - int ret; + 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"); - ret = peripheral_gdbus_i2c_read(i2c, data, (int)length); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to read data from device, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length) { - int ret; + 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"); - ret = peripheral_gdbus_i2c_write(i2c, data, (int)length); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to write data to device, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data) { - int ret; - uint16_t w_data, dummy = 0; + 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"); - ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_READ, reg, I2C_SMBUS_BYTE_DATA, dummy, &w_data); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Smbus transaction failed, ret : %d", ret); - - *data = (uint8_t)w_data; + // TODO : replace interface function return ret; } int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data) { - int ret; - uint16_t dummy = 0; + 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"); - ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_WRITE, reg, I2C_SMBUS_BYTE_DATA, (uint16_t)data, &dummy); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Smbus transaction failed, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data) { - int ret; - uint16_t dummy = 0, data_out; + 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"); - ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_READ, reg, I2C_SMBUS_WORD_DATA, dummy, &data_out); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Smbus transaction failed, ret : %d", ret); - - *data = data_out; + // TODO : replace interface function return ret; } int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data) { - int ret; - uint16_t dummy = 0; + 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"); - ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_WRITE, reg, I2C_SMBUS_WORD_DATA, data, &dummy); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Smbus transaction failed, ret : %d", ret); + // TODO : replace interface function return ret; } diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index fdd0de7..1329bf1 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -98,57 +98,49 @@ int peripheral_pwm_close(peripheral_pwm_h pwm) int peripheral_pwm_set_period(peripheral_pwm_h pwm, uint32_t period_ns) { - int ret; + 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"); - ret = peripheral_gdbus_pwm_set_period(pwm, (int)period_ns); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set period, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle_ns) { - int ret; + 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"); - ret = peripheral_gdbus_pwm_set_duty_cycle(pwm, (int)duty_cycle_ns); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set duty cycle, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity) { - int ret; + 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"); - ret = peripheral_gdbus_pwm_set_polarity(pwm, polarity); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set polarity, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, bool enable) { - int ret; + 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"); - ret = peripheral_gdbus_pwm_set_enable(pwm, enable); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set enable, ret : %d", ret); + // TODO : replace interface function return ret; } diff --git a/src/peripheral_spi.c b/src/peripheral_spi.c index 34e777c..b25dee4 100644 --- a/src/peripheral_spi.c +++ b/src/peripheral_spi.c @@ -99,104 +99,89 @@ int peripheral_spi_close(peripheral_spi_h spi) int peripheral_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode) { - int ret; + 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"); - ret = peripheral_gdbus_spi_set_mode(spi, mode); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set mode, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order) { - int ret; + 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"); - bool lsb = (bit_order == PERIPHERAL_SPI_BIT_ORDER_LSB) ? true : false; - ret = peripheral_gdbus_spi_set_bit_order(spi, lsb); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set lsb first, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits) { - int ret; + 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"); - ret = peripheral_gdbus_spi_set_bits_per_word(spi, (unsigned char)bits); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set bits per word, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_spi_set_frequency(peripheral_spi_h spi, uint32_t freq_hz) { - int ret; + 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"); - ret = peripheral_gdbus_spi_set_frequency(spi, (unsigned int)freq_hz); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set frequency, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_spi_read(peripheral_spi_h spi, uint8_t *data, uint32_t length) { - int ret; + 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"); - ret = peripheral_gdbus_spi_read(spi, data, (int)length); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to read from spi device, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_spi_write(peripheral_spi_h spi, uint8_t *data, uint32_t length) { - int ret; + 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"); - ret = peripheral_gdbus_spi_write(spi, data, (int)length); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to write to spi device, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_spi_transfer(peripheral_spi_h spi, uint8_t *txdata, uint8_t *rxdata, uint32_t length) { - int ret; + 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"); - ret = peripheral_gdbus_spi_transfer(spi, txdata, rxdata, (int)length); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to read and write, ret : %d", ret); + // TODO : replace interface function return ret; } diff --git a/src/peripheral_uart.c b/src/peripheral_uart.c index 10ef561..70d711a 100644 --- a/src/peripheral_uart.c +++ b/src/peripheral_uart.c @@ -54,7 +54,7 @@ static bool __is_feature_supported() int peripheral_uart_open(int port, peripheral_uart_h *uart) { peripheral_uart_h handle; - int ret; + 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, "Invalid uart handle"); @@ -86,7 +86,7 @@ int peripheral_uart_open(int port, peripheral_uart_h *uart) */ int peripheral_uart_close(peripheral_uart_h uart) { - int ret; + 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"); @@ -107,60 +107,52 @@ int peripheral_uart_close(peripheral_uart_h uart) */ int peripheral_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud) { - int ret; + 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"); - ret = peripheral_gdbus_uart_set_baud_rate(uart, baud); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set baudrate, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size) { - int ret; + 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"); - ret = peripheral_gdbus_uart_set_byte_size(uart, byte_size); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set uart mode, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity) { - int ret; + 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"); - ret = peripheral_gdbus_uart_set_parity(uart, parity); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set uart mode, ret : %d", ret); + // TODO : replace interface function return ret; } int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits) { - int ret; + 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"); - ret = peripheral_gdbus_uart_set_stop_bits(uart, stop_bits); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set uart mode, ret : %d", ret); + // TODO : replace interface function return ret; } @@ -171,19 +163,14 @@ int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_b */ 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; + 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"); - bool xonxoff = (sw_flow_control == PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF) ? true : false; - bool rtscts = (hw_flow_control == PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS) ? true : false; - - ret = peripheral_gdbus_uart_set_flow_control(uart, xonxoff, rtscts); - if (ret != PERIPHERAL_ERROR_NONE) - _E("Failed to set flocontrol, ret : %d", ret); + // TODO : replace interface function return ret; } @@ -193,15 +180,13 @@ int peripheral_uart_set_flow_control(peripheral_uart_h uart, peripheral_uart_sof */ int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length) { - int ret; + 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"); - ret = peripheral_gdbus_uart_read(uart, data, (int)length); - if (ret < PERIPHERAL_ERROR_NONE) - _E("Failed to read from uart device, ret : %d", ret); + // TODO : replace interface function return ret; } @@ -211,15 +196,13 @@ int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length) */ int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, uint32_t length) { - int ret; + 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"); - ret = peripheral_gdbus_uart_write(uart, data, (int)length); - if (ret < PERIPHERAL_ERROR_NONE) - _E("Failed to write to uart device, ret : %d", ret); + // TODO : replace interface function return ret; } -- 2.7.4 From 2841452b5dfca59cee77e1bb749013a8244a9306 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 22:13:29 +0900 Subject: [PATCH 10/16] gdbus: refactor gdbus proxy functions - changed to static - proxy init function has been modified to return error. Change-Id: I220d66e31d19c4cd7e27caa18f2c5cd2cba19b00 Signed-off-by: Segwon --- include/gdbus/peripheral_gdbus_gpio.h | 3 --- include/gdbus/peripheral_gdbus_i2c.h | 3 --- include/gdbus/peripheral_gdbus_pwm.h | 3 --- include/gdbus/peripheral_gdbus_spi.h | 3 --- include/gdbus/peripheral_gdbus_uart.h | 3 --- src/gdbus/peripheral_gdbus_gpio.c | 27 +++++++++++++++++++-------- src/gdbus/peripheral_gdbus_i2c.c | 26 +++++++++++++++++++++----- src/gdbus/peripheral_gdbus_pwm.c | 26 +++++++++++++++++++++----- src/gdbus/peripheral_gdbus_spi.c | 26 +++++++++++++++++++++----- src/gdbus/peripheral_gdbus_uart.c | 27 +++++++++++++++++++++------ src/peripheral_gpio.c | 4 ---- src/peripheral_i2c.c | 3 --- src/peripheral_pwm.c | 3 --- src/peripheral_spi.c | 3 --- src/peripheral_uart.c | 3 --- 15 files changed, 103 insertions(+), 60 deletions(-) diff --git a/include/gdbus/peripheral_gdbus_gpio.h b/include/gdbus/peripheral_gdbus_gpio.h index f9e35e6..3fd5307 100644 --- a/include/gdbus/peripheral_gdbus_gpio.h +++ b/include/gdbus/peripheral_gdbus_gpio.h @@ -17,9 +17,6 @@ #ifndef __PERIPHERAL_GDBUS_GPIO_H__ #define __PERIPHERAL_GDBUS_GPIO_H__ -void gpio_proxy_init(void); -void gpio_proxy_deinit(void); - int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio); int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio); diff --git a/include/gdbus/peripheral_gdbus_i2c.h b/include/gdbus/peripheral_gdbus_i2c.h index 30604c7..0670442 100644 --- a/include/gdbus/peripheral_gdbus_i2c.h +++ b/include/gdbus/peripheral_gdbus_i2c.h @@ -17,9 +17,6 @@ #ifndef __PERIPHERAL_GDBUS_I2C_H__ #define __PERIPHERAL_GDBUS_I2C_H__ -void i2c_proxy_init(void); -void i2c_proxy_deinit(void); - int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address); int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c); diff --git a/include/gdbus/peripheral_gdbus_pwm.h b/include/gdbus/peripheral_gdbus_pwm.h index 0ce6159..148e938 100644 --- a/include/gdbus/peripheral_gdbus_pwm.h +++ b/include/gdbus/peripheral_gdbus_pwm.h @@ -17,9 +17,6 @@ #ifndef __PERIPHERAL_GDBUS_PWM_H__ #define __PERIPHERAL_GDBUS_PWM_H__ -void pwm_proxy_init(void); -void pwm_proxy_deinit(void); - int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin); int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm); diff --git a/include/gdbus/peripheral_gdbus_spi.h b/include/gdbus/peripheral_gdbus_spi.h index d6be9b5..8a6ac61 100644 --- a/include/gdbus/peripheral_gdbus_spi.h +++ b/include/gdbus/peripheral_gdbus_spi.h @@ -16,9 +16,6 @@ #ifndef __PERIPHERAL_GDBUS_SPI_H_ #define __PERIPHERAL_GDBUS_SPI_H_ -void spi_proxy_init(void); -void spi_proxy_deinit(); - int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs); int peripheral_gdbus_spi_close(peripheral_spi_h spi); diff --git a/include/gdbus/peripheral_gdbus_uart.h b/include/gdbus/peripheral_gdbus_uart.h index d19440c..175452c 100644 --- a/include/gdbus/peripheral_gdbus_uart.h +++ b/include/gdbus/peripheral_gdbus_uart.h @@ -16,9 +16,6 @@ #ifndef __PERIPHERAL_GDBUS_UART_H_ #define __PERIPHERAL_GDBUS_UART_H_ -void uart_proxy_init(void); -void uart_proxy_deinit(); - int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port); int peripheral_gdbus_uart_close(peripheral_uart_h uart); diff --git a/src/gdbus/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c index 17a7f2f..ca5badd 100644 --- a/src/gdbus/peripheral_gdbus_gpio.c +++ b/src/gdbus/peripheral_gdbus_gpio.c @@ -30,13 +30,14 @@ static PeripheralIoGdbusGpio *gpio_proxy = NULL; -void gpio_proxy_init(void) +static int __gpio_proxy_init() { GError *error = NULL; if (gpio_proxy != NULL) { + _E("Gpio proxy is already created"); g_object_ref(gpio_proxy); - return; + return PERIPHERAL_ERROR_NONE; } gpio_proxy = peripheral_io_gdbus_gpio_proxy_new_for_bus_sync( @@ -46,16 +47,19 @@ void gpio_proxy_init(void) PERIPHERAL_GDBUS_GPIO_PATH, NULL, &error); + if (gpio_proxy == NULL) { - _E("Can not create gpio proxy : %s", error->message); + _E("Failed to create gpio proxy : %s", error->message); g_error_free(error); - return; + return PERIPHERAL_ERROR_UNKNOWN; } + + return PERIPHERAL_ERROR_NONE; } -void gpio_proxy_deinit() +static void __gpio_proxy_deinit() { - if (gpio_proxy) { + if (gpio_proxy != NULL) { g_object_unref(gpio_proxy); if (!G_IS_OBJECT(gpio_proxy)) gpio_proxy = NULL; @@ -68,7 +72,9 @@ int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio) gint32 ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; - if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + ret = __gpio_proxy_init(); + if (ret != PERIPHERAL_ERROR_NONE) + return ret; if (peripheral_io_gdbus_gpio_call_open_sync( gpio_proxy, @@ -115,7 +121,10 @@ int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio) GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + if (gpio_proxy == NULL) { + _E("Can't try to gpio close because gpio proxy is NULL."); + return PERIPHERAL_ERROR_UNKNOWN; + } if (peripheral_io_gdbus_gpio_call_close_sync( gpio_proxy, @@ -128,5 +137,7 @@ int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio) return PERIPHERAL_ERROR_UNKNOWN; } + __gpio_proxy_deinit(); + return ret; } \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c index 63fda68..b10b10f 100644 --- a/src/gdbus/peripheral_gdbus_i2c.c +++ b/src/gdbus/peripheral_gdbus_i2c.c @@ -28,13 +28,14 @@ static PeripheralIoGdbusI2c *i2c_proxy = NULL; -void i2c_proxy_init(void) +static int __i2c_proxy_init() { GError *error = NULL; if (i2c_proxy != NULL) { + _E("I2c proxy is already created"); g_object_ref(i2c_proxy); - return; + return PERIPHERAL_ERROR_NONE; } i2c_proxy = peripheral_io_gdbus_i2c_proxy_new_for_bus_sync( @@ -44,9 +45,17 @@ void i2c_proxy_init(void) PERIPHERAL_GDBUS_I2C_PATH, NULL, &error); + + if (i2c_proxy == NULL) { + _E("Failed to create i2c proxy : %s", error->message); + g_error_free(error); + return PERIPHERAL_ERROR_UNKNOWN; + } + + return PERIPHERAL_ERROR_NONE; } -void i2c_proxy_deinit() +static void __i2c_proxy_deinit() { if (i2c_proxy) { g_object_unref(i2c_proxy); @@ -61,7 +70,9 @@ int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) peripheral_error_e ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; - if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + ret = __i2c_proxy_init(); + if (ret != PERIPHERAL_ERROR_NONE) + return ret; if (peripheral_io_gdbus_i2c_call_open_sync( i2c_proxy, @@ -95,7 +106,10 @@ int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c) GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + if (i2c_proxy == NULL) { + _E("Can't try to i2c close because i2c proxy is NULL."); + return PERIPHERAL_ERROR_UNKNOWN; + } if (peripheral_io_gdbus_i2c_call_close_sync( i2c_proxy, @@ -108,5 +122,7 @@ int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c) return PERIPHERAL_ERROR_UNKNOWN; } + __i2c_proxy_deinit(); + return ret; } \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c index f512e2c..3279d15 100644 --- a/src/gdbus/peripheral_gdbus_pwm.c +++ b/src/gdbus/peripheral_gdbus_pwm.c @@ -31,13 +31,14 @@ static PeripheralIoGdbusPwm *pwm_proxy = NULL; -void pwm_proxy_init(void) +static int __pwm_proxy_init() { GError *error = NULL; if (pwm_proxy != NULL) { + _E("Pwm proxy is already created"); g_object_ref(pwm_proxy); - return; + return PERIPHERAL_ERROR_NONE; } pwm_proxy = peripheral_io_gdbus_pwm_proxy_new_for_bus_sync( @@ -47,9 +48,17 @@ void pwm_proxy_init(void) PERIPHERAL_GDBUS_PWM_PATH, NULL, &error); + + if (pwm_proxy == NULL) { + _E("Failed to create pwm proxy : %s", error->message); + g_error_free(error); + return PERIPHERAL_ERROR_UNKNOWN; + } + + return PERIPHERAL_ERROR_NONE; } -void pwm_proxy_deinit() +static void __pwm_proxy_deinit() { if (pwm_proxy) { g_object_unref(pwm_proxy); @@ -64,7 +73,9 @@ int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) peripheral_error_e ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; - if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + ret = __pwm_proxy_init(); + if (ret != PERIPHERAL_ERROR_NONE) + return ret; if (peripheral_io_gdbus_pwm_call_open_sync( pwm_proxy, @@ -119,7 +130,10 @@ int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm) GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + if (pwm_proxy == NULL) { + _E("Can't try to pwm close because pwm proxy is NULL."); + return PERIPHERAL_ERROR_UNKNOWN; + } if (peripheral_io_gdbus_pwm_call_close_sync( pwm_proxy, @@ -132,5 +146,7 @@ int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm) return PERIPHERAL_ERROR_UNKNOWN; } + __pwm_proxy_deinit(); + return ret; } \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c index e286f40..80e267a 100644 --- a/src/gdbus/peripheral_gdbus_spi.c +++ b/src/gdbus/peripheral_gdbus_spi.c @@ -28,13 +28,14 @@ static PeripheralIoGdbusSpi *spi_proxy = NULL; -void spi_proxy_init(void) +static int __spi_proxy_init() { GError *error = NULL; if (spi_proxy != NULL) { + _E("Spi proxy is already created"); g_object_ref(spi_proxy); - return; + return PERIPHERAL_ERROR_NONE; } spi_proxy = peripheral_io_gdbus_spi_proxy_new_for_bus_sync( @@ -44,9 +45,17 @@ void spi_proxy_init(void) PERIPHERAL_GDBUS_SPI_PATH, NULL, &error); + + if (spi_proxy == NULL) { + _E("Failed to create spi proxy : %s", error->message); + g_error_free(error); + return PERIPHERAL_ERROR_UNKNOWN; + } + + return PERIPHERAL_ERROR_NONE; } -void spi_proxy_deinit() +static void __spi_proxy_deinit() { if (spi_proxy) { g_object_unref(spi_proxy); @@ -61,7 +70,9 @@ int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) peripheral_error_e ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; - if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + ret = __spi_proxy_init(); + if (ret != PERIPHERAL_ERROR_NONE) + return ret; if (peripheral_io_gdbus_spi_call_open_sync( spi_proxy, @@ -95,7 +106,10 @@ int peripheral_gdbus_spi_close(peripheral_spi_h spi) GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + if (spi_proxy == NULL) { + _E("Can't try to spi close because spi proxy is NULL."); + return PERIPHERAL_ERROR_UNKNOWN; + } if (peripheral_io_gdbus_spi_call_close_sync( spi_proxy, @@ -108,5 +122,7 @@ int peripheral_gdbus_spi_close(peripheral_spi_h spi) return PERIPHERAL_ERROR_UNKNOWN; } + __spi_proxy_deinit(); + return ret; } \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c index 16111dd..99620b6 100644 --- a/src/gdbus/peripheral_gdbus_uart.c +++ b/src/gdbus/peripheral_gdbus_uart.c @@ -28,13 +28,14 @@ static PeripheralIoGdbusUart *uart_proxy = NULL; -void uart_proxy_init(void) +static int __uart_proxy_init() { GError *error = NULL; if (uart_proxy != NULL) { + _E("Uart proxy is already created"); g_object_ref(uart_proxy); - return; + return PERIPHERAL_ERROR_NONE; } uart_proxy = peripheral_io_gdbus_uart_proxy_new_for_bus_sync( @@ -44,9 +45,17 @@ void uart_proxy_init(void) PERIPHERAL_GDBUS_UART_PATH, NULL, &error); + + if (uart_proxy == NULL) { + _E("Failed to create uart proxy : %s", error->message); + g_error_free(error); + return PERIPHERAL_ERROR_UNKNOWN; + } + + return PERIPHERAL_ERROR_NONE; } -void uart_proxy_deinit() +static void __uart_proxy_deinit() { if (uart_proxy) { g_object_unref(uart_proxy); @@ -61,7 +70,9 @@ int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port) peripheral_error_e ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; - if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + ret = __uart_proxy_init(); + if (ret != PERIPHERAL_ERROR_NONE) + return ret; if (peripheral_io_gdbus_uart_call_open_sync( uart_proxy, @@ -94,8 +105,10 @@ int peripheral_gdbus_uart_close(peripheral_uart_h uart) GError *error = NULL; peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; - + if (uart_proxy == NULL) { + _E("Can't try to uart close because uart proxy is NULL."); + return PERIPHERAL_ERROR_UNKNOWN; + } if (peripheral_io_gdbus_uart_call_close_sync( uart_proxy, uart->handle, @@ -107,5 +120,7 @@ int peripheral_gdbus_uart_close(peripheral_uart_h uart) return PERIPHERAL_ERROR_UNKNOWN; } + __uart_proxy_deinit(); + return ret; } \ No newline at end of file diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index a66cbaa..6a03a5a 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -69,8 +69,6 @@ int peripheral_gpio_open(int gpio_pin, peripheral_gpio_h *gpio) } handle->pin = gpio_pin; - gpio_proxy_init(); - ret = peripheral_gdbus_gpio_open(handle); if (ret != PERIPHERAL_ERROR_NONE) { @@ -99,7 +97,6 @@ int peripheral_gpio_close(peripheral_gpio_h gpio) ret = peripheral_gdbus_gpio_close(gpio); if (ret != PERIPHERAL_ERROR_NONE) _E("Failed to close the gpio pin, ret : %d", ret); - gpio_proxy_deinit(); free(gpio); gpio = NULL; @@ -124,7 +121,6 @@ int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direct return ret; } - /** * @brief Sets the edge mode of the gpio pin. */ diff --git a/src/peripheral_i2c.c b/src/peripheral_i2c.c index 60e0c59..d729356 100644 --- a/src/peripheral_i2c.c +++ b/src/peripheral_i2c.c @@ -74,8 +74,6 @@ int peripheral_i2c_open(int bus, int address, peripheral_i2c_h *i2c) return PERIPHERAL_ERROR_OUT_OF_MEMORY; } - i2c_proxy_init(); - ret = peripheral_gdbus_i2c_open(handle, bus, address); if (ret != PERIPHERAL_ERROR_NONE) { @@ -98,7 +96,6 @@ int peripheral_i2c_close(peripheral_i2c_h i2c) ret = peripheral_gdbus_i2c_close(i2c); if (ret != PERIPHERAL_ERROR_NONE) _E("Failed to close i2c communcation, ret : %d", ret); - i2c_proxy_deinit(); free(i2c); i2c = NULL; diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index 1329bf1..e21bcbb 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -66,8 +66,6 @@ int peripheral_pwm_open(int chip, int pin, peripheral_pwm_h *pwm) return PERIPHERAL_ERROR_OUT_OF_MEMORY; } - pwm_proxy_init(); - ret = peripheral_gdbus_pwm_open(handle, chip, pin); if (ret != PERIPHERAL_ERROR_NONE) { @@ -90,7 +88,6 @@ int peripheral_pwm_close(peripheral_pwm_h pwm) if ((ret = peripheral_gdbus_pwm_close(pwm)) < 0) _E("Failed to close PWM chip, continuing anyway, ret : %d", ret); - pwm_proxy_deinit(); free(pwm); return ret; diff --git a/src/peripheral_spi.c b/src/peripheral_spi.c index b25dee4..68e9761 100644 --- a/src/peripheral_spi.c +++ b/src/peripheral_spi.c @@ -66,8 +66,6 @@ int peripheral_spi_open(int bus, int cs, peripheral_spi_h *spi) return PERIPHERAL_ERROR_OUT_OF_MEMORY; } - spi_proxy_init(); - ret = peripheral_gdbus_spi_open(handle, bus, cs); if (ret != PERIPHERAL_ERROR_NONE) { @@ -91,7 +89,6 @@ int peripheral_spi_close(peripheral_spi_h spi) if (ret < PERIPHERAL_ERROR_NONE) _E("Failed to close SPI device, continuing anyway, ret : %d", ret); - spi_proxy_deinit(); free(spi); return ret; diff --git a/src/peripheral_uart.c b/src/peripheral_uart.c index 70d711a..ad58c0c 100644 --- a/src/peripheral_uart.c +++ b/src/peripheral_uart.c @@ -67,8 +67,6 @@ int peripheral_uart_open(int port, peripheral_uart_h *uart) return PERIPHERAL_ERROR_OUT_OF_MEMORY; } - uart_proxy_init(); - ret = peripheral_gdbus_uart_open(handle, port); if (ret != PERIPHERAL_ERROR_NONE) { @@ -94,7 +92,6 @@ int peripheral_uart_close(peripheral_uart_h uart) ret = peripheral_gdbus_uart_close(uart); if (ret < PERIPHERAL_ERROR_NONE) _E("Failed to close uart communication, continuing anyway, ret : %d", ret); - uart_proxy_deinit(); free(uart); uart = NULL; -- 2.7.4 From 3ab40f8b2bb51572a4263ea0821fe27bd1dbc9e0 Mon Sep 17 00:00:00 2001 From: Segwon Date: Tue, 14 Nov 2017 22:27:05 +0900 Subject: [PATCH 11/16] gdbus: add check error in gdbus functions when gdbus request to daemon for open/close, it can receive return value TRUE with ret that it is not PERIPEHRAL_ERROR_NONE. In the case of requesting open to daemon, getting fd from list is meaningless. In the case of requesting close to daemon, proxy deinit function must not be run. Change-Id: I6ca7b1c98a15ca17159123903cd9d8ebe57c353c Signed-off-by: Segwon --- src/gdbus/peripheral_gdbus_gpio.c | 16 +++++++++++----- src/gdbus/peripheral_gdbus_i2c.c | 19 ++++++++++++------- src/gdbus/peripheral_gdbus_pwm.c | 18 ++++++++++++------ src/gdbus/peripheral_gdbus_spi.c | 18 ++++++++++++------ src/gdbus/peripheral_gdbus_uart.c | 19 +++++++++++++------ 5 files changed, 60 insertions(+), 30 deletions(-) diff --git a/src/gdbus/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c index ca5badd..d03ceda 100644 --- a/src/gdbus/peripheral_gdbus_gpio.c +++ b/src/gdbus/peripheral_gdbus_gpio.c @@ -68,8 +68,8 @@ static void __gpio_proxy_deinit() int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio) { + int ret; GError *error = NULL; - gint32 ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; ret = __gpio_proxy_init(); @@ -85,11 +85,15 @@ int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio) &fd_list, NULL, &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); + _E("Failed to request daemon to gpio open : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } + // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. + if (ret != PERIPHERAL_ERROR_NONE) + return ret; + gpio->fd_direction = g_unix_fd_list_get(fd_list, GPIO_FD_INDEX_DIRECTION, &error); if (gpio->fd_direction < 0) { _E("Failed to get fd for gpio direction : %s", error->message); @@ -118,8 +122,8 @@ int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio) int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; if (gpio_proxy == NULL) { _E("Can't try to gpio close because gpio proxy is NULL."); @@ -132,12 +136,14 @@ int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio) &ret, NULL, &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); + _E("Failed to request daemon to gpio close : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } - __gpio_proxy_deinit(); + // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request. + if (ret == PERIPHERAL_ERROR_NONE) + __gpio_proxy_deinit(); return ret; } \ No newline at end of file diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c index b10b10f..5ee8906 100644 --- a/src/gdbus/peripheral_gdbus_i2c.c +++ b/src/gdbus/peripheral_gdbus_i2c.c @@ -66,8 +66,8 @@ static void __i2c_proxy_deinit() int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; ret = __i2c_proxy_init(); @@ -84,16 +84,19 @@ int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) &fd_list, NULL, &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); + _E("Failed to request daemon to i2c open : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } + // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. + if (ret != PERIPHERAL_ERROR_NONE) + return ret; + i2c->fd = g_unix_fd_list_get(fd_list, I2C_FD_INDEX, &error); if (i2c->fd < 0) { _E("Failed to get fd for i2c : %s", error->message); g_error_free(error); - ret = PERIPHERAL_ERROR_UNKNOWN; } g_object_unref(fd_list); @@ -103,8 +106,8 @@ int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address) int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; if (i2c_proxy == NULL) { _E("Can't try to i2c close because i2c proxy is NULL."); @@ -117,12 +120,14 @@ int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c) &ret, NULL, &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); + _E("Failed to request daemon to i2c close : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } - __i2c_proxy_deinit(); + // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request. + if (ret == PERIPHERAL_ERROR_NONE) + __i2c_proxy_deinit(); return ret; -} \ No newline at end of file +} diff --git a/src/gdbus/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c index 3279d15..eb26bf5 100644 --- a/src/gdbus/peripheral_gdbus_pwm.c +++ b/src/gdbus/peripheral_gdbus_pwm.c @@ -69,8 +69,8 @@ static void __pwm_proxy_deinit() int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; ret = __pwm_proxy_init(); @@ -87,11 +87,15 @@ int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) &fd_list, NULL, &error) == FALSE) { - _E("%s", error->message); + _E("Failed to request daemon to pwm open : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } + // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. + if (ret != PERIPHERAL_ERROR_NONE) + return ret; + pwm->fd_period = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_PERIOD, &error); if (pwm->fd_period < 0) { _E("Failed to get fd for pwm period : %s", error->message); @@ -127,8 +131,8 @@ int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin) int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; if (pwm_proxy == NULL) { _E("Can't try to pwm close because pwm proxy is NULL."); @@ -141,12 +145,14 @@ int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm) &ret, NULL, &error) == FALSE) { - _E("%s", error->message); + _E("Failed to request daemon to pwm close : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } - __pwm_proxy_deinit(); + // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request. + if (ret == PERIPHERAL_ERROR_NONE) + __pwm_proxy_deinit(); return ret; -} \ No newline at end of file +} diff --git a/src/gdbus/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c index 80e267a..d58edfe 100644 --- a/src/gdbus/peripheral_gdbus_spi.c +++ b/src/gdbus/peripheral_gdbus_spi.c @@ -66,8 +66,8 @@ static void __spi_proxy_deinit() int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; ret = __spi_proxy_init(); @@ -84,11 +84,15 @@ int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) &fd_list, NULL, &error) == FALSE) { - _E("%s", error->message); + _E("Failed to request daemon to spi open : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } + // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. + if (ret != PERIPHERAL_ERROR_NONE) + return ret; + spi->fd = g_unix_fd_list_get(fd_list, SPI_FD_INDEX, &error); if (spi->fd < 0) { _E("Failed to get fd for spi : %s", error->message); @@ -103,8 +107,8 @@ int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs) int peripheral_gdbus_spi_close(peripheral_spi_h spi) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; if (spi_proxy == NULL) { _E("Can't try to spi close because spi proxy is NULL."); @@ -117,12 +121,14 @@ int peripheral_gdbus_spi_close(peripheral_spi_h spi) &ret, NULL, &error) == FALSE) { - _E("%s", error->message); + _E("Failed to request daemon to spi close : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } - __spi_proxy_deinit(); + // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request. + if (ret == PERIPHERAL_ERROR_NONE) + __spi_proxy_deinit(); return ret; -} \ No newline at end of file +} diff --git a/src/gdbus/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c index 99620b6..985f2b4 100644 --- a/src/gdbus/peripheral_gdbus_uart.c +++ b/src/gdbus/peripheral_gdbus_uart.c @@ -66,8 +66,8 @@ static void __uart_proxy_deinit() int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; GUnixFDList *fd_list = NULL; ret = __uart_proxy_init(); @@ -83,11 +83,15 @@ int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port) &fd_list, NULL, &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); + _E("Failed to request daemon to uart open : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } + // TODO : If ret is not PERIPHERAL_ERROR_NONE, fd list it NULL from daemon. + if (ret != PERIPHERAL_ERROR_NONE) + return ret; + uart->fd = g_unix_fd_list_get(fd_list, UART_FD_INDEX, &error); if (uart->fd < 0) { _E("Failed to get fd for uart : %s", error->message); @@ -102,25 +106,28 @@ int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port) int peripheral_gdbus_uart_close(peripheral_uart_h uart) { + int ret; GError *error = NULL; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; if (uart_proxy == NULL) { _E("Can't try to uart close because uart proxy is NULL."); return PERIPHERAL_ERROR_UNKNOWN; } + if (peripheral_io_gdbus_uart_call_close_sync( uart_proxy, uart->handle, &ret, NULL, &error) == FALSE) { - _E("Error in %s() : %s", __func__, error->message); + _E("Failed to request daemon to uart close : %s", error->message); g_error_free(error); return PERIPHERAL_ERROR_UNKNOWN; } - __uart_proxy_deinit(); + // TODO : If the return value is not PERIPHERAL_ERROR_NONE, the daemon returns status before close request. + if (ret == PERIPHERAL_ERROR_NONE) + __uart_proxy_deinit(); return ret; -} \ No newline at end of file +} -- 2.7.4 From 2f57c46d2d36e7de3cfbb4af31b6f1722b753d13 Mon Sep 17 00:00:00 2001 From: Segwon Date: Wed, 15 Nov 2017 10:57:02 +0900 Subject: [PATCH 12/16] gdbus: change 'peripheral_gdbus.h' file name to 'peripheral_gdbus_common.h' - for match with interface Change-Id: Ib6f2ee970976462c4b52d9a028a8ac956d17b80a Signed-off-by: Segwon --- include/gdbus/{peripheral_gdbus.h => peripheral_gdbus_common.h} | 6 +++--- src/gdbus/peripheral_gdbus_gpio.c | 2 +- src/gdbus/peripheral_gdbus_i2c.c | 2 +- src/gdbus/peripheral_gdbus_pwm.c | 2 +- src/gdbus/peripheral_gdbus_spi.c | 2 +- src/gdbus/peripheral_gdbus_uart.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) rename include/gdbus/{peripheral_gdbus.h => peripheral_gdbus_common.h} (90%) diff --git a/include/gdbus/peripheral_gdbus.h b/include/gdbus/peripheral_gdbus_common.h similarity index 90% rename from include/gdbus/peripheral_gdbus.h rename to include/gdbus/peripheral_gdbus_common.h index ff726de..685efdb 100644 --- a/include/gdbus/peripheral_gdbus.h +++ b/include/gdbus/peripheral_gdbus_common.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef __PERIPHERAL_GDBUS_H__ -#define __PERIPHERAL_GDBUS_H__ +#ifndef __PERIPHERAL_GDBUS_COMMON_H__ +#define __PERIPHERAL_GDBUS_COMMON_H__ #include @@ -26,4 +26,4 @@ #define PERIPHERAL_GDBUS_SPI_PATH "/Org/Tizen/Peripheral_io/Spi" #define PERIPHERAL_GDBUS_NAME "org.tizen.peripheral_io" -#endif /* __PERIPHERAL_GDBUS_H__ */ +#endif /* __PERIPHERAL_GDBUS_COMMON_H__ */ diff --git a/src/gdbus/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c index d03ceda..f5e6b0b 100644 --- a/src/gdbus/peripheral_gdbus_gpio.c +++ b/src/gdbus/peripheral_gdbus_gpio.c @@ -19,7 +19,7 @@ #include #include "peripheral_io.h" -#include "peripheral_gdbus.h" +#include "peripheral_gdbus_common.h" #include "peripheral_common.h" #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c index 5ee8906..767332b 100644 --- a/src/gdbus/peripheral_gdbus_i2c.c +++ b/src/gdbus/peripheral_gdbus_i2c.c @@ -19,7 +19,7 @@ #include #include "peripheral_io.h" -#include "peripheral_gdbus.h" +#include "peripheral_gdbus_common.h" #include "peripheral_common.h" #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" diff --git a/src/gdbus/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c index eb26bf5..e9b501b 100644 --- a/src/gdbus/peripheral_gdbus_pwm.c +++ b/src/gdbus/peripheral_gdbus_pwm.c @@ -19,7 +19,7 @@ #include #include "peripheral_io.h" -#include "peripheral_gdbus.h" +#include "peripheral_gdbus_common.h" #include "peripheral_common.h" #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" diff --git a/src/gdbus/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c index d58edfe..2d07cd3 100644 --- a/src/gdbus/peripheral_gdbus_spi.c +++ b/src/gdbus/peripheral_gdbus_spi.c @@ -19,7 +19,7 @@ #include #include "peripheral_io.h" -#include "peripheral_gdbus.h" +#include "peripheral_gdbus_common.h" #include "peripheral_common.h" #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" diff --git a/src/gdbus/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c index 985f2b4..32d7992 100644 --- a/src/gdbus/peripheral_gdbus_uart.c +++ b/src/gdbus/peripheral_gdbus_uart.c @@ -19,7 +19,7 @@ #include #include "peripheral_io.h" -#include "peripheral_gdbus.h" +#include "peripheral_gdbus_common.h" #include "peripheral_common.h" #include "peripheral_internal.h" #include "peripheral_io_gdbus.h" -- 2.7.4 From 26cf17a8048b905ce1ce236fe4cd5294b903df4f Mon Sep 17 00:00:00 2001 From: Segwon Date: Wed, 15 Nov 2017 11:03:38 +0900 Subject: [PATCH 13/16] including : move the '#include' duplicate written to common file Change-Id: I5926833c5cef4f5d82bcca78164289562b53c2ca Signed-off-by: Segwon --- CMakeLists.txt | 3 +++ include/gdbus/peripheral_gdbus_common.h | 9 +++++++++ include/gdbus/peripheral_gdbus_gpio.h | 2 ++ include/gdbus/peripheral_gdbus_i2c.h | 2 ++ include/gdbus/peripheral_gdbus_pwm.h | 2 ++ include/gdbus/peripheral_gdbus_spi.h | 3 +++ include/gdbus/peripheral_gdbus_uart.h | 3 +++ include/interface/peripheral_interface_common.h | 11 +++++++++++ include/interface/peripheral_interface_gpio.h | 2 +- include/interface/peripheral_interface_i2c.h | 4 +--- include/interface/peripheral_interface_pwm.h | 2 +- include/interface/peripheral_interface_spi.h | 2 +- include/interface/peripheral_interface_uart.h | 4 +--- src/gdbus/peripheral_gdbus_gpio.c | 10 +--------- src/gdbus/peripheral_gdbus_i2c.c | 10 +--------- src/gdbus/peripheral_gdbus_pwm.c | 10 +--------- src/gdbus/peripheral_gdbus_spi.c | 10 +--------- src/gdbus/peripheral_gdbus_uart.c | 10 +--------- src/interface/peripheral_interface_gpio.c | 11 ----------- src/interface/peripheral_interface_i2c.c | 9 --------- src/interface/peripheral_interface_pwm.c | 11 ----------- src/interface/peripheral_interface_spi.c | 9 --------- src/interface/peripheral_interface_uart.c | 11 ----------- 23 files changed, 45 insertions(+), 105 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b17fa7..7fd0979 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,9 @@ INCLUDE_DIRECTORIES(${INC_DIR}) INCLUDE_DIRECTORIES(${INC_DIR}/gdbus) INCLUDE_DIRECTORIES(${INC_DIR}/interface) +SET(SRC_DIR src) +INCLUDE_DIRECTORIES(${SRC_DIR}/gdbus) + INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) FOREACH(flag ${${fw_name}_CFLAGS}) diff --git a/include/gdbus/peripheral_gdbus_common.h b/include/gdbus/peripheral_gdbus_common.h index 685efdb..9a8450e 100644 --- a/include/gdbus/peripheral_gdbus_common.h +++ b/include/gdbus/peripheral_gdbus_common.h @@ -13,10 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __PERIPHERAL_GDBUS_COMMON_H__ #define __PERIPHERAL_GDBUS_COMMON_H__ #include +#include +#include +#include + +#include "peripheral_io.h" +#include "peripheral_internal.h" +#include "peripheral_common.h" +#include "peripheral_io_gdbus.h" #define PERIPHERAL_GDBUS_INTERFACE "org.tizen.peripheral_io" #define PERIPHERAL_GDBUS_GPIO_PATH "/Org/Tizen/Peripheral_io/Gpio" diff --git a/include/gdbus/peripheral_gdbus_gpio.h b/include/gdbus/peripheral_gdbus_gpio.h index 3fd5307..c63aeba 100644 --- a/include/gdbus/peripheral_gdbus_gpio.h +++ b/include/gdbus/peripheral_gdbus_gpio.h @@ -17,6 +17,8 @@ #ifndef __PERIPHERAL_GDBUS_GPIO_H__ #define __PERIPHERAL_GDBUS_GPIO_H__ +#include "peripheral_gdbus_common.h" + int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio); int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio); diff --git a/include/gdbus/peripheral_gdbus_i2c.h b/include/gdbus/peripheral_gdbus_i2c.h index 0670442..e1b1722 100644 --- a/include/gdbus/peripheral_gdbus_i2c.h +++ b/include/gdbus/peripheral_gdbus_i2c.h @@ -17,6 +17,8 @@ #ifndef __PERIPHERAL_GDBUS_I2C_H__ #define __PERIPHERAL_GDBUS_I2C_H__ +#include "peripheral_gdbus_common.h" + int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address); int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c); diff --git a/include/gdbus/peripheral_gdbus_pwm.h b/include/gdbus/peripheral_gdbus_pwm.h index 148e938..70a4b02 100644 --- a/include/gdbus/peripheral_gdbus_pwm.h +++ b/include/gdbus/peripheral_gdbus_pwm.h @@ -17,6 +17,8 @@ #ifndef __PERIPHERAL_GDBUS_PWM_H__ #define __PERIPHERAL_GDBUS_PWM_H__ +#include "peripheral_gdbus_common.h" + int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin); int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm); diff --git a/include/gdbus/peripheral_gdbus_spi.h b/include/gdbus/peripheral_gdbus_spi.h index 8a6ac61..94b2242 100644 --- a/include/gdbus/peripheral_gdbus_spi.h +++ b/include/gdbus/peripheral_gdbus_spi.h @@ -13,9 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __PERIPHERAL_GDBUS_SPI_H_ #define __PERIPHERAL_GDBUS_SPI_H_ +#include "peripheral_gdbus_common.h" + int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs); int peripheral_gdbus_spi_close(peripheral_spi_h spi); diff --git a/include/gdbus/peripheral_gdbus_uart.h b/include/gdbus/peripheral_gdbus_uart.h index 175452c..bf7af68 100644 --- a/include/gdbus/peripheral_gdbus_uart.h +++ b/include/gdbus/peripheral_gdbus_uart.h @@ -13,9 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __PERIPHERAL_GDBUS_UART_H_ #define __PERIPHERAL_GDBUS_UART_H_ +#include "peripheral_gdbus_common.h" + int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port); int peripheral_gdbus_uart_close(peripheral_uart_h uart); diff --git a/include/interface/peripheral_interface_common.h b/include/interface/peripheral_interface_common.h index 33a8d39..a69254e 100644 --- a/include/interface/peripheral_interface_common.h +++ b/include/interface/peripheral_interface_common.h @@ -17,6 +17,17 @@ #ifndef __PERIPHERAL_INTERFACE_COMMON_H__ #define __PERIPHERAL_INTERFACE_COMMON_H__ +#include +#include +#include +#include +#include +#include + +#include "peripheral_io.h" +#include "peripheral_internal.h" +#include "peripheral_common.h" + #define CHECK_ERROR(val) \ do { \ if (val < 0) { \ diff --git a/include/interface/peripheral_interface_gpio.h b/include/interface/peripheral_interface_gpio.h index cc68e92..ff3a794 100644 --- a/include/interface/peripheral_interface_gpio.h +++ b/include/interface/peripheral_interface_gpio.h @@ -17,7 +17,7 @@ #ifndef __PERIPHERAL_INTERFACE_GPIO_H__ #define __PERIPHERAL_INTERFACE_GPIO_H__ -#include "peripheral_io.h" +#include "peripheral_interface_common.h" #define SYSFS_GPIO_DIR "/sys/class/gpio" #define GPIO_BUFFER_MAX 64 diff --git a/include/interface/peripheral_interface_i2c.h b/include/interface/peripheral_interface_i2c.h index 41326d6..6e3dc23 100644 --- a/include/interface/peripheral_interface_i2c.h +++ b/include/interface/peripheral_interface_i2c.h @@ -17,9 +17,7 @@ #ifndef __PERIPHERAL_INTERFACE_I2C_H__ #define __PERIPHERAL_INTERFACE_I2C_H__ -#include - -#include "peripheral_io.h" +#include "peripheral_interface_common.h" #define SYSFS_I2C_DIR "/dev/i2c" #define I2C_BUFFER_MAX 64 diff --git a/include/interface/peripheral_interface_pwm.h b/include/interface/peripheral_interface_pwm.h index 0867663..f37b40d 100644 --- a/include/interface/peripheral_interface_pwm.h +++ b/include/interface/peripheral_interface_pwm.h @@ -17,7 +17,7 @@ #ifndef __PERIPHERAL_INTERFACE_PWM_H__ #define __PERIPHERAL_INTERFACE_PWM_H__ -#include "peripheral_io.h" +#include "peripheral_interface_common.h" /** * @brief pwm_close() deinit pwm pin. diff --git a/include/interface/peripheral_interface_spi.h b/include/interface/peripheral_interface_spi.h index d7a471d..801c324 100644 --- a/include/interface/peripheral_interface_spi.h +++ b/include/interface/peripheral_interface_spi.h @@ -17,7 +17,7 @@ #ifndef __PERIPHERAL_INTERFACE_SPI_H__ #define __PERIPHERAL_INTERFACE_SPI_H__ -#include "peripheral_io.h" +#include "peripheral_interface_common.h" int peripheral_interface_spi_close(peripheral_spi_h spi); int peripheral_interface_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode); diff --git a/include/interface/peripheral_interface_uart.h b/include/interface/peripheral_interface_uart.h index 4648ae1..c4c82ec 100644 --- a/include/interface/peripheral_interface_uart.h +++ b/include/interface/peripheral_interface_uart.h @@ -17,9 +17,7 @@ #ifndef __PERIPHERAL_INTERFACE_UART_H__ #define __PERIPHERAL_INTERFACE_UART_H__ -#include "peripheral_io.h" - -#include +#include "peripheral_interface_common.h" /** * @brief uart_close() closes uart port. diff --git a/src/gdbus/peripheral_gdbus_gpio.c b/src/gdbus/peripheral_gdbus_gpio.c index f5e6b0b..c8a6d8c 100644 --- a/src/gdbus/peripheral_gdbus_gpio.c +++ b/src/gdbus/peripheral_gdbus_gpio.c @@ -14,15 +14,7 @@ * limitations under the License. */ -#include -#include -#include - -#include "peripheral_io.h" -#include "peripheral_gdbus_common.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" -#include "peripheral_io_gdbus.h" +#include "peripheral_gdbus_gpio.h" #define GPIO_FD_INDEX_DIRECTION 0 #define GPIO_FD_INDEX_EDGE 1 diff --git a/src/gdbus/peripheral_gdbus_i2c.c b/src/gdbus/peripheral_gdbus_i2c.c index 767332b..29ba888 100644 --- a/src/gdbus/peripheral_gdbus_i2c.c +++ b/src/gdbus/peripheral_gdbus_i2c.c @@ -14,15 +14,7 @@ * limitations under the License. */ -#include -#include -#include - -#include "peripheral_io.h" -#include "peripheral_gdbus_common.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" -#include "peripheral_io_gdbus.h" +#include "peripheral_gdbus_i2c.h" #define I2C_FD_INDEX 0 diff --git a/src/gdbus/peripheral_gdbus_pwm.c b/src/gdbus/peripheral_gdbus_pwm.c index e9b501b..48ff164 100644 --- a/src/gdbus/peripheral_gdbus_pwm.c +++ b/src/gdbus/peripheral_gdbus_pwm.c @@ -14,15 +14,7 @@ * limitations under the License. */ -#include -#include -#include - -#include "peripheral_io.h" -#include "peripheral_gdbus_common.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" -#include "peripheral_io_gdbus.h" +#include "peripheral_gdbus_pwm.h" #define PWM_FD_INDEX_PERIOD 0 #define PWM_FD_INDEX_DUTY_CYCLE 1 diff --git a/src/gdbus/peripheral_gdbus_spi.c b/src/gdbus/peripheral_gdbus_spi.c index 2d07cd3..fce5a41 100644 --- a/src/gdbus/peripheral_gdbus_spi.c +++ b/src/gdbus/peripheral_gdbus_spi.c @@ -14,15 +14,7 @@ * limitations under the License. */ -#include -#include -#include - -#include "peripheral_io.h" -#include "peripheral_gdbus_common.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" -#include "peripheral_io_gdbus.h" +#include "peripheral_gdbus_spi.h" #define SPI_FD_INDEX 0 diff --git a/src/gdbus/peripheral_gdbus_uart.c b/src/gdbus/peripheral_gdbus_uart.c index 32d7992..852e244 100644 --- a/src/gdbus/peripheral_gdbus_uart.c +++ b/src/gdbus/peripheral_gdbus_uart.c @@ -14,15 +14,7 @@ * limitations under the License. */ -#include -#include -#include - -#include "peripheral_io.h" -#include "peripheral_gdbus_common.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" -#include "peripheral_io_gdbus.h" +#include "peripheral_gdbus_uart.h" #define UART_FD_INDEX 0 diff --git a/src/interface/peripheral_interface_gpio.c b/src/interface/peripheral_interface_gpio.c index 7d4ef2f..950de19 100644 --- a/src/interface/peripheral_interface_gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -14,18 +14,7 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include -#include - -#include "peripheral_interface_common.h" #include "peripheral_interface_gpio.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" #define MAX_ERR_LEN 255 diff --git a/src/interface/peripheral_interface_i2c.c b/src/interface/peripheral_interface_i2c.c index fadbf63..87be206 100644 --- a/src/interface/peripheral_interface_i2c.c +++ b/src/interface/peripheral_interface_i2c.c @@ -14,18 +14,9 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include #include -#include "peripheral_interface_common.h" #include "peripheral_interface_i2c.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" #define MAX_ERR_LEN 255 diff --git a/src/interface/peripheral_interface_pwm.c b/src/interface/peripheral_interface_pwm.c index faefc1a..bbfeefb 100644 --- a/src/interface/peripheral_interface_pwm.c +++ b/src/interface/peripheral_interface_pwm.c @@ -14,18 +14,7 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include -#include - -#include "peripheral_interface_common.h" #include "peripheral_interface_pwm.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" #define SYSFS_PWM_PATH "/sys/class/pwm" diff --git a/src/interface/peripheral_interface_spi.c b/src/interface/peripheral_interface_spi.c index 1c83726..e8a0fc6 100644 --- a/src/interface/peripheral_interface_spi.c +++ b/src/interface/peripheral_interface_spi.c @@ -14,19 +14,10 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include #include #include -#include "peripheral_interface_common.h" #include "peripheral_interface_spi.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" #define SYSFS_SPI_DIR "/dev/spidev" #define SYSFS_SPI_BUFSIZ "/sys/module/spidev/parameters/bufsiz" diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c index a0f9637..4944bb9 100644 --- a/src/interface/peripheral_interface_uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -14,20 +14,9 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include #include -#include -#include -#include "peripheral_interface_common.h" #include "peripheral_interface_uart.h" -#include "peripheral_common.h" -#include "peripheral_internal.h" #define PATH_BUF_MAX 64 #define UART_BUF_MAX 16 -- 2.7.4 From ca21b2731e07b6de6423a591a3c33afba2210f7f Mon Sep 17 00:00:00 2001 From: Segwon Date: Wed, 15 Nov 2017 11:59:38 +0900 Subject: [PATCH 14/16] handle: change file name 'peripheral_internal.h' to 'peripheral_handle.h' - the word 'internal' does not mean defining a handle structure. Change-Id: Ica3650be46eb2285aaa543b1aadd3ae0a0f822cf Signed-off-by: Segwon --- include/gdbus/peripheral_gdbus_common.h | 2 +- include/interface/peripheral_interface_common.h | 2 +- include/{peripheral_internal.h => peripheral_handle.h} | 6 +++--- src/peripheral_gpio.c | 2 +- src/peripheral_i2c.c | 2 +- src/peripheral_pwm.c | 2 +- src/peripheral_spi.c | 2 +- src/peripheral_uart.c | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) rename include/{peripheral_internal.h => peripheral_handle.h} (92%) diff --git a/include/gdbus/peripheral_gdbus_common.h b/include/gdbus/peripheral_gdbus_common.h index 9a8450e..ed8c397 100644 --- a/include/gdbus/peripheral_gdbus_common.h +++ b/include/gdbus/peripheral_gdbus_common.h @@ -23,7 +23,7 @@ #include #include "peripheral_io.h" -#include "peripheral_internal.h" +#include "peripheral_handle.h" #include "peripheral_common.h" #include "peripheral_io_gdbus.h" diff --git a/include/interface/peripheral_interface_common.h b/include/interface/peripheral_interface_common.h index a69254e..f0bd657 100644 --- a/include/interface/peripheral_interface_common.h +++ b/include/interface/peripheral_interface_common.h @@ -25,7 +25,7 @@ #include #include "peripheral_io.h" -#include "peripheral_internal.h" +#include "peripheral_handle.h" #include "peripheral_common.h" #define CHECK_ERROR(val) \ diff --git a/include/peripheral_internal.h b/include/peripheral_handle.h similarity index 92% rename from include/peripheral_internal.h rename to include/peripheral_handle.h index 5c62dee..be8a066 100644 --- a/include/peripheral_internal.h +++ b/include/peripheral_handle.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __PERIPHERAL_INTERNAL_H__ -#define __PERIPHERAL_INTERNAL_H__ +#ifndef __PERIPHERAL_HANDLE_H__ +#define __PERIPHERAL_HANDLE_H__ /** * @brief Internal struct for gpio context @@ -63,4 +63,4 @@ struct _peripheral_spi_s { int fd; }; -#endif /* __PERIPHERAL_INTERNAL_H__ */ +#endif /* __PERIPHERAL_HANDLE_H__ */ diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index 6a03a5a..06806ec 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -24,7 +24,7 @@ #include "peripheral_io.h" #include "peripheral_gdbus_gpio.h" #include "peripheral_common.h" -#include "peripheral_internal.h" +#include "peripheral_handle.h" #define PERIPHERAL_IO_GPIO_FEATURE "http://tizen.org/feature/peripheral_io.gpio" diff --git a/src/peripheral_i2c.c b/src/peripheral_i2c.c index d729356..89c1674 100644 --- a/src/peripheral_i2c.c +++ b/src/peripheral_i2c.c @@ -23,7 +23,7 @@ #include "peripheral_io.h" #include "peripheral_gdbus_i2c.h" #include "peripheral_common.h" -#include "peripheral_internal.h" +#include "peripheral_handle.h" #define PERIPHERAL_IO_I2C_FEATURE "http://tizen.org/feature/peripheral_io.i2c" diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index e21bcbb..c671ff4 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -23,7 +23,7 @@ #include "peripheral_io.h" #include "peripheral_gdbus_pwm.h" #include "peripheral_common.h" -#include "peripheral_internal.h" +#include "peripheral_handle.h" #define PERIPHERAL_IO_PWM_FEATURE "http://tizen.org/feature/peripheral_io.pwm" diff --git a/src/peripheral_spi.c b/src/peripheral_spi.c index 68e9761..0a9e95e 100644 --- a/src/peripheral_spi.c +++ b/src/peripheral_spi.c @@ -24,7 +24,7 @@ #include "peripheral_io.h" #include "peripheral_gdbus_spi.h" #include "peripheral_common.h" -#include "peripheral_internal.h" +#include "peripheral_handle.h" #define PERIPHERAL_IO_SPI_FEATURE "http://tizen.org/feature/peripheral_io.spi" diff --git a/src/peripheral_uart.c b/src/peripheral_uart.c index ad58c0c..0d67c98 100644 --- a/src/peripheral_uart.c +++ b/src/peripheral_uart.c @@ -23,7 +23,7 @@ #include "peripheral_io.h" #include "peripheral_gdbus_uart.h" #include "peripheral_common.h" -#include "peripheral_internal.h" +#include "peripheral_handle.h" #define PERIPHERAL_IO_UART_FEATURE "http://tizen.org/feature/peripheral_io.uart" -- 2.7.4 From 53da683cf99b7be5ba4e8bec3d060f6593a59cbe Mon Sep 17 00:00:00 2001 From: Segwon Date: Wed, 15 Nov 2017 15:52:34 +0900 Subject: [PATCH 15/16] including: remove unnecessary header files Change-Id: Ice8e09e5654bbc2e94d5c41b5e1d5d86e5b78239 Signed-off-by: Segwon --- include/gdbus/peripheral_gdbus_common.h | 1 - include/interface/peripheral_interface_common.h | 3 --- include/peripheral_common.h | 2 +- src/peripheral_gpio.c | 4 ---- src/peripheral_i2c.c | 3 --- src/peripheral_pwm.c | 3 --- src/peripheral_spi.c | 4 ---- src/peripheral_uart.c | 3 --- 8 files changed, 1 insertion(+), 22 deletions(-) diff --git a/include/gdbus/peripheral_gdbus_common.h b/include/gdbus/peripheral_gdbus_common.h index ed8c397..6885a61 100644 --- a/include/gdbus/peripheral_gdbus_common.h +++ b/include/gdbus/peripheral_gdbus_common.h @@ -17,7 +17,6 @@ #ifndef __PERIPHERAL_GDBUS_COMMON_H__ #define __PERIPHERAL_GDBUS_COMMON_H__ -#include #include #include #include diff --git a/include/interface/peripheral_interface_common.h b/include/interface/peripheral_interface_common.h index f0bd657..8cb2ed8 100644 --- a/include/interface/peripheral_interface_common.h +++ b/include/interface/peripheral_interface_common.h @@ -19,9 +19,6 @@ #include #include -#include -#include -#include #include #include "peripheral_io.h" diff --git a/include/peripheral_common.h b/include/peripheral_common.h index 19352be..c5702d3 100644 --- a/include/peripheral_common.h +++ b/include/peripheral_common.h @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __PERIPHERAL_COMMON_H__ #define __PERIPHERAL_COMMON_H__ -#include #include #undef LOG_TAG diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index 06806ec..5992d16 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -14,12 +14,8 @@ * limitations under the License. */ -#include #include -#include -#include #include -#include #include "peripheral_io.h" #include "peripheral_gdbus_gpio.h" diff --git a/src/peripheral_i2c.c b/src/peripheral_i2c.c index 89c1674..c61374b 100644 --- a/src/peripheral_i2c.c +++ b/src/peripheral_i2c.c @@ -14,10 +14,7 @@ * limitations under the License. */ -#include #include -#include -#include #include #include "peripheral_io.h" diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index c671ff4..74f807a 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -14,10 +14,7 @@ * limitations under the License. */ -#include #include -#include -#include #include #include "peripheral_io.h" diff --git a/src/peripheral_spi.c b/src/peripheral_spi.c index 0a9e95e..61d3b79 100644 --- a/src/peripheral_spi.c +++ b/src/peripheral_spi.c @@ -14,11 +14,7 @@ * limitations under the License. */ -#include "peripheral_io.h" - -#include #include -#include #include #include "peripheral_io.h" diff --git a/src/peripheral_uart.c b/src/peripheral_uart.c index 0d67c98..d63c100 100644 --- a/src/peripheral_uart.c +++ b/src/peripheral_uart.c @@ -14,10 +14,7 @@ * limitations under the License. */ -#include #include -#include -#include #include #include "peripheral_io.h" -- 2.7.4 From 2db5b00566952b5d6fe2cfa42ef386248d5327ff Mon Sep 17 00:00:00 2001 From: Segwon Date: Wed, 15 Nov 2017 16:24:33 +0900 Subject: [PATCH 16/16] log: change file name "peripheral_common.h" to "peripheral_log.h" Change-Id: I96c150951c7cb2c5517b305e00909b0bca5cacff Signed-off-by: Segwon --- include/gdbus/peripheral_gdbus_common.h | 2 +- include/interface/peripheral_interface_common.h | 2 +- include/{peripheral_common.h => peripheral_log.h} | 0 src/peripheral_gpio.c | 2 +- src/peripheral_i2c.c | 2 +- src/peripheral_pwm.c | 2 +- src/peripheral_spi.c | 2 +- src/peripheral_uart.c | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename include/{peripheral_common.h => peripheral_log.h} (100%) diff --git a/include/gdbus/peripheral_gdbus_common.h b/include/gdbus/peripheral_gdbus_common.h index 6885a61..62b0717 100644 --- a/include/gdbus/peripheral_gdbus_common.h +++ b/include/gdbus/peripheral_gdbus_common.h @@ -23,8 +23,8 @@ #include "peripheral_io.h" #include "peripheral_handle.h" -#include "peripheral_common.h" #include "peripheral_io_gdbus.h" +#include "peripheral_log.h" #define PERIPHERAL_GDBUS_INTERFACE "org.tizen.peripheral_io" #define PERIPHERAL_GDBUS_GPIO_PATH "/Org/Tizen/Peripheral_io/Gpio" diff --git a/include/interface/peripheral_interface_common.h b/include/interface/peripheral_interface_common.h index 8cb2ed8..2646cc6 100644 --- a/include/interface/peripheral_interface_common.h +++ b/include/interface/peripheral_interface_common.h @@ -23,7 +23,7 @@ #include "peripheral_io.h" #include "peripheral_handle.h" -#include "peripheral_common.h" +#include "peripheral_log.h" #define CHECK_ERROR(val) \ do { \ diff --git a/include/peripheral_common.h b/include/peripheral_log.h similarity index 100% rename from include/peripheral_common.h rename to include/peripheral_log.h diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index 5992d16..040d862 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -19,8 +19,8 @@ #include "peripheral_io.h" #include "peripheral_gdbus_gpio.h" -#include "peripheral_common.h" #include "peripheral_handle.h" +#include "peripheral_log.h" #define PERIPHERAL_IO_GPIO_FEATURE "http://tizen.org/feature/peripheral_io.gpio" diff --git a/src/peripheral_i2c.c b/src/peripheral_i2c.c index c61374b..e89e401 100644 --- a/src/peripheral_i2c.c +++ b/src/peripheral_i2c.c @@ -19,8 +19,8 @@ #include "peripheral_io.h" #include "peripheral_gdbus_i2c.h" -#include "peripheral_common.h" #include "peripheral_handle.h" +#include "peripheral_log.h" #define PERIPHERAL_IO_I2C_FEATURE "http://tizen.org/feature/peripheral_io.i2c" diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index 74f807a..fb1ed14 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -19,8 +19,8 @@ #include "peripheral_io.h" #include "peripheral_gdbus_pwm.h" -#include "peripheral_common.h" #include "peripheral_handle.h" +#include "peripheral_log.h" #define PERIPHERAL_IO_PWM_FEATURE "http://tizen.org/feature/peripheral_io.pwm" diff --git a/src/peripheral_spi.c b/src/peripheral_spi.c index 61d3b79..13c2b05 100644 --- a/src/peripheral_spi.c +++ b/src/peripheral_spi.c @@ -19,8 +19,8 @@ #include "peripheral_io.h" #include "peripheral_gdbus_spi.h" -#include "peripheral_common.h" #include "peripheral_handle.h" +#include "peripheral_log.h" #define PERIPHERAL_IO_SPI_FEATURE "http://tizen.org/feature/peripheral_io.spi" diff --git a/src/peripheral_uart.c b/src/peripheral_uart.c index d63c100..d7d3577 100644 --- a/src/peripheral_uart.c +++ b/src/peripheral_uart.c @@ -19,8 +19,8 @@ #include "peripheral_io.h" #include "peripheral_gdbus_uart.h" -#include "peripheral_common.h" #include "peripheral_handle.h" +#include "peripheral_log.h" #define PERIPHERAL_IO_UART_FEATURE "http://tizen.org/feature/peripheral_io.uart" -- 2.7.4