Commit Graph

7378 Commits

Author SHA1 Message Date
Fabio Utzig 8908e505ce py/sequence: Fix reverse slicing of lists. 2016-10-30 15:54:19 -02: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 1ba4db5685 tests/btree1: Fix out of memory error running on esp8266. 2016-10-29 19:53:31 +03:00
Paul Sokolovsky 64c6bdb8ee esp8266/modutime: Consistently convert to MP_ROM_QSTR/MP_ROM_PTR. 2016-10-29 18:48:04 +03:00
Paul Sokolovsky 369233105b stmhal/modutime: Consistently convert to MP_ROM_QSTR/MP_ROM_PTR. 2016-10-29 17:46:47 +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 c62679bdaa unix/mphalport.h: Add dummy definition of mp_hal_ticks_cpu().
To fix coverage build.
2016-10-29 17:23:05 +03:00
Paul Sokolovsky 6a2c6098f4 windows: Enable utime_mphal following unix, define mp_hal_ticks_*.
mp_hal_ticks_ms, mp_hal_ticks_us taken from unix port, mp_hal_ticks_cpu
dummy.
2016-10-29 14:32:15 +03:00
Paul Sokolovsky 3cc87b1e2a unix/modtime: Switch ticks/sleep_ms/us() to utime_mphal. 2016-10-29 14:17:02 +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 99ed0f25cb unix/mphalport.h: Add warning of mp_hal_delay_ms() implementation.
It's implemented in terms of usleep(), and POSIX doesn't guarantee that
usleep() can sleep for more than a second. This restriction unlikely
applies to any real-world system, but...
2016-10-29 13:38:02 +03:00
Scott Shawcroft 7a24abb27c lib/utils/pyexec: Return FORCED_EXIT from pyexec_file when its stopped by CTRL - C. 2016-10-28 20:19:30 -07:00
Scott Shawcroft 5b3a143ffe atmel-samd: Rework tick timer to use TC5 and support neopixel status LED.
The tick timer needed to be reworked because the ASF delay functions also
use the SysTick timer. Now, it uses TC5 and calls out to the autoreset
logic every tick. Fixes #43.

