Commit Graph

607 Commits

Author SHA1 Message Date
Alexander Steffen
ebb9396274 esp8266,minimal,pic16bit: Use size_t for mp_builtin_open argument.
py/builtin.h declares mp_builtin_open with the first argument of type
size_t.  Make all implementations conform to this declaration.
2017-06-28 11:45:52 +10:00
Damien George
caa132a236 esp8266/machine_rtc: Use correct arithmetic for aligning RTC mem len. 2017-06-26 14:29:30 +10:00
Paul Sokolovsky
602f7e2189 esp8266/README: Make "Documentation" a top-level section. 2017-06-24 17:38:53 +03:00
Paul Sokolovsky
0fe825b89e esp8266: Enable MICROPY_ENABLE_FINALISER.
GC finalization should be enabled for modlwip, or it may lead to GC
problems with socket objects. This decreases usable heap size from
36288 to 35968 (-320) bytes.
2017-06-23 20:12:33 +03:00
Damien George
46b849ab49 esp8266: Move mp_hal_pin_open_drain from esp_mphal.c to machine_pin.c.
It belongs with the other pin config functions in machine_pin.c.  Also,
esp_mphal.c is put in iRAM so this change saves about 300 bytes of iRAM
(and mp_hal_pin_open_drain is not a time critical function so doesn't
need to be in iRAM).
2017-06-22 16:39:09 +10:00
Damien George
85acf7645f esp8266: Reinstate 1-wire scripts by sym-linking to drivers/onewire/.
No changes have been made to the code, the files just moved.
2017-06-22 16:33:20 +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
Damien George
eeaab1897b extmmod/modonewire: Rename public module to mp_module_onewire.
This follows naming scheme of other modules in extmod.
2017-06-22 16:17:46 +10:00
Damien George
6cc4da4cb8 extmod: Move modonewire.c from esp8266 to extmod directory.
It's now generic enough to be used by any port.
2017-06-22 16:06:00 +10:00
Damien George
0c13b95cdc esp8266/modonewire: Make timings static and remove onewire.timings func.
The 1-wire bus is defined with fixed timings so there should be no need to
change them dynamically at runtime.  Making the timings fixed saves about
270 bytes of code and 20 bytes of RAM.
2017-06-22 15:53:13 +10:00
Damien George
68c640d7cb esp8266/modonewire: Move low-level 1-wire bus code to modonewire.c.
The reason it was separated is so that the low-level code could be put in
iRAM, for timing reasons.  But:

1. Tests show that it's not necessary to have this code in iRAM for it to
function correctly, and taking it out of iRAM reclaims some of that precious
resource.  Furthermore, even though these functions were in iRAM there were
some functions that it called (eg pin get/set functions) which were not in
iRAM, so partially defeated the purpose of putting the 1-wire code in iRAM.

2. It's easier to reuse this 1-wire code in other ports if it's in a single
file.

