circuitpython/shared-bindings/busio
Jeff Epler e1b4e9b7c7 UART: Always allocate UART objects in the long-lived pool
Particularly when they have buffers that are written via IRQ or DMA,
UART objects do not relocate gracefully.  If such an object is
relocated to the long-lived pool after its original creation, the
IRQ or DMA will write to an unexpected location within the Python
heap, leading to a variety of symptoms.  The most frequent symptom
is inability to read from the UART.

Consider the particular case of atmel-samd: usart_uart_obj_t
contains a usart_async_descriptor contains a _usart_async_device.
In _sercom_init_irq_param the address of this contained
_usart_async_device is assigned to a global array
sercom_to_sercom_dev which is later used from the interrupt context
_sercom_usart_interrupt_handler to store the received data in the
right ring buffer.

When the UART object is relocated to the long-lived heap, there's no
mechanism to re-point these internal pointers, so instead take the
cowardly way and allocate the UART object as long-lived.

Happily, almost all UART objects are likely to be long-lived, so
this is unlikely to have a negative effect on memory usage or heap
fragmentation.

Closes: #1056
2018-08-08 19:21:57 -05:00
..
I2C.c add timeout keyword to I2C - for bitbangio - ignored for busio 2018-05-13 21:54:44 -04:00
I2C.h add timeout keyword to I2C - for bitbangio - ignored for busio 2018-05-13 21:54:44 -04:00
OneWire.c Do not allow a *io object to be used after deinit(). 2017-10-03 12:07:17 -07:00
OneWire.h Do not allow a *io object to be used after deinit(). 2017-10-03 12:07:17 -07:00
SPI.c Merge remote-tracking branch 'adafruit/2.x' into merge_2x 2018-02-27 15:24:16 -08:00
SPI.h atmel-samd: Correct computation of SPI baud rate. 2018-01-30 12:08:41 -05:00
UART.c UART: Always allocate UART objects in the long-lived pool 2018-08-08 19:21:57 -05:00
UART.h Implement UART for 3.0 + related fixes. 2018-02-21 17:18:49 -05:00
__init__.c Implement UART for 3.0 + related fixes. 2018-02-21 17:18:49 -05:00
__init__.h Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master. 2017-08-25 22:17:07 -04:00