int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio);
int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio);
-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);
#endif /* __PERIPHERAL_GDBUS_GPIO_H__ */
int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address);
int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c);
-int peripheral_gdbus_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length);
-int peripheral_gdbus_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length);
-int peripheral_gdbus_i2c_smbus_ioctl(peripheral_i2c_h i2c, uint8_t read_write, uint8_t command, uint32_t size, uint16_t data_in, uint16_t *data_out);
#endif /* __PERIPHERAL_GDBUS_I2C_H__ */
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_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_set_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_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_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_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);
#endif /* __PERIPHERAL_GDBUS_UART_H_ */
#define GPIO_FD_INDEX_EDGE 1
#define GPIO_FD_INDEX_VALUE 2
-extern int peripheral_gpio_interrupted_cb_handler(int pin, int value, unsigned long long timestamp, int err);
-
static 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_error_free(error);
return;
}
-
- g_signal_connect(gpio_proxy,
- "interrupted-cb",
- G_CALLBACK(__peripheral_gpio_interrupted_cb),
- NULL);
}
void gpio_proxy_deinit()
}
return ret;
-}
-
-int peripheral_gdbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction)
-{
- 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_direction_sync(
- gpio_proxy,
- gpio->handle,
- direction,
- &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_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_set_edge_mode_sync(
- gpio_proxy,
- gpio->handle,
- edge,
- &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_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;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_set_interrupted_cb_sync(
- gpio_proxy,
- gpio->handle,
- &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_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_unset_interrupted_cb_sync(
- gpio_proxy,
- gpio->handle,
- &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_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)
-{
- 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(
- 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;
-}
+}
\ No newline at end of file
}
return ret;
-}
-
-int peripheral_gdbus_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- GVariant *data_array;
- GVariantIter *iter;
- guint8 str;
- int i = 0;
-
- if (i2c_proxy == NULL || data == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_i2c_call_read_sync(
- i2c_proxy,
- i2c->handle,
- length,
- &data_array,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- g_variant_get(data_array, "a(y)", &iter);
- while (g_variant_iter_loop(iter, "(y)", &str)) {
- data[i] = str;
- if (i++ == length) break;
- }
- g_variant_iter_free(iter);
- g_variant_unref(data_array);
-
- return ret;
-}
-
-int peripheral_gdbus_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- GVariantBuilder *builder;
- GVariant *g_data;
- int i = 0;
-
- if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
-
- for (i = 0; i < length; i++)
- g_variant_builder_add(builder, "(y)", data[i]);
- g_variant_builder_add(builder, "(y)", 0x00);
-
- g_data = g_variant_new("a(y)", builder);
- g_variant_builder_unref(builder);
-
- if (peripheral_io_gdbus_i2c_call_write_sync(
- i2c_proxy,
- i2c->handle,
- length,
- g_data,
- &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_i2c_smbus_ioctl(peripheral_i2c_h i2c, uint8_t read_write, uint8_t command, uint32_t size, uint16_t data_in, uint16_t *data_out)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_i2c_call_smbus_ioctl_sync(
- i2c_proxy,
- i2c->handle,
- read_write,
- command,
- size,
- data_in,
- data_out,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
+}
\ No newline at end of file
}
return ret;
-}
-
-int peripheral_gdbus_pwm_set_period(peripheral_pwm_h pwm, int period)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_pwm_call_set_period_sync(
- pwm_proxy,
- pwm->handle,
- period,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-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 (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_pwm_call_set_duty_cycle_sync(
- pwm_proxy,
- pwm->handle,
- duty_cycle_ns,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_gdbus_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_pwm_call_set_polarity_sync(
- pwm_proxy,
- pwm->handle,
- polarity,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_gdbus_pwm_set_enable(peripheral_pwm_h pwm, bool enable)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_pwm_call_set_enable_sync(
- pwm_proxy,
- pwm->handle,
- enable,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
+}
\ No newline at end of file
}
return ret;
-}
-
-int peripheral_gdbus_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode)
-{
- 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_mode_sync(
- spi_proxy,
- spi->handle,
- (guchar)mode,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_gdbus_spi_set_bit_order(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_bit_order_sync(
- spi_proxy,
- spi->handle,
- lsb,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-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_per_word_sync(
- spi_proxy,
- spi->handle,
- bits,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-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 (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_spi_call_set_frequency_sync(
- spi_proxy,
- spi->handle,
- freq_hz,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_gdbus_spi_read(peripheral_spi_h spi, unsigned char *data, int length)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- GVariant *data_array;
- GVariantIter *iter;
- guint8 str;
- int i = 0;
-
- if (spi_proxy == NULL || data == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_spi_call_read_sync(
- spi_proxy,
- spi->handle,
- length,
- &data_array,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- g_variant_get(data_array, "a(y)", &iter);
- while (g_variant_iter_loop(iter, "(y)", &str)) {
- data[i] = str;
- if (i++ == length) break;
- }
- g_variant_iter_free(iter);
- g_variant_unref(data_array);
-
- return ret;
-}
-
-int peripheral_gdbus_spi_write(peripheral_spi_h spi, unsigned char *data, int length)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- GVariantBuilder *builder;
- GVariant *data_array;
- int i = 0;
-
- if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
-
- for (i = 0; i < length; i++)
- g_variant_builder_add(builder, "(y)", data[i]);
- g_variant_builder_add(builder, "(y)", 0x00);
-
- data_array = g_variant_new("a(y)", builder);
- g_variant_builder_unref(builder);
-
- if (peripheral_io_gdbus_spi_call_write_sync(
- spi_proxy,
- spi->handle,
- length,
- data_array,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-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;
- GVariantBuilder *builder;
- GVariant *rx_data_array;
- GVariant *tx_data_array;
- GVariantIter *iter;
- guint8 str;
- int i = 0;
-
- if (spi_proxy == NULL || !rx_data || !tx_data) return PERIPHERAL_ERROR_UNKNOWN;
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
-
- for (i = 0; i < length; i++)
- g_variant_builder_add(builder, "(y)", tx_data[i]);
- g_variant_builder_add(builder, "(y)", 0x00);
-
- tx_data_array = g_variant_new("a(y)", builder);
- g_variant_builder_unref(builder);
-
- if (peripheral_io_gdbus_spi_call_transfer_sync(
- spi_proxy,
- spi->handle,
- length,
- tx_data_array,
- &rx_data_array,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("%s", error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- i = 0;
- g_variant_get(rx_data_array, "a(y)", &iter);
- while (g_variant_iter_loop(iter, "(y)", &str)) {
- rx_data[i] = str;
- if (i++ == length) break;
- }
- g_variant_iter_free(iter);
- g_variant_unref(rx_data_array);
-
- return ret;
-}
+}
\ No newline at end of file
}
return ret;
-}
-
-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_set_baud_rate_sync(
- uart_proxy,
- uart->handle,
- baud,
- &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_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_byte_size_sync(
- uart_proxy,
- uart->handle,
- byte_size,
- &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_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_parity_sync(
- uart_proxy,
- uart->handle,
- parity,
- &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_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_flow_control_sync(
- uart_proxy,
- uart->handle,
- xonxoff,
- rtscts,
- &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_read(peripheral_uart_h uart, uint8_t *data, int length)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- GVariant *data_array;
- GVariantIter *iter;
- guint8 str;
- int i = 0;
-
- if (uart_proxy == NULL || data == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_uart_call_read_sync(
- uart_proxy,
- uart->handle,
- length,
- &data_array,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- g_variant_get(data_array, "a(y)", &iter);
- while (g_variant_iter_loop(iter, "(y)", &str)) {
- data[i] = str;
- if (i++ == length) break;
- }
- g_variant_iter_free(iter);
- g_variant_unref(data_array);
-
- return ret;
-}
-
-int peripheral_gdbus_uart_write(peripheral_uart_h uart, uint8_t *data, int length)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- GVariantBuilder *builder;
- GVariant *g_data;
- int i = 0;
-
- if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
-
- for (i = 0; i < length; i++)
- g_variant_builder_add(builder, "(y)", data[i]);
- g_variant_builder_add(builder, "(y)", 0x00);
-
- g_data = g_variant_new("a(y)", builder);
- g_variant_builder_unref(builder);
-
- if (peripheral_io_gdbus_uart_call_write_sync(
- uart_proxy,
- uart->handle,
- length,
- g_data,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
+}
\ No newline at end of file
<arg type="u" name="handle" direction="in"/>
<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="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="SetInterruptedCb">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="UnsetInterruptedCb">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <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">
<arg type="u" name="handle" direction="in"/>
<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 type="a(y)" name="data" direction="out">
- <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
- </arg>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="Write">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="length" direction="in"/>
- <arg type="a(y)" name="data" direction="in">
- <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
- </arg>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="SmbusIoctl">
- <arg type="u" name="handle" direction="in"/>
- <arg type="y" name="read_write" direction="in"/>
- <arg type="y" name="command" direction="in"/>
- <arg type="u" name="size" direction="in"/>
- <arg type="q" name="data_in" direction="in"/>
- <arg type="q" name="data_out" direction="out"/>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
<interface name="org.tizen.peripheral_io.pwm">
<method name="Open">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="SetPeriod">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="period" direction="in"/>
- <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="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="SetEnable">
- <arg type="u" name="handle" direction="in"/>
- <arg type="b" name="enable" direction="in"/>
- <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="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="SetByteSize">
- <arg type="u" name="handle" direction="in"/>
- <arg type="u" name="byte_size" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="SetParity">
- <arg type="u" name="handle" 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">
- <arg type="u" name="handle" direction="in"/>
- <arg type="b" name="xonxoff" direction="in"/>
- <arg type="b" name="rtscts" direction="in"/>
- <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 type="a(y)" name="data" direction="out">
- <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
- </arg>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="Write">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="length" direction="in"/>
- <arg type="a(y)" name="data" direction="in">
- <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
- </arg>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
<interface name="org.tizen.peripheral_io.spi">
<method name="Open">
<arg type="u" name="handle" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="SetMode">
- <arg type="u" name="handle" direction="in"/>
- <arg type="y" name="mode" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <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="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="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="Read">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="length" direction="in"/>
- <arg type="a(y)" name="data" direction="out">
- <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
- </arg>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="Write">
- <arg type="u" name="handle" direction="in"/>
- <arg type="i" name="length" direction="in"/>
- <arg type="a(y)" name="data" direction="in">
- <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
- </arg>
- <arg type="i" name="result" direction="out"/>
- </method>
- <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">
- <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
- </arg>
- <arg type="a(y)" name="rx_data" direction="out">
- <annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
- </arg>
- <arg type="i" name="result" direction="out"/>
- </method>
</interface>
</node>
return (gpio_feature == GPIO_FEATURE_TRUE ? true : false);
}
-typedef struct {
- peripheral_gpio_h handle;
- peripheral_gpio_interrupted_cb callback;
- void *user_data;
-} interrupted_cb_info_s;
-
-static GList *interrupted_cb_info_list = NULL;
-
-int peripheral_gpio_interrupted_cb_handler(int pin, int value, unsigned long long timestamp, int error)
-{
- GList *link;
- interrupted_cb_info_s *cb_info;
-
- link = interrupted_cb_info_list;
- while (link) {
- 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;
-}
-
-static int __interrupted_cb_info_list_append(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data)
-{
- GList *link;
- interrupted_cb_info_s *cb_info = NULL;
-
- link = interrupted_cb_info_list;
- while (link) {
- 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 (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;
- }
-
- interrupted_cb_info_list = g_list_append(interrupted_cb_info_list, cb_info);
- }
-
- cb_info->handle = gpio;
- cb_info->callback = callback;
- cb_info->user_data = user_data;
-
- return PERIPHERAL_ERROR_NONE;
-}
-
-static int __interrupted_cb_info_list_remove(peripheral_gpio_h gpio)
-{
- GList *link;
- interrupted_cb_info_s *cb_info;
-
- link = interrupted_cb_info_list;
- while (link) {
- cb_info = (interrupted_cb_info_s*)link->data;
-
- 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;
- }
- link = g_list_next(link);
- }
-
- return PERIPHERAL_ERROR_NONE;
-}
-
/**
* @brief Initializes(export) gpio pin and creates gpio handle.
*/
RETVM_IF((direction < PERIPHERAL_GPIO_DIRECTION_IN) || (direction > PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid direction input");
/* call gpio_set_direction */
- ret = peripheral_gdbus_gpio_set_direction(gpio, direction);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set gpio direction, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
RETVM_IF((edge < PERIPHERAL_GPIO_EDGE_NONE) || (edge > PERIPHERAL_GPIO_EDGE_BOTH), PERIPHERAL_ERROR_INVALID_PARAMETER, "edge input is invalid");
/* call gpio_set_edge_mode */
- ret = peripheral_gdbus_gpio_set_edge_mode(gpio, edge);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set edge mode of the gpio pin, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF(callback == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio interrupted callback is NULL");
- ret = peripheral_gdbus_gpio_set_interrupted_cb(gpio, callback, user_data);
- if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to set gpio interrupted cb, ret : %d", ret);
- return ret;
- }
-
- /* set isr */
- ret = __interrupted_cb_info_list_append(gpio, callback, user_data);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to append gpio interrupt callback info, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
- ret = peripheral_gdbus_gpio_unset_interrupted_cb(gpio);
- if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to unset gpio interrupt callback, ret : %d", ret);
- return ret;
- }
-
- ret = __interrupted_cb_info_list_remove(gpio);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to remove gpio interrupt callback info, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
RETVM_IF(value == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio read value is invalid");
/* 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);
+ // TODO : replace interface function
return ret;
}
RETVM_IF((value != 0) && (value != 1), PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio value is invalid");
/* 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);
+ // TODO : replace interface function
return ret;
}
int peripheral_i2c_close(peripheral_i2c_h i2c)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_i2c_read(i2c, data, (int)length);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to read data from device, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_i2c_write(i2c, data, (int)length);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to write data to device, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data)
{
- int ret;
- uint16_t w_data, dummy = 0;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- 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);
-
- *data = (uint8_t)w_data;
+ // TODO : replace interface function
return ret;
}
int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data)
{
- int ret;
- uint16_t dummy = 0;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- 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);
+ // TODO : replace interface function
return ret;
}
int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data)
{
- int ret;
- uint16_t dummy = 0, data_out;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- 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);
-
- *data = data_out;
+ // TODO : replace interface function
return ret;
}
int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data)
{
- int ret;
- uint16_t dummy = 0;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
- 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);
+ // TODO : replace interface function
return ret;
}
int peripheral_pwm_set_period(peripheral_pwm_h pwm, uint32_t period_ns)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- ret = peripheral_gdbus_pwm_set_period(pwm, (int)period_ns);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set period, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle_ns)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- 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);
+ // TODO : replace interface function
return ret;
}
int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
RETVM_IF((polarity < PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH) || (polarity > PERIPHERAL_PWM_POLARITY_ACTIVE_LOW), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid polarity parameter");
- ret = peripheral_gdbus_pwm_set_polarity(pwm, polarity);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set polarity, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, bool enable)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
- ret = peripheral_gdbus_pwm_set_enable(pwm, enable);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set enable, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF((mode < PERIPHERAL_SPI_MODE_0) || (mode > PERIPHERAL_SPI_MODE_3), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid spi mode parameter");
- ret = peripheral_gdbus_spi_set_mode(spi, mode);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set mode, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF((bit_order < PERIPHERAL_SPI_BIT_ORDER_MSB) || (bit_order > PERIPHERAL_SPI_BIT_ORDER_LSB), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid bit order parameter");
- 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);
+ // TODO : replace interface function
return ret;
}
int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- 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);
+ // TODO : replace interface function
return ret;
}
int peripheral_spi_set_frequency(peripheral_spi_h spi, uint32_t freq_hz)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
- ret = peripheral_gdbus_spi_set_frequency(spi, (unsigned int)freq_hz);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set frequency, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_spi_read(peripheral_spi_h spi, uint8_t *data, uint32_t length)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_spi_read(spi, data, (int)length);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to read from spi device, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_spi_write(peripheral_spi_h spi, uint8_t *data, uint32_t length)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_spi_write(spi, data, (int)length);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to write to spi device, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_spi_transfer(peripheral_spi_h spi, uint8_t *txdata, uint8_t *rxdata, uint32_t length)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(txdata == NULL || rxdata == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_spi_transfer(spi, txdata, rxdata, (int)length);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to read and write, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_uart_open(int port, peripheral_uart_h *uart)
{
peripheral_uart_h handle;
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid uart handle");
*/
int peripheral_uart_close(peripheral_uart_h uart)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
*/
int peripheral_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((baud < PERIPHERAL_UART_BAUD_RATE_0) || (baud > PERIPHERAL_UART_BAUD_RATE_230400), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid baud input");
- ret = peripheral_gdbus_uart_set_baud_rate(uart, baud);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set baudrate, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
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_byte_size(uart, byte_size);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set uart mode, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((parity < PERIPHERAL_UART_PARITY_NONE) || (parity > PERIPHERAL_UART_PARITY_ODD), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_uart_set_parity(uart, parity);
- if (ret != PERIPHERAL_ERROR_NONE)
- _E("Failed to set uart mode, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
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);
+ // TODO : replace interface function
return ret;
}
*/
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;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((sw_flow_control < PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE) || (sw_flow_control > PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid sw_flow_control parameter");
RETVM_IF((hw_flow_control < PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE) || (hw_flow_control > PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid hw_flow_control parameter");
- 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);
+ // TODO : replace interface function
return ret;
}
*/
int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_uart_read(uart, data, (int)length);
- if (ret < PERIPHERAL_ERROR_NONE)
- _E("Failed to read from uart device, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}
*/
int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, uint32_t length)
{
- int ret;
+ int ret = PERIPHERAL_ERROR_NONE;
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = peripheral_gdbus_uart_write(uart, data, (int)length);
- if (ret < PERIPHERAL_ERROR_NONE)
- _E("Failed to write to uart device, ret : %d", ret);
+ // TODO : replace interface function
return ret;
}