3. If it turns out that certain code does need to be in iRAM then one can
use the MP_FASTCODE macro to do that.
2017-06-22 15:47:56 +10:00
Damien George
c06aa5be00 esp8266: Make onewire module and support code usable by other ports. 2017-06-20 19:11:46 +10:00
Damien George
101fc187f0 esp8266/Makefile: Add LIB_SRC_C variable to qstr auto-extraction list. 2017-06-20 15:20:09 +10:00
Damien George
4f9858e86d stmhal: Move pybstdio.c to lib/utils/sys_stdio_mphal.c for common use.
It provides sys.stdin, sys.stdout, sys.stderr for bare-metal targets based
on mp_hal functions.
2017-06-15 18:55:34 +10:00
Damien George
76ec04a6d9 esp8266/Makefile: Allow FROZEN_DIR,FROZEN_MPY_DIR to be overridden. 2017-06-15 18:45:18 +10:00
Damien George
48d867b4a6 all: Make more use of mp_raise_{msg,TypeError,ValueError} helpers. 2017-06-15 11:54:41 +10:00
Paul Sokolovsky
a47b871131 esp8266/Makefile: Bump axTLS TLS record buffer size to 5K.
The latest fashion is pushing certificate sub-chains, instead of a single
certificate, during TLS handshake. These are pushed via single TLS record
and effectively put minimum size limit on TLS record buffer. Recently,
these commonly grew over 4K, so we have little choice but to adjust.
2017-06-14 01:28:22 +03:00
Paul Sokolovsky
52410ef5b3 esp8266/Makefile: Add clean-modules target.
Helpful when dealing with frozen modules (and whole applications).
2017-06-10 18:13:43 +03:00
Tamas TEVESZ
1dd18c5260 esp8266/Makefile: replace references to make with $(MAKE)
make is not always GNU make; the latter  may go by different names.
This helps builds on systems where the default make is not GNU make.
2017-06-08 13:42:23 +10:00
Damien George
6ff0ecfffc ports: Convert from using stmhal's input() to core provided version. 2017-06-01 16:02:49 +10:00
Ville Skyttä
ca16c38210 various: Spelling fixes 2017-05-29 11:36:05 +03:00
Damien George
22fdb91571 esp8266/mpconfigport.h: Remove duplicate link to lwip module.
It's already included in the core when MICROPY_PY_LWIP is defined.
2017-05-26 17:06:31 +10:00
Damien George
eea584860d esp8266/modules: Mount filesystem at root when creating for first time. 2017-05-26 17:05:58 +10:00
Paul Sokolovsky
bcf31a3908 esp8266, stmhal, zephyr: Rename machine.Pin high/low methods to on/off.
For consistent Pin/Signal class hierarchy. With it, Signal is a proper
(while still ducktyped) subclass of a Pin, and any (direct) usage of Pin
can be replace with Signal.

