I tried to use a distance sensor on BBC:microbit PIN2. uint32_t pulseIn(uint32_t pin, uint32_t state, uint32_t timeout) failed to work correctly. I realized in NRF_GPIO->IN PIN2 modifies bit 1 not bit 2 as L:36 implies.
Modifying L:36 uint32_t bit = 1 << pin; //p.ulPin; to uint32_t bit = 1 << pin - 1; //p.ulPin; fixes the thing and enables the desired functionality.
I tried to use a distance sensor on BBC:microbit PIN2.
uint32_t pulseIn(uint32_t pin, uint32_t state, uint32_t timeout)
failed to work correctly. I realized inNRF_GPIO->IN
PIN2 modifies bit 1 not bit 2 as L:36 implies.Modifying L:36
uint32_t bit = 1 << pin; //p.ulPin;
touint32_t bit = 1 << pin - 1; //p.ulPin;
fixes the thing and enables the desired functionality.