Documentation of interrupt handlers and callback functions #939

Open
opened 2022-07-24 08:45:46 -05:00 by fjansson · 1 comment
fjansson commented 2022-07-24 08:45:46 -05:00 (Migrated from github.com)

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.
I've read the [Raspberry Pi Pico C/C++ SDK](https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf) 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](https://github.com/raspberrypi/pico-examples/blob/master/pwm/led_fade/pwm_led_fade.c) 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](https://github.com/raspberrypi/pico-examples/blob/master/gpio/hello_gpio_irq/hello_gpio_irq.c), 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.
xadhoom commented 2023-02-27 04:10:08 -06:00 (Migrated from github.com)
  • 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.

> * in other callbacks, for example for [GPIO interrupts](https://github.com/raspberrypi/pico-examples/blob/master/gpio/hello_gpio_irq/hello_gpio_irq.c), 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.`
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#939
No description provided.