As stmhal's class is reused both as machine.Pin and legacy pyb.Pin,
high/low methods actually retained there.
2017-05-21 17:44:58 +03:00
Damien George
aca898eeb0 esp8266/machine_uart: Add uart.any() method.
Returns 0 or 1, corresponding to no or at least 1 char waiting.
2017-05-19 15:48:22 +10:00
puuu
4b235800a4 esp8266/modnetwork: In connect, fix potential buffer overflows. 2017-05-16 17:30:45 +10:00
Robert HH
71df60cf42 esp8266/ets_alt_task.c: Prevent spurious large increment of ticks_ms()
This happened when the overflow counter for ticks_ms() was interrupted
by an external hard interrupt (issue #3076).
2017-05-13 17:56:16 +10:00
Paul Sokolovsky
ddf0b7dbc3 esp8266/scripts: Move initsetup & port_diag tools to modules/. 2017-05-12 17:58:50 +03:00
Paul Sokolovsky
e9308c189a esp8266/scripts: Move drivers/modules to modules/ (frozen bytecode). 2017-05-12 17:57:23 +03:00
Paul Sokolovsky
5f7ce2a1ca esp8266/modules/flashbdev: Reserve one sector for native code storage. 2017-05-12 16:08:54 +03:00
Paul Sokolovsky
3e05df7fd1 esp8266/modesp: flash_user_start: Use value from linker script.
Make esp8266_common.ld export size reserved to all code segments, and use
that in esp.flash_user_start() implementation.
2017-05-12 16:00:05 +03:00
Paul Sokolovsky
0987ad5e30 esp8266/esp8266.ld, esp8266_ota.ld: Grow main firmware size by 32KB.
To accommodate both system and user frozen modules.
2017-05-12 16:00:05 +03:00
Damien George
f1609bc843 ports: Add ilistdir in uos module. 2017-05-10 12:13:53 +10:00
Damien George
e62235f8c7 esp8266: Change default settings to mount flash at root dir. 2017-05-05 20:15:10 +10:00
Paul Sokolovsky
fbe7a81e30 esp8266/README: Add notice about 512K version. 2017-04-14 01:03:46 +03:00
Paul Sokolovsky
40acbc2e10 esp8266/README: Replace reference of alpha status to beta status. 2017-04-14 00:56:41 +03:00
Paul Sokolovsky
605ff91efd extmod/machine_signal: Support all Pin's arguments to the constructor.
This implements the orginal idea is that Signal is a subclass of Pin, and
thus can accept all the same argument as Pin, and additionally, "inverted"
param. On the practical side, it allows to avoid many enclosed parenses for
a typical declararion, e.g. for Zephyr:

Signal(Pin(("GPIO_0", 1))).

Of course, passing a Pin to Signal constructor is still supported and is the
most generic form (e.g. Unix port will only support such form, as it doesn't
have "builtin" Pins), what's introduces here is just practical readability
optimization.

"value" kwarg is treated as applying to a Signal (i.e. accounts for possible
inversion).
2017-04-11 00:12:20 +03:00
Damien George
7df4558df8 esp8266: Remove unused entry in port root pointers. 2017-04-03 16:10:46 +10:00
Damien George
4c307bfba1 all: Move BYTES_PER_WORD definition from ports to py/mpconfig.h
It can still be overwritten by a port in mpconfigport.h but for almost
all cases one can use the provided default.
2017-04-01 11:39:38 +11:00
Damien George
b6c7e4b143 all: Use full path name when including mp-readline/timeutils/netutils.
This follows the pattern of how all other headers are now included, and
makes it explicit where the header file comes from.  This patch also
removes -I options from Makefile's that specify the mp-readline/timeutils/
netutils directories, which are no longer needed.
2017-03-31 22:29:39 +11:00
Damien George
1145dd35f2 esp8266: Update for changes to mp_obj_str_get_data. 2017-03-29 12:56:45 +11:00
Damien George
1d7e3113db esp8266: Update to use size_t for tuple/list accessors. 2017-03-29 12:56:45 +11:00
Damien George
f648e5442b esp8266/modesp: Remove long-obsolete and unused espconn bindings. 2017-03-27 12:05:18 +11:00
Damien George
9c388f66cf esp8266/modesp: Use mp_obj_str_get_str instead of mp_obj_str_get_data. 2017-03-26 19:19:48 +11:00
Damien George
125eae1ba3 py/modbuiltins: For round() builtin use nearbyint instead of round.
The C nearbyint function has exactly the semantics that Python's round()
requires, whereas C's round() requires extra steps to handle rounding of
numbers half way between integers.  So using nearbyint reduces code size
and potentially eliminates any source of errors in the handling of half-way
numbers.

Also, bare-metal implementations of nearbyint can be more efficient than
round, so further code size is saved (and efficiency improved).

nearbyint is provided in the C99 standard so it should be available on all
supported platforms.
2017-03-24 11:00:45 +11:00
Krzysztof Blazewicz
75589272ef all/Makefile: Remove -ansi from GCC flags, its ignored anyway.
The -ansi flag is used for C dialect selection and it is equivalent to -std=c90.
Because it goes right before -std=gnu99 it is ignored as for conflicting flags
GCC always uses the last one.
2017-03-23 15:32:12 +11:00
Damien George
5d05ff1406 esp8266/machine_pin: Fix pin.irq() to work when all args are keywords. 2017-03-21 15:28:31 +11:00
Damien George
b16c35486f esp8266/machine_pin: Fix memset size for zeroing of pin_irq_is_hard.
Thanks to @robert-hh.
2017-03-21 15:13:15 +11:00
Damien George
9ee4641850 esp8266/machine_pin: Make pin.irq arguments positional.
All arguments to pin.irq are converted from keyword-only to positional, and
can still be specified by keyword so it's a backwards compatible change.

The default value for the "trigger" arg is changed from 0 (no trigger)
to rising+falling edge.
2017-03-20 15:20:26 +11:00
Damien George
2507c83b0e esp8266/machine_pin: Add "hard" parameter to pin.irq, soft by default. 2017-03-20 15:20:26 +11:00