Commit Graph

670 Commits

Author SHA1 Message Date
jerryneedell c6a15f76ad esp8266: add neopixel_write - remove neopixel.py (#339)
For ESP8266, remove frozen module neopixel.py and add neopixel_write to mpconfigport.h. Use  [Adafruit_CircuitPython_Neopixel/neopixel.py](https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel) instead.
2017-10-16 18:29:42 -07:00
Dan Halbert e2ce87e250 Merge pull request #336 from tannewt/2.x
esp8266: Correct SPI functionality when write_value is provided.
2017-10-16 18:43:28 -04:00
Scott Shawcroft c216c2876f esp8266: Actually disable pins when reset on reload. 2017-10-16 15:13:09 -07:00
Scott Shawcroft 6c7d35c40c esp8266: Correct SPI functionality when write_value is provided.
It used to introduce extra clocks to the bus rather than changing the
value output.

This fixes SD cards.
2017-10-16 14:54:23 -07:00
Dan Halbert c478c10923 Do not allow a *io object to be used after deinit().
Fixes #278, #277, #276, #275.
2017-10-03 12:07:17 -07:00
Dan Halbert e1eb1802a6 esp8266: restore machine module 2017-09-02 18:54:27 -07:00
Dan Halbert a0d0b27faf Fix issue #207, esp8266 file operations problems (#222)
The frozen module `_boot.py` was not being loaded on restart
because `pyexec_frozen_module()` did not know about the new `.frozen`
pseudo-directory. Updated lower-level routine to look in the right place.
Also made ".frozen" and related values be `#define`s.
2017-09-01 16:12:26 -04:00
Dan Halbert 59faa05a10 Add ".frozen" to end of sys.path, so that internal frozen modules are visible on boot. 2017-08-31 11:38:00 -07:00
Dan Halbert fdb97eda09 Add microcontroller.cpu.temperature, for use as a simple sensor on minimal boards. (#211)
* Add microcontroller.cpu, the sole instance of microcontroller.Processor.
microcontroller.cpu.frequency is the clock frequency, in Hz.
microcontroller.cpu.temperature is the reading from the internal temperature sensor, in Celsius. None if not available.

* Squeeze firmware size by using -finline-limit. Otherwise non-Express builds were slightly too big.

* Update submodules.

* Fix documentation glitches
2017-08-31 13:48:30 -04:00
Dan Halbert c679c80c71 Modernize module and class static dicts; update freetouch 2017-08-27 15:02:50 -04:00
Dan Halbert ef61b5ecb5 Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master.
cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
2017-08-25 22:17:07 -04:00
Ein Terakawa ab2c64cc76 esp8266: Fix UART stop bit constants.
As per the "ESP8266 Technical Reference".
2017-08-21 22:50:07 +10:00
Damien George 4ec803a42a all: Make static dicts use mp_rom_map_elem_t type and MP_ROM_xxx macros. 2017-08-21 21:34:23 +10:00
Javier Candeira 35a1fea90b all: Raise exceptions via mp_raise_XXX
- Changed: ValueError, TypeError, NotImplementedError
  - OSError invocations unchanged, because the corresponding utility
    function takes ints, not strings like the long form invocation.
  - OverflowError, IndexError and RuntimeError etc. not changed for now
    until we decide whether to add new utility functions.
2017-08-13 22:52:33 +10:00
Damien George 7d4a2f773c all: Make use of $(TOP) variable in Makefiles, instead of "..".
$(TOP) is defined in py/mkenv.mk and should be used to refer to the top
level of this repository.
2017-08-11 12:22:19 +10:00
Damien George f9dfd8aa3b minimal,esp8266,pic16bit: Remove unused stmhal include from Makefile. 2017-08-11 12:17:47 +10:00
Scott Shawcroft 6ace744667 esp8266: Introduce `multiterminal` module for managing a secondary
serial connection such as WebREPL.

Fixes #181.
2017-08-07 14:30:11 -07:00
Alexander Steffen 55f33240f3 all: Use the name MicroPython consistently in comments
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Paul Sokolovsky e6bb25317b esp8266: Convert to mp_rom_map_elem_t. 2017-07-30 18:13:01 +03:00
Paul Sokolovsky e3864b5907 esp8266/modesp: Remove unused constants: STA_MODE, etc.
WiFi mode selection happens on the level of individual interfaces.
2017-07-30 12:37:35 +03:00
Girts Folkmanis af1ede930b esp8266: fix "uos" includes
Fix couple places in startup scripts that still had "import uos". This
would cause an exception when _boot.py was executed during startup.
2017-07-22 21:18:37 -04:00
Alex Robbins 4662006119 esp8266/mpconfigport.h: Make socket a weak link
This way it can be overridden by a socket module in Python, as in other
ports.
2017-07-19 09:36:51 +03:00
Damien George 761e4c7ff6 all: Remove trailing spaces, per coding conventions. 2017-07-19 13:12:10 +10:00
Alexander Steffen 299bc62586 all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.

This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.

The rules are as follows.

Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _

In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.

py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-07-18 11:57:39 +10:00
Damien George 48b745cfc8 esp8266/mpconfigport_512k: Use terse error messages to get 512k to fit. 2017-07-04 15:31:36 +10:00
Scott Shawcroft 725d715a1b shared-bindings: Introduce storage.remount() so you can set root as
writeable and prevent USB from editing it.
2017-06-28 16:18:13 -07:00
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
Scott Shawcroft a0058e6712 Introduce a random module that is a subset of CPython's random. It
also initializes in the same way where it takes from a true random
source when available through os.urandom(). After initializing, it
produces deterministic results until the seed is set.

This replaces urandom!

Fixes #139.
2017-06-27 17:37:24 -07:00
Scott Shawcroft 778e975936 Split uos module into os and storage.
os is a subset of CPython's os. storage contains additional
file system mounting functionality based on UNIX's mount
management.

Fixes #140
2017-06-27 15:17:30 -07: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
Scott Shawcroft 30ee7019ca Merge tag 'v1.9.1'
Fixes for stmhal USB mass storage, lwIP bindings and VFS regressions

This release provides an important fix for the USB mass storage device in
the stmhal port by implementing the SCSI SYNCHRONIZE_CACHE command, which
is now require by some Operating Systems.  There are also fixes for the
lwIP bindings to improve non-blocking sockets and error codes.  The VFS has
some regressions fixed including the ability to statvfs the root.

All changes are listed below.

py core:
- modbuiltins: add core-provided version of input() function
- objstr: catch case of negative "maxsplit" arg to str.rsplit()
- persistentcode: allow to compile with complex numbers disabled
- objstr: allow to compile with obj-repr D, and unicode disabled
- modsys: allow to compile with obj-repr D and PY_ATTRTUPLE disabled
- provide mp_decode_uint_skip() to help reduce stack usage
- makeqstrdefs.py: make script run correctly with Python 2.6
- objstringio: if created from immutable object, follow copy on write policy

extmod:
- modlwip: connect: for non-blocking mode, return EINPROGRESS
- modlwip: fix error codes for duplicate calls to connect()
- modlwip: accept: fix error code for non-blocking mode
- vfs: allow to statvfs the root directory
- vfs: allow "buffering" and "encoding" args to VFS's open()
- modframebuf: fix signed/unsigned comparison pendantic warning

lib:
- libm: use isfinite instead of finitef, for C99 compatibility
- utils/interrupt_char: remove support for KBD_EXCEPTION disabled

tests:
- basics/string_rsplit: add tests for negative "maxsplit" argument
- float: convert "sys.exit()" to "raise SystemExit"
- float/builtin_float_minmax: PEP8 fixes
- basics: convert "sys.exit()" to "raise SystemExit"
- convert remaining "sys.exit()" to "raise SystemExit"

unix port:
- convert to use core-provided version of built-in import()
- Makefile: replace references to make with $(MAKE)

windows port:
- convert to use core-provided version of built-in import()

qemu-arm port:
- Makefile: adjust object-file lists to get correct dependencies
- enable micropython.mem_*() functions to allow more tests

stmhal port:
- boards: enable DAC for NUCLEO_F767ZI board
- add support for NUCLEO_F446RE board
- pass USB handler as parameter to allow more than one USB handler
- usb: use local USB handler variable in Start-of-Frame handler
- usb: make state for USB device private to top-level USB driver
- usbdev: for MSC implement SCSI SYNCHRONIZE_CACHE command
- convert from using stmhal's input() to core provided version

cc3200 port:
- convert from using stmhal's input() to core provided version

teensy port:
- convert from using stmhal's input() to core provided version

esp8266 port:
- Makefile: replace references to make with $(MAKE)
- Makefile: add clean-modules target
- convert from using stmhal's input() to core provided version

zephyr port:
- modusocket: getaddrinfo: Fix mp_obj_len() usage
- define MICROPY_PY_SYS_PLATFORM (to "zephyr")
- machine_pin: use native Zephyr types for Zephyr API calls

docs:
- machine.Pin: remove out_value() method
- machine.Pin: add on() and off() methods
- esp8266: consistently replace Pin.high/low methods with .on/off
- esp8266/quickref: polish Pin.on()/off() examples
- network: move confusingly-named cc3200 Server class to its reference
- uos: deconditionalize, remove minor port-specific details
- uos: move cc3200 port legacy VFS mounting functions to its ref doc
- machine: sort machine classes in logical order, not alphabetically
- network: first step to describe standard network class interface

examples:
- embedding: use core-provided KeyboardInterrupt object
2017-06-20 10:56:05 -07: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
Scott Shawcroft c7efd2cae9 shared-bindings: Move enum-like classes out of DigitalInOut into digitalio.
Also, rename Direction.IN to Direction.INPUT and Direction.OUT to Direction.OUTPUT.

This simplifies using them. Prior to the nativeio split this would have led to
clutter in the top-level namespace but having digitalio prevents this.

Fixes #152
2017-06-16 13:47:01 -07: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