aboutsummaryrefslogtreecommitdiff
path: root/extmod
AgeCommit message (Collapse)Author
2016-10-30extmod/utime_mphal: Allow ticks functions period be configurable by a port.Paul Sokolovsky
Using MICROPY_PY_UTIME_TICKS_PERIOD config var.
2016-10-29extmod/utime_mphal: Implement ticks_add(), add to all maintained ports.Paul Sokolovsky
2016-10-29extmod/utime_mphal: Add MP_THREAD_GIL_EXIT/ENTER warppers for sleep functions.Paul Sokolovsky
Ported from unix port.
2016-10-29extmod/utime_mphal: ticks_diff(): switch arg order, return signed value.Paul Sokolovsky
Based on the earlier discussed RFC. Practice showed that the most natural order for arguments corresponds to mathematical subtraction: ticks_diff(x, y) <=> x - y Also, practice showed that in real life, it's hard to order events by time of occurance a priori, events tend to miss deadlines, etc. and the expected order breaks. And then there's a need to detect such cases. And ticks_diff can be used exactly for this purpose, if it returns a signed, instead of unsigned, value. E.g. if x is scheduled time for event, and y is the current time, then if ticks_diff(x, y) < 0 then event has missed a deadline (and e.g. needs to executed ASAP or skipped). Returning in this case a large unsigned number (like ticks_diff behaved previously) doesn't make sense, and such "large unsigned number" can't be reliably detected per our definition of ticks_* function (we don't expose to user level maximum value, it can be anything, relatively small or relatively large).
2016-10-26extmod/moduos_dupterm: Renamed to uos_dupterm.Paul Sokolovsky
As part of file naming clean up (moduos_dupterm doesn't implement a full module, so should skip "mod" prefix, similar to other files in extmod/).
2016-10-24extmod/vfs_fat_file: Make file.close() a no-op if file already closed.Damien George
As per CPython semantics. In particular, file.__del__() should not raise an exception if the file is already closed.
2016-10-21py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.Damien George
In order to have more fine-grained control over how builtin functions are constructed, the MP_DECLARE_CONST_FUN_OBJ macros are made more specific, with suffix of _0, _1, _2, _3, _VAR, _VAR_BETEEN or _KW. These names now match the MP_DEFINE_CONST_FUN_OBJ macros.
2016-10-19extmod/vfs_fat_file: Check fatfs f_sync() and f_close() returns for errors.Alex March
2016-10-15extmod/modussl_mbedtls: Add dummy setblocking() method.Paul Sokolovsky
Accepts only value of True.
2016-10-14extmod/utime_mphal: sleep_us/ms(): Don't wait on negative argument.Paul Sokolovsky
2016-10-14extmod/utime_mphal: Factor out implementations in terms of mp_hal_* for reuse.Paul Sokolovsky
As long as a port implement mp_hal_sleep_ms(), mp_hal_ticks_ms(), etc. functions, it can just use standard implementations of utime.sleel_ms(), utime.ticks_ms(), etc. Python-level functions.
2016-10-13extmod/modujson: Fix nanbox build.Damien George
2016-10-13extmod/modujson: Implement ujson.load() to load JSON from a stream.Damien George
This refactors ujson.loads(s) to behave as ujson.load(StringIO(s)). Increase in code size is: 366 bytes for unix x86-64, 180 bytes for stmhal, 84 bytes for esp8266.
2016-10-11extmod/vfs_fat: Add file and directory checks for remove and rmdir.Alex March
2016-10-11extmod/machine_i2c: Use writes not reads in i2c.scan().Radomir Dopieralski
As per discussion in #2449, using write requests instead of read requests for I2C.scan() seems to support a larger number of devices, especially ones that are write-only. Even a read-only I2C device has to implement writes in order to be able to receive the address of the register to read.
2016-10-11extmod/uzlib: Update to upstream v2.1.Paul Sokolovsky
Adds check that LZ offsets fall into the sliding dictionary used. This catches a case when uzlib.DecompIO with a smaller dictionary is used to decompress data which was compressed with a larger dictionary. Previously, this would lead to producing invalid data or crash, now an exception will be thrown.
2016-10-07extmod/vfs_fat_file: Use MP_Exxx errno constants.Damien George
2016-10-07extmod: Use mp_raise_OSError helper function.Damien George
2016-10-07extmod/modlwip: Use mp_raise_OSError helper function.Damien George
Reduces esp8266 code size by about 230 bytes.
2016-10-07extmod/vfs_fat: Use mp_raise_OSError helper function.Damien George
2016-10-04extmod/machine_spi: Add optional support for fast software SPI.Damien George
If a port defines MICROPY_PY_MACHINE_SPI_MIN_DELAY then it can use a faster software SPI loop that does not make calls to the delay_us function.
2016-10-04extmod/machine_spi: Use delay_half, not baudrate, for internal timing.Damien George
The delay_half parameter must be specified by the port to set up the timing of the software SPI. This allows the port to adjust the timing value to better suit its timing characteristics, as well as provide a more accurate printing of the baudrate.
2016-10-03extmod/machine_spi: Factor out software SPI code from esp8266 to extmod.Damien George
2016-10-03extmod/machine_spi: Simplify SPI xfer function to only take one buf len.Damien George
There is no need to take src_len and dest_len arguments. The case of reading-only with a single output byte (originally src_len=1, dest_len>1) is now handled by using the output buffer as the input buffer, and using memset to fill the output byte into this buffer. This simplifies the implementations of the spi_transfer protocol function.
2016-09-28extmod/machine_i2c: Add support for the addrsize parameter in mem xfers.Radomir Dopieralski
The memory read/write I2C functions now take an optional keyword-only parameter that specifies the number of bits in the memory address. Only mem-addrs that are a multiple of 8-bits are supported (otherwise the behaviour is undefined). Due to the integer type used for the address, for values larger than 32 bits, only 32 bits of address will be sent, and the rest will be padded with 0s. Right now no exception is raised when that happens. For values smaller than 8, no address is sent. Also no exception then. Tested with a VL6180 sensor, which has 16-bit register addresses. Due to code refactoring, this patch reduces stmhal and esp8266 builds by about 50 bytes.
2016-09-27extmod/vfs_fat: Add fat_vfs_statvfs(), reused from stmhal.Alex March
2016-09-24extmod/uzlib/: Update uzlib to v2.0.3.Paul Sokolovsky
Fixes for more pedantic warnings.
2016-09-24extmod/moduzlib: DecompIO: Add support for gzip-formatted streams.Paul Sokolovsky
This uses extension introduced in CPython 3.5: if wbits (dictionary size code) has value 16 + 8..15, it means that gzip-formatted stream expected.
2016-09-24extmod/uzlib: Add tinfgzip.c (gzip header parsing) from upstream.Paul Sokolovsky
2016-09-23extmod/modussl_mbedtls: Add server_hostname param for wrap_socket().Paul Sokolovsky
In CPython, module-level .wrap_socket() function actually doesn't accept (or document) this param, only SSLContext.wrap_socket() has.
2016-09-22extmod/machine_i2c: Add clock stretching support.Radomir Dopieralski
When the clock is too fast for the i2c slave, it can temporarily hold down the scl line to signal to the master that it needs to wait. The master should check the scl line when it is releasing it after transmitting data, and wait for it to be released. This change has been tested with a logic analyzer and an i2c slace implemented on an atmega328p using its twi peripheral, clocked at 8Mhz. Without the change, the i2c communication works up to aboy 150kHz frequency, and above that results in the slave stuck in an unresponsive state. With this change, communication has been tested to work up to 400kHz.
2016-09-22extmod/modussl_mbedtls: Use 2-component include paths.Paul Sokolovsky
This is required to use mbedTLS versions from various sources, e.g. mainline vs embedded into Zephyr RTOS.
2016-09-22extmod/modussl_mbedtls: Implement key= and cert= args to wrap_socket().Paul Sokolovsky
Unlike standard keyfile= and certfile=, these accept byte buffer objects (to not depend on FS implementation).
2016-09-21extmod/modubinascii: Fix crc32() function on 32-bit platforms.Pavol Rusnak
2016-09-21extmod/uctypes: Allow full 32-bit address range.Stefan Agner
Use mp_obj_int_get_truncated to allow the full 32-bit address range as first parameter.
2016-09-21extmod/modussl_mbedtls: Initial implementation of mbedTLS ussl module.Paul Sokolovsky
2016-09-22all: Remove 'name' member from mp_obj_module_t struct.Damien George
One can instead lookup __name__ in the modules dict to get the value.
2016-09-05extmod/framebuf: Add the xstep!=0 case to scroll() method.Radomir Dopieralski
Adds horizontal scrolling. Right now, I'm just leaving the margins created by the scrolling as they were -- so they will repeat the edge of the framebuf. This is fast, and the user can always fill the margins themselves.
2016-09-04extmod/moduzlib: Support wbits arg to DecompIO.Paul Sokolovsky
2016-09-04extmod/modframebuf: Include font from stmhal directory explicitly.Damien George
So that users of framebuf don't need to have stmhal directory in their path. (Eventually the font can be moved elsewhere.)
2016-09-03extmod/moduzlib: Use mperrno.h for error constants.Paul Sokolovsky
2016-09-03extmod/moduzlib: Implement zlib stream decompressor class, DecompIO.Paul Sokolovsky
2016-09-02extmod/modframebuf: Fix fill and scroll when height not divisible by 8.Radomir Dopieralski
There was a bug in `framebuf1_fill` function, that makes it leave a few lines unfilled at the bottom if the height is not divisible by 8. A similar bug is fixed in the scroll method.
2016-09-01extmod: Add machine_spi with generic SPI C-protocol and helper methods.Damien George
The idea is that all ports can use these helper methods and only need to provide initialisation of the SPI bus, as well as a single transfer function. The coding pattern follows the stream protocol and helper methods.
2016-08-27extmod/modframebuf: Fix pixel accessor to return a 1-bit result.Damien George
2016-08-26esp8266/modous: Add os.umount method to unmount a filesystem.Radomir Dopieralski
This is an object-oriented approach, where uos is only a proxy for the methods on the vfs object. Some internals had to be exposed (the STATIC keyword removed) for this to work. Fixes #2338.
2016-08-24extmod/modubinascii: Make crc32() support configurable.Paul Sokolovsky
Disable by default, enable in unix port.
2016-08-24extmod/modubinascii: implement binascii.crc32Pavol Rusnak
2016-08-24extmod/modbtree: do CHECK_ERROR after __bt_seq()Krzysztof Blazewicz
In `btree_seq()`, when `__bt_seq()` gets called with invalid `flags` argument it will return `RET_ERROR` and it won't initialize `val`. If field `data` of uninitialized `val` is passed to `mp_obj_new_bytes()` it causes a segfault.
2016-08-17extmod/uzlib/: Update uzlib to v2.0.2.Paul Sokolovsky
Consistently use stdint types. Fixes stmhal build.