Added neopixel status colors and corrected the latch time from ms to us.
Fixes #42.
2016-10-28 20:16:39 -07:00
Scott Shawcroft 9008b93962 atmel-samd: Fix typo in ASF. 2016-10-28 20:12:24 -07: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 e381efed4a unix/modtime: Use ticks_diff() implementation from extmod/utime_mphal.c. 2016-10-29 04:58:06 +03:00
Paul Sokolovsky aee6483536 zephyr/README: Update for the current featureset, add more info. 2016-10-28 21:51:18 +03:00
Paul Sokolovsky 938c693948 zephyr: Support time -> utime module "weaklink".
So, now it's possible to just do normal Python's "import time".
2016-10-28 21:38:52 +03:00
Alex March cc0cc67815 tests/extmod/uhashlib_sha256: Rename sha256.py test. 2016-10-28 19:51:54 +03:00
Alex March b83ac44e82 tests/extmod/uhashlib_sha1: Coverage for SHA1 algorithm. 2016-10-28 19:51:46 +03:00
Paul Sokolovsky b0feef7a57 zephyr/zephyr_getchar: Update for recent Zephyr refactor of console hooks.
uart_irq_input_hook_set() was renamed to uart_console_in_debug_hook_install()
and accepts different params.
2016-10-28 17:53:10 +03:00
Paul Sokolovsky c28f9df63a docs/library/network: Typo fixes, consistent acronym capitalization. 2016-10-28 12:03:35 +03:00
Paul Sokolovsky b9a88683a4 docs/library/network: Reword intro paragraph. 2016-10-28 04:42:27 +03:00
Scott Shawcroft fc78f6950f atmel-samd: Add D13 as flash write indicator on Arduino Zero. 2016-10-27 17:49:52 -07:00
Scott Shawcroft 86a1d1db30 atmel-samd: Fix autoreset when no repl is present and keep running mss storage code during a sleep. 2016-10-27 17:48:42 -07:00
Alex March 964fb2450e tests/basics/gc1: Garbage collector threshold() coverage. 2016-10-27 22:15:42 +03:00
Paul Sokolovsky 8a49905a2f py/stream: Typo fix in comment. 2016-10-27 22:13:45 +03:00
Scott Shawcroft 3a9cb1ac49 atmel-samd: Fix Arduino SPI pin. Datasheet net name is wrong. :-( 2016-10-26 20:16:53 -07:00
Alex March 52aa532050 qemu-arm: Exclude new vfs_fat tests. 2016-10-27 12:25:28 +11:00
Alex March fbca4f94b3 tests/extmod/vfs_fat_oldproto: Test old block device protocol. 2016-10-27 12:22:43 +11:00
Alex March 38a9359339 tests/extmod/vfs_fat_fsusermount: Improve fsusermount test coverage. 2016-10-27 12:22:42 +11:00
Scott Shawcroft 85e4d3572d atmel-samd: Add named pins for Arduino Zero SPI. Fixes #11. 2016-10-26 18:02:34 -07:00
Scott Shawcroft 2098515f6a atmel-samd: Rework pin definitions to share most of the data structures and included based on ASF defines. 2016-10-26 17:57:47 -07:00
Daniel Thompson 67b6d9d499 zephyr: Initial implementation of machine.Pin.
The integration with Zephyr is fairly clean but as MicroPython Hardware API
requires pin ID to be a single value, but Zephyr operates GPIO in terms of
ports and pins, not just pins, a "hierarchical" ID is required, using tuple
of (port, pin). Port is a string, effectively a device name of a GPIO port,
per Zephyr conventions these are "GPIO_0", "GPIO_1", etc.; pin is integer
number of pin with the port (supposed to be in range 0-31).

Example of pin initialization:

pin = Pin(("GPIO_1", 21), Pin.OUT)

(an LED on FRDM-K64F's Port B, Pin 21).

There is support for in/out pins and pull up/pull down but currently
there is no interrupt support.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2016-10-27 00:47:26 +03:00
Scott Shawcroft 73848f4cd0 atmel-samd: Stop aliasing os to uos and time to utime. They expose different APIs. Fixes #23. 2016-10-26 13:33:50 -07:00
Scott Shawcroft 34fa81eaf3 atmel-samd: Hook in DTR for more ports and make the serial TX more resiliant to long strings. 2016-10-26 13:32:41 -07:00
Scott Shawcroft 04284a9fe3 Merge pull request #38 from tannewt/autoreset
atmel-samd: Support auto-reset based on USB write activity.
2016-10-26 11:12:55 -07:00
Vincenzo Frascino a3519332b6 zephyr: Use board/SoC values for startup banner based on Zephyr config.
This patch modifies the HW macro definition in order to let micropython
report correctly the BOARD and the SOC on which it is working on.
2016-10-26 19:00:16 +03:00
Paul Sokolovsky 3cdccb9b14 zephyr: Fix mp_hal_set_interrupt_char() declaration to be compatible.
With other ports. Other ports declare it in mphalport.h, it can be
inline or macro.
2016-10-26 17:53:28 +03:00
Paul Sokolovsky 6832cbd69d lib/utils/pyexec: Fix compilation warning of type vs format mismatch.
This happens with some compilers on some architectures, which don't define
size_t as unsigned int. MicroPython's printf() dooesn't support obscure
format specifiers for size_t, so the obvious choice is to explicitly cast
to unsigned, to match %u used in printf().
2016-10-26 13:45:03 +03:00
Vincenzo Frascino c38ea32810 lib/utils/pyexec: Add mp_hal_set_interrupt_char() prototype.
This patch removes a compilation warning in pyexec.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2016-10-26 13:42:27 +03:00
Paul Sokolovsky 73b72799f3 examples/http_server_simplistic: Add "not suitable for real use" note. 2016-10-26 12:25:33 +03:00
Scott Shawcroft d189a3f3cf atmel-samd: Support auto-reset based on USB write activity.
It will soft-reboot micropython after a burst of writes to the
file system. This means that after you save files on your computer
they will be automatically rerun.

This can be disabled in the build by unsetting AUTORESET_TIMER in
mpconfigboard.h.

Using the REPL will also prevent the soft resets until you reset
with CTRL-D manually.
2016-10-25 18:36:37 -07:00
Scott Shawcroft 614c1fdba2 atmel-samd: Only output to USB after DTR and don't send anything larger than the room left in the USB TX buffer. 2016-10-25 18:29:04 -07: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
Scott Shawcroft b7768a74a7 atmel-samd: Fix file system init.
Adding the USB write protection prevented file system reset from
working. Since it happens before USB start we temporarily set the
volume to writeable and then set it back to read-only before USB is
started.
2016-10-25 15:13:43 -07:00
Scott Shawcroft d05299f57a atmel-samd: Add D13 led as mass storage write indicator. 2016-10-25 15:06:05 -07:00
Scott Shawcroft 3a5aad516a atmel-samd: Remove unused header. 2016-10-25 15:04:20 -07:00
Scott Shawcroft fff96a0ce6 atmel-samd: Fix include guard. 2016-10-25 15:03:22 -07:00