Wykres commitów

347 Commity (7e820792dadde74ac283465b9497ad4c313db379)

Autor SHA1 Wiadomość Data
Damien George 0d56c65d3e extmod/moduselect: Fix comment describing endif. 2016-11-21 15:47:48 +11:00
Paul Sokolovsky 5362bcc487 extmod/machine_mem: Typo fix in comment. 2016-11-21 01:09:17 +03:00
Paul Sokolovsky 8f5bc3ffc0 stmhal/moduselect: Move to extmod/ for reuse by other ports. 2016-11-21 00:05:56 +03:00
Radomir Dopieralski e81a5353cb extmod/machine_i2c: Release SDA on bus error 2016-11-17 12:43:13 +11:00
Radomir Dopieralski 9a82b67f39 extmod/machine_i2c: Raise an error when clock stretching times out 2016-11-17 12:43:13 +11:00
Radomir Dopieralski 702928915c extmod/machine_i2c: Make the clock stretching timeout configurable 2016-11-17 12:43:12 +11:00
Damien George e5ef15a9d7 py/lexer: Provide generic mp_lexer_new_from_file based on mp_reader.
If a port defines MICROPY_READER_POSIX or MICROPY_READER_FATFS then
lexer.c now provides an implementation of mp_lexer_new_from_file using
the mp_reader_new_file function.
2016-11-16 18:13:51 +11:00
Damien George 6b239c271c py: Factor out persistent-code reader into separate files.
Implementations of persistent-code reader are provided for POSIX systems
and systems using FatFS.  Macros to use these are MICROPY_READER_POSIX and
MICROPY_READER_FATFS respectively.  If an alternative implementation is
needed then a port can define the function mp_reader_new_file.
2016-11-16 18:13:50 +11:00
Paul Sokolovsky 59a1201da9 all: Remove readall() method, which is equivalent to read() w/o args.
Its addition was due to an early exploration on how to add CPython-like
stream interface. It's clear that it's not needed and just takes up
bytes in all ports.
2016-11-14 00:24:22 +03:00
Paul Sokolovsky 0cbc07227c extmod/moduheapq: Adhoc changes to support ordering by utime.ticks_ms().
As required for further elaboration of uasyncio, like supporting baremetal
systems with wraparound timesources. This is not intended to be public
interface, and likely will be further refactored in the future.
2016-11-12 02:33:17 +03:00
Paul Sokolovsky 9b345a9e48 extmod/utime_mphal: ticks_diff/ticks_add: Don't hardcode 32-bit types.
Use normal mp_int_t/mp_uint_t types, algorithms (hm, formulas) can work
with any type width.
2016-11-03 23:54:16 +03:00
Paul Sokolovsky 10bde6933e extmod/utime_mphal: ticks_diff(): Optimize to avoid if conditions. 2016-11-02 02:50:48 +03:00
Paul Sokolovsky e429daa572 extmod/utime_mphal: Fix implementation of new semantics of ticks_diff().
Now the function properly uses ring arithmetic to return signed value
in range (inclusive):
[-MICROPY_PY_UTIME_TICKS_PERIOD/2, MICROPY_PY_UTIME_TICKS_PERIOD/2-1].

