Commit Graph

110 Commits (jebbatime)

Author SHA1 Message Date
Damien George cd9de63c0e drivers/wiznet5k: Allow selecting maximum fixed buffer size for MACRAW.
Enabling WIZCHIP_USE_MAX_BUFFER will make the TX/RX buffers the maximum
available size, for use with MACRAW mode.
2019-12-13 12:34:42 +11:00
Jeremy Herbert 4f0f3dfb41 drivers/sdcard: Raise exception on timeout of readinto.
Otherwise the code can get stuck in an infinite loop if the SD card fails
to respond to a read.
2019-11-06 11:34:02 +11:00
Damien George 5954387858 drivers/onewire/ds18x20.py: Add support for DS1822 sensor.
DS1822P sensors behave just like the DS18B20 except for the following:
- it has a different family code: 0x22
- it has only the GND and DQ pins connected, it uses parasitic power from
  the data line

Contributed by @nebelgrau77.
2019-10-16 14:28:13 +11:00
Damien George 7418dbf12d drivers/cyw43: Add low-level CYW43xx Bluetooth HCI UART driver. 2019-10-01 09:50:48 +10:00
Damien George 8cde5faedd drivers/memory/spiflash: Add support to put SPI flash in sleep mode. 2019-07-03 01:27:33 +10:00
Damien George 7b70ab7258 drivers: Add driver for CYW43xx WiFi SoCs. 2019-06-03 16:47:35 +10:00
Damien George 02afc0d241 drivers/display/ssd1306.py: Change to use new i2c.writevto() method.
Fixes issue #3482.
2019-05-20 15:06:39 +10:00
Andrew Leech 2ed2ec1711 drivers/memory/spiflash: Rework wait_sr to fix uninit'd variable 'sr'. 2019-03-08 23:11:13 +11:00
Damien George f102ac54e9 drivers/dht: Allow open-drain-high call to be DHT specific if needed.
Some ports (eg esp8266) need to have specific behaviour for driving a DHT
reliably.
2019-01-22 00:23:05 +11:00
Peter Hinch 40a7e8c472 drivers/sdcard: Remove debugging print statement in ioctl method. 2018-09-20 16:54:58 +10:00
Peter Hinch 1628cd0e59 drivers/sdcard: In test use os.umount and machine module instead of pyb.
pyb.umount(None, mountpoint) no longer works.
2018-09-20 16:09:28 +10:00
Damien George dc77fdb7d4 drivers/display/lcd160cr.py: In fast_spi, send command before flushing.
The intention of oflush() is to flush the "fast SPI" command itself so that
the SPI object is ready to use when the function returns.
2018-09-18 13:49:49 +10:00
roland c1c798fbc3 drivers/cc3000: Use cc3000_time_t instead of time_t for custom typedef.
Otherwise it can clash with time_t from the C standard include headers.
2018-08-08 16:37:26 +10:00
Mateusz Kijowski 1751f5ac7b drivers/sdcard: Do not release CS during the middle of read operations.
It seems that some cards do not tolerate releasing the card (by setting CS
high) after issuing CMD17 (and 18) and raising it again before reading
data. Somehow this causes the 0xfe data start marker not being read and
SDCard.readinto() is spinning forever (or until this byte is in the data).

This seems to fix weird behviour of SDCard.readblocks() returning different
data, also solved hanging os.mount() for my case with a 16GB Infineon card.

This stackexchange answer gives more context:
https://electronics.stackexchange.com/questions/307214/sd-card-spi-interface-issue-read-operation-returns-0x3f-0xff-instead-of-0x7f-0#307268
2018-07-05 19:39:06 +10:00
Damien George 1747d15c3a drivers/sdcard: Fix bug in computing number of sectors on SD Card.
This was a typo from the very first commit of this file.
2018-06-15 18:02:40 +10:00
Damien George 8b8c083625 drivers/sdcard: Change driver to use new block-device protocol. 2018-06-15 18:01:36 +10:00
Damien George b78ca32476 drivers/memory/spiflash: Add functions for direct erase/read/write.
These new API functions do not use the cache.
2018-06-14 16:52:56 +10:00
Damien George cc5a94044a drivers/memory/spiflash: Rename functions to indicate they use cache.
This patch renames the existing SPI flash API functions to reflect the fact
that the go through the cache:

    mp_spiflash_flush -> mp_spiflash_cache_flush
    mp_spiflash_read  -> mp_spiflash_cached_read
    mp_spiflash_write -> mp_spiflash_cached_write
