Im new to Zephyr and Im trying to measure the GPIO handler latency. I have modified the samples/basic/button example to toggle LED pin when the handler rises. The test is to measure the time between input pin change and output pin change. I have measured maximal value about 3us and typical about 2.6us. The processor is SAME70 @ 300MHz so 3us is 900 instructions - why it took so long? It should be in tenth of ns. Do I have correct approach or am I doing something wrong? I have checked the sensor drivers and they are using the same workflow.
The handler code is
void button_pressed(struct device *gpiob, struct gpio_callback *cb, u32_t pins)
gpio_pin_write(dev, LED, cnt % 2);
printk("Button pressed at %d\n", k_cycle_get_32());