interface: add prefix 'peripheral_interface' to file and function name. 68/159968/3
authorSegwon <segwon.han@samsung.com>
Tue, 14 Nov 2017 03:26:22 +0000 (12:26 +0900)
committerSegwon <segwon.han@samsung.com>
Tue, 14 Nov 2017 03:42:24 +0000 (12:42 +0900)
Change-Id: I23b6fe4aa850e4a713aa6e419ab334681e596d39
Signed-off-by: Segwon <segwon.han@samsung.com>
12 files changed:
CMakeLists.txt
include/interface/peripheral_interface_gpio.h [moved from include/interface/gpio.h with 60% similarity]
include/interface/peripheral_interface_i2c.h [moved from include/interface/i2c.h with 74% similarity]
include/interface/peripheral_interface_pwm.h [moved from include/interface/pwm.h with 79% similarity]
include/interface/peripheral_interface_spi.h [new file with mode: 0644]
include/interface/peripheral_interface_uart.h [moved from include/interface/uart.h with 79% similarity]
include/interface/spi.h [deleted file]
src/interface/peripheral_interface_gpio.c [moved from src/interface/gpio.c with 77% similarity]
src/interface/peripheral_interface_i2c.c [moved from src/interface/i2c.c with 84% similarity]
src/interface/peripheral_interface_pwm.c [moved from src/interface/pwm.c with 86% similarity]
src/interface/peripheral_interface_spi.c [moved from src/interface/spi.c with 85% similarity]
src/interface/peripheral_interface_uart.c [moved from src/interface/uart.c with 87% similarity]

index 714f3d0..335e42a 100644 (file)
@@ -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
similarity index 60%
rename from include/interface/gpio.h
rename to include/interface/peripheral_interface_gpio.h
index b4d6ccc..cf5d76c 100644 (file)
@@ -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
similarity index 74%
rename from include/interface/i2c.h
rename to include/interface/peripheral_interface_i2c.h
index 6846649..b41c555 100644 (file)
@@ -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 <stdint.h>
 
@@ -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__ */
similarity index 79%
rename from include/interface/pwm.h
rename to include/interface/peripheral_interface_pwm.h
index 7a9f0d0..833de2b 100644 (file)
@@ -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 (file)
index 0000000..937caa7
--- /dev/null
@@ -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__ */
similarity index 79%
rename from include/interface/uart.h
rename to include/interface/peripheral_interface_uart.h
index a0505ee..f5273fe 100644 (file)
@@ -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 (file)
index 3708363..0000000
+++ /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__ */
similarity index 77%
rename from src/interface/gpio.c
rename to src/interface/peripheral_interface_gpio.c
index 352e8c9..e4620ca 100644 (file)
 #include <fcntl.h>
 #include <poll.h>
 
-#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
similarity index 84%
rename from src/interface/i2c.c
rename to src/interface/peripheral_interface_i2c.c
index fec6ea2..9da17bd 100644 (file)
 #include <fcntl.h>
 #include <sys/ioctl.h>
 
-#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;
 
similarity index 86%
rename from src/interface/pwm.c
rename to src/interface/peripheral_interface_pwm.c
index 2d34ec7..a5cae4d 100644 (file)
@@ -22,7 +22,7 @@
 #include <unistd.h>
 #include <stdbool.h>
 
-#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};
similarity index 85%
rename from src/interface/spi.c
rename to src/interface/peripheral_interface_spi.c
index c212792..1296d9f 100644 (file)
@@ -23,7 +23,7 @@
 #include <sys/ioctl.h>
 #include <linux/spi/spidev.h>
 
-#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;
similarity index 87%
rename from src/interface/uart.c
rename to src/interface/peripheral_interface_uart.c
index fcddde9..92fffce 100644 (file)
@@ -24,7 +24,7 @@
 #include <stdbool.h>
 #include <sys/ioctl.h>
 
-#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;