int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio);
int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio);
-int peripheral_gdbus_gpio_get_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e *direction);
int peripheral_gdbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction);
+int peripheral_gdbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge);
+int peripheral_gdbus_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data);
+int peripheral_gdbus_gpio_unset_interrupted_cb(peripheral_gpio_h gpio);
int peripheral_gdbus_gpio_read(peripheral_gpio_h gpio, int *value);
int peripheral_gdbus_gpio_write(peripheral_gpio_h gpio, int value);
-int peripheral_gdbus_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e *edge);
-int peripheral_gdbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge);
-int peripheral_gdbus_gpio_register_cb(peripheral_gpio_h gpio, gpio_isr_cb callback, void *user_data);
-int peripheral_gdbus_gpio_unregister_cb(peripheral_gpio_h gpio);
#endif /* __PERIPHERAL_GDBUS_GPIO_H__ */
void pwm_proxy_init(void);
void pwm_proxy_deinit(void);
-int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int device, int channel);
+int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin);
int peripheral_gdbus_pwm_close(peripheral_pwm_h pwm);
int peripheral_gdbus_pwm_set_period(peripheral_pwm_h pwm, int period);
-int peripheral_gdbus_pwm_get_period(peripheral_pwm_h pwm, int *period);
-int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle);
-int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle);
+int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle_ns);
int peripheral_gdbus_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity);
-int peripheral_gdbus_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e *polarity);
int peripheral_gdbus_pwm_set_enable(peripheral_pwm_h pwm, bool enable);
-int peripheral_gdbus_pwm_get_enable(peripheral_pwm_h pwm, bool *enable);
#endif /* __PERIPHERAL_GDBUS_PWM_H__ */
int peripheral_gdbus_spi_open(peripheral_spi_h spi, int bus, int cs);
int peripheral_gdbus_spi_close(peripheral_spi_h spi);
int peripheral_gdbus_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode);
-int peripheral_gdbus_spi_get_mode(peripheral_spi_h spi, peripheral_spi_mode_e *mode);
-int peripheral_gdbus_spi_set_lsb_first(peripheral_spi_h spi, bool lsb);
-int peripheral_gdbus_spi_get_lsb_first(peripheral_spi_h spi, bool *lsb);
-int peripheral_gdbus_spi_set_bits(peripheral_spi_h spi, unsigned char bits);
-int peripheral_gdbus_spi_get_bits(peripheral_spi_h spi, unsigned char *bits);
-int peripheral_gdbus_spi_set_frequency(peripheral_spi_h spi, unsigned int freq);
-int peripheral_gdbus_spi_get_frequency(peripheral_spi_h spi, unsigned int *freq);
+int peripheral_gdbus_spi_set_bit_order(peripheral_spi_h spi, bool lsb);
+int peripheral_gdbus_spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits);
+int peripheral_gdbus_spi_set_frequency(peripheral_spi_h spi, unsigned int freq_hz);
int peripheral_gdbus_spi_read(peripheral_spi_h spi, unsigned char *data, int length);
int peripheral_gdbus_spi_write(peripheral_spi_h spi, unsigned char *data, int length);
-int peripheral_gdbus_spi_read_write(peripheral_spi_h spi, unsigned char *tx_data, unsigned char *rx_data, int length);
+int peripheral_gdbus_spi_transfer(peripheral_spi_h spi, unsigned char *tx_data, unsigned char *rx_data, int length);
#endif /* __PERIPHERAL_GDBUS_SPI_H_ */
int peripheral_gdbus_uart_open(peripheral_uart_h uart, int port);
int peripheral_gdbus_uart_close(peripheral_uart_h uart);
-int peripheral_gdbus_uart_flush(peripheral_uart_h uart);
-int peripheral_gdbus_uart_set_baudrate(peripheral_uart_h uart, peripheral_uart_baudrate_e baud);
-int peripheral_gdbus_uart_set_mode(peripheral_uart_h uart, peripheral_uart_bytesize_e bytesize, peripheral_uart_parity_e parity, peripheral_uart_stopbits_e stopbits);
-int peripheral_gdbus_uart_set_flowcontrol(peripheral_uart_h uart, bool xonxoff, bool rtscts);
+int peripheral_gdbus_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud);
+int peripheral_gdbus_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size);
+int peripheral_gdbus_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity);
+int peripheral_gdbus_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits);
+int peripheral_gdbus_uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts);
int peripheral_gdbus_uart_read(peripheral_uart_h uart, uint8_t *data, int length);
int peripheral_gdbus_uart_write(peripheral_uart_h uart, uint8_t *data, int length);
#include "peripheral_internal.h"
#include "peripheral_io_gdbus.h"
-extern int peripheral_gpio_isr_callback(int pin, int value, unsigned long long timestamp);
-
-void handle_gpio_changed(
- PeripheralIoGdbusGpio *gpio,
- gint pin,
- gint value,
- guint64 timestamp,
- gpointer user_data);
+extern int peripheral_gpio_interrupted_cb_handler(int pin, int value, unsigned long long timestamp, int err);
PeripheralIoGdbusGpio *gpio_proxy = NULL;
+static void __peripheral_gpio_interrupted_cb(PeripheralIoGdbusGpio *gpio, gint pin, gint value, guint64 timestamp, gpointer user_data)
+{
+ int err = PERIPHERAL_ERROR_NONE;
+ if (!gpio)
+ err = PERIPHERAL_ERROR_IO_ERROR;
+
+ peripheral_gpio_interrupted_cb_handler(pin, value, timestamp, err);
+}
+
void gpio_proxy_init(void)
{
GError *error = NULL;
}
g_signal_connect(gpio_proxy,
- "gpio-changed",
- G_CALLBACK(handle_gpio_changed),
+ "interrupted-cb",
+ G_CALLBACK(__peripheral_gpio_interrupted_cb),
NULL);
}
}
}
-void handle_gpio_changed(
- PeripheralIoGdbusGpio *gpio,
- gint pin,
- gint value,
- guint64 timestamp,
- gpointer user_data)
-{
- if (!gpio)
- return;
-
- peripheral_gpio_isr_callback(pin, value, timestamp);
-}
-
int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio)
{
GError *error = NULL;
return ret;
}
-int peripheral_gdbus_gpio_get_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e *direction)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- gint value = 0;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_get_direction_sync(
- gpio_proxy,
- gpio->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
- g_error_free(error);
- }
-
- if (value >= PERIPHERAL_GPIO_DIRECTION_IN && value <= PERIPHERAL_GPIO_DIRECTION_OUT_HIGH)
- *direction = value;
- else
- return PERIPHERAL_ERROR_UNKNOWN;
-
- return ret;
-}
-
int peripheral_gdbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction)
{
GError *error = NULL;
return ret;
}
-int peripheral_gdbus_gpio_read(peripheral_gpio_h gpio, int *value)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_read_sync(
- gpio_proxy,
- gpio->handle,
- value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_gdbus_gpio_write(peripheral_gpio_h gpio, int value)
+int peripheral_gdbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_gpio_call_write_sync(
+ if (peripheral_io_gdbus_gpio_call_set_edge_mode_sync(
gpio_proxy,
gpio->handle,
- value,
+ edge,
&ret,
NULL,
&error) == FALSE) {
return ret;
}
-int peripheral_gdbus_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e *edge)
+int peripheral_gdbus_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- gint value = 0;
if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_gpio_call_get_edge_mode_sync(
+ if (peripheral_io_gdbus_gpio_call_set_interrupted_cb_sync(
gpio_proxy,
gpio->handle,
- &value,
&ret,
NULL,
&error) == FALSE) {
return PERIPHERAL_ERROR_UNKNOWN;
}
- if (value >= PERIPHERAL_GPIO_EDGE_NONE && value <= PERIPHERAL_GPIO_EDGE_BOTH)
- *edge = value;
- else
- return PERIPHERAL_ERROR_UNKNOWN;
-
return ret;
}
-int peripheral_gdbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge)
+int peripheral_gdbus_gpio_unset_interrupted_cb(peripheral_gpio_h gpio)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_gpio_call_set_edge_mode_sync(
+ if (peripheral_io_gdbus_gpio_call_unset_interrupted_cb_sync(
gpio_proxy,
gpio->handle,
- edge,
&ret,
NULL,
&error) == FALSE) {
return ret;
}
-int peripheral_gdbus_gpio_register_cb(peripheral_gpio_h gpio, gpio_isr_cb callback, void *user_data)
+int peripheral_gdbus_gpio_read(peripheral_gpio_h gpio, int *value)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_gpio_call_register_irq_sync(
+ if (peripheral_io_gdbus_gpio_call_read_sync(
gpio_proxy,
gpio->handle,
+ value,
&ret,
NULL,
&error) == FALSE) {
return ret;
}
-int peripheral_gdbus_gpio_unregister_cb(peripheral_gpio_h gpio)
+int peripheral_gdbus_gpio_write(peripheral_gpio_h gpio, int value)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_gpio_call_unregister_irq_sync(
+ if (peripheral_io_gdbus_gpio_call_write_sync(
gpio_proxy,
gpio->handle,
+ value,
&ret,
NULL,
&error) == FALSE) {
}
return ret;
-}
+}
\ No newline at end of file
}
}
-int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int device, int channel)
+int peripheral_gdbus_pwm_open(peripheral_pwm_h pwm, int chip, int pin)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (peripheral_io_gdbus_pwm_call_open_sync(
pwm_proxy,
- device,
- channel,
+ chip,
+ pin,
&pwm->handle,
&ret,
NULL,
return ret;
}
-int peripheral_gdbus_pwm_get_period(peripheral_pwm_h pwm, int *period)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- gint value = 0;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_pwm_call_get_period_sync(
- pwm_proxy,
- pwm->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- *period = value;
-
- return ret;
-}
-
-int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle)
+int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle_ns)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (peripheral_io_gdbus_pwm_call_set_duty_cycle_sync(
pwm_proxy,
pwm->handle,
- duty_cycle,
+ duty_cycle_ns,
&ret,
NULL,
&error) == FALSE) {
return ret;
}
-int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- gint value = 0;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_pwm_call_get_duty_cycle_sync(
- pwm_proxy,
- pwm->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- *duty_cycle = value;
-
- return ret;
-}
-
int peripheral_gdbus_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity)
{
GError *error = NULL;
return ret;
}
-int peripheral_gdbus_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e *polarity)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- gint value = 0;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_pwm_call_get_polarity_sync(
- pwm_proxy,
- pwm->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- if (!value)
- *polarity = PERIPHERAL_PWM_POLARITY_NORMAL;
- else
- *polarity = PERIPHERAL_PWM_POLARITY_INVERSED;
-
- return ret;
-}
-
int peripheral_gdbus_pwm_set_enable(peripheral_pwm_h pwm, bool enable)
{
GError *error = NULL;
return ret;
}
-
-int peripheral_gdbus_pwm_get_enable(peripheral_pwm_h pwm, bool *enable)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- gboolean value = 0;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_pwm_call_get_enable_sync(
- pwm_proxy,
- pwm->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- if (!value)
- *enable = false;
- else
- *enable = true;
-
- return ret;
-}
-
return ret;
}
-int peripheral_gdbus_spi_get_mode(peripheral_spi_h spi, peripheral_spi_mode_e *mode)
+int peripheral_gdbus_spi_set_bit_order(peripheral_spi_h spi, bool lsb)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- guchar value;
if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_spi_call_get_mode_sync(
- spi_proxy,
- spi->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- if (value <= PERIPHERAL_SPI_MODE_3)
- *mode = value;
- else
- _E("Invalid mode : %d", value);
-
- return ret;
-}
-
-int peripheral_gdbus_spi_set_lsb_first(peripheral_spi_h spi, bool lsb)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_spi_call_set_lsb_first_sync(
+ if (peripheral_io_gdbus_spi_call_set_bit_order_sync(
spi_proxy,
spi->handle,
lsb,
return ret;
}
-int peripheral_gdbus_spi_get_lsb_first(peripheral_spi_h spi, bool *lsb)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- gboolean value;
-
- if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_spi_call_get_lsb_first_sync(
- spi_proxy,
- spi->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- *lsb = value ? true : false;
-
- return ret;
-}
-
-int peripheral_gdbus_spi_set_bits(peripheral_spi_h spi, unsigned char bits)
+int peripheral_gdbus_spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_spi_call_set_bits_sync(
+ if (peripheral_io_gdbus_spi_call_set_bits_per_word_sync(
spi_proxy,
spi->handle,
bits,
return ret;
}
-int peripheral_gdbus_spi_get_bits(peripheral_spi_h spi, unsigned char *bits)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- guchar value;
-
- if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_spi_call_get_bits_sync(
- spi_proxy,
- spi->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- *bits = (unsigned char)value;
-
- return ret;
-}
-
-int peripheral_gdbus_spi_set_frequency(peripheral_spi_h spi, unsigned int freq)
+int peripheral_gdbus_spi_set_frequency(peripheral_spi_h spi, unsigned int freq_hz)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
if (peripheral_io_gdbus_spi_call_set_frequency_sync(
spi_proxy,
spi->handle,
- freq,
+ freq_hz,
&ret,
NULL,
&error) == FALSE) {
return ret;
}
-int peripheral_gdbus_spi_get_frequency(peripheral_spi_h spi, unsigned int *freq)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- guint value;
-
- if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_spi_call_get_frequency_sync(
- spi_proxy,
- spi->handle,
- &value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- *freq = (unsigned int)value;
-
- return ret;
-}
-
int peripheral_gdbus_spi_read(peripheral_spi_h spi, unsigned char *data, int length)
{
GError *error = NULL;
return ret;
}
-int peripheral_gdbus_spi_read_write(peripheral_spi_h spi, unsigned char *tx_data, unsigned char *rx_data, int length)
+int peripheral_gdbus_spi_transfer(peripheral_spi_h spi, unsigned char *tx_data, unsigned char *rx_data, int length)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
tx_data_array = g_variant_new("a(y)", builder);
g_variant_builder_unref(builder);
- if (peripheral_io_gdbus_spi_call_read_write_sync(
+ if (peripheral_io_gdbus_spi_call_transfer_sync(
spi_proxy,
spi->handle,
length,
return ret;
}
-int peripheral_gdbus_uart_flush(peripheral_uart_h uart)
+int peripheral_gdbus_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud)
{
GError *error = NULL;
gint32 ret = PERIPHERAL_ERROR_NONE;
if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_uart_call_flush_sync(
+ if (peripheral_io_gdbus_uart_call_set_baud_rate_sync(
uart_proxy,
uart->handle,
+ baud,
&ret,
NULL,
&error) == FALSE) {
return ret;
}
-int peripheral_gdbus_uart_set_baudrate(peripheral_uart_h uart, peripheral_uart_baudrate_e baud)
+int peripheral_gdbus_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size)
{
GError *error = NULL;
gint32 ret = PERIPHERAL_ERROR_NONE;
if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_uart_call_set_baudrate_sync(
+ if (peripheral_io_gdbus_uart_call_set_byte_size_sync(
uart_proxy,
uart->handle,
- baud,
+ byte_size,
&ret,
NULL,
&error) == FALSE) {
return ret;
}
-int peripheral_gdbus_uart_set_mode(peripheral_uart_h uart, peripheral_uart_bytesize_e bytesize, peripheral_uart_parity_e parity, peripheral_uart_stopbits_e stopbits)
+int peripheral_gdbus_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity)
{
GError *error = NULL;
gint32 ret = PERIPHERAL_ERROR_NONE;
if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_uart_call_set_mode_sync(
+ if (peripheral_io_gdbus_uart_call_set_parity_sync(
uart_proxy,
uart->handle,
- bytesize,
parity,
- stopbits,
&ret,
NULL,
&error) == FALSE) {
return ret;
}
-int peripheral_gdbus_uart_set_flowcontrol(peripheral_uart_h uart, bool xonxoff, bool rtscts)
+int peripheral_gdbus_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_uart_call_set_stop_bits_sync(
+ uart_proxy,
+ uart->handle,
+ stop_bits,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_uart_set_flow_control(peripheral_uart_h uart, bool xonxoff, bool rtscts)
{
GError *error = NULL;
gint32 ret = PERIPHERAL_ERROR_NONE;
if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
- if (peripheral_io_gdbus_uart_call_set_flowcontrol_sync(
+ if (peripheral_io_gdbus_uart_call_set_flow_control_sync(
uart_proxy,
uart->handle,
xonxoff,
#include "peripheral_io_gdbus.h"
typedef struct {
- int pin;
- gpio_isr_cb callback;
+ peripheral_gpio_h handle;
+ peripheral_gpio_interrupted_cb callback;
void *user_data;
-} gpio_isr_data_s;
+} interrupted_cb_info_s;
-static GList *gpio_isr_list = NULL;
+static GList *interrupted_cb_info_list = NULL;
-int peripheral_gpio_isr_callback(int pin, int value, unsigned long long timestamp)
+int peripheral_gpio_interrupted_cb_handler(int pin, int value, unsigned long long timestamp, int error)
{
GList *link;
- gpio_isr_data_s *isr_data;
- gpio_isr_cb_s cb_data;
+ interrupted_cb_info_s *cb_info;
- link = gpio_isr_list;
+ link = interrupted_cb_info_list;
while (link) {
- isr_data = (gpio_isr_data_s*)link->data;
-
- if (isr_data->pin == pin) {
- cb_data.pin = pin;
- cb_data.value = value;
- cb_data.timestamp = timestamp;
- if (isr_data->callback)
- isr_data->callback(&cb_data, isr_data->user_data);
+ cb_info = (interrupted_cb_info_s*)link->data;
+ if (cb_info->handle->pin == pin) {
+ if (cb_info->callback)
+ cb_info->callback(cb_info->handle, error, cb_info->user_data);
return PERIPHERAL_ERROR_NONE;
}
link = g_list_next(link);
return PERIPHERAL_ERROR_NONE;
}
-int peripheral_gpio_isr_set(int pin, gpio_isr_cb callback, void *user_data)
+static int __interrupted_cb_info_list_append(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data)
{
GList *link;
- gpio_isr_data_s *isr_data = NULL;
+ interrupted_cb_info_s *cb_info = NULL;
- link = gpio_isr_list;
+ link = interrupted_cb_info_list;
while (link) {
- gpio_isr_data_s *tmp;
- tmp = (gpio_isr_data_s*)link->data;
- if (tmp->pin == pin) {
- isr_data = tmp;
+ interrupted_cb_info_s *tmp;
+ tmp = (interrupted_cb_info_s*)link->data;
+ if (tmp->handle == gpio) {
+ cb_info = tmp;
break;
}
link = g_list_next(link);
}
- if (isr_data == NULL) {
- isr_data = (gpio_isr_data_s*)calloc(1, sizeof(gpio_isr_data_s));
- if (isr_data == NULL) {
- _E("failed to allocate gpio_isr_data_s");
+ if (cb_info == NULL) {
+ cb_info = (interrupted_cb_info_s*)calloc(1, sizeof(interrupted_cb_info_s));
+ if (cb_info == NULL) {
+ _E("failed to allocate interrupted_cb_info_s");
return PERIPHERAL_ERROR_OUT_OF_MEMORY;
}
- gpio_isr_list = g_list_append(gpio_isr_list, isr_data);
+ link = g_list_append(link, cb_info);
}
- isr_data->pin = pin;
- isr_data->callback = callback;
- isr_data->user_data = user_data;
+ cb_info->handle = gpio;
+ cb_info->callback = callback;
+ cb_info->user_data = user_data;
return PERIPHERAL_ERROR_NONE;
}
-int peripheral_gpio_isr_unset(int pin)
+static int __interrupted_cb_info_list_remove(peripheral_gpio_h gpio)
{
GList *link;
- gpio_isr_data_s *isr_data;
+ interrupted_cb_info_s *cb_info;
- link = gpio_isr_list;
+ link = interrupted_cb_info_list;
while (link) {
- isr_data = (gpio_isr_data_s*)link->data;
+ cb_info = (interrupted_cb_info_s*)link->data;
- if (isr_data->pin == pin) {
- gpio_isr_list = g_list_remove_link(gpio_isr_list, link);
+ if (cb_info->handle == gpio) {
+ interrupted_cb_info_list = g_list_remove_link(interrupted_cb_info_list, link);
free(link->data);
g_list_free(link);
break;
}
/**
- * @brief Gets direction of the gpio.
- */
-int peripheral_gpio_get_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e *direction)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
-
- ret = peripheral_gdbus_gpio_get_direction(gpio, direction);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get direction of the gpio pin, ret : %d", ret);
-
- return ret;
-}
-
-
-/**
* @brief Sets direction of the gpio pin.
*/
int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction)
int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
- RETVM_IF(direction > PERIPHERAL_GPIO_DIRECTION_OUT_HIGH, PERIPHERAL_ERROR_INVALID_PARAMETER,
- "Invalid direction input");
/* call gpio_set_direction */
ret = peripheral_gdbus_gpio_set_direction(gpio, direction);
return ret;
}
-/**
- * @brief Reads value of the gpio.
- */
-int peripheral_gpio_read(peripheral_gpio_h gpio, int *value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
-
- /* call gpio_read */
- ret = peripheral_gdbus_gpio_read(gpio, value);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to read value of the gpio pin, ret : %d", ret);
-
- return ret;
-}
-
-/**
- * @brief Writes value to the gpio.
- */
-int peripheral_gpio_write(peripheral_gpio_h gpio, int value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
-
- /* call gpio_write */
- ret = peripheral_gdbus_gpio_write(gpio, value);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to write to the gpio pin, ret : %d", ret);
-
- return ret;
-}
-
-/**
- * @brief Gets the edge mode of the gpio.
- */
-int peripheral_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e *edge)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
-
- ret = peripheral_gdbus_gpio_get_edge_mode(gpio, edge);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get edge mode of the gpio pin, ret : %d", ret);
-
- return ret;
-}
/**
* @brief Sets the edge mode of the gpio pin.
/**
* @brief Registers a callback function to be invoked when the gpio interrupt is triggered.
*/
-int peripheral_gpio_register_cb(peripheral_gpio_h gpio, gpio_isr_cb callback, void *user_data)
+int peripheral_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data)
{
int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
- ret = peripheral_gdbus_gpio_register_cb(gpio, callback, user_data);
+ ret = peripheral_gdbus_gpio_set_interrupted_cb(gpio, callback, user_data);
if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to register cb, ret : %d", ret);
+ _E("Failed to set gpio interrupted cb, ret : %d", ret);
return ret;
}
/* set isr */
- ret = peripheral_gpio_isr_set(gpio->pin, callback, user_data);
+ ret = __interrupted_cb_info_list_append(gpio, callback, user_data);
if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to register gpio isr, ret : %d", ret);
+ _E("Failed to append gpio interrupt callback info, ret : %d", ret);
return ret;
}
/**
* @brief Unregisters the callback function for the gpio handler.
*/
-int peripheral_gpio_unregister_cb(peripheral_gpio_h gpio)
+int peripheral_gpio_unset_interrupted_cb(peripheral_gpio_h gpio)
{
int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
- ret = peripheral_gdbus_gpio_unregister_cb(gpio);
+ ret = peripheral_gdbus_gpio_unset_interrupted_cb(gpio);
if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to unregister gpio isr, ret : %d", ret);
+ _E("Failed to unset gpio interrupt callback, ret : %d", ret);
return ret;
}
- /* clean up isr */
- ret = peripheral_gpio_isr_unset(gpio->pin);
+ ret = __interrupted_cb_info_list_remove(gpio);
+ if (ret != PERIPHERAL_ERROR_NONE)
+ _E("Failed to remove gpio interrupt callback info, ret : %d", ret);
return ret;
}
/**
- * @brief Gets pin number of the gpio handle.
+ * @brief Reads value of the gpio.
*/
-int peripheral_gpio_get_pin(peripheral_gpio_h gpio, int *gpio_pin)
+int peripheral_gpio_read(peripheral_gpio_h gpio, uint32_t *value)
{
+ int ret = PERIPHERAL_ERROR_NONE;
+
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
- *gpio_pin = gpio->pin;
+ /* call gpio_read */
+ ret = peripheral_gdbus_gpio_read(gpio, (int *)value);
+ if (ret != PERIPHERAL_ERROR_NONE)
+ _E("Failed to read value of the gpio pin, ret : %d", ret);
- return PERIPHERAL_ERROR_NONE;
+ return ret;
+}
+
+/**
+ * @brief Writes value to the gpio.
+ */
+int peripheral_gpio_write(peripheral_gpio_h gpio, uint32_t value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
+
+ /* call gpio_write */
+ ret = peripheral_gdbus_gpio_write(gpio, (int)value);
+ if (ret != PERIPHERAL_ERROR_NONE)
+ _E("Failed to write to the gpio pin, ret : %d", ret);
+
+ return ret;
}
return ret;
}
-int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length)
+int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
{
int ret;
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL || length < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_i2c_read(i2c, data, length);
+ ret = peripheral_gdbus_i2c_read(i2c, data, (int)length);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to read data from device, ret : %d", ret);
return ret;
}
-int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length)
+int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
{
int ret;
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL || length < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_i2c_write(i2c, data, length);
+ ret = peripheral_gdbus_i2c_write(i2c, data, (int)length);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to write data to device, ret : %d", ret);
return ret;
}
-int peripheral_i2c_read_byte(peripheral_i2c_h i2c, uint8_t *data)
+int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data)
{
int ret;
uint16_t w_data, dummy = 0;
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_READ, 0x0, I2C_SMBUS_BYTE, dummy, &w_data);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to read, ret : %d", ret);
-
- *data = (uint8_t)w_data;
-
- return ret;
-}
-
-int peripheral_i2c_write_byte(peripheral_i2c_h i2c, uint8_t data)
-{
- int ret = PERIPHERAL_ERROR_NONE;
- uint16_t dummy = 0;
-
- RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
-
- ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_WRITE, dummy, I2C_SMBUS_BYTE, (uint16_t)data, &dummy);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to write, ret : %d", ret);
-
- return ret;
-}
-
-int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t address, uint8_t *data)
-{
- int ret;
- uint16_t w_data, dummy = 0;
-
- RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
-
- ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_READ, address, I2C_SMBUS_BYTE_DATA, dummy, &w_data);
+ ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_READ, reg, I2C_SMBUS_BYTE_DATA, dummy, &w_data);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Smbus transaction failed, ret : %d", ret);
return ret;
}
-int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t address, uint8_t data)
+int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data)
{
int ret;
uint16_t dummy = 0;
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_WRITE, address, I2C_SMBUS_BYTE_DATA, (uint16_t)data, &dummy);
+ ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_WRITE, reg, I2C_SMBUS_BYTE_DATA, (uint16_t)data, &dummy);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Smbus transaction failed, ret : %d", ret);
return ret;
}
-int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t address, uint16_t *data)
+int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data)
{
int ret;
uint16_t dummy = 0, data_out;
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_READ, address, I2C_SMBUS_WORD_DATA, dummy, &data_out);
+ ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_READ, reg, I2C_SMBUS_WORD_DATA, dummy, &data_out);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Smbus transaction failed, ret : %d", ret);
return ret;
}
-int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t address, uint16_t data)
+int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data)
{
int ret;
uint16_t dummy = 0;
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_WRITE, address, I2C_SMBUS_WORD_DATA, data, &dummy);
+ ret = peripheral_gdbus_i2c_smbus_ioctl(i2c, I2C_SMBUS_WRITE, reg, I2C_SMBUS_WORD_DATA, data, &dummy);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Smbus transaction failed, ret : %d", ret);
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetDirection">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="direction" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
<method name="SetDirection">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="direction" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="Read">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="value" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="Write">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="value" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="GetEdgeMode">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="edge" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
<method name="SetEdgeMode">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="edge" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="RegisterIrq">
+ <method name="SetInterruptedCb">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="UnregisterIrq">
+ <method name="UnsetInterruptedCb">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <signal name='GpioChanged'>
+ <signal name='InterruptedCb'>
<arg type='i' name='pin'/>
<arg type='i' name='value'/>
<arg type='t' name='timestamp'/>
</signal>
+ <method name="Read">
+ <arg type="u" name="handle" direction="in"/>
+ <arg type="i" name="value" direction="out"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
+ <method name="Write">
+ <arg type="u" name="handle" direction="in"/>
+ <arg type="i" name="value" direction="in"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
</interface>
<interface name="org.tizen.peripheral_io.i2c">
<method name="Open">
</interface>
<interface name="org.tizen.peripheral_io.pwm">
<method name="Open">
- <arg type="i" name="device" direction="in"/>
- <arg type="i" name="channel" direction="in"/>
+ <arg type="i" name="chip" direction="in"/>
+ <arg type="i" name="pin" direction="in"/>
<arg type="u" name="handle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
<arg type="i" name="period" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetPeriod">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="period" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
<method name="SetDutyCycle">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="duty_cycle" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetDutyCycle">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="duty_cycle" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
<method name="SetPolarity">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="polarity" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetPolarity">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="polarity" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
<method name="SetEnable">
<arg type="u" name="handle" direction="in"/>
<arg type="b" name="enable" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetEnable">
- <arg type="u" name="handle" direction="in"/>
- <arg type="b" name="enable" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
<interface name="org.tizen.peripheral_io.uart">
<method name="Open">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="Flush">
+ <method name="SetBaudRate">
<arg type="u" name="handle" direction="in"/>
+ <arg type="u" name="baudrate" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="SetBaudrate">
+ <method name="SetByteSize">
<arg type="u" name="handle" direction="in"/>
- <arg type="u" name="baudrate" direction="in"/>
+ <arg type="u" name="byte_size" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="SetMode">
+ <method name="SetParity">
<arg type="u" name="handle" direction="in"/>
- <arg type="u" name="byte_size" direction="in"/>
<arg type="u" name="parity" direction="in"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
+ <method name="SetStopBits">
+ <arg type="u" name="handle" direction="in"/>
<arg type="u" name="stop_bits" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="SetFlowcontrol">
+ <method name="SetFlowControl">
<arg type="u" name="handle" direction="in"/>
<arg type="b" name="xonxoff" direction="in"/>
<arg type="b" name="rtscts" direction="in"/>
<arg type="y" name="mode" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetMode">
- <arg type="u" name="handle" direction="in"/>
- <arg type="y" name="mode" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="SetLsbFirst">
+ <method name="SetBitOrder">
<arg type="u" name="handle" direction="in"/>
<arg type="b" name="lsb" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetLsbFirst">
- <arg type="u" name="handle" direction="in"/>
- <arg type="b" name="lsb" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="SetBits">
+ <method name="SetBitsPerWord">
<arg type="u" name="handle" direction="in"/>
<arg type="y" name="bits" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetBits">
- <arg type="u" name="handle" direction="in"/>
- <arg type="y" name="bits" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
<method name="SetFrequency">
<arg type="u" name="handle" direction="in"/>
<arg type="u" name="freq" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="GetFrequency">
- <arg type="u" name="handle" direction="in"/>
- <arg type="u" name="freq" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
<method name="Read">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="length" direction="in"/>
</arg>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="ReadWrite">
+ <method name="Transfer">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="length" direction="in"/>
<arg type="a(y)" name="tx_data" direction="in">
#include "peripheral_common.h"
#include "peripheral_internal.h"
-int peripheral_pwm_open(int device, int channel, peripheral_pwm_h *pwm)
+int peripheral_pwm_open(int chip, int pin, peripheral_pwm_h *pwm)
{
peripheral_pwm_h handle;
int ret = PERIPHERAL_ERROR_NONE;
- RETVM_IF(device < 0 || channel < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ RETVM_IF(chip < 0 || pin < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
/* Initialize */
handle = (peripheral_pwm_h)calloc(1, sizeof(struct _peripheral_pwm_s));
pwm_proxy_init();
- ret = peripheral_gdbus_pwm_open(handle, device, channel);
+ ret = peripheral_gdbus_pwm_open(handle, chip, pin);
if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to open PWM device : %d, channel : %d", device, channel);
+ _E("Failed to open PWM chip : %d, pin : %d", chip, pin);
free(handle);
handle = NULL;
}
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
if ((ret = peripheral_gdbus_pwm_close(pwm)) < 0)
- _E("Failed to close PWM device, continuing anyway, ret : %d", ret);
+ _E("Failed to close PWM chip, continuing anyway, ret : %d", ret);
pwm_proxy_deinit();
free(pwm);
return ret;
}
-int peripheral_pwm_set_period(peripheral_pwm_h pwm, int period)
+int peripheral_pwm_set_period(peripheral_pwm_h pwm, uint32_t period_ns)
{
int ret;
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- ret = peripheral_gdbus_pwm_set_period(pwm, period);
+ ret = peripheral_gdbus_pwm_set_period(pwm, (int)period_ns);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to set period, ret : %d", ret);
return ret;
}
-int peripheral_pwm_get_period(peripheral_pwm_h pwm, int *period)
+int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle_ns)
{
int ret;
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- ret = peripheral_gdbus_pwm_get_period(pwm, period);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get period, ret : %d", ret);
-
- return ret;
-}
-
-int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle)
-{
- int ret;
-
- RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
-
- ret = peripheral_gdbus_pwm_set_duty_cycle(pwm, duty_cycle);
+ ret = peripheral_gdbus_pwm_set_duty_cycle(pwm, (int)duty_cycle_ns);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to set duty cycle, ret : %d", ret);
return ret;
}
-int peripheral_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle)
-{
- int ret;
-
- RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
-
- ret = peripheral_gdbus_pwm_get_duty_cycle(pwm, duty_cycle);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get duty cycle, ret : %d", ret);
-
- return ret;
-}
-
int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity)
{
int ret;
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- RETVM_IF(polarity > PERIPHERAL_PWM_POLARITY_INVERSED, PERIPHERAL_ERROR_INVALID_PARAMETER,
- "Invalid polarity parameter");
ret = peripheral_gdbus_pwm_set_polarity(pwm, polarity);
if (ret != PERIPHERAL_ERROR_NONE)
return ret;
}
-int peripheral_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e *polarity)
-{
- int ret;
-
- RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
-
- ret = peripheral_gdbus_pwm_get_polarity(pwm, polarity);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get polarity, ret : %d", ret);
-
- return ret;
-}
-
-int peripheral_pwm_set_enable(peripheral_pwm_h pwm, bool enable)
+int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, bool enable)
{
int ret;
return ret;
}
-
-int peripheral_pwm_get_enable(peripheral_pwm_h pwm, bool *enable)
-{
- int ret;
-
- RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
-
- ret = peripheral_gdbus_pwm_get_enable(pwm, enable);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get enable, ret : %d", ret);
-
- return ret;
-}
return ret;
}
-int peripheral_spi_get_mode(peripheral_spi_h spi, peripheral_spi_mode_e *mode)
+int peripheral_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order)
{
int ret;
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- ret = peripheral_gdbus_spi_get_mode(spi, mode);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get spi mode, ret : %d", ret);
-
- return ret;
-}
-
-int peripheral_spi_set_lsb_first(peripheral_spi_h spi, bool lsb)
-{
- int ret;
-
- RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
-
- ret = peripheral_gdbus_spi_set_lsb_first(spi, lsb);
+ bool lsb = (bit_order == PERIPHERAL_SPI_BIT_ORDER_LSB) ? true : false;
+ ret = peripheral_gdbus_spi_set_bit_order(spi, lsb);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to set lsb first, ret : %d", ret);
return ret;
}
-int peripheral_spi_get_lsb_first(peripheral_spi_h spi, bool *lsb)
-{
- int ret;
-
- RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
-
- ret = peripheral_gdbus_spi_get_lsb_first(spi, lsb);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get lsb first, ret : %d", ret);
-
- return ret;
-}
-
-int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, unsigned char bits)
+int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits)
{
int ret;
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- ret = peripheral_gdbus_spi_set_bits(spi, bits);
+ ret = peripheral_gdbus_spi_set_bits_per_word(spi, (unsigned char)bits);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to set bits per word, ret : %d", ret);
return ret;
}
-int peripheral_spi_get_bits_per_word(peripheral_spi_h spi, unsigned char *bits)
+int peripheral_spi_set_frequency(peripheral_spi_h spi, uint32_t freq_hz)
{
int ret;
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- ret = peripheral_gdbus_spi_get_bits(spi, bits);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get bits per word, ret : %d", ret);
-
- return ret;
-}
-
-int peripheral_spi_set_frequency(peripheral_spi_h spi, unsigned int freq)
-{
- int ret;
-
- RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
-
- ret = peripheral_gdbus_spi_set_frequency(spi, freq);
+ ret = peripheral_gdbus_spi_set_frequency(spi, (unsigned int)freq_hz);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to set frequency, ret : %d", ret);
return ret;
}
-int peripheral_spi_get_frequency(peripheral_spi_h spi, unsigned int *freq)
-{
- int ret;
-
- RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
-
- ret = peripheral_gdbus_spi_get_frequency(spi, freq);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to get spi frequency, ret : %d", ret);
-
- return ret;
-}
-
-int peripheral_spi_read(peripheral_spi_h spi, unsigned char *data, int length)
+int peripheral_spi_read(peripheral_spi_h spi, uint8_t *data, uint32_t length)
{
int ret;
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- ret = peripheral_gdbus_spi_read(spi, data, length);
+ ret = peripheral_gdbus_spi_read(spi, data, (int)length);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to read from spi device, ret : %d", ret);
return ret;
}
-int peripheral_spi_write(peripheral_spi_h spi, unsigned char *data, int length)
+int peripheral_spi_write(peripheral_spi_h spi, uint8_t *data, uint32_t length)
{
int ret;
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- ret = peripheral_gdbus_spi_write(spi, data, length);
+ ret = peripheral_gdbus_spi_write(spi, data, (int)length);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to write to spi device, ret : %d", ret);
return ret;
}
-int peripheral_spi_read_write(peripheral_spi_h spi, unsigned char *txdata, unsigned char *rxdata, int length)
+int peripheral_spi_transfer(peripheral_spi_h spi, uint8_t *txdata, uint8_t *rxdata, uint32_t length)
{
int ret;
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- ret = peripheral_gdbus_spi_read_write(spi, txdata, rxdata, length);
+ ret = peripheral_gdbus_spi_transfer(spi, txdata, rxdata, (int)length);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to read and write, ret : %d", ret);
}
/**
- * @brief Flush all input that has received but not yet been read by the uart
- * device, or all output written but not transmitted to the uart device.
+ * @brief Sets baudrate of the uart device.
*/
-int peripheral_uart_flush(peripheral_uart_h uart)
+int peripheral_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud)
{
int ret;
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
+ RETVM_IF(baud > PERIPHERAL_UART_BAUD_RATE_230400, PERIPHERAL_ERROR_INVALID_PARAMETER,
+ "Invalid baud input");
- ret = peripheral_gdbus_uart_flush(uart);
+ ret = peripheral_gdbus_uart_set_baud_rate(uart, baud);
if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to flush, ret : %d", ret);
+ _E("Failed to set baudrate, ret : %d", ret);
return ret;
}
-/**
- * @brief Sets baudrate of the uart device.
- */
-int peripheral_uart_set_baudrate(peripheral_uart_h uart, peripheral_uart_baudrate_e baud)
+int peripheral_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size)
{
int ret;
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
- RETVM_IF(baud > PERIPHERAL_UART_BAUDRATE_230400, PERIPHERAL_ERROR_INVALID_PARAMETER,
- "Invalid baud input");
+ RETVM_IF((byte_size < PERIPHERAL_UART_BYTE_SIZE_5BIT) || (byte_size > PERIPHERAL_UART_BYTE_SIZE_8BIT), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_uart_set_baudrate(uart, baud);
+ ret = peripheral_gdbus_uart_set_byte_size(uart, byte_size);
if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set baudrate, ret : %d", ret);
+ _E("Failed to set uart mode, ret : %d", ret);
return ret;
}
-/**
- * @brief Sets baudrate of the uart device.
- */
-int peripheral_uart_set_mode(peripheral_uart_h uart, peripheral_uart_bytesize_e bytesize, peripheral_uart_parity_e parity, peripheral_uart_stopbits_e stopbits)
+int peripheral_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity)
{
int ret;
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
- RETVM_IF(bytesize > PERIPHERAL_UART_BYTESIZE_8BIT
- || parity > PERIPHERAL_UART_PARITY_ODD
- || stopbits > PERIPHERAL_UART_STOPBITS_2BIT,
- PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ RETVM_IF((parity < PERIPHERAL_UART_PARITY_NONE) || (parity > PERIPHERAL_UART_PARITY_ODD), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_uart_set_mode(uart, bytesize, parity, stopbits);
+ ret = peripheral_gdbus_uart_set_parity(uart, parity);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to set uart mode, ret : %d", ret);
return ret;
}
+int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits)
+{
+ int ret;
+
+ RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
+ RETVM_IF((stop_bits < PERIPHERAL_UART_STOP_BITS_1BIT) || (stop_bits > PERIPHERAL_UART_STOP_BITS_2BIT), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = peripheral_gdbus_uart_set_stop_bits(uart, stop_bits);
+ if (ret != PERIPHERAL_ERROR_NONE)
+ _E("Failed to set uart mode, ret : %d", ret);
+
+ return ret;
+}
+
+
/**
* @brief Sets baudrate of the uart device.
*/
-int peripheral_uart_set_flowcontrol(peripheral_uart_h uart, bool xonxoff, bool rtscts)
+int peripheral_uart_set_flow_control(peripheral_uart_h uart, peripheral_uart_software_flow_control_e sw_flow_control, peripheral_uart_hardware_flow_control_e hw_flow_control)
{
int ret;
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
- ret = peripheral_gdbus_uart_set_flowcontrol(uart, xonxoff, rtscts);
+ bool xonxoff = (sw_flow_control == PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF) ? true : false;
+ bool rtscts = (hw_flow_control == PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS) ? true : false;
+
+ ret = peripheral_gdbus_uart_set_flow_control(uart, xonxoff, rtscts);
if (ret != PERIPHERAL_ERROR_NONE)
_E("Failed to set flocontrol, ret : %d", ret);
/**
* @brief Reads data from the uart device.
*/
-int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, int length)
+int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length)
{
int ret;
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF(data == NULL || length < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_uart_read(uart, data, length);
+ ret = peripheral_gdbus_uart_read(uart, data, (int)length);
if (ret < PERIPHERAL_ERROR_NONE)
_E("Failed to read from uart device, ret : %d", ret);
/**
* @brief Write data to the uart device.
*/
-int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, int length)
+int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, uint32_t length)
{
int ret;
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF(data == NULL || length < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_uart_write(uart, data, length);
+ ret = peripheral_gdbus_uart_write(uart, data, (int)length);
if (ret < PERIPHERAL_ERROR_NONE)
_E("Failed to write to uart device, ret : %d", ret);