hello Nordic
i am working with nrf52840, with zephyr (i am new to zephyr)
i have an issue with not responding pin interrupt on an input pin
this is my trigger pin configuration:
{
int ret = 0;
struct augusi7210_data *drv_data = dev->data;
const struct augusi7210_dev_config *cfg = dev->config;
const struct device *alert;
// config as input pin with intrrupt:
alert = device_get_binding(cfg->alert_name);
if (NULL == alert)
{
LOG_ERR("Error: didn't find %s device", cfg->alert_name);
return -ENOTSUP;
}
ret = gpio_pin_configure(alert, cfg->alert_pin, GPIO_INPUT | cfg->alert_flags);
if (ret != 0)
{
LOG_ERR("Error %d: failed to configure %s pin %d", ret, cfg->alert_name, cfg->alert_pin);
return -ENOTSUP;
}
// ret = gpio_pin_interrupt_configure(alert, cfg->alert_pin, GPIO_INT_EDGE_BOTH);
ret = gpio_pin_interrupt_configure(alert, cfg->alert_pin, GPIO_INT_EDGE_TO_ACTIVE);
if (ret != 0)
{
LOG_ERR("Error %d: failed to configure interrupt on %s pin %d", ret, cfg->alert_name, cfg->alert_pin);
return -ENOTSUP;
}
// set handler:
gpio_init_callback(&alert_cb_data, alert_handler, BIT(cfg->alert_pin));
// enable trigger:
gpio_add_callback(alert, &alert_cb_data);
LOG_INF("Set up alert at %s pin %d", cfg->alert_name, cfg->alert_pin);
return 0;
}
this struct is declared globally in the module:
static struct gpio_callback alert_cb_data;
this is the pin set in the dts:
augusi7210@30 {
compatible = "si,augusi7210";
reg = <0x30>;
alert_gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>;
label = "AUGU_SI7210";
this is the handler:
void alert_handler(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
{
LOG_ERR("Magnetic Field Senesed");
}
this is the api struct:
static const struct sensor_driver_api augusi7210_driver_api = {
.trigger_set = augusi7210_trigger_set
};
and this is to my understanding the initiation of it:
#define DT_DRV_COMPAT si_augusi7210
#define AUGU_SI7210_INIT(n) \
static const struct augusi7210_dev_config augusi7210_config_##n = { \
.i2c_bus_name = DT_BUS_LABEL(DT_DRV_INST(n)), \
.i2c_addr = DT_INST_REG_ADDR(n), \
.alert_name = COND_CODE_1(DT_NODE_HAS_PROP(DT_DRV_INST(n),alert_gpios), (DT_PROP_BY_PHANDLE_IDX(DT_DRV_INST(n), alert_gpios, 0, label)), (NULL)), \
.alert_pin = COND_CODE_1(DT_NODE_HAS_PROP(DT_DRV_INST(n),alert_gpios), (DT_PHA_BY_IDX(DT_DRV_INST(n), alert_gpios, 0, pin)), (0)), \
.alert_flags = COND_CODE_1(DT_NODE_HAS_PROP(DT_DRV_INST(n),alert_gpios), (DT_PHA_BY_IDX(DT_DRV_INST(n), alert_gpios, 0, flags)), (0)) \
}; \
\
static struct augusi7210_data augusi7210_data_##n; \
\
DEVICE_AND_API_INIT(augusi7210_##n, DT_INST_LABEL(n), \
augusi7210_init, &augusi7210_data_##n, \
&augusi7210_config_##n, APPLICATION, \
CONFIG_SENSOR_INIT_PRIORITY, \
&augusi7210_driver_api);
DT_INST_FOREACH_STATUS_OKAY(AUGU_SI7210_INIT)
when connecting the input pin to vdd of the device i do not get an interrupt .. any ideas will be appreciated
best regards
Ziv