Commit Graph

12081 Commits

Author SHA1 Message Date
Damien George e8398a5856 extmod: Update to use new mp_get_stream helper.
With this patch objects are only checked that they have the stream protocol
at the start of their use as a stream, and afterwards the efficient
mp_get_stream() helper is used to extract the stream protocol C methods.
2018-06-18 12:35:56 +10:00
Damien George 6abede2ca9 py/stream: Introduce and use efficient mp_get_stream to access stream_p.
The existing mp_get_stream_raise() helper does explicit checks that the
input object is a real pointer object, has a non-NULL stream protocol, and
has the desired stream C method (read/write/ioctl).  In most cases it is
not necessary to do these checks because it is guaranteed that the input
object has the stream protocol and desired C methods.  For example, native
objects that use the stream wrappers (eg mp_stream_readinto_obj) in their
locals dict always have the stream protocol (or else they shouldn't have
these wrappers in their locals dict).

This patch introduces an efficient mp_get_stream() which doesn't do any
checks and just extracts the stream protocol struct.  This should be used
in all cases where the argument object is known to be a stream.  The
existing mp_get_stream_raise() should be used primarily to verify that an
object does have the correct stream protocol methods.

All uses of mp_get_stream_raise() in py/stream.c have been converted to use
mp_get_stream() because the argument is guaranteed to be a proper stream
object.

This patch improves efficiency of stream operations and reduces code size.
2018-06-18 12:35:56 +10:00
Damien George 31cf49c672 examples/embedding: Add code markup and fix typo in README.md. 2018-06-18 12:29:22 +10:00
Damien George ceff433fcc stm32/mboot: Adjust user-reset-mode timeout so it ends with mode=1.
If the user button is held down indefinitely (eg unintenionally, or because
the GPIO signal of the user button is connected to some external device)
then it makes sense to end the reset mode cycle with the default mode of
1, which executes code as normal.
2018-06-18 12:23:27 +10:00
Dan Halbert be5eb91df8
Merge pull request #938 from sommersoft/esp_busio_fix
ESP8266: Fix pin locking during busio.SPI.configure
2018-06-16 11:49:20 -04:00
Scott Shawcroft 35ead7bf39
Merge pull request #935 from dhalbert/mount_name_clash_check
do not permit mounting over a directory or file with the same name as the mount point
2018-06-16 08:37:52 -07:00
Damien George 564abb01a5 extmod/vfs_fat_diskio: Factor disk ioctl code to reduce code size.
Functionality is unchanged.
2018-06-16 18:21:42 +10:00
Dan Halbert 92b531d0c3
Merge pull request #939 from tannewt/travis840
Add auto-build for nrf52840 development kit, PCA10056
2018-06-15 21:10:53 -04:00
Dan Halbert e475256b38
Merge pull request #937 from tannewt/separate_peripherals_lib
Split out the peripherals library in preparation of sharing with MakeCode
2018-06-15 19:45:14 -04:00
Scott Shawcroft b4338921de Add auto-build for nrf52840 development kit, PCA10056 2018-06-15 16:34:26 -07:00
Scott Shawcroft a5e03b76a6 Split out the peripherals library in preparation of sharing with MakeCode. 2018-06-15 16:16:21 -07:00
Dan Halbert f152889938 do not permit mounting over a directory or file with the same name as the mount point 2018-06-15 13:53:30 -04:00
Limor "Ladyada" Fried 9fc0ec6af8
Merge pull request #934 from microbuilder/usbboot
[WIP] nRF52840 USB Bootloader
2018-06-15 09:35:30 -07:00
Scott Shawcroft 5ce1d71206
Merge pull request #932 from dhalbert/listdir_root
fix os.listdir() when current dir is '/'
2018-06-15 09:34:08 -07:00
Dan Halbert 327b0f76da fix os.listdir() when current dir is '/' 2018-06-15 10:51:03 -04: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 34b2f6b6fc esp32/modules: Include umqtt library in frozen modules. 2018-06-15 16:39:49 +10:00
Damien George d61d119c94 esp32: Update to latest ESP IDF. 2018-06-15 16:23:53 +10:00
sommersoft 23b6d33455 fixes #642; spi_init_gpio() is now bypassed for both construct and configure 2018-06-15 05:03:52 +00:00
Damien George 7be4a23c0c stm32/i2cslave: Fix ordering of event callbacks in slave IRQ handler.
It's possible (at least on F4 MCU's) to have RXNE and STOPF set at the same
time during a call to the slave IRQ handler.  In such cases RXNE should be
handled before STOPF so that all bytes are processed before
i2c_slave_process_rx_end() is called.
2018-06-15 14:15:31 +10:00
Damien George bc5e8a2cb6 stm32/i2c: Fix num_acks calculation in i2c_write for F0 and F7 MCU's.
Due to buffering of outgoing bytes on the I2C bus, detection of a NACK
using the ISR_NACKF flag needs to account for the case where ISR_NACKF
corresponds to the previous-to-previous byte.
2018-06-15 14:10:53 +10:00
Scott Shawcroft 720042f964
Merge pull request #930 from dhalbert/sd_card_audio_play
Fix playing audio from SD card
2018-06-14 18:57:24 -07:00
Dan Halbert fa814a32ce Make Trinket M0 build fit; make RAMFS in vfs_fat_* tests be compliant with expected API 2018-06-14 21:02:12 -04:00
Damien George 37a7257aff stm32/timer: Support TIM1 on F0 MCUs. 2018-06-15 10:50:08 +10:00
Dan Halbert e724bc1c4e Fix playing audio from SD card 2018-06-14 18:47:40 -04: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 335d26b27d stm32/boards/STM32L476DISC: Update SPI flash config for cache change. 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
hathach 35d38dbfed update nrf52840 bootloader hex 2018-06-13 17:27:55 +07:00
Damien George cf1509c911 esp32/fatfs_port: Implement get_fattime so FAT files have a timestamp.
Fixes issue #3859.
2018-06-13 14:13:34 +10:00
Damien George d11fb09333 extmod/modussl_axtls: Fix __del__ to point to mp_stream_close_obj. 2018-06-13 13:16:21 +10:00
Scott Shawcroft 618943d90a
Merge pull request #926 from nickzoic/circuitpython-nickzoic-716-pulseio-esp8266
Implement pulseio.PulseIn and PulseOut for ESP8266 #716
2018-06-12 18:33:16 -07:00
Dan Halbert 144c0597e9
Merge pull request #928 from tannewt/fix_uart_timeout
Correct UART reads to return error on timeout.
2018-06-12 18:41:18 -04:00
Scott Shawcroft ee817a2fa8 Correct UART reads to return error on timeout.
This causes read to correctly return None instead of b''.

