")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/daemon)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/daemon/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/interface/include)
SET(PERIPHERAL-BUS "peripheral-bus")
--- /dev/null
+/*
+ * 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_BUS_H__
+#define __PERIPHERAL_BUS_H__
+
+#include <gio/gio.h>
+
+#include "peripheral_io_gdbus.h"
+#include "peripheral_bus_board.h"
+
+typedef enum {
+ PERIPHERAL_BUS_TYPE_GPIO = 0,
+ PERIPHERAL_BUS_TYPE_I2C,
+ PERIPHERAL_BUS_TYPE_PWM,
+ PERIPHERAL_BUS_TYPE_ADC,
+ PERIPHERAL_BUS_TYPE_UART,
+ PERIPHERAL_BUS_TYPE_SPI,
+} peripheral_bus_type_e;
+
+typedef struct {
+ pb_board_s *board;
+ /* daemon variable */
+ char *adc_path;
+ /* devices */
+ GList *gpio_list;
+ GList *i2c_list;
+ GList *pwm_list;
+ GList *uart_list;
+ GList *spi_list;
+ /* gdbus variable */
+ guint reg_id;
+ GDBusConnection *connection;
+ PeripheralIoGdbusGpio *gpio_skeleton;
+ PeripheralIoGdbusI2c *i2c_skeleton;
+ PeripheralIoGdbusPwm *pwm_skeleton;
+ PeripheralIoGdbusAdc *adc_skeleton;
+ PeripheralIoGdbusUart *uart_skeleton;
+ PeripheralIoGdbusSpi *spi_skeleton;
+} peripheral_bus_s;
+
+typedef struct {
+ char *id;
+ pid_t pid;
+ pid_t pgid;
+} pb_client_info_s;
+
+typedef struct {
+ /* gpio info */
+ int pin;
+ int direction;
+ int edge;
+ /* interrupt variable */
+ int irq_en;
+ int value_fd;
+ GIOChannel *io;
+ guint io_id;
+ /* gdbus variable */
+ PeripheralIoGdbusGpio *gpio_skeleton;
+} peripheral_bus_gpio_s;
+
+typedef struct {
+ /* i2c device information */
+ int bus;
+ int address;
+ int fd;
+ /* data buffer */
+ uint8_t *buffer;
+ int buffer_size;
+} peripheral_bus_i2c_s;
+
+typedef struct {
+ int device;
+ int channel;
+} peripheral_bus_pwm_s;
+
+typedef struct {
+ int port;
+ int fd;
+ uint8_t *buffer;
+ int buffer_size;
+} peripheral_bus_uart_s;
+
+typedef struct {
+ int bus;
+ int cs;
+ int fd;
+ /* data buffer */
+ uint8_t *rx_buf;
+ uint8_t *tx_buf;
+ int rx_buf_size;
+ int tx_buf_size;
+} peripheral_bus_spi_s;
+
+typedef struct {
+ peripheral_bus_type_e type;
+ uint watch_id;
+ GList **list;
+ /* client info */
+ pb_client_info_s client_info;
+ union {
+ peripheral_bus_gpio_s gpio;
+ peripheral_bus_i2c_s i2c;
+ peripheral_bus_pwm_s pwm;
+ peripheral_bus_uart_s uart;
+ peripheral_bus_spi_s spi;
+ } dev;
+} peripheral_bus_data_s;
+
+typedef peripheral_bus_data_s *pb_data_h;
+
+void peripheral_bus_emit_gpio_changed(PeripheralIoGdbusGpio *gpio,
+ gint pin,
+ gint value,
+ guint64 timestamp);
+#endif /* __PERIPHERAL_BUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 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_BUS_ADC_H__
+#define __PERIPHERAL_BUS_ADC_H__
+
+char *peripheral_bus_adc_get_path(unsigned int device);
+int peripheral_bus_adc_read(unsigned int device, unsigned int channel, char *path, int *data);
+
+#endif /* __PERIPHERAL_BUS_ADC_H__ */
--- /dev/null
+/*
+ * Copyright (c) 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_BUS_BOARD_H__
+#define __PERIPHERAL_BUS_BOARD_H__
+
+#define BOARD_DEVICE_TREE "/proc/device-tree/model"
+#define BOARD_PINS_MAX 4
+#define BOARD_ARGS_MAX 2
+
+typedef enum {
+ PB_BOARD_ARTIK710 = 0,
+ PB_BOARD_ARTIK530,
+ PB_BOARD_RP3_B_12,
+ PB_BOARD_UNKOWN,
+} pb_board_type_e;
+
+typedef enum {
+ PB_BOARD_DEV_GPIO = 0,
+ PB_BOARD_DEV_I2C,
+ PB_BOARD_DEV_PWM,
+ PB_BOARD_DEV_ADC,
+ PB_BOARD_DEV_UART,
+ PB_BOARD_DEV_SPI,
+ PB_BOARD_DEV_MAX,
+} pb_board_dev_e;
+
+typedef struct {
+ pb_board_type_e type;
+ char *name;
+ char *path;
+} pb_board_type_s;
+
+typedef struct {
+ pb_board_dev_e dev_type;
+ unsigned int pins[BOARD_PINS_MAX];
+ unsigned int num_pins;
+ unsigned int args[BOARD_ARGS_MAX];
+} pb_board_dev_s;
+
+typedef struct {
+ pb_board_type_e type;
+ pb_board_dev_s *dev;
+ unsigned int num_dev;
+} pb_board_s;
+
+pb_board_dev_s *peripheral_bus_board_find_device(pb_board_dev_e dev_type, pb_board_s *board, int arg, ...);
+pb_board_s *peripheral_bus_board_init(void);
+void peripheral_bus_board_deinit(pb_board_s *board);
+
+#endif /* __PERIPHERAL_BUS_BOARD_H__ */
--- /dev/null
+/*
+ * 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_BUS_GPIO_H__
+#define __PERIPHERAL_BUS_GPIO_H__
+
+int peripheral_bus_gpio_open(gint pin, pb_data_h *handle, gpointer user_data);
+int peripheral_bus_gpio_set_direction(pb_data_h handle, gint direction);
+int peripheral_bus_gpio_get_direction(pb_data_h handle, gint *direction);
+int peripheral_bus_gpio_set_edge(pb_data_h handle, gint edge);
+int peripheral_bus_gpio_get_edge(pb_data_h handle, gint *edge);
+int peripheral_bus_gpio_write(pb_data_h handle, gint value);
+int peripheral_bus_gpio_read(pb_data_h handle, gint *value);
+int peripheral_bus_gpio_register_irq(pb_data_h handle);
+int peripheral_bus_gpio_unregister_irq(pb_data_h handle);
+int peripheral_bus_gpio_close(pb_data_h handle);
+
+#endif /* __PERIPHERAL_BUS_GPIO_H__ */
--- /dev/null
+/*
+ * 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_BUS_I2C_H__
+#define __PERIPHERAL_BUS_I2C_H__
+
+int peripheral_bus_i2c_open(int bus, int address, pb_data_h *handle, gpointer user_data);
+int peripheral_bus_i2c_close(pb_data_h handle);
+int peripheral_bus_i2c_read(pb_data_h handle, int length, GVariant **data_array);
+int peripheral_bus_i2c_write(pb_data_h handle, int length, GVariant *data_array);
+int peripheral_bus_i2c_smbus_ioctl(pb_data_h handle, uint8_t read_write, uint8_t command, uint32_t size, uint16_t data_in, uint16_t *data_out);
+
+#endif /* __PERIPHERAL_BUS_I2C_H__ */
--- /dev/null
+/*
+ * 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_BUS_PWM_H__
+#define __PERIPHERAL_BUS_PWM_H__
+
+int peripheral_bus_pwm_open(int device, int channel, pb_data_h *handle, gpointer user_data);
+int peripheral_bus_pwm_close(pb_data_h handle);
+int peripheral_bus_pwm_set_period(pb_data_h handle, int period);
+int peripheral_bus_pwm_get_period(pb_data_h handle, int *period);
+int peripheral_bus_pwm_set_duty_cycle(pb_data_h handle, int duty_cycle);
+int peripheral_bus_pwm_get_duty_cycle(pb_data_h handle, int *duty_cycle);
+int peripheral_bus_pwm_set_polarity(pb_data_h handle, int polarity);
+int peripheral_bus_pwm_get_polarity(pb_data_h handle, int *polarity);
+int peripheral_bus_pwm_set_enable(pb_data_h handle, bool enable);
+int peripheral_bus_pwm_get_enable(pb_data_h handle, bool *enable);
+
+#endif /* __PERIPHERAL_BUS_PWM_H__ */
--- /dev/null
+/*
+ * Copyright (c) 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_BUS_SPI_H__
+#define __PERIPHERAL_BUS_SPI_H__
+
+int peripheral_bus_spi_open(int bus, int cs, pb_data_h *handle, gpointer user_data);
+int peripheral_bus_spi_close(pb_data_h handle);
+int peripheral_bus_spi_set_mode(pb_data_h handle, unsigned char mode);
+int peripheral_bus_spi_get_mode(pb_data_h handle, unsigned char *mode);
+int peripheral_bus_spi_set_lsb_first(pb_data_h handle, gboolean lsb);
+int peripheral_bus_spi_get_lsb_first(pb_data_h handle, gboolean *lsb);
+int peripheral_bus_spi_set_bits(pb_data_h handle, unsigned char bits);
+int peripheral_bus_spi_get_bits(pb_data_h handle, unsigned char *bits);
+int peripheral_bus_spi_set_frequency(pb_data_h handle, unsigned int freq);
+int peripheral_bus_spi_get_frequency(pb_data_h handle, unsigned int *freq);
+int peripheral_bus_spi_read(pb_data_h handle, GVariant **data_array, int length);
+int peripheral_bus_spi_write(pb_data_h handle, GVariant *data_array, int length);
+int peripheral_bus_spi_read_write(pb_data_h handle, GVariant *tx_data_array, GVariant **rx_data_array, int length);
+
+#endif /* __PERIPHERAL_BUS_SPI_H__ */
--- /dev/null
+/*
+ * 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_BUS_UART_H__
+#define __PERIPHERAL_BUS_UART_H__
+
+int peripheral_bus_uart_open(int port, pb_data_h *handle, gpointer user_data);
+int peripheral_bus_uart_close(pb_data_h handle);
+int peripheral_bus_uart_flush(pb_data_h handle);
+int peripheral_bus_uart_set_baudrate(pb_data_h handle, int baudrate);
+int peripheral_bus_uart_set_mode(pb_data_h handle, int byte_size, int parity, int stop_bits);
+int peripheral_bus_uart_set_flowcontrol(pb_data_h handle, int xonxoff, int rtscts);
+int peripheral_bus_uart_read(pb_data_h handle, GVariant **data_array, int length);
+int peripheral_bus_uart_write(pb_data_h handle, GVariant *data_array, int length);
+
+#endif /* __PERIPHERAL_BUS_UART_H__ */
--- /dev/null
+/*
+ * Copyright (c) 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_UTIL_H__
+#define __PERIPHERAL_UTIL_H__
+
+GVariant *peripheral_bus_build_variant_ay(uint8_t *data, int length);
+pb_data_h peripheral_bus_data_new(GList **plist);
+int peripheral_bus_data_free(pb_data_h handle);
+
+#endif /* __PERIPHERAL_UTIL_H__ */
--- /dev/null
+/*
+ * 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_COMMON_H__
+#define __PERIPHERAL_COMMON_H__
+
+#include <unistd.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "PERIPHERAL-BUS"
+
+#define _E(fmt, arg...) LOGE(fmt, ##arg)
+#define _D(fmt, arg...) LOGD(fmt, ##arg)
+#define _W(fmt, arg...) LOGW(fmt, ##arg)
+
+#define RET_IF(expr) \
+ do { \
+ if (expr) { \
+ _E("(%s)", #expr); \
+ return; \
+ } \
+ } while (0)
+#define RETV_IF(expr, val) \
+ do {\
+ if (expr) { \
+ _E("(%s)", #expr); \
+ return (val); \
+ } \
+ } while (0)
+#define RETM_IF(expr, fmt, arg...) \
+ do {\
+ if (expr) { \
+ _E(fmt, ##arg); \
+ return; \
+ } \
+ } while (0)
+#define RETVM_IF(expr, val, fmt, arg...) \
+ do {\
+ if (expr) { \
+ _E(fmt, ##arg); \
+ return (val); \
+ } \
+ } while (0)
+
+#endif /* __PERIPHERAL_COMMON_H__ */
+++ /dev/null
-/*
- * 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_BUS_H__
-#define __PERIPHERAL_BUS_H__
-
-#include <gio/gio.h>
-
-#include "peripheral_io_gdbus.h"
-#include "peripheral_bus_board.h"
-
-typedef enum {
- PERIPHERAL_BUS_TYPE_GPIO = 0,
- PERIPHERAL_BUS_TYPE_I2C,
- PERIPHERAL_BUS_TYPE_PWM,
- PERIPHERAL_BUS_TYPE_ADC,
- PERIPHERAL_BUS_TYPE_UART,
- PERIPHERAL_BUS_TYPE_SPI,
-} peripheral_bus_type_e;
-
-typedef struct {
- pb_board_s *board;
- /* daemon variable */
- char *adc_path;
- /* devices */
- GList *gpio_list;
- GList *i2c_list;
- GList *pwm_list;
- GList *uart_list;
- GList *spi_list;
- /* gdbus variable */
- guint reg_id;
- GDBusConnection *connection;
- PeripheralIoGdbusGpio *gpio_skeleton;
- PeripheralIoGdbusI2c *i2c_skeleton;
- PeripheralIoGdbusPwm *pwm_skeleton;
- PeripheralIoGdbusAdc *adc_skeleton;
- PeripheralIoGdbusUart *uart_skeleton;
- PeripheralIoGdbusSpi *spi_skeleton;
-} peripheral_bus_s;
-
-typedef struct {
- char *id;
- pid_t pid;
- pid_t pgid;
-} pb_client_info_s;
-
-typedef struct {
- /* gpio info */
- int pin;
- int direction;
- int edge;
- /* interrupt variable */
- int irq_en;
- int value_fd;
- GIOChannel *io;
- guint io_id;
- /* gdbus variable */
- PeripheralIoGdbusGpio *gpio_skeleton;
-} peripheral_bus_gpio_s;
-
-typedef struct {
- /* i2c device information */
- int bus;
- int address;
- int fd;
- /* data buffer */
- uint8_t *buffer;
- int buffer_size;
-} peripheral_bus_i2c_s;
-
-typedef struct {
- int device;
- int channel;
-} peripheral_bus_pwm_s;
-
-typedef struct {
- int port;
- int fd;
- uint8_t *buffer;
- int buffer_size;
-} peripheral_bus_uart_s;
-
-typedef struct {
- int bus;
- int cs;
- int fd;
- /* data buffer */
- uint8_t *rx_buf;
- uint8_t *tx_buf;
- int rx_buf_size;
- int tx_buf_size;
-} peripheral_bus_spi_s;
-
-typedef struct {
- peripheral_bus_type_e type;
- uint watch_id;
- GList **list;
- /* client info */
- pb_client_info_s client_info;
- union {
- peripheral_bus_gpio_s gpio;
- peripheral_bus_i2c_s i2c;
- peripheral_bus_pwm_s pwm;
- peripheral_bus_uart_s uart;
- peripheral_bus_spi_s spi;
- } dev;
-} peripheral_bus_data_s;
-
-typedef peripheral_bus_data_s *pb_data_h;
-
-void peripheral_bus_emit_gpio_changed(PeripheralIoGdbusGpio *gpio,
- gint pin,
- gint value,
- guint64 timestamp);
-#endif /* __PERIPHERAL_BUS_H__ */
+++ /dev/null
-/*
- * Copyright (c) 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_BUS_ADC_H__
-#define __PERIPHERAL_BUS_ADC_H__
-
-char *peripheral_bus_adc_get_path(unsigned int device);
-int peripheral_bus_adc_read(unsigned int device, unsigned int channel, char *path, int *data);
-
-#endif /* __PERIPHERAL_BUS_ADC_H__ */
+++ /dev/null
-/*
- * Copyright (c) 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_BUS_BOARD_H__
-#define __PERIPHERAL_BUS_BOARD_H__
-
-#define BOARD_DEVICE_TREE "/proc/device-tree/model"
-#define BOARD_PINS_MAX 4
-#define BOARD_ARGS_MAX 2
-
-typedef enum {
- PB_BOARD_ARTIK710 = 0,
- PB_BOARD_ARTIK530,
- PB_BOARD_RP3_B_12,
- PB_BOARD_UNKOWN,
-} pb_board_type_e;
-
-typedef enum {
- PB_BOARD_DEV_GPIO = 0,
- PB_BOARD_DEV_I2C,
- PB_BOARD_DEV_PWM,
- PB_BOARD_DEV_ADC,
- PB_BOARD_DEV_UART,
- PB_BOARD_DEV_SPI,
- PB_BOARD_DEV_MAX,
-} pb_board_dev_e;
-
-typedef struct {
- pb_board_type_e type;
- char *name;
- char *path;
-} pb_board_type_s;
-
-typedef struct {
- pb_board_dev_e dev_type;
- unsigned int pins[BOARD_PINS_MAX];
- unsigned int num_pins;
- unsigned int args[BOARD_ARGS_MAX];
-} pb_board_dev_s;
-
-typedef struct {
- pb_board_type_e type;
- pb_board_dev_s *dev;
- unsigned int num_dev;
-} pb_board_s;
-
-pb_board_dev_s *peripheral_bus_board_find_device(pb_board_dev_e dev_type, pb_board_s *board, int arg, ...);
-pb_board_s *peripheral_bus_board_init(void);
-void peripheral_bus_board_deinit(pb_board_s *board);
-
-#endif /* __PERIPHERAL_BUS_BOARD_H__ */
+++ /dev/null
-/*
- * 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_BUS_GPIO_H__
-#define __PERIPHERAL_BUS_GPIO_H__
-
-int peripheral_bus_gpio_open(gint pin, pb_data_h *handle, gpointer user_data);
-int peripheral_bus_gpio_set_direction(pb_data_h handle, gint direction);
-int peripheral_bus_gpio_get_direction(pb_data_h handle, gint *direction);
-int peripheral_bus_gpio_set_edge(pb_data_h handle, gint edge);
-int peripheral_bus_gpio_get_edge(pb_data_h handle, gint *edge);
-int peripheral_bus_gpio_write(pb_data_h handle, gint value);
-int peripheral_bus_gpio_read(pb_data_h handle, gint *value);
-int peripheral_bus_gpio_register_irq(pb_data_h handle);
-int peripheral_bus_gpio_unregister_irq(pb_data_h handle);
-int peripheral_bus_gpio_close(pb_data_h handle);
-
-#endif /* __PERIPHERAL_BUS_GPIO_H__ */
+++ /dev/null
-/*
- * 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_BUS_I2C_H__
-#define __PERIPHERAL_BUS_I2C_H__
-
-int peripheral_bus_i2c_open(int bus, int address, pb_data_h *handle, gpointer user_data);
-int peripheral_bus_i2c_close(pb_data_h handle);
-int peripheral_bus_i2c_read(pb_data_h handle, int length, GVariant **data_array);
-int peripheral_bus_i2c_write(pb_data_h handle, int length, GVariant *data_array);
-int peripheral_bus_i2c_smbus_ioctl(pb_data_h handle, uint8_t read_write, uint8_t command, uint32_t size, uint16_t data_in, uint16_t *data_out);
-
-#endif /* __PERIPHERAL_BUS_I2C_H__ */
+++ /dev/null
-/*
- * 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_BUS_PWM_H__
-#define __PERIPHERAL_BUS_PWM_H__
-
-int peripheral_bus_pwm_open(int device, int channel, pb_data_h *handle, gpointer user_data);
-int peripheral_bus_pwm_close(pb_data_h handle);
-int peripheral_bus_pwm_set_period(pb_data_h handle, int period);
-int peripheral_bus_pwm_get_period(pb_data_h handle, int *period);
-int peripheral_bus_pwm_set_duty_cycle(pb_data_h handle, int duty_cycle);
-int peripheral_bus_pwm_get_duty_cycle(pb_data_h handle, int *duty_cycle);
-int peripheral_bus_pwm_set_polarity(pb_data_h handle, int polarity);
-int peripheral_bus_pwm_get_polarity(pb_data_h handle, int *polarity);
-int peripheral_bus_pwm_set_enable(pb_data_h handle, bool enable);
-int peripheral_bus_pwm_get_enable(pb_data_h handle, bool *enable);
-
-#endif /* __PERIPHERAL_BUS_PWM_H__ */
+++ /dev/null
-/*
- * Copyright (c) 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_BUS_SPI_H__
-#define __PERIPHERAL_BUS_SPI_H__
-
-int peripheral_bus_spi_open(int bus, int cs, pb_data_h *handle, gpointer user_data);
-int peripheral_bus_spi_close(pb_data_h handle);
-int peripheral_bus_spi_set_mode(pb_data_h handle, unsigned char mode);
-int peripheral_bus_spi_get_mode(pb_data_h handle, unsigned char *mode);
-int peripheral_bus_spi_set_lsb_first(pb_data_h handle, gboolean lsb);
-int peripheral_bus_spi_get_lsb_first(pb_data_h handle, gboolean *lsb);
-int peripheral_bus_spi_set_bits(pb_data_h handle, unsigned char bits);
-int peripheral_bus_spi_get_bits(pb_data_h handle, unsigned char *bits);
-int peripheral_bus_spi_set_frequency(pb_data_h handle, unsigned int freq);
-int peripheral_bus_spi_get_frequency(pb_data_h handle, unsigned int *freq);
-int peripheral_bus_spi_read(pb_data_h handle, GVariant **data_array, int length);
-int peripheral_bus_spi_write(pb_data_h handle, GVariant *data_array, int length);
-int peripheral_bus_spi_read_write(pb_data_h handle, GVariant *tx_data_array, GVariant **rx_data_array, int length);
-
-#endif /* __PERIPHERAL_BUS_SPI_H__ */
+++ /dev/null
-/*
- * 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_BUS_UART_H__
-#define __PERIPHERAL_BUS_UART_H__
-
-int peripheral_bus_uart_open(int port, pb_data_h *handle, gpointer user_data);
-int peripheral_bus_uart_close(pb_data_h handle);
-int peripheral_bus_uart_flush(pb_data_h handle);
-int peripheral_bus_uart_set_baudrate(pb_data_h handle, int baudrate);
-int peripheral_bus_uart_set_mode(pb_data_h handle, int byte_size, int parity, int stop_bits);
-int peripheral_bus_uart_set_flowcontrol(pb_data_h handle, int xonxoff, int rtscts);
-int peripheral_bus_uart_read(pb_data_h handle, GVariant **data_array, int length);
-int peripheral_bus_uart_write(pb_data_h handle, GVariant *data_array, int length);
-
-#endif /* __PERIPHERAL_BUS_UART_H__ */
+++ /dev/null
-/*
- * Copyright (c) 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_UTIL_H__
-#define __PERIPHERAL_UTIL_H__
-
-GVariant *peripheral_bus_build_variant_ay(uint8_t *data, int length);
-pb_data_h peripheral_bus_data_new(GList **plist);
-int peripheral_bus_data_free(pb_data_h handle);
-
-#endif /* __PERIPHERAL_UTIL_H__ */
+++ /dev/null
-/*
- * 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_COMMON_H__
-#define __PERIPHERAL_COMMON_H__
-
-#include <unistd.h>
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "PERIPHERAL-BUS"
-
-#define _E(fmt, arg...) LOGE(fmt, ##arg)
-#define _D(fmt, arg...) LOGD(fmt, ##arg)
-#define _W(fmt, arg...) LOGW(fmt, ##arg)
-
-#define RET_IF(expr) \
- do { \
- if (expr) { \
- _E("(%s)", #expr); \
- return; \
- } \
- } while (0)
-#define RETV_IF(expr, val) \
- do {\
- if (expr) { \
- _E("(%s)", #expr); \
- return (val); \
- } \
- } while (0)
-#define RETM_IF(expr, fmt, arg...) \
- do {\
- if (expr) { \
- _E(fmt, ##arg); \
- return; \
- } \
- } while (0)
-#define RETVM_IF(expr, val, fmt, arg...) \
- do {\
- if (expr) { \
- _E(fmt, ##arg); \
- return (val); \
- } \
- } while (0)
-
-#endif /* __PERIPHERAL_COMMON_H__ */