pico-sdk
pico-sdk copied to clipboard
Documentation of interrupt handlers and callback functions
I've read the Raspberry Pi Pico C/C++ SDK manual, regarding interrupt handlers and callback functions. The following points are unclear to me, and I think they are not documented. Would it be possible to improve the documentation here?
- in the callback function for the PWM_IRQ_WRAP irq, one must call pwm_clear_irq(slice_num); This is shown in the example but not in the manual. Does it matter if this is done first or last in the routine?
- in other callbacks, for example for GPIO interrupts, one apparently does not have to clear the corresponding irq.
- are there restrictions on what one can do in a callback function? In the manual I only saw that calling the sleep functions is not allowed. (I expected calling printf would be a bad idea (is printf reentrant?), but the gpio example does it.
- in other callbacks, for example for GPIO interrupts, one apparently does not have to clear the corresponding irq.
Sorry for chiming in, the 2nd point is explained in the docs, albeit not in the gpio_set_irq_enabled_with_callback function. Check for gpio_acknowledge_irq which states For callbacks set with gpio_set_irq_enabled_with_callback gpio_set_irq_callback, this function is called automatically.