From: Adrian Szyndela Date: Wed, 23 Jun 2021 15:17:50 +0000 (+0200) Subject: move and remove private headers X-Git-Tag: submit/tizen/20210629.011533~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F55%2F260355%2F6;p=platform%2Fcore%2Fapi%2Fperipheral-io.git move and remove private headers Leave only public header in include/. Remove peripheral_handle.h by moving struct definitions into respective source files. Change-Id: I7a5042fbf68667499a1247bc8efcf704447e1d4d --- diff --git a/include/interface/peripheral_interface_common.h b/include/interface/peripheral_interface_common.h deleted file mode 100644 index 675c3fb..0000000 --- a/include/interface/peripheral_interface_common.h +++ /dev/null @@ -1,49 +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 __PERIPHERAL_INTERFACE_COMMON_H__ -#define __PERIPHERAL_INTERFACE_COMMON_H__ - -#include -#include -#include - -#include "peripheral_io.h" -#include "peripheral_handle.h" -#include "peripheral_log.h" - -#define MAX_ERR_LEN 255 - -#define CHECK_ERROR(expr) \ - do { \ - if (expr) { \ - if (errno == EAGAIN) \ - return PERIPHERAL_ERROR_TRY_AGAIN; \ - if (errno == EINVAL) \ - return PERIPHERAL_ERROR_INVALID_PARAMETER; \ - char errmsg[MAX_ERR_LEN]; \ - strerror_r(errno, errmsg, sizeof(errmsg)); \ - _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \ - return PERIPHERAL_ERROR_IO_ERROR; \ - } \ - } while (0) - -typedef struct predefined_type { - char *type; - int len; -} predefined_type_s; - -#endif /*__PERIPHERAL_INTERFACE_COMMON_H__*/ diff --git a/include/peripheral_handle.h b/include/peripheral_handle.h deleted file mode 100644 index 4585021..0000000 --- a/include/peripheral_handle.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017-2018 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_HANDLE_H__ -#define __PERIPHERAL_HANDLE_H__ - -#include -#include "peripheral_io.h" - -typedef struct _peripheral_gpio_interrupted_cb_info_s { - // vermagic value is used to verify structure inside csapi - // do not move it and value field to different place inside structure - // otherwise update csapi accordingly - int vermagic; - int value; - GThread *thread; - peripheral_gpio_interrupted_cb cb; - peripheral_error_e error; - void *user_data; - gint status; -} interrupted_cb_info_s; - -/** - * @brief Internal struct for gpio context - */ -struct _peripheral_gpio_s { - // vermagic value is used to verify structure inside csapi - // do not move it and callback info field to different place inside structure - // otherwise update csapi accordingly - int vermagic; - interrupted_cb_info_s cb_info; - int pin; - int fd_direction; - int fd_edge; - int fd_value; - peripheral_gpio_direction_e direction; - peripheral_gpio_edge_e edge; -}; - -/** - * @brief Internal struct for i2c context - */ -struct _peripheral_i2c_s { - int fd; -}; - -/** - * @brief Internal struct for pwm context - */ -struct _peripheral_pwm_s { - int chip; - int pin; - int fd_period; - int fd_duty_cycle; - int fd_polarity; - int fd_enable; -}; - -/** - * @brief Internal struct for adc context - */ -struct _peripheral_adc_s { - int fd; -}; - -/** - * @brief Internal struct for uart context - */ -struct _peripheral_uart_s { - int fd; -}; - -/** - * @brief Internal struct for spi context - */ -struct _peripheral_spi_s { - int fd; -}; - -#endif /* __PERIPHERAL_HANDLE_H__ */ diff --git a/include/peripheral_log.h b/include/peripheral_log.h deleted file mode 100644 index c5702d3..0000000 --- a/include/peripheral_log.h +++ /dev/null @@ -1,58 +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 __PERIPHERAL_COMMON_H__ -#define __PERIPHERAL_COMMON_H__ - -#include - -#undef LOG_TAG -#define LOG_TAG "PERIPHERAL-IO" - -#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__ */ diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..77ff0f7 --- /dev/null +++ b/src/common.h @@ -0,0 +1,47 @@ +/* + * 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__ + +#include +#include +#include + +#include "log.h" + +#define MAX_ERR_LEN 255 + +#define CHECK_ERROR(expr) \ + do { \ + if (expr) { \ + if (errno == EAGAIN) \ + return PERIPHERAL_ERROR_TRY_AGAIN; \ + if (errno == EINVAL) \ + return PERIPHERAL_ERROR_INVALID_PARAMETER; \ + char errmsg[MAX_ERR_LEN]; \ + strerror_r(errno, errmsg, sizeof(errmsg)); \ + _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \ + return PERIPHERAL_ERROR_IO_ERROR; \ + } \ + } while (0) + +typedef struct predefined_type { + char *type; + int len; +} predefined_type_s; + +#endif /*__PERIPHERAL_INTERFACE_COMMON_H__*/ diff --git a/src/log.h b/src/log.h new file mode 100644 index 0000000..c5702d3 --- /dev/null +++ b/src/log.h @@ -0,0 +1,58 @@ +/* + * 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 + +#undef LOG_TAG +#define LOG_TAG "PERIPHERAL-IO" + +#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__ */ diff --git a/src/peripheral_adc.c b/src/peripheral_adc.c index 9aa81c6..79a9fc4 100644 --- a/src/peripheral_adc.c +++ b/src/peripheral_adc.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -23,8 +24,8 @@ #include #include "peripheral_io.h" -#include "peripheral_interface_common.h" -#include "peripheral_log.h" +#include "common.h" +#include "log.h" #define PERIPHERAL_IO_ADC_FEATURE "http://tizen.org/feature/peripheral_io.adc" @@ -34,6 +35,13 @@ #define ADC_BUFFER_MAX 64 +/** + * @brief Internal struct for adc context + */ +struct _peripheral_adc_s { + int fd; +}; + static int adc_feature = ADC_FEATURE_UNKNOWN; static bool __is_feature_supported(void) diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index 86da489..d700aaf 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -14,15 +14,17 @@ * limitations under the License. */ +#include #include #include +#include #include #include #include #include "peripheral_io.h" -#include "peripheral_interface_common.h" -#include "peripheral_log.h" +#include "common.h" +#include "log.h" #define PERIPHERAL_IO_GPIO_FEATURE "http://tizen.org/feature/peripheral_io.gpio" @@ -37,6 +39,36 @@ #define GPIO_BUFFER_MAX 64 +typedef struct _peripheral_gpio_interrupted_cb_info_s { + // vermagic value is used to verify structure inside csapi + // do not move it and value field to different place inside structure + // otherwise update csapi accordingly + int vermagic; + int value; + GThread *thread; + peripheral_gpio_interrupted_cb cb; + peripheral_error_e error; + void *user_data; + gint status; +} interrupted_cb_info_s; + +/** + * @brief Internal struct for gpio context + */ +struct _peripheral_gpio_s { + // vermagic value is used to verify structure inside csapi + // do not move it and callback info field to different place inside structure + // otherwise update csapi accordingly + int vermagic; + interrupted_cb_info_s cb_info; + int pin; + int fd_direction; + int fd_edge; + int fd_value; + peripheral_gpio_direction_e direction; + peripheral_gpio_edge_e edge; +}; + static int gpio_feature = GPIO_FEATURE_UNKNOWN; static bool __is_feature_supported(void) diff --git a/src/peripheral_i2c.c b/src/peripheral_i2c.c index 4076094..b36ffab 100644 --- a/src/peripheral_i2c.c +++ b/src/peripheral_i2c.c @@ -14,14 +14,15 @@ * limitations under the License. */ #include +#include #include #include #include #include #include "peripheral_io.h" -#include "peripheral_interface_common.h" -#include "peripheral_log.h" +#include "common.h" +#include "log.h" #define PERIPHERAL_IO_I2C_FEATURE "http://tizen.org/feature/peripheral_io.i2c" @@ -47,6 +48,13 @@ */ #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ +/** + * @brief Internal struct for i2c context + */ +struct _peripheral_i2c_s { + int fd; +}; + union i2c_smbus_data { uint8_t byte; uint16_t word; diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index 51b447c..0eaf94b 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -16,13 +16,14 @@ #include #include +#include #include #include #include #include "peripheral_io.h" -#include "peripheral_interface_common.h" -#include "peripheral_log.h" +#include "common.h" +#include "log.h" #define PERIPHERAL_IO_PWM_FEATURE "http://tizen.org/feature/peripheral_io.pwm" @@ -32,6 +33,18 @@ #define PWM_BUF_MAX 16 +/** + * @brief Internal struct for pwm context + */ +struct _peripheral_pwm_s { + int chip; + int pin; + int fd_period; + int fd_duty_cycle; + int fd_polarity; + int fd_enable; +}; + static int pwm_feature = PWM_FEATURE_UNKNOWN; static bool __is_feature_supported(void) diff --git a/src/peripheral_spi.c b/src/peripheral_spi.c index 9381d00..6e50968 100644 --- a/src/peripheral_spi.c +++ b/src/peripheral_spi.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -24,8 +25,8 @@ #include #include "peripheral_io.h" -#include "peripheral_interface_common.h" -#include "peripheral_log.h" +#include "common.h" +#include "log.h" #define PERIPHERAL_IO_SPI_FEATURE "http://tizen.org/feature/peripheral_io.spi" @@ -33,6 +34,13 @@ #define SPI_FEATURE_FALSE 0 #define SPI_FEATURE_TRUE 1 +/** + * @brief Internal struct for spi context + */ +struct _peripheral_spi_s { + int fd; +}; + static int spi_feature = SPI_FEATURE_UNKNOWN; static bool __is_feature_supported(void) diff --git a/src/peripheral_uart.c b/src/peripheral_uart.c index daeb2e0..a2e10ee 100644 --- a/src/peripheral_uart.c +++ b/src/peripheral_uart.c @@ -15,6 +15,8 @@ */ #include +#include +#include #include #include #include @@ -23,8 +25,8 @@ #include #include "peripheral_io.h" -#include "peripheral_interface_common.h" -#include "peripheral_log.h" +#include "common.h" +#include "log.h" #define PERIPHERAL_IO_UART_FEATURE "http://tizen.org/feature/peripheral_io.uart" @@ -36,6 +38,13 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) #endif +/** + * @brief Internal struct for uart context + */ +struct _peripheral_uart_s { + int fd; +}; + static const int peripheral_uart_br[] = { B0, B50, B75, B110, B134, B150, B200, B300, B600, B1200,