From 51f7a136a730021d33185616392fe7ab41daca34 Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Thu, 1 Feb 2024 08:40:42 +0000 Subject: [PATCH] SPI EEPROM: Document impact of PR13549. --- eeprom/spi/SPI.md | 5 ++++- eeprom/spi/eep_spi.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/eeprom/spi/SPI.md b/eeprom/spi/SPI.md index 6e50d4f..3c5650d 100644 --- a/eeprom/spi/SPI.md +++ b/eeprom/spi/SPI.md @@ -22,9 +22,12 @@ The driver has the following attributes: As of Jan 2024 this driver has been updated to fix a bug where the device page size was less than 256. A further aim was to make the driver more generic, with -a better chance of working with other SPI EEPROM chips. The constructor has +a high chance of working with other SPI EEPROM chips. The constructor has additional optional args to support this. +On Pyboard D soft SPI should be used pending resolution of +[this PR](https://github.com/micropython/micropython/pull/13549). + Code samples assume one or more Microchip devices. If using the STM chip the SPI baudrate should be 5MHz and the chip size must be specified to the `EEPROM` constructor, e.g.: diff --git a/eeprom/spi/eep_spi.py b/eeprom/spi/eep_spi.py index a127102..d1707a6 100644 --- a/eeprom/spi/eep_spi.py +++ b/eeprom/spi/eep_spi.py @@ -24,16 +24,16 @@ def get_eep(stm): if stm: if ESP8266: spi = SoftSPI(baudrate=5_000_000, sck=Pin(4), miso=Pin(0), mosi=Pin(2)) - else: # Pyboard. 1.22.1 hard SPI seems to have a read bug + else: # Pyboard. See https://github.com/micropython/micropython/pull/13549 # spi = SPI(2, baudrate=5_000_000) - spi = SoftSPI(baudrate=5_000_000, sck=Pin('Y6'), miso=Pin('Y7'), mosi=Pin('Y8')) + spi = SoftSPI(baudrate=5_000_000, sck=Pin("Y6"), miso=Pin("Y7"), mosi=Pin("Y8")) eep = EEPROM(spi, cspins, 256) else: if ESP8266: spi = SoftSPI(baudrate=20_000_000, sck=Pin(4), miso=Pin(0), mosi=Pin(2)) else: # spi = SPI(2, baudrate=20_000_000) - spi = SoftSPI(baudrate=20_000_000, sck=Pin('Y6'), miso=Pin('Y7'), mosi=Pin('Y8')) + spi = SoftSPI(baudrate=20_000_000, sck=Pin("Y6"), miso=Pin("Y7"), mosi=Pin("Y8")) eep = EEPROM(spi, cspins, 128) print("Instantiated EEPROM") return eep