2018-06-14 16:52:56 +10:00
Damien George 86fe73beb9 drivers/memory/spiflash: Move cache buffer to user-provided config.
This patch removes the global cache variables from the SPI flash driver and
now requires the user to provide the cache memory themselves, via the SPI
flash configuration struct.  This allows to either have a shared cache for
multiple SPI flash devices (by sharing a mp_spiflash_cache_t struct), or
have a single cache per device (or a mix of these options).

To configure the cache use:

    mp_spiflash_cache_t spi_bdev_cache;

    const mp_spiflash_config_t spiflash_config =
        // any bus options
        .cache = &spi_bdev_cache,
    };
2018-06-14 16:52:56 +10:00
Damien George 5a5bc4a61f drivers/wiznet5k: Fix bug with MACRAW socket calculating packet size. 2018-06-01 13:44:09 +10:00
Damien George bdc875e602 drivers/memory/spiflash: Fix bugs in and clean up read/write functions.
mp_spiflash_read had a bug in it where "dest" and "addr" were incremented
twice for a certain special case.  This was fixed, which then allowed the
function to be simplified to reduce code size.

mp_spiflash_write had a bug in it where "src" was not incremented correctly
for the case where the data to be written included the caching buffer as
well as some bytes after this buffer.  This was fixed and the resulting
code simplified.
2018-03-13 14:13:30 +11:00
Damien George cc34b087f0 drivers/memory/spiflash: Fix setting of QE bit in flash register. 2018-03-11 11:25:38 +11:00
Damien George a739b35a96 drivers/memory/spiflash: Change to use low-level SPI object not uPy one.
This patch alters the SPI-flash memory driver so that it uses the new
low-level C SPI protocol (from drivers/bus/spi.h) instead of the uPy SPI
protocol (from extmod/machine_spi.h).  This allows the SPI-flash driver to
be used independently from the uPy runtime.
2018-03-10 00:59:43 +11:00
Damien George 58ebeca6a9 drivers/bus: Pull out software SPI implementation to dedicated driver.
This patch takes the software SPI implementation from extmod/machine_spi.c
and moves it to a dedicated file in drivers/bus/softspi.c.  This allows the
SPI driver to be used independently of the uPy runtime, making it a more
general component.
2018-03-10 00:59:43 +11:00
Damien George 4e48700f9a drivers/memory/spiflash: Add support for QSPI interface.
The spiflash memory driver is reworked to allow the underlying bus to be
either normal SPI or QSPI.  In both cases the bus can be implemented in
software or hardware, as long as the spiflash driver is passed the correct
configuration structure.
2018-03-02 23:54:09 +11:00
Damien George 1da2d45de6 drivers/bus: Add QSPI abstract type with software QSPI implementation.
A new directory drivers/bus/ is introduced, which can hold implementations
of bus drivers.  A software QSPI implementation is added.
2018-03-02 23:52:59 +11:00
Damien George 3759aa2cc9 drivers/sdcard: Update SD mounting example code for ESP8266. 2018-02-18 23:40:54 +11:00
Damien George 93d5c9e1c4 drivers/cc3200: Update to work with new stm32 SPI API. 2018-02-05 14:32:56 +11:00
Hemanth kumar a44892dd0d drivers/sdcard: Update doc for ESP8266 to use correct SPI number.
machine.SPI(0) results in ValueError on ESP8266.  SPI(1) is the user
hardware SPI port (or use SPI(-1) for software SPI).
2018-01-31 21:25:58 +11:00
Damien George efdda2c62d stm32: Add support for DHT11/DHT22 sensors. 2018-01-31 18:12:53 +11:00
Damien George a40ce1d829 esp8266/modules: Move dht.py driver to drivers/dht directory. 2018-01-31 18:11:06 +11:00
Ayke van Laethem a275cb0f48 drivers/sdcard: Avoid allocation on the heap.
This commit fixes two things:
 1. Do not allocate on the heap in readblocks() - unless the block size
    is bigger than 512 bytes.
 2. Raise an error instead of returning 1 to indicate an error: the FAT
    block device layer does not check the return value. And other
    backends (e.g. esp32 blockdev) also raise an error instead of
    returning non-zero.
