Is the hw enabled to get notified when the USB is plugged in and out?
If I remember well, this wasn’t the case for the nRF9161 prototype.
nRF9151 - switching off the RP2040 on USB
@AchimKraus I fixed it per your feedback. GPIO1 and GPIO2 are connected to P0.08 and P0.09 respectively.
static void npm1300_event_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
{
if (pins & BIT(NPM1300_EVENT_VBUS_DETECTED)) {
LOG_INF("PM Vbus connected");
} else if (pins & BIT(NPM1300_EVENT_VBUS_REMOVED)) {
LOG_INF("PM Vbus removed");
}
}
...
static struct gpio_callback event_cb;
gpio_init_callback(&event_cb, npm1300_event_callback,
BIT(NPM1300_EVENT_VBUS_DETECTED) |
BIT(NPM1300_EVENT_VBUS_REMOVED));
ret = mfd_npm1300_add_callback(npm1300_mfd_dev, &event_cb);
works :-).
Woo!