Fixes #874
2018-06-12 14:03:27 -07:00
Scott Shawcroft ab0bc1c2f8
Merge pull request #927 from dhalbert/pdmin_serializer_on_off
PDMIn: turn serializer on when starting DMA
2018-06-12 10:42:08 -07:00
Dan Halbert 4691b30c02 PDMIn: turn serializer on when starting DMA 2018-06-12 12:35:51 -04:00
Damien George 035906419d extmod/uos_dupterm: Use native C stream methods on dupterm object.
This patch changes dupterm to call the native C stream methods on the
connected stream objects, instead of calling the Python readinto/write
methods.  This is much more efficient for native stream objects like UART
and webrepl and doesn't require allocating a special dupterm array.

This change is a minor breaking change from the user's perspective because
dupterm no longer accepts pure user stream objects to duplicate on.  But
with the recent addition of uio.IOBase it is possible to still create such
classes just by inheriting from uio.IOBase, for example:

    import uio, uos

    class MyStream(uio.IOBase):
        def write(self, buf):
            # existing write implementation
        def readinto(self, buf):
            # existing readinto implementation

    uos.dupterm(MyStream())
2018-06-12 15:06:11 +10:00
Damien George 5042d98514 stm32/Makefile: Rebuild all qstrs when any board configuration changes. 2018-06-12 13:53:43 +10:00
Damien George 7ad04d17da py/mkrules.mk: Regenerate all qstrs when config files change.
A port can define QSTR_GLOBAL_DEPENDENCIES to add extra files.
2018-06-12 13:53:43 +10:00
Damien George 0501427907 esp32: Remove port-specific uhashlib implementation and use common one.
Now that the common module has mbedtls support for both SHA1 and SHA256 it
can now be used on this port.
2018-06-12 13:50:11 +10:00
Yonatan Goldschmidt c2fb725e72 extmod/moduhashlib: Make function objects STATIC.
These are not exported to anyone anyway.
2018-06-12 13:50:11 +10:00
Yonatan Goldschmidt 6963ee9075 extmod/moduhashlib: Allow using the sha256 implementation of mbedTLS. 2018-06-12 13:50:11 +10:00
Yonatan Goldschmidt 6630354ffe extmod/moduhashlib: Allow to disable the sha256 class.
Via the config value MICROPY_PY_UHASHLIB_SHA256.  Default to enabled to
keep backwards compatibility.

Also add default value for the sha1 class, to at least document its
existence.
2018-06-12 13:50:11 +10:00
Yonatan Goldschmidt 38682d4629 extmod/moduhashlib: Reorder funcs so that they are grouped by hash type.
Makes the code much more readable by reducing the number of #ifdefs and
keeping related functions close.
2018-06-12 13:47:20 +10:00
Yonatan Goldschmidt b045ebd354 extmod/moduhashlib: Prefix all Python methods and objects with uhashlib.
For consistency with other modules, and to help avoid clashes with the
actual underlying functions that do the hashing (eg
crypto-algorithms/sha256.c:sha256_update).
2018-06-12 13:44:09 +10:00
Dan Halbert d427ed64a2
Merge pull request #925 from tannewt/latest_asf4
Update to the latest ASF4 which includes an I2C timeout extension …
2018-06-11 23:05:24 -04:00
Damien George c901cc6862 tests/extmod: Add test for VFS and user-defined filesystem and files. 2018-06-12 12:29:26 +10:00
Damien George 9144b1f10c tests/io: Add simple IOBase test. 2018-06-12 12:29:26 +10:00