From: Segwon Date: Mon, 13 Nov 2017 05:31:31 +0000 (+0900) Subject: interface: move interface header files to top level include folder. X-Git-Tag: submit/tizen_4.0/20171220.125806^2~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=682d82c41643130b0966cf6ff7cf8612b1419c14;p=platform%2Fcore%2Fapi%2Fperipheral-io.git interface: move interface header files to top level include folder. - seperated for readability. - included interface files when running build. Signed-off-by: Segwon Change-Id: I4847dc8a7cf5f81de098a730c640229dfbc8a560 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 29d9721..714f3d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) +INCLUDE_DIRECTORIES(${INC_DIR}/interface) INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) @@ -47,6 +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/peripheral_gdbus_gpio.c src/peripheral_gdbus_i2c.c src/peripheral_gdbus_pwm.c diff --git a/include/interface/gpio.h b/include/interface/gpio.h new file mode 100644 index 0000000..b0b7c5b --- /dev/null +++ b/include/interface/gpio.h @@ -0,0 +1,48 @@ +/* + * 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 __GPIO_H__ +#define __GPIO_H__ + +#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 gpio_open(int gpiopin); +int gpio_close(int gpiopin); +int gpio_set_edge_mode(int gpiopin, gpio_edge_e edge); +int gpio_get_edge_mode(int gpiopin, gpio_edge_e *edge); +int gpio_set_direction(int gpiopin, gpio_direction_e dir); +int gpio_get_direction(int gpiopin, gpio_direction_e *dir); +int gpio_write(int gpiopin, int value); +int gpio_read(int gpiopin, int *value); + +int gpio_open_isr(int gpiopin); +int gpio_close_isr(int file_hndl); +int gpio_read_isr(void *fdset, char *rev_buf, int length); +#endif/*__GPIO_H__*/ diff --git a/include/interface/i2c.h b/include/interface/i2c.h new file mode 100644 index 0000000..f0d4668 --- /dev/null +++ b/include/interface/i2c.h @@ -0,0 +1,65 @@ +/* + * 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 __I2C_H__ +#define __I2C_H__ + +#include + +#define SYSFS_I2C_DIR "/dev/i2c" +#define I2C_BUFFER_MAX 64 + +#define I2C_SLAVE 0x0703 /* Use this slave address */ +#define I2C_SMBUS 0x0720 /* SMBus transfer */ + +/* i2c_smbus_xfer read or write markers */ +#define I2C_SMBUS_READ 1 +#define I2C_SMBUS_WRITE 0 + +/* SMBus transaction types */ +#define I2C_SMBUS_QUICK 0 +#define I2C_SMBUS_BYTE 1 +#define I2C_SMBUS_BYTE_DATA 2 +#define I2C_SMBUS_WORD_DATA 3 + +/* + * Data for SMBus Messages + */ +#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ + +union i2c_smbus_data { + uint8_t byte; + uint16_t word; + uint8_t block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ + /* and one more for user-space compatibility */ +}; + +/* This is the structure as used in the I2C_SMBUS ioctl call */ +struct i2c_smbus_ioctl_data { + uint8_t read_write; + uint8_t command; + uint32_t size; + union i2c_smbus_data *data; +}; + +int i2c_open(int bus, int *fd); +int i2c_close(int fd); +int i2c_set_address(int fd, int address); +int i2c_read(int fd, unsigned char *data, int length); +int i2c_write(int fd, const unsigned char *data, int length); +int i2c_smbus_ioctl(int fd, struct i2c_smbus_ioctl_data *data); + +#endif/* __I2C_H__ */ diff --git a/include/interface/pwm.h b/include/interface/pwm.h new file mode 100644 index 0000000..26243d3 --- /dev/null +++ b/include/interface/pwm.h @@ -0,0 +1,125 @@ +/* + * 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 __PWM_H__ +#define __PWM_H__ + +/** + * @brief Enumeration for Polarity + */ +typedef enum { + PWM_POLARITY_NORMAL = 0, + PWM_POLARITY_INVERSED, +} pwm_polarity_e; + +/** +* @brief pwm_open() init pwm pin. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int pwm_open(int chip, int pin); + +/** +* @brief pwm_close() deinit pwm pin. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int pwm_close(int chip, int pin); + +/** +* @brief pwm_set_period() sets the pwm period. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @param[in] period pwm period +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int pwm_set_period(int chip, int pin, int period); + +/** +* @brief pwm_get_period() gets the pwm period. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @param[out] period pwm period +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int pwm_get_period(int chip, int pin, int *period); + +/** +* @brief pwm_set_duty_cycle() sets the pwm duty cycle. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @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(int chip, int pin, int duty_cycle); + +/** +* @brief pwm_get_duty_cycle() gets the pwm duty cycle. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @param[out] duty_cycle pwm duty cycle +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int pwm_get_duty_cycle(int chip, int pin, int *duty_cycle); + +/** +* @brief pwm_set_polarity() sets the pwm polarity. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @param[in] polarity pwm polarity +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int pwm_set_polarity(int chip, int pin, pwm_polarity_e polarity); +/** +* @brief pwm_get_polarity() gets the pwm polarity. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @param[out] polarity pwm polarity +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int pwm_get_polarity(int chip, int pin, pwm_polarity_e *polarity); + +/** +* @brief pwm_set_enable() sets the pwm state. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @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(int chip, int pin, bool enable); + +/** +* @brief pwm_get_enable() checks if pwm state is enabled. +* +* @param[in] chip pwm chip number +* @param[in] pin pwm pin number +* @param[out] enable pwm enable/disabled state value +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int pwm_get_enable(int chip, int pin, bool *enable); + +#endif /* __PWM_H__ */ diff --git a/include/interface/spi.h b/include/interface/spi.h new file mode 100644 index 0000000..9937c41 --- /dev/null +++ b/include/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 __SPI_H__ +#define __SPI_H__ + +int spi_open(int bus, int cs, int *fd); +int spi_close(int fd); +int spi_set_mode(int fd, unsigned char mode); +int spi_set_bit_order(int fd, unsigned char lsb); +int spi_set_bits_per_word(int fd, unsigned char bits); +int spi_set_frequency(int fd, unsigned int freq); +int spi_get_buffer_size(int *bufsiz); +int spi_read(int fd, unsigned char *rxbuf, int length); +int spi_write(int fd, unsigned char *txbuf, int length); +int spi_transfer(int fd, unsigned char *txbuf, unsigned char *rxbuf, int length); + +#endif /* __SPI_H__ */ diff --git a/include/interface/uart.h b/include/interface/uart.h new file mode 100644 index 0000000..413b23e --- /dev/null +++ b/include/interface/uart.h @@ -0,0 +1,185 @@ +/* + * 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 __UART_H__ +#define __UART_H__ + +#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_valid_baudrate() validation check of input baudrate +* +* @param[in] baudrate baudrate for uart +* @return On success, valid input. On failure, NULL is returned. +*/ +int uart_valid_baud_rate(unsigned int baud_rate); + +/** +* @brief uart_open() initializes uart port. +* +* @param[in] port uart port +* @param[in] file_hndl handle of uart port +* @return On success, handle of uart_context is returned. On failure, NULL is returned. +*/ +int uart_open(int port, int *file_hndl); + +/** +* @brief uart_close() closes uart port. +* +* @param[in] file_hndl handle of uart_context +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int uart_close(int file_hndl); + +/** +* @brief uart_flush() flushes uart buffer. +* +* @param[in] file_hndl handle of uart_context +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int uart_flush(int file_hndl); + +/** +* @brief uart_set_baudrate() sets uart baud rate. +* +* @param[in] file_hndl handle of uart_context +* @param[in] baud uart baud rate +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int uart_set_baud_rate(int file_hndl, 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 uart_set_mode(int file_hndl, 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 +* @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(int file_hndl, uart_byte_size_e byte_size); + +/** +* @brief peripheral_bus_uart_set_parity() set parity bit. +* +* @param[in] file_hndl handle of uart_context +* @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(int file_hndl, uart_parity_e parity); + +/** +* @brief peripheral_bus_uart_set_stop_bits() set stop bits. +* +* @param[in] file_hndl handle of uart_context +* @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(int file_hndl, uart_stop_bits_e stop_bits); + +/** +* @brief uart_set_flow_control() set flow control settings. +* +* @param[in] file_hndl handle of uart_context +* @param[in] xonxoff ixon/ixoff +* @param[in] rtscts rts/cts +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int uart_set_flow_control(int file_hndl, bool xonxoff, bool rtscts); + +/** +* @brief uart_read() reads data over uart bus. +* +* @param[in] file_hndl handle of uart_context +* @param[in] buf the pointer of data buffer +* @param[in] length size to read +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int uart_read(int file_hndl, uint8_t *buf, unsigned int length); + +/** +* @brief uart_write() writes data over uart bus. +* +* @param[in] file_hndl handle of uart_context +* @param[in] buf the pointer of data buffer +* @param[in] length size to write +* @return On success, 0 is returned. On failure, a negative value is returned. +*/ +int uart_write(int file_hndl, uint8_t *buf, unsigned int length); + +#endif /* __UART_H__ */ + diff --git a/src/interface/include/gpio.h b/src/interface/include/gpio.h deleted file mode 100644 index b0b7c5b..0000000 --- a/src/interface/include/gpio.h +++ /dev/null @@ -1,48 +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 __GPIO_H__ -#define __GPIO_H__ - -#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 gpio_open(int gpiopin); -int gpio_close(int gpiopin); -int gpio_set_edge_mode(int gpiopin, gpio_edge_e edge); -int gpio_get_edge_mode(int gpiopin, gpio_edge_e *edge); -int gpio_set_direction(int gpiopin, gpio_direction_e dir); -int gpio_get_direction(int gpiopin, gpio_direction_e *dir); -int gpio_write(int gpiopin, int value); -int gpio_read(int gpiopin, int *value); - -int gpio_open_isr(int gpiopin); -int gpio_close_isr(int file_hndl); -int gpio_read_isr(void *fdset, char *rev_buf, int length); -#endif/*__GPIO_H__*/ diff --git a/src/interface/include/i2c.h b/src/interface/include/i2c.h deleted file mode 100644 index f0d4668..0000000 --- a/src/interface/include/i2c.h +++ /dev/null @@ -1,65 +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 __I2C_H__ -#define __I2C_H__ - -#include - -#define SYSFS_I2C_DIR "/dev/i2c" -#define I2C_BUFFER_MAX 64 - -#define I2C_SLAVE 0x0703 /* Use this slave address */ -#define I2C_SMBUS 0x0720 /* SMBus transfer */ - -/* i2c_smbus_xfer read or write markers */ -#define I2C_SMBUS_READ 1 -#define I2C_SMBUS_WRITE 0 - -/* SMBus transaction types */ -#define I2C_SMBUS_QUICK 0 -#define I2C_SMBUS_BYTE 1 -#define I2C_SMBUS_BYTE_DATA 2 -#define I2C_SMBUS_WORD_DATA 3 - -/* - * Data for SMBus Messages - */ -#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ - -union i2c_smbus_data { - uint8_t byte; - uint16_t word; - uint8_t block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ - /* and one more for user-space compatibility */ -}; - -/* This is the structure as used in the I2C_SMBUS ioctl call */ -struct i2c_smbus_ioctl_data { - uint8_t read_write; - uint8_t command; - uint32_t size; - union i2c_smbus_data *data; -}; - -int i2c_open(int bus, int *fd); -int i2c_close(int fd); -int i2c_set_address(int fd, int address); -int i2c_read(int fd, unsigned char *data, int length); -int i2c_write(int fd, const unsigned char *data, int length); -int i2c_smbus_ioctl(int fd, struct i2c_smbus_ioctl_data *data); - -#endif/* __I2C_H__ */ diff --git a/src/interface/include/pwm.h b/src/interface/include/pwm.h deleted file mode 100644 index 26243d3..0000000 --- a/src/interface/include/pwm.h +++ /dev/null @@ -1,125 +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 __PWM_H__ -#define __PWM_H__ - -/** - * @brief Enumeration for Polarity - */ -typedef enum { - PWM_POLARITY_NORMAL = 0, - PWM_POLARITY_INVERSED, -} pwm_polarity_e; - -/** -* @brief pwm_open() init pwm pin. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int pwm_open(int chip, int pin); - -/** -* @brief pwm_close() deinit pwm pin. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int pwm_close(int chip, int pin); - -/** -* @brief pwm_set_period() sets the pwm period. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @param[in] period pwm period -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int pwm_set_period(int chip, int pin, int period); - -/** -* @brief pwm_get_period() gets the pwm period. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @param[out] period pwm period -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int pwm_get_period(int chip, int pin, int *period); - -/** -* @brief pwm_set_duty_cycle() sets the pwm duty cycle. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @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(int chip, int pin, int duty_cycle); - -/** -* @brief pwm_get_duty_cycle() gets the pwm duty cycle. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @param[out] duty_cycle pwm duty cycle -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int pwm_get_duty_cycle(int chip, int pin, int *duty_cycle); - -/** -* @brief pwm_set_polarity() sets the pwm polarity. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @param[in] polarity pwm polarity -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int pwm_set_polarity(int chip, int pin, pwm_polarity_e polarity); -/** -* @brief pwm_get_polarity() gets the pwm polarity. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @param[out] polarity pwm polarity -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int pwm_get_polarity(int chip, int pin, pwm_polarity_e *polarity); - -/** -* @brief pwm_set_enable() sets the pwm state. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @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(int chip, int pin, bool enable); - -/** -* @brief pwm_get_enable() checks if pwm state is enabled. -* -* @param[in] chip pwm chip number -* @param[in] pin pwm pin number -* @param[out] enable pwm enable/disabled state value -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int pwm_get_enable(int chip, int pin, bool *enable); - -#endif /* __PWM_H__ */ diff --git a/src/interface/include/spi.h b/src/interface/include/spi.h deleted file mode 100644 index 9937c41..0000000 --- a/src/interface/include/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__ - -int spi_open(int bus, int cs, int *fd); -int spi_close(int fd); -int spi_set_mode(int fd, unsigned char mode); -int spi_set_bit_order(int fd, unsigned char lsb); -int spi_set_bits_per_word(int fd, unsigned char bits); -int spi_set_frequency(int fd, unsigned int freq); -int spi_get_buffer_size(int *bufsiz); -int spi_read(int fd, unsigned char *rxbuf, int length); -int spi_write(int fd, unsigned char *txbuf, int length); -int spi_transfer(int fd, unsigned char *txbuf, unsigned char *rxbuf, int length); - -#endif /* __SPI_H__ */ diff --git a/src/interface/include/uart.h b/src/interface/include/uart.h deleted file mode 100644 index 413b23e..0000000 --- a/src/interface/include/uart.h +++ /dev/null @@ -1,185 +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 __UART_H__ -#define __UART_H__ - -#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_valid_baudrate() validation check of input baudrate -* -* @param[in] baudrate baudrate for uart -* @return On success, valid input. On failure, NULL is returned. -*/ -int uart_valid_baud_rate(unsigned int baud_rate); - -/** -* @brief uart_open() initializes uart port. -* -* @param[in] port uart port -* @param[in] file_hndl handle of uart port -* @return On success, handle of uart_context is returned. On failure, NULL is returned. -*/ -int uart_open(int port, int *file_hndl); - -/** -* @brief uart_close() closes uart port. -* -* @param[in] file_hndl handle of uart_context -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int uart_close(int file_hndl); - -/** -* @brief uart_flush() flushes uart buffer. -* -* @param[in] file_hndl handle of uart_context -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int uart_flush(int file_hndl); - -/** -* @brief uart_set_baudrate() sets uart baud rate. -* -* @param[in] file_hndl handle of uart_context -* @param[in] baud uart baud rate -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int uart_set_baud_rate(int file_hndl, 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 uart_set_mode(int file_hndl, 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 -* @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(int file_hndl, uart_byte_size_e byte_size); - -/** -* @brief peripheral_bus_uart_set_parity() set parity bit. -* -* @param[in] file_hndl handle of uart_context -* @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(int file_hndl, uart_parity_e parity); - -/** -* @brief peripheral_bus_uart_set_stop_bits() set stop bits. -* -* @param[in] file_hndl handle of uart_context -* @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(int file_hndl, uart_stop_bits_e stop_bits); - -/** -* @brief uart_set_flow_control() set flow control settings. -* -* @param[in] file_hndl handle of uart_context -* @param[in] xonxoff ixon/ixoff -* @param[in] rtscts rts/cts -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int uart_set_flow_control(int file_hndl, bool xonxoff, bool rtscts); - -/** -* @brief uart_read() reads data over uart bus. -* -* @param[in] file_hndl handle of uart_context -* @param[in] buf the pointer of data buffer -* @param[in] length size to read -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int uart_read(int file_hndl, uint8_t *buf, unsigned int length); - -/** -* @brief uart_write() writes data over uart bus. -* -* @param[in] file_hndl handle of uart_context -* @param[in] buf the pointer of data buffer -* @param[in] length size to write -* @return On success, 0 is returned. On failure, a negative value is returned. -*/ -int uart_write(int file_hndl, uint8_t *buf, unsigned int length); - -#endif /* __UART_H__ */ -