Hi,the Nordic team
I use the SED device by system on mode.I found that my static average power consumption increased by more than 20 ua after I defined an IO port to use and interrupt wake-up. The lowest power consumption did not go to a few ua, and the lowest power consumption was 20 ua.
this is my code:
// init GPIO and Interrupt
void report_gpio_init(void)
{
if (!device_is_ready(report_gpio.port)) {
LOG_ERR("GPIO port not ready");
return;
}
gpio_pin_configure_dt(&report_gpio, GPIO_INPUT);
gpio_pin_interrupt_configure_dt(&report_gpio, GPIO_INT_EDGE_BOTH);
gpio_init_callback(&report_gpio_cb, report_gpio_callback, BIT(report_gpio.pin));
gpio_add_callback(report_gpio.port, &report_gpio_cb);
LOG_INF("Report GPIO initialized");
}
static void report_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
{
LOG_INF("GPIO triggered, sending status");
// 提交工作队列进行上报
k_work_submit_to_queue(&coap_server_workq, &report_status_work);
}
k_work_init(&report_status_work, gpio_status_report);
void gpio_status_report(struct k_work *item)
{
ARG_UNUSED(item);
// 读取引脚电平
bool pin_state = gpio_pin_get_dt(&report_gpio);
LOG_INF("Sending GPIO status via CoAP: %d", pin_state);
uint8_t payload = pin_state ? 1 : 0;
coap_send_request(COAP_METHOD_POST,
(const struct sockaddr *)&provisioning_client_addr,
status_option, &payload, sizeof(payload), NULL);
}