2018-01-10 19:14:46 +11:00
Jim Mussared bb3412291a drivers/display/ssd1306: Fix super() call in SSD1306 driver. 2018-01-10 17:56:10 +11:00
Ayke van Laethem b90f51f86a drivers/sdcard: Support old SD cards (<=2GB). 2017-12-22 16:49:58 +11:00
Peter Hinch 479392a56e drivers/display/ssd1306: Make SSD1306 class inherit from FrameBuffer. 2017-12-13 14:45:04 +11:00
Peter Hinch ccaa5f5b0b drivers/nrf24l01: Make driver and test run on pyboard, ESP8266, ESP32. 2017-11-20 11:37:47 +11:00
Damien George c0ea91bc89 drivers/wiznet5k: Get low-level W5500 driver working.
This patch implements the basic SPI read/write functions for the W5500
chip.  It also allows _WIZCHIP_ to be configured externally to select the
specific Wiznet chip.
2017-10-16 15:34:08 +11:00
Li Weiwei 73e387cff6 drivers/wiznet5k: Improve the performance of socket ops with threading.
Use MICROPY_THREAD_YIELD() instead of HAL_Delay in busy waiting to improve
the performance of connect, send, recv, sento and recvfrom.
2017-10-16 13:32:34 +11:00
Damien George ca2427c313 drivers/display/ssd1306: Make poweron() work the same with SSD1306_SPI.
The poweroff() and poweron() methods are used to do soft power control of
the display, and this patch makes these methods work the same for both I2C
and SPI interfaces.
2017-10-06 12:48:44 +11:00
Tiago Queiroz 7df4083ac6 drivers/display/ssd1306: Implement SSD1306_I2C poweron method.
After a poweroff(), the poweron() method does a soft power-on and any
previous state of the display persists.
2017-10-06 12:47:22 +11:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George 54acd0b0f0 drivers/nrf24l01: Make nRF24L01 test script more portable. 2017-10-03 20:00:31 +11:00
Peter Hinch 8fa03fee77 drivers/display/ssd1306.py: Improve performance of graphics methods.
It removes the need for a wrapper Python function to dispatch to the
framebuf method which makes each function call a bit faster, roughly 2.5x.
This patch also adds the rest of the framebuf methods to the SSD class.
2017-09-25 16:13:32 +10:00
Damien George 613510bce8 drivers/memory/spiflash: Change from hard-coded soft SPI to generic SPI.
The SPI flash driver now supports using an arbitrary SPI object to
communicate with the flash chip, and in particular can use a hardware SPI
peripheral.
2017-08-29 11:37:18 +10:00
Javier Candeira 35a1fea90b all: Raise exceptions via mp_raise_XXX
- Changed: ValueError, TypeError, NotImplementedError
  - OSError invocations unchanged, because the corresponding utility
    function takes ints, not strings like the long form invocation.
  - OverflowError, IndexError and RuntimeError etc. not changed for now
    until we decide whether to add new utility functions.
2017-08-13 22:52:33 +10:00
Alexander Steffen 55f33240f3 all: Use the name MicroPython consistently in comments
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Alexander Steffen 299bc62586 all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.

This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.

The rules are as follows.

Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _

In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.

py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-07-18 11:57:39 +10:00
Damien George 683df1c8d5 drivers/onewire: Enable pull-up when init'ing the 1-wire pin.
A previous version of the 1-wire driver (which was recently replaced by the
current one) had this behaviour and it allows to create a 1-wire bus
without any external pull-up resistors.
2017-06-26 17:48:05 +10:00
Damien George a065d78675 drivers/onewire: Move onewire.py, ds18x20.py from esp8266 to drivers.
These drivers can now be used by any port (so long as that port has the
_onewire driver from extmod/modonewire.c).

These drivers replace the existing 1-wire and DS18X20 drivers in the
drivers/onewire directory.  The existing ones were pyboard-specific and
not very efficient nor minimal (although the 1-wire driver was written in
pure Python it only worked at large enough CPU frequency).

This commit brings backwards incompatible API changes to the existing
1-wire drivers.  User code should be converted to use the new drivers, or
check out the old version of the code and keep a local copy (it should
continue to work unchanged).
2017-06-22 16:28:07 +10:00
Paul Sokolovsky 1c9ee49756 drivers: Replace deprecated Pin.high()/low() methods with .__call__(1/0). 2017-05-21 17:44:58 +03:00