summaryrefslogtreecommitdiff
path: root/shared-bindings/busio
AgeCommit message (Collapse)Author
2020-03-05rename routines to be clearer; fix wiznet arg typesDan Halbert
2020-02-28new pin validation routines; don't use mp_const_none if NULL will doDan Halbert
2020-02-18Addition of RS485 supportDave Marples
2020-02-18Addition of RTS/CTS/RS485 UART functionalityDave Marples
2020-02-11doc typoDan Halbert
2020-02-11fix doc indentationDan Halbert
2020-02-11nrf: add SPIM3 supportDan Halbert
2019-12-04protocols: Allow them to be (optionally) type-safeJeff Epler
Protocols are nice, but there is no way for C code to verify whether a type's "protocol" structure actually implements some particular protocol. As a result, you can pass an object that implements the "vfs" protocol to one that expects the "stream" protocol, and the opposite of awesomeness ensues. This patch adds an OPTIONAL (but enabled by default) protocol identifier as the first member of any protocol structure. This identifier is simply a unique QSTR chosen by the protocol designer and used by each protocol implementer. When checking for protocol support, instead of just checking whether the object's type has a non-NULL protocol field, use `mp_proto_get` which implements the protocol check when possible. The existing protocols are now named: protocol_framebuf protocol_i2c protocol_pin protocol_stream protocol_spi protocol_vfs (most of these are unused in CP and are just inherited from MP; vfs and stream are definitely used though) I did not find any crashing examples, but here's one to give a flavor of what is improved, using `micropython_coverage`. Before the change, the vfs "ioctl" protocol is invoked, and the result is not intelligible as json (but it could have resulted in a hard fault, potentially): >>> import uos, ujson >>> u = uos.VfsPosix('/tmp') >>> ujson.load(u) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: syntax error in JSON After the change, the vfs object is correctly detected as not supporting the stream protocol: >>> ujson.load(p) Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: stream operation not supported
2019-11-27'seconds'Dan Halbert
2019-11-27Squeeze pyruler zh_Latn_pinyinDan Halbert
2019-11-27make UART.write be blocking on SAMD; add timeout propertyDan Halbert
2019-10-29Update I2C and SPI documentationDan Halbert
2019-08-27More size_t usageScott Shawcroft
2019-08-23Use size_t and document buffers can be the same.Scott Shawcroft
2019-08-22Add writeto_then_readfrom to I2C API. Deprecate stop kwarg.Scott Shawcroft
writeto_then_readfrom has been added to do a write -> no stop -> repeated start -> read sequence. This is done to match the capabilities of Blinka on Linux. Code that uses stop=False will not work correctly on Blinka. To fix, if stop=False then use writeto_then_readfrom otherwise use writeto then readfrom_into. First step in #2082
2019-07-19Add support for grayscale displays that are < 8 bit depth.Scott Shawcroft
This also improves Palette so it stores the original RGB888 colors. Lastly, it adds I2CDisplay as a display bus to talk over I2C. Particularly useful for the SSD1306. Fixes #1828. Fixes #1956
2019-07-03changed type of receiver_buffer_size to uint16_tiot49
2019-06-12Refactor deinit check to reduce code size.Scott Shawcroft
2019-06-07Merge pull request #1920 from tannewt/fix_rstsommersoft
Improve rST consistency for rst2pyi use
2019-06-06This __init__.h should be redundant. I deleted it for youBaozhu Zuo
2019-05-30Improve rST consistency for rst2pyi useScott Shawcroft
2019-04-09Fix version skew for bast_pro_mini buildDan Halbert
2019-04-06Stop hard-coding SPI frequency in FourWireRadomir Dopieralski
Instead remember and use the frequency, polarity and phase that was set when the bus was first created.
2019-03-25Reuse existing error message in busio.i2cRadomir Dopieralski
Remove a period from the error message, so that the same message as in SPI and other places in I2C can be re-used.
2019-02-17A couple build fixes for mp_float_t = double (MICROPY_FLOAT_IMPL_DOUBLE).Lionel Debroux
Signed-off-by: Lionel Debroux <lionel_debroux@yahoo.fr>
2019-01-19CharacteristicBuffer: make it be a stream class; add lockingDan Halbert
2019-01-14Add subclass support to displayio.Scott Shawcroft
Also, swap make_news to accept a kwarg map and refine param checking. Fixes #1237
2018-12-30Remove nRF52832 supportDan Halbert
2018-12-04allow KeyboardInterrupt on UART read; fix nrf UART pin claiming; rename ↵Dan Halbert
feather 52840 UART pins
2018-12-03UART changes: timeout in secs, write bytes, etc.Dan Halbert
2018-11-08Move atmel-samd to tinyusb and support nRF flash.Scott Shawcroft
This started while adding USB MIDI support (and descriptor support is in this change.) When seeing that I'd have to implement the MIDI class logic twice, once for atmel-samd and once for nrf, I decided to refactor the USB stack so its shared across ports. This has led to a number of changes that remove items from the ports folder and move them into supervisor. Furthermore, we had external SPI flash support for nrf pending so I factored out the connection between the usb stack and the flash API as well. This PR also includes the QSPI support for nRF.
2018-10-02round SPI freq down; check max freqDan Halbert
2018-10-01nrf: remove error check for SPI baudrate too high; round to nearest baudrateDan Halbert
2018-09-18merge 3.0.2 to masterDan Halbert
2018-09-12UART fixes and enhancements; default board object fixDan Halbert
2018-08-08UART: Always allocate UART objects in the long-lived poolJeff Epler
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-07Support internationalisation.Scott Shawcroft
2018-05-13 add timeout keyword to I2C - for bitbangio - ignored for busioJerry Needell
2018-02-27Merge remote-tracking branch 'adafruit/2.x' into merge_2xScott Shawcroft
2018-02-21Implement UART for 3.0 + related fixes.Dan Halbert
1. UART: ported to ASF4. Allow rx-only and tx-only. Add .baudrate r/w property. 2. Make NeoPixel timing deterministic by turning off caches during NeoPixel writes. 3. Incorporate asf4 updates: a. async USART driver b. bringing Atmel START configuration closer to what we use c. Clock initialization order now specified by CIRCUITPY_GCLK_INIT_1ST and _LAST. 4. supervisor/port.c: Move commented-out clock-test pin setting to correct location.
2018-01-30documentation: caution on SPI clock speed for SAMD21Dan Halbert
2018-01-30atmel-samd: Correct computation of SPI baud rate.Dan Halbert
all: Add .frequency read-only property for busio.SPI to return actual frequency. Fix esp8266/posix_helpers.c, which was not up to date for the new long-lived/short-lived heap allocation scheme.
2018-01-02merge from 2.2.0 + fix up board defsDan Halbert
2017-12-05add SPI.write_readinto() - bidirectional SPIDan Halbert
2017-11-16non-DMA SPI working; adding this now for testing; will continue with DMADan Halbert
Also, fixed pin mappings for rev B Metro M4: swap PA12 and PA13 on SPI 2x3 header swap A3 and A5 Comment out all frozen modules in CPX again to make room while waiting for SPI flash.
2017-11-07Implement busio.I2c.Dan Halbert
* Added asf4_conf/samd*/hpl_sercom_config.h * Adjusted clocks in peripheral_clk_config.h. * Put some frozen libs back in CPX for testing. * Implement common-hal I2C * Add samd*_peripherals.h in parallel with samd*_pins.h for common functions and data. * Store SERCOM index in pins table for convenience. * Canonicalize some #include guard names in various .h files. simpler reset of SERCOMs; remove unused routine
2017-11-03Allow empty reads and writes for busio.SPIRadomir Dopieralski
This is mostly for convenience, so that user code doesn't need to add additional checks. Also, bring the bitbangio into compatibility with busio wrt. empty buffers.
2017-10-30Allow writing buffer of length zero to I2C device; it can be used to poll ↵Dan Halbert
for existence.
2017-10-25shared-bindings: Check that I2C and SPI reads and writes are given a buffer ↵Scott Shawcroft
of at least 1. (#370) Fixes #358
2017-10-03Do not allow a *io object to be used after deinit().Dan Halbert
Fixes #278, #277, #276, #275.