Anchor Monitor GPIO dwm-simple

Hi, I would like to monitor a GPIO pin on an anchor, and if it goes high, I would like to change the mode of the anchor to anchor initator. In the dwm-simple code there is a function on_dwm_evt, and within that there is a switch-case statement for p_evt->header.id. Is it possible to add another case or have the function trigger on the event that a specific GPIO pin goes high? Thanks!

Hi, it is possible.
If the change of status of the gpio is not high speed you can monitor the pin by polling method. otherwise I suggest you configure an interruption.

Once the change is detected you can do something like this:

dwm_cfg_anchor_t cfg;
int rv;
cfg.initiator = 1;
cfg.bridge = 0;
cfg.common.enc_en = 1;
cfg.common.led_en = 1;
cfg.common.ble_en = 1;
cfg.common.fw_update_en = 1;
cfg.common.uwb_mode = DWM_UWB_MODE_ACTIVE;
rv = dwm_cfg_anchor_set(&cfg);

regards

1 Like

Thank you very much. This was helpful.

Do I need to reset after I do the cfg command for it to take effect?

Cheers

yes is required
regards