tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
587 stars 182 forks source link

sx127x/sx126x: Fix "runtime error: alloc in interrupt" #525

Closed ofauchon closed 1 year ago

ofauchon commented 1 year ago

New checks for "heap allocation in interrupts" had been recently added to TinyGo: https://github.com/tinygo-org/tinygo/commit/f41b6a3b96574c29002b2b6c5585f9faa3766a29

Both SX127x and SX126x were impacted by this feature as they were using slices in Interrupt Handler (while using spi functions) .

As a result, the code was crashing when receiving new interrupts ( RX Done / TX Done for example):

panic: runtime error: alloc in interrupt

This PR provides a fix and cleanup:

Code was tested on Dragino LGT92 (stm32l0 + sx127x) and Lora E5 dev board (sx126x)

deadprogram commented 1 year ago

Thank you very much for the fixes here @ofauchon now merging.