That means that function can properly process 2 time values away from
each other within MICROPY_PY_UTIME_TICKS_PERIOD/2 ticks, but away in
both directions. For example, if tick value 'a' predates tick value 'b',
ticks_diff(a, b) will return negative value, and positive value otherwise.
But at positive value of MICROPY_PY_UTIME_TICKS_PERIOD/2-1, the result
of the function will wrap around to negative -MICROPY_PY_UTIME_TICKS_PERIOD/2,
in other words, if a follows b in more than MICROPY_PY_UTIME_TICKS_PERIOD/2 - 1
ticks, the function will "consider" a to actually predate b.
2016-10-30 03:07:22 +03:00
Paul Sokolovsky 76146b3d9a extmod/utime_mphal: Allow ticks functions period be configurable by a port.
Using MICROPY_PY_UTIME_TICKS_PERIOD config var.
2016-10-30 03:02:07 +03:00
Paul Sokolovsky d86cac4b82 extmod/utime_mphal: Implement ticks_add(), add to all maintained ports. 2016-10-29 17:30:05 +03:00
Paul Sokolovsky 6a87084019 extmod/utime_mphal: Add MP_THREAD_GIL_EXIT/ENTER warppers for sleep functions.
Ported from unix port.
2016-10-29 13:42:36 +03:00
Paul Sokolovsky 6ed5583f8c extmod/utime_mphal: ticks_diff(): switch arg order, return signed value.
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-29 05:02:24 +03:00
Paul Sokolovsky f00ecdb54d extmod/moduos_dupterm: Renamed to uos_dupterm.
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-26 02:08:37 +03:00
Damien George 5694201930 extmod/vfs_fat_file: Make file.close() a no-op if file already closed.
As per CPython semantics.  In particular, file.__del__() should not raise
an exception if the file is already closed.
2016-10-24 12:59:20 +11:00
Damien George 4ebdb1f2b2 py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.
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-21 16:26:01 +11:00
Alex March 84679e0c06 extmod/vfs_fat_file: Check fatfs f_sync() and f_close() returns for errors. 2016-10-19 15:57:07 +11:00
Paul Sokolovsky 06234a6115 extmod/modussl_mbedtls: Add dummy setblocking() method.
Accepts only value of True.
2016-10-15 23:46:13 +03:00
Paul Sokolovsky 36f97f19b4 extmod/utime_mphal: sleep_us/ms(): Don't wait on negative argument. 2016-10-14 22:19:45 +03:00
Paul Sokolovsky a97284423e extmod/utime_mphal: Factor out implementations in terms of mp_hal_* for reuse.
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-14 20:14:01 +03:00
Damien George f2f8ae110b extmod/modujson: Fix nanbox build. 2016-10-13 12:09:18 +11:00
Damien George e93c1ca5da extmod/modujson: Implement ujson.load() to load JSON from a stream.
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-13 11:46:14 +11:00
Alex March d02f3a57f4 extmod/vfs_fat: Add file and directory checks for remove and rmdir. 2016-10-11 16:03:52 +11:00
Radomir Dopieralski eaef6b5324 extmod/machine_i2c: Use writes not reads in i2c.scan().
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-11 15:30:46 +11:00
Paul Sokolovsky 39968aaaff extmod/uzlib: Update to upstream v2.1.
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-11 07:13:23 +03:00
Damien George dc43508cc2 extmod/vfs_fat_file: Use MP_Exxx errno constants. 2016-10-07 14:14:41 +11:00
Damien George 75af908c0e extmod: Use mp_raise_OSError helper function. 2016-10-07 13:52:14 +11:00
Damien George 06d0083468 extmod/modlwip: Use mp_raise_OSError helper function.
Reduces esp8266 code size by about 230 bytes.
2016-10-07 13:47:57 +11:00
Damien George 620c4c32bf extmod/vfs_fat: Use mp_raise_OSError helper function. 2016-10-07 13:44:55 +11:00
Damien George b0eb0d6153 extmod/machine_spi: Add optional support for fast software SPI.
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-04 13:46:40 +11:00
Damien George b932b2dd1f extmod/machine_spi: Use delay_half, not baudrate, for internal timing.
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-04 13:43:02 +11:00
Damien George d434ce3fca extmod/machine_spi: Factor out software SPI code from esp8266 to extmod. 2016-10-03 16:43:44 +11:00
Damien George 5bb28c7f10 extmod/machine_spi: Simplify SPI xfer function to only take one buf len.
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-10-03 12:39:31 +11:00
Radomir Dopieralski 219245e10f extmod/machine_i2c: Add support for the addrsize parameter in mem xfers.
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-28 14:45:29 +10:00
Alex March dcf14c1b18 extmod/vfs_fat: Add fat_vfs_statvfs(), reused from stmhal. 2016-09-27 13:48:45 +10:00
Paul Sokolovsky 67d52d8cb9 extmod/uzlib/: Update uzlib to v2.0.3.
Fixes for more pedantic warnings.
2016-09-24 16:07:18 +03:00
Paul Sokolovsky 7b901d6fb7 extmod/moduzlib: DecompIO: Add support for gzip-formatted streams.
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-24 15:30:11 +03:00
Paul Sokolovsky d8a4d9d67c extmod/uzlib: Add tinfgzip.c (gzip header parsing) from upstream. 2016-09-24 15:28:51 +03:00
Paul Sokolovsky 46ab042230 extmod/modussl_mbedtls: Add server_hostname param for wrap_socket().
In CPython, module-level .wrap_socket() function actually doesn't accept
(or document) this param, only SSLContext.wrap_socket() has.
2016-09-23 01:44:23 +03:00
Radomir Dopieralski ec078af985 extmod/machine_i2c: Add clock stretching support.
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-22 14:10:02 +10:00
Paul Sokolovsky 080e4d44f3 extmod/modussl_mbedtls: Use 2-component include paths.
This is required to use mbedTLS versions from various sources, e.g.
mainline vs embedded into Zephyr RTOS.
2016-09-22 01:30:48 +03:00
Paul Sokolovsky 5f0ecb72c2 extmod/modussl_mbedtls: Implement key= and cert= args to wrap_socket().
Unlike standard keyfile= and certfile=, these accept byte buffer objects
(to not depend on FS implementation).
2016-09-22 00:17:44 +03:00
Pavol Rusnak 7f5a541b84 extmod/modubinascii: Fix crc32() function on 32-bit platforms. 2016-09-21 21:40:18 +03:00
Stefan Agner b84e1231c9 extmod/uctypes: Allow full 32-bit address range.
Use mp_obj_int_get_truncated to allow the full 32-bit address range
as first parameter.
2016-09-21 21:37:08 +03:00
Paul Sokolovsky 9ea2882317 extmod/modussl_mbedtls: Initial implementation of mbedTLS ussl module. 2016-09-21 21:25:33 +03:00
Damien George 93c4a6a3f7 all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00