This patch adds gpio isr callback data deliverd via gpio_isr_cb().
A gpio isr callback data is delivered as a structure, which contains
the pin number, the pin value, and the timestamp(ms) when the gpio
interrupt occurred.
Change-Id: Iee60dc4d33fe856d46fda83c487ed27d8d1fadae
Signed-off-by: jino.cho <jino.cho@samsung.com>
PERIPHERAL_GPIO_EDGE_BOTH, /**< Interrupt on rising & falling */
} peripheral_gpio_edge_e;
+/**
+ * @brief Gpio isr callback data delivered via gpio_isr_cb().
+ * @details A gpio isr callback data is delivered as a structure, which contains
+ * the pin number, the pin value, and the timestamp of the gpio interrupt
+ * in microseconds.
+ * @since_tizen 4.0
+ */
+typedef struct {
+ int pin;
+ int value;
+ unsigned long long timestamp;
+} gpio_isr_cb_s;
+
/**
* @brief The handle to the gpio pin
* @since_tizen 4.0
* @brief Called when the gpio interrupt is triggered.
* @since_tizen 4.0
*
+ * @param[in] data The gpio isr callback data
* @param[in] user_data The user data passed from the callback registration function
*
* @see peripheral_gpio_register_cb()
* @see peripheral_gpio_unregister_cb()
*/
-typedef void(*gpio_isr_cb)(void *user_data);
+typedef void(*gpio_isr_cb)(gpio_isr_cb_s *data, void *user_data);
/**
* @brief Registers a callback function to be invoked when the gpio interrupt is triggered.
#include "peripheral_internal.h"
#include "peripheral_io_gdbus.h"
-extern int peripheral_gpio_isr_callback(int pin);
-void handle_gpio_changed(PeripheralIoGdbusGpio *gpio, gint pin, gint state, gpointer user_data);
+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);
PeripheralIoGdbusGpio *gpio_proxy = NULL;
void handle_gpio_changed(
PeripheralIoGdbusGpio *gpio,
gint pin,
- gint state,
+ gint value,
+ guint64 timestamp,
gpointer user_data)
{
if (!gpio)
return;
- peripheral_gpio_isr_callback(pin);
+ peripheral_gpio_isr_callback(pin, value, timestamp);
}
int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio)
static GList *gpio_isr_list = NULL;
-int peripheral_gpio_isr_callback(int pin)
+int peripheral_gpio_isr_callback(int pin, int value, unsigned long long timestamp)
{
GList *link;
gpio_isr_data_s *isr_data;
+ gpio_isr_cb_s cb_data;
link = gpio_isr_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(isr_data->user_data);
+ isr_data->callback(&cb_data, isr_data->user_data);
return PERIPHERAL_ERROR_NONE;
}
link = g_list_next(link);
</method>
<signal name='GpioChanged'>
<arg type='i' name='pin'/>
- <arg type='i' name='state'/>
+ <arg type='i' name='value'/>
+ <arg type='t' name='timestamp'/>
</signal>
</interface>
<interface name="org.tizen.peripheral_io.i2c">
return ret;
}
-void gpio_irq_test_isr(void *user_data)
+void gpio_irq_test_isr(gpio_isr_cb_s *data, void *user_data)
{
int pin;
peripheral_gpio_h gpio = user_data;
#define MMA7455_YOUT8 0x07 //Register for reading the Y-Axis
#define MMA7455_ZOUT8 0x08 //Register for reading the Z-Axis
-static void i2c_mma7455_isr(void *user_data)
+static void i2c_mma7455_isr(gpio_isr_cb_s *data, void *user_data)
{
peripheral_i2c_h i2c = user_data;
uint8_t x_pos, y_pos, z_pos;