From c127ace28a4faeb93ef86743c703a14258137efc Mon Sep 17 00:00:00 2001 From: Javier Candeira Date: Mon, 14 Aug 2017 15:42:25 +1000 Subject: docs/library/machine.RTC.rst: Fix typo. --- docs/library/machine.RTC.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/library/machine.RTC.rst b/docs/library/machine.RTC.rst index 2a53b9146..95fa2b4ce 100644 --- a/docs/library/machine.RTC.rst +++ b/docs/library/machine.RTC.rst @@ -38,7 +38,7 @@ Methods Resets the RTC to the time of January 1, 2015 and starts running it again. -.. method:: RTC.alarm(id, time, /*, repeat=False) +.. method:: RTC.alarm(id, time, \*, repeat=False) Set the RTC alarm. Time might be either a millisecond value to program the alarm to current time + time_in_ms in the future, or a datetimetuple. If the time passed is in -- cgit v1.2.3 From 0aa1d3f4477f56faf3bfc2891be627b86d87a63b Mon Sep 17 00:00:00 2001 From: Alex Robbins Date: Fri, 4 Aug 2017 18:01:35 -0500 Subject: docs/library/ubinascii: Update base64 docs. This clarifies return values and the handling of invalid (e.g. newline) characters. Encoding conforms to RFC 3548, but decoding does not, as it ignores invalid characters in base64 input. Instead, it conforms to MIME handling of base64 (RFC 2045). Note that CPython doesn't document handling of invalid characters in a2b_base64() docs: https://docs.python.org/3/library/binascii.html#binascii.a2b_base64 , so we specify it more explicitly than it, based on CPython's actual behavior (with which MicroPython now compliant). --- docs/library/ubinascii.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/library/ubinascii.rst b/docs/library/ubinascii.rst index 0664d5b09..192d34514 100644 --- a/docs/library/ubinascii.rst +++ b/docs/library/ubinascii.rst @@ -29,8 +29,12 @@ Functions .. function:: a2b_base64(data) - Convert Base64-encoded data to binary representation. Returns bytes string. + Decode base64-encoded data, ignoring invalid characters in the input. + Conforms to `RFC 2045 s.6.8 `_. + Returns a bytes object. .. function:: b2a_base64(data) - Encode binary data in Base64 format. Returns string. + Encode binary data in base64 format, as in `RFC 3548 + `_. Returns the encoded data + followed by a newline character, as a bytes object. -- cgit v1.2.3 From ccaad5327087eb93c3c5329b02ba7c11d95c0487 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 20 Aug 2017 09:04:48 +0300 Subject: docs/library/usocket: Move socket.error to its own section. It's too minor a point to start the module description with it. --- docs/library/usocket.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/library/usocket.rst b/docs/library/usocket.rst index 70d4f49fc..18a8f8fcd 100644 --- a/docs/library/usocket.rst +++ b/docs/library/usocket.rst @@ -9,12 +9,6 @@ This module provides access to the BSD socket interface. -.. admonition:: Difference to CPython - :class: attention - - CPython used to have a ``socket.error`` exception which is now deprecated, - and is an alias of `OSError`. In MicroPython, use `OSError` directly. - .. admonition:: Difference to CPython :class: attention @@ -250,3 +244,13 @@ Methods the length of *buf*. Return value: number of bytes written. + +.. exception:: socket.error + + MicroPython does NOT have this exception. + + .. admonition:: Difference to CPython + :class: attention + + CPython used to have a ``socket.error`` exception which is now deprecated, + and is an alias of `OSError`. In MicroPython, use `OSError` directly. -- cgit v1.2.3 From 3f915704833e2bf8b2d8b977640e8c630c5c5ef7 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 20 Aug 2017 09:49:12 +0300 Subject: docs/library/usocket: Describe complete information on address formats. Describe that the only portable way to deal with addresses is by using getaddrinfo(). Describe that some ports may support tuple addresses using "socket" module (vs "usocket" of native MicroPython). --- docs/library/usocket.rst | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/library/usocket.rst b/docs/library/usocket.rst index 18a8f8fcd..65e24e266 100644 --- a/docs/library/usocket.rst +++ b/docs/library/usocket.rst @@ -21,11 +21,47 @@ This module provides access to the BSD socket interface. Socket address format(s) ------------------------ -The functions below which expect a network address, accept it in the format of -*(ipv4_address, port)*, where *ipv4_address* is a string with dot-notation numeric -IPv4 address, e.g. ``"8.8.8.8"``, and port is integer port number in the range -1-65535. Note the domain names are not accepted as *ipv4_address*, they should be -resolved first using `usocket.getaddrinfo()`. +The native socket address format of the ``usocket`` module is an opaque data type +returned by `getaddrinfo` function, which must be used to resolve textual address +(including numeric addresses):: + + sockaddr = usocket.getaddrinfo('www.micropython.org', 80)[0][-1] + # You must use getaddrinfo() even for numeric addresses + sockaddr = usocket.getaddrinfo('127.0.0.1', 80)[0][-1] + # Now you can use that address + sock.connect(addr) + +Using `getaddrinfo` is the most efficient (both in terms of memory and processing +power) and portable way to work with addresses. + +However, ``socket`` module (note the difference with native MicroPython +``usocket`` module described here) provides CPython-compatible way to specify +addresses using tuples, as described below. Note that depending on a +`MicroPython port`, ``socket`` module can be builtin or need to be +installed from `micropython-lib` (as in the case of `MicroPython Unix port`), +and some ports still accept only numeric addresses in the tuple format, +and require to use `getaddrinfo` function to resolve domain names. + +Summing up: + +* Always use `getaddrinfo` when writing portable applications. +* Tuple addresses described below can be used as a shortcut for + quick hacks and interactive use, if your port supports them. + +Tuple address format for ``socket`` module: + +* IPv4: *(ipv4_address, port)*, where *ipv4_address* is a string with + dot-notation numeric IPv4 address, e.g. ``"8.8.8.8"``, and *port* is and + integer port number in the range 1-65535. Note the domain names are not + accepted as *ipv4_address*, they should be resolved first using + `usocket.getaddrinfo()`. +* IPv6: *(ipv6_address, port, flowinfo, scopeid)*, where *ipv6_address* + is a string with colon-notation numeric IPv6 address, e.g. ``"2001:db8::1"``, + and *port* is an integer port number in the range 1-65535. *flowinfo* + must be 0. *scopeid* is the interface scope identifier for link-local + addresses. Note the domain names are not accepted as *ipv6_address*, + they should be resolved first using `usocket.getaddrinfo()`. Availability + of IPv6 support depends on a `MicroPython port`. Functions --------- -- cgit v1.2.3 From 46583e905771222d7b8395e4c33569e2624f1943 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 20 Aug 2017 10:11:44 +0300 Subject: docs/glossary: Elaborate on possible MicroPython port differences. State that this doc describes generic, "core" MicroPython functionality, any particular port may diverge in both directions, by both omitting some functionality, and adding more, both cases described outside the generic documentation. --- docs/reference/glossary.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/reference/glossary.rst b/docs/reference/glossary.rst index 4099ae951..0f93fff23 100644 --- a/docs/reference/glossary.rst +++ b/docs/reference/glossary.rst @@ -68,7 +68,13 @@ Glossary MicroPython supports different :term:`boards `, RTOSes, and OSes, and can be relatively easily adapted to new systems. MicroPython with support for a particular system is called a - "port" to that system. + "port" to that system. Different ports may have widely different + functionality. This documentation is intended to be a reference + of the generic APIs available across different ports ("MicroPython + core"). Note that some ports may still omit some APIs described + here (e.g. due to resource constraints). Any such differences, + and port-specific extensions beyond MicroPython core functionality, + would be described in the separate port-specific documentation. MicroPython Unix port Unix port is one of the major :term:`MicroPython ports `. -- cgit v1.2.3 From 387a8d26f9b54b37928aa08641b159334b669219 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 20 Aug 2017 10:44:02 +0300 Subject: docs/glossary: Fix typos in micropython-lib paragraph. --- docs/reference/glossary.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/reference/glossary.rst b/docs/reference/glossary.rst index 0f93fff23..98979afa9 100644 --- a/docs/reference/glossary.rst +++ b/docs/reference/glossary.rst @@ -54,10 +54,10 @@ Glossary separate project `micropython-lib `_ which provides implementations for many modules from CPython's - standard library. However, large subset of these modules required + standard library. However, large subset of these modules require POSIX-like environment (Linux, MacOS, Windows may be partially supported), and thus would work or make sense only with MicroPython - Unix port. Some subset of modules however usable for baremetal ports + Unix port. Some subset of modules is however usable for baremetal ports too. Unlike monolithic :term:`CPython` stdlib, micropython-lib modules -- cgit v1.2.3 From 64a3c52f663b09e10d028ba711132e7f69f450ae Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 22 Aug 2017 09:33:31 +0300 Subject: docs: Consistently link to micropython-lib in glossary. --- docs/library/index.rst | 5 ++--- docs/library/sys.rst | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/library/index.rst b/docs/library/index.rst index e884f266e..0789ea43d 100644 --- a/docs/library/index.rst +++ b/docs/library/index.rst @@ -40,8 +40,7 @@ information pertaining to a specific port. Beyond the built-in libraries described in this documentation, many more modules from the Python standard library, as well as further MicroPython -extensions to it, can be found in the `micropython-lib repository -`_. +extensions to it, can be found in `micropython-lib`. Python standard libraries and micro-libraries --------------------------------------------- @@ -54,7 +53,7 @@ e.g. ``ujson`` instead of ``json``. This is to signify that such a module is micro-library, i.e. implements only a subset of CPython module functionality. By naming them differently, a user has a choice to write a Python-level module to extend functionality for better compatibility with CPython (indeed, this is -what done by micropython-lib project mentioned above). +what done by the `micropython-lib` project mentioned above). On some embedded platforms, where it may be cumbersome to add Python-level wrapper modules to achieve naming compatibility with CPython, micro-modules diff --git a/docs/library/sys.rst b/docs/library/sys.rst index 0bec35cc9..d49577306 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -28,7 +28,7 @@ Functions this function takes just exception value instead of exception type, exception value, and traceback object; *file* argument should be positional; further arguments are not supported. CPython-compatible - ``traceback`` module can be found in micropython-lib. + ``traceback`` module can be found in `micropython-lib`. Constants --------- -- cgit v1.2.3 From 1f78e7a43130acfa4bedf16c1007a1b0f37c75c3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 23 Aug 2017 11:46:35 +1000 Subject: docs: Bump version to 1.9.2. --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/conf.py b/docs/conf.py index 2c3423d99..a8df37315 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -98,7 +98,7 @@ copyright = '2014-2017, Damien P. George, Paul Sokolovsky, and contributors' # # We don't follow "The short X.Y version" vs "The full version, including alpha/beta/rc tags" # breakdown, so use the same version identifier for both to avoid confusion. -version = release = '1.9.1' +version = release = '1.9.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- cgit v1.2.3 From b84268d49c1099a193d2fdc92e3831f9eef8b3b3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 23 Aug 2017 17:01:43 +1000 Subject: docs/pyboard/tutorial: Add "timeout=0" to UART in pass-through example. Without this the pass-through will pause for 1 second at each character. --- docs/pyboard/tutorial/pass_through.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/pyboard/tutorial/pass_through.rst b/docs/pyboard/tutorial/pass_through.rst index a94e7363d..012a90764 100644 --- a/docs/pyboard/tutorial/pass_through.rst +++ b/docs/pyboard/tutorial/pass_through.rst @@ -15,4 +15,4 @@ It's as simple as:: if uart.any(): usb.write(uart.read(256)) - pass_through(pyb.USB_VCP(), pyb.UART(1, 9600)) + pass_through(pyb.USB_VCP(), pyb.UART(1, 9600, timeout=0)) -- cgit v1.2.3 From 358a7ba014ef649334b79a8500ae8ac2227c54af Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 28 Aug 2017 13:51:05 +0300 Subject: docs: More xrefs to "MicroPython port" in glossary. --- docs/library/network.rst | 8 ++++---- docs/library/usocket.rst | 4 ++-- docs/reference/glossary.rst | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'docs') diff --git a/docs/library/network.rst b/docs/library/network.rst index de93c0e01..eef23acbe 100644 --- a/docs/library/network.rst +++ b/docs/library/network.rst @@ -39,9 +39,9 @@ Common network adapter interface ================================ This section describes an (implied) abstract base class for all network -interface classes implemented by different ports of MicroPython for -different hardware. This means that MicroPython does not actually -provide `AbstractNIC` class, but any actual NIC class, as described +interface classes implemented by `MicroPython ports ` +for different hardware. This means that MicroPython does not actually +provide ``AbstractNIC`` class, but any actual NIC class, as described in the following sections, implements methods as described here. .. class:: AbstractNIC(id=None, ...) @@ -411,7 +411,7 @@ parameter should be `id`. print(ap.config('channel')) Following are commonly supported parameters (availability of a specific parameter - depends on network technology type, driver, and MicroPython port). + depends on network technology type, driver, and `MicroPython port`). ========= =========== Parameter Description diff --git a/docs/library/usocket.rst b/docs/library/usocket.rst index 65e24e266..dfdcd68bc 100644 --- a/docs/library/usocket.rst +++ b/docs/library/usocket.rst @@ -117,12 +117,12 @@ Constants .. data:: usocket.SOL_* Socket option levels (an argument to `setsockopt()`). The exact - inventory depends on a MicroPython port. + inventory depends on a `MicroPython port`. .. data:: usocket.SO_* Socket options (an argument to `setsockopt()`). The exact - inventory depends on a MicroPython port. + inventory depends on a `MicroPython port`. Constants specific to WiPy: diff --git a/docs/reference/glossary.rst b/docs/reference/glossary.rst index 98979afa9..4cd3d84cc 100644 --- a/docs/reference/glossary.rst +++ b/docs/reference/glossary.rst @@ -56,9 +56,9 @@ Glossary which provides implementations for many modules from CPython's standard library. However, large subset of these modules require POSIX-like environment (Linux, MacOS, Windows may be partially - supported), and thus would work or make sense only with MicroPython - Unix port. Some subset of modules is however usable for baremetal ports - too. + supported), and thus would work or make sense only with + `MicroPython Unix port`. Some subset of modules is however usable + for `baremetal` ports too. Unlike monolithic :term:`CPython` stdlib, micropython-lib modules are intended to be installed individually - either using manual -- cgit v1.2.3 From c5c095690fc8294068e88c71baca92bf757ad91c Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 28 Aug 2017 14:00:16 +0300 Subject: docs/library/network: Fix ref to "socket" module (should be "usocket"). --- docs/library/network.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/library/network.rst b/docs/library/network.rst index eef23acbe..def6bee74 100644 --- a/docs/library/network.rst +++ b/docs/library/network.rst @@ -9,7 +9,7 @@ This module provides network drivers and routing configuration. To use this module, a MicroPython variant/build with network capabilities must be installed. Network drivers for specific hardware are available within this module and are used to configure hardware network interface(s). Network services provided -by configured interfaces are then available for use via the :mod:`socket` +by configured interfaces are then available for use via the :mod:`usocket` module. For example:: -- cgit v1.2.3 From d5336ba13637bdf07721d02c1095304bf32224ee Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 29 Aug 2017 00:08:40 +0300 Subject: docs/machine.Signal: Improve style/grammar and add usage example. --- docs/library/machine.Signal.rst | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/library/machine.Signal.rst b/docs/library/machine.Signal.rst index 486908627..a1a29164b 100644 --- a/docs/library/machine.Signal.rst +++ b/docs/library/machine.Signal.rst @@ -4,17 +4,44 @@ class Signal -- control and sense external I/O devices ====================================================== -The Signal class is a simple extension of Pin class. Unlike Pin, which +The Signal class is a simple extension of the `Pin` class. Unlike Pin, which can be only in "absolute" 0 and 1 states, a Signal can be in "asserted" (on) or "deasserted" (off) states, while being inverted (active-low) or -not. Summing up, it adds logical inversion support to Pin functionality. +not. In other words, it adds logical inversion support to Pin functionality. While this may seem a simple addition, it is exactly what is needed to support wide array of simple digital devices in a way portable across different boards, which is one of the major MicroPython goals. Regardless -whether different users have an active-high or active-low LED, a normally -open or normally closed relay - you can develop single, nicely looking +of whether different users have an active-high or active-low LED, a normally +open or normally closed relay - you can develop a single, nicely looking application which works with each of them, and capture hardware -configuration differences in few lines on the config file of your app. +configuration differences in few lines in the config file of your app. + +Example:: + + from machine import Pin, Signal + + # Suppose you have an active-high LED on pin 0 + led1_pin = Pin(0, Pin.OUT) + # ... and active-low LED on pin 1 + led2_pin = Pin(1, Pin.OUT) + + # Now to light up both of them using Pin class, you'll need to set + # them to different values + led1_pin.value(1) + led2_pin.value(0) + + # Signal class allows to abstract away active-high/active-low + # difference + led1 = Signal(led1_pin, invert=False) + led2 = Signal(led2_pin, invert=True) + + # Now lighting up them looks the same + led1.value(1) + led2.value(1) + + # Even better: + led1.on() + led2.on() Following is the guide when Signal vs Pin should be used: @@ -33,11 +60,11 @@ architecture of MicroPython: Pin offers the lowest overhead, which may be important when bit-banging protocols. But Signal adds additional flexibility on top of Pin, at the cost of minor overhead (much smaller than if you implemented active-high vs active-low device differences in -Python manually!). Also, Pin is low-level object which needs to be +Python manually!). Also, Pin is a low-level object which needs to be implemented for each support board, while Signal is a high-level object which comes for free once Pin is implemented. -If in doubt, give the Signal a try! Once again, it is developed to save +If in doubt, give the Signal a try! Once again, it is offered to save developers from the need to handle unexciting differences like active-low vs active-high signals, and allow other users to share and enjoy your application, instead of being frustrated by the fact that it doesn't -- cgit v1.2.3 From e30ba2f1c7d0cccaf62640aa97de9fd6e82dcab7 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 14 Jun 2017 16:02:57 +1000 Subject: docs/library: Add description of "index" parameter to uos.dupterm(). --- docs/library/uos.rst | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/library/uos.rst b/docs/library/uos.rst index 7c52c1eea..43bf69cc0 100644 --- a/docs/library/uos.rst +++ b/docs/library/uos.rst @@ -89,8 +89,22 @@ Functions Return a bytes object with n random bytes. Whenever possible, it is generated by the hardware random number generator. -.. function:: dupterm(stream_object) +.. function:: dupterm(stream_object, index=0) - Duplicate or switch MicroPython terminal (the REPL) on the passed stream-like - object. The given object must implement the ``readinto()`` and ``write()`` - methods. If ``None`` is passed, previously set redirection is cancelled. + Duplicate or switch the MicroPython terminal (the REPL) on the given stream-like + object. The *stream_object* argument must implement the ``readinto()`` and + ``write()`` methods. The stream should be in non-blocking mode and + ``readinto()`` should return ``None`` if there is no data available for reading. + + After calling this function all terminal output is repeated on this stream, + and any input that is available on the stream is passed on to the terminal input. + + The *index* parameter should be a non-negative integer and specifies which + duplication slot is set. A given port may implement more than one slot (slot 0 + will always be available) and in that case terminal input and output is + duplicated on all the slots that are set. + + If ``None`` is passed as the *stream_object* then duplication is cancelled on + the slot given by *index*. + + The function returns the previous stream-like object in the given slot. -- cgit v1.2.3 From fe6f0354f6c1392dbdcfc7d9331c6a5ef3b3773a Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 29 Aug 2017 16:53:30 +1000 Subject: docs/library/micropython: Fix typo in RST formatting. --- docs/library/micropython.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/library/micropython.rst b/docs/library/micropython.rst index 4ff0b0c15..c13a7391b 100644 --- a/docs/library/micropython.rst +++ b/docs/library/micropython.rst @@ -46,7 +46,7 @@ Functions .. function:: mem_info([verbose]) - Print information about currently used memory. If the *verbose`* argument + Print information about currently used memory. If the *verbose* argument is given then extra information is printed. The information that is printed is implementation dependent, but currently -- cgit v1.2.3 From 4a93801c12898898744131f57d79cf216d0861b3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 6 Sep 2017 14:09:13 +1000 Subject: all: Update Makefiles and others to build with new ports/ dir layout. Also renames "stmhal" to "stm32" in documentation and everywhere else. --- .gitattributes | 11 -- .travis.yml | 46 ++++---- README.md | 34 +++--- docs/reference/constrained.rst | 2 +- examples/pins.py | 2 +- extmod/modframebuf.c | 2 +- mpy-cross/Makefile | 2 +- mpy-cross/main.c | 2 +- ports/bare-arm/Makefile | 2 +- ports/cc3200/Makefile | 2 +- ports/cc3200/application.mk | 4 +- ports/cc3200/bootmgr/bootloader.mk | 2 +- ports/esp8266/Makefile | 2 +- ports/esp8266/esp_mphal.h | 2 +- ports/esp8266/modules/ds18x20.py | 2 +- ports/esp8266/modules/onewire.py | 2 +- ports/esp8266/modules/upip.py | 2 +- ports/esp8266/modules/upip_utarfile.py | 2 +- ports/minimal/Makefile | 2 +- ports/pic16bit/Makefile | 2 +- ports/qemu-arm/Makefile | 2 +- ports/stm32/Makefile | 4 +- ports/stm32/README.md | 6 +- .../boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h | 2 +- .../boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h | 2 +- .../boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h | 2 +- ports/stm32/help.c | 2 +- ports/stm32/modules/lcd160cr.py | 2 +- ports/stm32/modules/lcd160cr_test.py | 2 +- ports/stm32/modules/onewire.py | 2 +- ports/stm32/mpconfigport.h | 4 +- ports/stm32/mphalport.h | 4 +- ports/stm32/pin_defs_stm32.c | 31 +++++ ports/stm32/pin_defs_stm32.h | 131 +++++++++++++++++++++ ports/stm32/pin_defs_stmhal.c | 31 ----- ports/stm32/pin_defs_stmhal.h | 131 --------------------- ports/teensy/Makefile | 8 +- ports/teensy/lcd.c | 2 +- ports/unix/Makefile | 6 +- ports/unix/modules/upip.py | 2 +- ports/unix/modules/upip_utarfile.py | 2 +- ports/windows/.appveyor.yml | 2 +- ports/windows/Makefile | 16 +-- ports/windows/README.md | 4 +- ports/windows/msvc/genhdr.targets | 2 +- ports/windows/msvc/paths.props | 26 ++-- ports/windows/msvc/sources.props | 22 ++-- ports/windows/windows_mphal.h | 2 +- ports/zephyr/Makefile | 2 +- py/mkrules.mk | 2 +- tests/run-tests | 4 +- tools/check_code_size.sh | 2 +- tools/codestats.sh | 44 +++---- 53 files changed, 311 insertions(+), 322 deletions(-) create mode 100644 ports/stm32/pin_defs_stm32.c create mode 100644 ports/stm32/pin_defs_stm32.h delete mode 100644 ports/stm32/pin_defs_stmhal.c delete mode 100644 ports/stm32/pin_defs_stmhal.h (limited to 'docs') diff --git a/.gitattributes b/.gitattributes index 6822bd21c..1ac507944 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,17 +15,6 @@ # These should also not be modified by git. tests/basics/string_cr_conversion.py -text tests/basics/string_crlf_conversion.py -text -stmhal/pybcdc.inf_template -text -stmhal/usbd_* -text -stmhal/boards/*/stm32f4xx_hal_conf.h -text -stmhal/usbdev/** -text -stmhal/usbhost/** -text -cc3200/hal/aes.c -text -cc3200/hal/aes.h -text -cc3200/hal/des.c -text -cc3200/hal/i2s.c -text -cc3200/hal/i2s.h -text -cc3200/version.h -text ports/stm32/pybcdc.inf_template -text ports/stm32/usbd_* -text ports/stm32/boards/*/stm32f4xx_hal_conf.h -text diff --git a/.travis.yml b/.travis.yml index 14d5df0a4..db51567f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,40 +28,40 @@ before_script: script: - make -C mpy-cross - - make -C minimal CROSS=1 build/firmware.bin - - ls -l minimal/build/firmware.bin + - make -C ports/minimal CROSS=1 build/firmware.bin + - ls -l ports/minimal/build/firmware.bin - tools/check_code_size.sh - mkdir -p ${HOME}/persist # Save new firmware for reference, but only if building a main branch, not a pull request - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cp minimal/build/firmware.bin ${HOME}/persist/; fi' - - make -C unix deplibs - - make -C unix - - make -C unix nanbox - - make -C bare-arm - - make -C qemu-arm test - - make -C stmhal - - make -C stmhal BOARD=PYBV11 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1 - - make -C stmhal BOARD=STM32F769DISC - - make -C stmhal BOARD=STM32L476DISC - - make -C teensy - - make -C cc3200 BTARGET=application BTYPE=release - - make -C cc3200 BTARGET=bootloader BTYPE=release - - make -C windows CROSS_COMPILE=i686-w64-mingw32- + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cp ports/minimal/build/firmware.bin ${HOME}/persist/; fi' + - make -C ports/unix deplibs + - make -C ports/unix + - make -C ports/unix nanbox + - make -C ports/bare-arm + - make -C ports/qemu-arm test + - make -C ports/stm32 + - make -C ports/stm32 BOARD=PYBV11 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1 + - make -C ports/stm32 BOARD=STM32F769DISC + - make -C ports/stm32 BOARD=STM32L476DISC + - make -C ports/teensy + - make -C ports/cc3200 BTARGET=application BTYPE=release + - make -C ports/cc3200 BTARGET=bootloader BTYPE=release + - make -C ports/windows CROSS_COMPILE=i686-w64-mingw32- # run tests without coverage info #- (cd tests && MICROPY_CPYTHON3=python3.4 ./run-tests) #- (cd tests && MICROPY_CPYTHON3=python3.4 ./run-tests --emit native) # run tests with coverage info - - make -C unix coverage - - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests) - - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests -d thread) - - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --emit native) - - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --via-mpy -d basics float) + - make -C ports/unix coverage + - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests) + - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -d thread) + - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests --emit native) + - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests --via-mpy -d basics float) # run coveralls coverage analysis (try to, even if some builds/tests failed) - - (cd unix && coveralls --root .. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod) + - (cd ports/unix && coveralls --root ../.. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod) after_failure: - (cd tests && for exp in *.exp; do testbase=$(basename $exp .exp); echo -e "\nFAILURE $testbase"; diff -u $testbase.exp $testbase.out; done) - - (grep "FAIL" qemu-arm/build/console.out) + - (grep "FAIL" ports/qemu-arm/build/console.out) diff --git a/README.md b/README.md index 481cac4e4..ff609dba3 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ Major components in this repository: core library. - mpy-cross/ -- the MicroPython cross-compiler which is used to turn scripts into precompiled bytecode. -- unix/ -- a version of MicroPython that runs on Unix. -- stmhal/ -- a version of MicroPython that runs on the PyBoard and similar +- ports/unix/ -- a version of MicroPython that runs on Unix. +- ports/stm32/ -- a version of MicroPython that runs on the PyBoard and similar STM32 boards (using ST's Cube HAL drivers). -- minimal/ -- a minimal MicroPython port. Start with this if you want +- ports/minimal/ -- a minimal MicroPython port. Start with this if you want to port MicroPython to another microcontroller. - tests/ -- test framework and test scripts. - docs/ -- user documentation in Sphinx reStructuredText format. Rendered @@ -45,13 +45,13 @@ Major components in this repository: to select needed board/port at the bottom left corner). Additional components: -- bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used +- ports/bare-arm/ -- a bare minimum version of MicroPython for ARM MCUs. Used mostly to control code size. -- teensy/ -- a version of MicroPython that runs on the Teensy 3.1 +- ports/teensy/ -- a version of MicroPython that runs on the Teensy 3.1 (preliminary but functional). -- pic16bit/ -- a version of MicroPython for 16-bit PIC microcontrollers. -- cc3200/ -- a version of MicroPython that runs on the CC3200 from TI. -- esp8266/ -- an experimental port for ESP8266 WiFi modules. +- ports/pic16bit/ -- a version of MicroPython for 16-bit PIC microcontrollers. +- ports/cc3200/ -- a version of MicroPython that runs on the CC3200 from TI. +- ports/esp8266/ -- an experimental port for ESP8266 WiFi modules. - extmod/ -- additional (non-core) modules implemented in C. - tools/ -- various tools, including the pyboard.py module. - examples/ -- a few example Python scripts. @@ -72,7 +72,7 @@ Alternatively, fallback implementation based on setjmp/longjmp can be used. To build (see section below for required dependencies): - $ cd unix + $ cd ports/unix $ make axtls $ make @@ -115,7 +115,7 @@ these additional dependencies, first fetch git submodules for them: $ git submodule update --init Use this same command to get the latest versions of dependencies, as -they are updated from time to time. After that, in `unix/` dir, execute: +they are updated from time to time. After that, in `ports/unix/` dir, execute: $ make deplibs @@ -123,25 +123,25 @@ This will build all available dependencies (regardless whether they are used or not). If you intend to build MicroPython with additional options (like cross-compiling), the same set of options should be passed to `make deplibs`. To actually enabled use of dependencies, edit -`unix/mpconfigport.mk` file, which has inline descriptions of the options. +`ports/unix/mpconfigport.mk` file, which has inline descriptions of the options. For example, to build SSL module (required for `upip` tool described above), set `MICROPY_PY_USSL` to 1. -In `unix/mpconfigport.mk`, you can also disable some dependencies enabled +In `ports/unix/mpconfigport.mk`, you can also disable some dependencies enabled by default, like FFI support, which requires libffi development files to be installed. -The STM version ---------------- +The STM32 version +----------------- -The "stmhal" port requires an ARM compiler, arm-none-eabi-gcc, and associated +The "stm32" port requires an ARM compiler, arm-none-eabi-gcc, and associated bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils and arm-none-eabi-gcc packages. Otherwise, try here: https://launchpad.net/gcc-arm-embedded To build: - $ cd stmhal + $ cd ports/stm32 $ make You then need to get your board into DFU mode. On the pyboard, connect the @@ -155,4 +155,4 @@ Then to flash the code via USB DFU to your device: This will use the included `tools/pydfu.py` script. If flashing the firmware does not work it may be because you don't have the correct permissions, and need to use `sudo make deploy`. -See the README.md file in the stmhal/ directory for further details. +See the README.md file in the ports/stm32/ directory for further details. diff --git a/docs/reference/constrained.rst b/docs/reference/constrained.rst index 14286aa26..e7de459bc 100644 --- a/docs/reference/constrained.rst +++ b/docs/reference/constrained.rst @@ -279,7 +279,7 @@ After importing the modules, execute: Then copy and paste all the Q(xxx) lines into a text editor. Check for and remove lines which are obviously invalid. Open the file qstrdefsport.h which -will be found in stmhal (or the equivalent directory for the architecture in +will be found in ports/stm32 (or the equivalent directory for the architecture in use). Copy and paste the corrected lines at the end of the file. Save the file, rebuild and flash the firmware. The outcome can be checked by importing the modules and again issuing: diff --git a/examples/pins.py b/examples/pins.py index ab359f692..aafdb4813 100644 --- a/examples/pins.py +++ b/examples/pins.py @@ -1,5 +1,5 @@ # Print a nice list of pins, their current settings, and available afs. -# Requires pins_af.py from stmhal/build-PYBV10/ directory. +# Requires pins_af.py from ports/stm32/build-PYBV10/ directory. import pyb import pins_af diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index f4e857129..239302295 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -33,7 +33,7 @@ #if MICROPY_PY_FRAMEBUF -#include "stmhal/font_petme128_8x8.h" +#include "ports/stm32/font_petme128_8x8.h" typedef struct _mp_obj_framebuf_t { mp_obj_base_t base; diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile index 5399b5ae7..53ce50c7f 100644 --- a/mpy-cross/Makefile +++ b/mpy-cross/Makefile @@ -65,7 +65,7 @@ SRC_C = \ # Add fmode when compiling with mingw gcc COMPILER_TARGET := $(shell $(CC) -dumpmachine) ifneq (,$(findstring mingw,$(COMPILER_TARGET))) - SRC_C += windows/fmode.c + SRC_C += ports/windows/fmode.c endif OBJ = $(PY_O) diff --git a/mpy-cross/main.c b/mpy-cross/main.c index ca8d9633f..225bc4309 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -36,7 +36,7 @@ #include "py/gc.h" #include "py/stackctrl.h" #ifdef _WIN32 -#include "windows/fmode.h" +#include "ports/windows/fmode.h" #endif // Command line options, with their defaults diff --git a/ports/bare-arm/Makefile b/ports/bare-arm/Makefile index 90c13de11..0fcd5d027 100644 --- a/ports/bare-arm/Makefile +++ b/ports/bare-arm/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h diff --git a/ports/cc3200/Makefile b/ports/cc3200/Makefile index 4c8b0b832..81531b108 100644 --- a/ports/cc3200/Makefile +++ b/ports/cc3200/Makefile @@ -14,7 +14,7 @@ PORT ?= /dev/ttyUSB1 # If the build directory is not given, make it reflect the board name. BUILD ?= build/$(BOARD)/$(BTYPE) -include ../py/mkenv.mk +include ../../py/mkenv.mk -include ../../localconfig.mk CROSS_COMPILE ?= arm-none-eabi- diff --git a/ports/cc3200/application.mk b/ports/cc3200/application.mk index 64891a2e7..19abe6616 100644 --- a/ports/cc3200/application.mk +++ b/ports/cc3200/application.mk @@ -18,7 +18,7 @@ APP_INC += -Iutil APP_INC += -Ibootmgr APP_INC += -I$(BUILD) APP_INC += -I$(BUILD)/genhdr -APP_INC += -I$(TOP)/stmhal +APP_INC += -I$(TOP)/ports/stm32 APP_CPPDEFINES = -Dgcc -DTARGET_IS_CC3200 -DSL_FULL -DUSE_FREERTOS @@ -151,7 +151,7 @@ APP_LIB_SRC_C = $(addprefix lib/,\ utils/sys_stdio_mphal.c \ ) -APP_STM_SRC_C = $(addprefix stmhal/,\ +APP_STM_SRC_C = $(addprefix ports/stm32/,\ bufhelper.c \ irq.c \ ) diff --git a/ports/cc3200/bootmgr/bootloader.mk b/ports/cc3200/bootmgr/bootloader.mk index b8aa9082c..44f1b7f42 100644 --- a/ports/cc3200/bootmgr/bootloader.mk +++ b/ports/cc3200/bootmgr/bootloader.mk @@ -98,7 +98,7 @@ $(BUILD)/misc/%.o: CFLAGS += -Os $(BUILD)/simplelink/%.o: CFLAGS += -Os $(BUILD)/drivers/cc3100/%.o: CFLAGS += -Os $(BUILD)/py/%.o: CFLAGS += -Os -$(BUILD)/stmhal/%.o: CFLAGS += -Os +$(BUILD)/ports/stm32/%.o: CFLAGS += -Os else $(error Invalid BTYPE specified) endif diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index fce11a7d4..70b4ce35c 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h diff --git a/ports/esp8266/esp_mphal.h b/ports/esp8266/esp_mphal.h index 913bd70dc..194e56f64 100644 --- a/ports/esp8266/esp_mphal.h +++ b/ports/esp8266/esp_mphal.h @@ -72,7 +72,7 @@ void ets_event_poll(void); // C-level pin HAL #include "etshal.h" #include "gpio.h" -#include "esp8266/modmachine.h" +#include "modmachine.h" #define MP_HAL_PIN_FMT "%u" #define mp_hal_pin_obj_t uint32_t #define mp_hal_get_pin_obj(o) mp_obj_get_pin(o) diff --git a/ports/esp8266/modules/ds18x20.py b/ports/esp8266/modules/ds18x20.py index faae59d90..1ec92d1c9 120000 --- a/ports/esp8266/modules/ds18x20.py +++ b/ports/esp8266/modules/ds18x20.py @@ -1 +1 @@ -../../drivers/onewire/ds18x20.py \ No newline at end of file +../../../drivers/onewire/ds18x20.py \ No newline at end of file diff --git a/ports/esp8266/modules/onewire.py b/ports/esp8266/modules/onewire.py index f6ec745e8..33f30e84f 120000 --- a/ports/esp8266/modules/onewire.py +++ b/ports/esp8266/modules/onewire.py @@ -1 +1 @@ -../../drivers/onewire/onewire.py \ No newline at end of file +../../../drivers/onewire/onewire.py \ No newline at end of file diff --git a/ports/esp8266/modules/upip.py b/ports/esp8266/modules/upip.py index 20d52a4ab..130eb6901 120000 --- a/ports/esp8266/modules/upip.py +++ b/ports/esp8266/modules/upip.py @@ -1 +1 @@ -../../tools/upip.py \ No newline at end of file +../../../tools/upip.py \ No newline at end of file diff --git a/ports/esp8266/modules/upip_utarfile.py b/ports/esp8266/modules/upip_utarfile.py index 149886291..d9653d6a6 120000 --- a/ports/esp8266/modules/upip_utarfile.py +++ b/ports/esp8266/modules/upip_utarfile.py @@ -1 +1 @@ -../../tools/upip_utarfile.py \ No newline at end of file +../../../tools/upip_utarfile.py \ No newline at end of file diff --git a/ports/minimal/Makefile b/ports/minimal/Makefile index c95d639af..ae295d655 100644 --- a/ports/minimal/Makefile +++ b/ports/minimal/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk CROSS = 0 diff --git a/ports/pic16bit/Makefile b/ports/pic16bit/Makefile index ebf4fc2e8..970e75d1f 100644 --- a/ports/pic16bit/Makefile +++ b/ports/pic16bit/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h diff --git a/ports/qemu-arm/Makefile b/ports/qemu-arm/Makefile index 71403cb5e..39e13853f 100644 --- a/ports/qemu-arm/Makefile +++ b/ports/qemu-arm/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk -include mpconfigport.mk # qstr definitions (must come before including py.mk) diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile index 58a0a7c7a..913f0913e 100644 --- a/ports/stm32/Makefile +++ b/ports/stm32/Makefile @@ -8,7 +8,7 @@ endif # If the build directory is not given, make it reflect the board name. BUILD ?= build-$(BOARD) -include ../py/mkenv.mk +include ../../py/mkenv.mk -include mpconfigport.mk include boards/$(BOARD)/mpconfigboard.mk @@ -206,7 +206,7 @@ SRC_C = \ timer.c \ led.c \ pin.c \ - pin_defs_stmhal.c \ + pin_defs_stm32.c \ pin_named_pins.c \ bufhelper.c \ dma.c \ diff --git a/ports/stm32/README.md b/ports/stm32/README.md index 32b6d4176..bb184e8db 100644 --- a/ports/stm32/README.md +++ b/ports/stm32/README.md @@ -24,7 +24,7 @@ bytecode. The cross-compiler is built and run on the host machine, using: $ make -C mpy-cross ``` This command should be executed from the root directory of this repository. -All other commands below should be executed from the stmhal/ directory. +All other commands below should be executed from the ports/stm32/ directory. An ARM compiler is required for the build, along with the associated binary utilities. The default compiler is `arm-none-eabi-gcc`, which is available for @@ -71,7 +71,7 @@ Or using `dfu-util` directly: ST Discovery or Nucleo boards have a builtin programmer called ST-LINK. With these boards and using Linux or OS X, you have the option to upload the -`stmhal` firmware using the `st-flash` utility from the +`stm32` firmware using the `st-flash` utility from the [stlink](https://github.com/texane/stlink) project. To do so, connect the board with a mini USB cable to its ST-LINK USB port and then use the make target `deploy-stlink`. For example, if you have the STM32F4DISCOVERY board, you can @@ -101,7 +101,7 @@ a mini USB cable to its ST-LINK USB port and then use the make target $ make BOARD=STM32F4DISC deploy-openocd The `openocd` program, which writes the firmware to the target board's flash, -is configured via the file `stmhal/boards/openocd_stm32f4.cfg`. This +is configured via the file `ports/stm32/boards/openocd_stm32f4.cfg`. This configuration should work for all boards based on a STM32F4xx MCU with a ST-LINKv2 interface. You can override the path to this configuration by setting `OPENOCD_CONFIG` in your Makefile or on the command line. diff --git a/ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h b/ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h index c20421f0f..a1fd2e083 100644 --- a/ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h +++ b/ports/stm32/boards/NUCLEO_F401RE/stm32f4xx_hal_conf.h @@ -46,7 +46,7 @@ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ -// This board doesn't really have USB, but the stmhal codebase doesn't build +// This board doesn't really have USB, but the stm32 codebase doesn't build // without some USB defined, so we leave this on for now. #define USE_USB_FS diff --git a/ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h b/ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h index e16fba155..0c424888f 100644 --- a/ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h +++ b/ports/stm32/boards/NUCLEO_F411RE/stm32f4xx_hal_conf.h @@ -46,7 +46,7 @@ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ -// This board doesn't really have USB, but the stmhal codebase doesn't build +// This board doesn't really have USB, but the stm32 codebase doesn't build // without some USB defined, so we leave this on for now. #define USE_USB_FS diff --git a/ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h b/ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h index 3d0ce926b..487ca009f 100644 --- a/ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h +++ b/ports/stm32/boards/NUCLEO_F446RE/stm32f4xx_hal_conf.h @@ -46,7 +46,7 @@ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ -// This board doesn't really have USB, but the stmhal codebase doesn't build +// This board doesn't really have USB, but the stm32 codebase doesn't build // without some USB defined, so we leave this on for now. #define USE_USB_FS diff --git a/ports/stm32/help.c b/ports/stm32/help.c index 87b2af526..ea0b6921b 100644 --- a/ports/stm32/help.c +++ b/ports/stm32/help.c @@ -26,7 +26,7 @@ #include "py/builtin.h" -const char *stmhal_help_text = +const char *stm32_help_text = "Welcome to MicroPython!\n" "\n" "For online help please visit http://micropython.org/help/.\n" diff --git a/ports/stm32/modules/lcd160cr.py b/ports/stm32/modules/lcd160cr.py index c0e180714..9e63f1d23 120000 --- a/ports/stm32/modules/lcd160cr.py +++ b/ports/stm32/modules/lcd160cr.py @@ -1 +1 @@ -../../drivers/display/lcd160cr.py \ No newline at end of file +../../../drivers/display/lcd160cr.py \ No newline at end of file diff --git a/ports/stm32/modules/lcd160cr_test.py b/ports/stm32/modules/lcd160cr_test.py index 56f091351..5f5bcc128 120000 --- a/ports/stm32/modules/lcd160cr_test.py +++ b/ports/stm32/modules/lcd160cr_test.py @@ -1 +1 @@ -../../drivers/display/lcd160cr_test.py \ No newline at end of file +../../../drivers/display/lcd160cr_test.py \ No newline at end of file diff --git a/ports/stm32/modules/onewire.py b/ports/stm32/modules/onewire.py index f6ec745e8..33f30e84f 120000 --- a/ports/stm32/modules/onewire.py +++ b/ports/stm32/modules/onewire.py @@ -1 +1 @@ -../../drivers/onewire/onewire.py \ No newline at end of file +../../../drivers/onewire/onewire.py \ No newline at end of file diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index 326aa2c20..21142c17b 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -92,7 +92,7 @@ #define MICROPY_PY_BUILTINS_INPUT (1) #define MICROPY_PY_BUILTINS_POW3 (1) #define MICROPY_PY_BUILTINS_HELP (1) -#define MICROPY_PY_BUILTINS_HELP_TEXT stmhal_help_text +#define MICROPY_PY_BUILTINS_HELP_TEXT stm32_help_text #define MICROPY_PY_BUILTINS_HELP_MODULES (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) @@ -345,4 +345,4 @@ static inline mp_uint_t disable_irq(void) { // We need to provide a declaration/definition of alloca() #include -#define MICROPY_PIN_DEFS_PORT_H "pin_defs_stmhal.h" +#define MICROPY_PIN_DEFS_PORT_H "pin_defs_stm32.h" diff --git a/ports/stm32/mphalport.h b/ports/stm32/mphalport.h index 8dd95c470..939df0b3d 100644 --- a/ports/stm32/mphalport.h +++ b/ports/stm32/mphalport.h @@ -27,7 +27,7 @@ void mp_hal_set_interrupt_char(int c); // -1 to disable // timing functions -#include "stmhal/irq.h" +#include "irq.h" #define mp_hal_quiet_timing_enter() raise_irq_pri(1) #define mp_hal_quiet_timing_exit(irq_state) restore_irq_pri(irq_state) @@ -44,7 +44,7 @@ static inline mp_uint_t mp_hal_ticks_cpu(void) { // C-level pin HAL -#include "stmhal/pin.h" +#include "pin.h" #define MP_HAL_PIN_FMT "%q" #define MP_HAL_PIN_MODE_INPUT (0) diff --git a/ports/stm32/pin_defs_stm32.c b/ports/stm32/pin_defs_stm32.c new file mode 100644 index 000000000..0aef5f95f --- /dev/null +++ b/ports/stm32/pin_defs_stm32.c @@ -0,0 +1,31 @@ +#include "py/obj.h" +#include "pin.h" + +// Returns the pin mode. This value returned by this macro should be one of: +// GPIO_MODE_INPUT, GPIO_MODE_OUTPUT_PP, GPIO_MODE_OUTPUT_OD, +// GPIO_MODE_AF_PP, GPIO_MODE_AF_OD, or GPIO_MODE_ANALOG. + +uint32_t pin_get_mode(const pin_obj_t *pin) { + GPIO_TypeDef *gpio = pin->gpio; + uint32_t mode = (gpio->MODER >> (pin->pin * 2)) & 3; + if (mode != GPIO_MODE_ANALOG) { + if (gpio->OTYPER & pin->pin_mask) { + mode |= 1 << 4; + } + } + return mode; +} + +// Returns the pin pullup/pulldown. The value returned by this macro should +// be one of GPIO_NOPULL, GPIO_PULLUP, or GPIO_PULLDOWN. + +uint32_t pin_get_pull(const pin_obj_t *pin) { + return (pin->gpio->PUPDR >> (pin->pin * 2)) & 3; +} + +// Returns the af (alternate function) index currently set for a pin. + +uint32_t pin_get_af(const pin_obj_t *pin) { + return (pin->gpio->AFR[pin->pin >> 3] >> ((pin->pin & 7) * 4)) & 0xf; +} + diff --git a/ports/stm32/pin_defs_stm32.h b/ports/stm32/pin_defs_stm32.h new file mode 100644 index 000000000..c5b286283 --- /dev/null +++ b/ports/stm32/pin_defs_stm32.h @@ -0,0 +1,131 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// This file contains pin definitions that are specific to the stm32 port. +// This file should only ever be #included by pin.h and not directly. + +enum { + PORT_A, + PORT_B, + PORT_C, + PORT_D, + PORT_E, + PORT_F, + PORT_G, + PORT_H, + PORT_I, + PORT_J, + PORT_K, +}; + +enum { + AF_FN_TIM, + AF_FN_I2C, + AF_FN_USART, + AF_FN_UART = AF_FN_USART, + AF_FN_SPI, + AF_FN_I2S, + AF_FN_SDMMC, +}; + +enum { + AF_PIN_TYPE_TIM_CH1 = 0, + AF_PIN_TYPE_TIM_CH2, + AF_PIN_TYPE_TIM_CH3, + AF_PIN_TYPE_TIM_CH4, + AF_PIN_TYPE_TIM_CH1N, + AF_PIN_TYPE_TIM_CH2N, + AF_PIN_TYPE_TIM_CH3N, + AF_PIN_TYPE_TIM_CH1_ETR, + AF_PIN_TYPE_TIM_ETR, + AF_PIN_TYPE_TIM_BKIN, + + AF_PIN_TYPE_I2C_SDA = 0, + AF_PIN_TYPE_I2C_SCL, + + AF_PIN_TYPE_USART_TX = 0, + AF_PIN_TYPE_USART_RX, + AF_PIN_TYPE_USART_CTS, + AF_PIN_TYPE_USART_RTS, + AF_PIN_TYPE_USART_CK, + AF_PIN_TYPE_UART_TX = AF_PIN_TYPE_USART_TX, + AF_PIN_TYPE_UART_RX = AF_PIN_TYPE_USART_RX, + AF_PIN_TYPE_UART_CTS = AF_PIN_TYPE_USART_CTS, + AF_PIN_TYPE_UART_RTS = AF_PIN_TYPE_USART_RTS, + + AF_PIN_TYPE_SPI_MOSI = 0, + AF_PIN_TYPE_SPI_MISO, + AF_PIN_TYPE_SPI_SCK, + AF_PIN_TYPE_SPI_NSS, + + AF_PIN_TYPE_I2S_CK = 0, + AF_PIN_TYPE_I2S_MCK, + AF_PIN_TYPE_I2S_SD, + AF_PIN_TYPE_I2S_WS, + AF_PIN_TYPE_I2S_EXTSD, + + AF_PIN_TYPE_SDMMC_CK = 0, + AF_PIN_TYPE_SDMMC_CMD, + AF_PIN_TYPE_SDMMC_D0, + AF_PIN_TYPE_SDMMC_D1, + AF_PIN_TYPE_SDMMC_D2, + AF_PIN_TYPE_SDMMC_D3, +}; + +// The HAL uses a slightly different naming than we chose, so we provide +// some #defines to massage things. Also I2S and SPI share the same +// peripheral. + +#define GPIO_AF5_I2S2 GPIO_AF5_SPI2 +#define GPIO_AF5_I2S3 GPIO_AF5_I2S3ext +#define GPIO_AF6_I2S2 GPIO_AF6_I2S2ext +#define GPIO_AF6_I2S3 GPIO_AF6_SPI3 +#define GPIO_AF7_I2S2 GPIO_AF7_SPI2 +#define GPIO_AF7_I2S3 GPIO_AF7_I2S3ext + +#define I2S2 SPI2 +#define I2S3 SPI3 + +enum { + PIN_ADC1 = (1 << 0), + PIN_ADC2 = (1 << 1), + PIN_ADC3 = (1 << 2), +}; + +// Note that SPI and I2S are really the same peripheral as far as the HAL +// is concerned, so there is no I2S_TypeDef. +// We use void* for SDMMC because not all MCUs have the SDMMC_TypeDef type. +#define PIN_DEFS_PORT_AF_UNION \ + TIM_TypeDef *TIM; \ + I2C_TypeDef *I2C; \ + USART_TypeDef *USART; \ + USART_TypeDef *UART; \ + SPI_TypeDef *SPI;\ + SPI_TypeDef *I2S; \ + void *SDMMC; \ + +typedef GPIO_TypeDef pin_gpio_t; + diff --git a/ports/stm32/pin_defs_stmhal.c b/ports/stm32/pin_defs_stmhal.c deleted file mode 100644 index 0aef5f95f..000000000 --- a/ports/stm32/pin_defs_stmhal.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "py/obj.h" -#include "pin.h" - -// Returns the pin mode. This value returned by this macro should be one of: -// GPIO_MODE_INPUT, GPIO_MODE_OUTPUT_PP, GPIO_MODE_OUTPUT_OD, -// GPIO_MODE_AF_PP, GPIO_MODE_AF_OD, or GPIO_MODE_ANALOG. - -uint32_t pin_get_mode(const pin_obj_t *pin) { - GPIO_TypeDef *gpio = pin->gpio; - uint32_t mode = (gpio->MODER >> (pin->pin * 2)) & 3; - if (mode != GPIO_MODE_ANALOG) { - if (gpio->OTYPER & pin->pin_mask) { - mode |= 1 << 4; - } - } - return mode; -} - -// Returns the pin pullup/pulldown. The value returned by this macro should -// be one of GPIO_NOPULL, GPIO_PULLUP, or GPIO_PULLDOWN. - -uint32_t pin_get_pull(const pin_obj_t *pin) { - return (pin->gpio->PUPDR >> (pin->pin * 2)) & 3; -} - -// Returns the af (alternate function) index currently set for a pin. - -uint32_t pin_get_af(const pin_obj_t *pin) { - return (pin->gpio->AFR[pin->pin >> 3] >> ((pin->pin & 7) * 4)) & 0xf; -} - diff --git a/ports/stm32/pin_defs_stmhal.h b/ports/stm32/pin_defs_stmhal.h deleted file mode 100644 index 6cf3b1b83..000000000 --- a/ports/stm32/pin_defs_stmhal.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// This file contains pin definitions that are specific to the stmhal port. -// This file should only ever be #included by pin.h and not directly. - -enum { - PORT_A, - PORT_B, - PORT_C, - PORT_D, - PORT_E, - PORT_F, - PORT_G, - PORT_H, - PORT_I, - PORT_J, - PORT_K, -}; - -enum { - AF_FN_TIM, - AF_FN_I2C, - AF_FN_USART, - AF_FN_UART = AF_FN_USART, - AF_FN_SPI, - AF_FN_I2S, - AF_FN_SDMMC, -}; - -enum { - AF_PIN_TYPE_TIM_CH1 = 0, - AF_PIN_TYPE_TIM_CH2, - AF_PIN_TYPE_TIM_CH3, - AF_PIN_TYPE_TIM_CH4, - AF_PIN_TYPE_TIM_CH1N, - AF_PIN_TYPE_TIM_CH2N, - AF_PIN_TYPE_TIM_CH3N, - AF_PIN_TYPE_TIM_CH1_ETR, - AF_PIN_TYPE_TIM_ETR, - AF_PIN_TYPE_TIM_BKIN, - - AF_PIN_TYPE_I2C_SDA = 0, - AF_PIN_TYPE_I2C_SCL, - - AF_PIN_TYPE_USART_TX = 0, - AF_PIN_TYPE_USART_RX, - AF_PIN_TYPE_USART_CTS, - AF_PIN_TYPE_USART_RTS, - AF_PIN_TYPE_USART_CK, - AF_PIN_TYPE_UART_TX = AF_PIN_TYPE_USART_TX, - AF_PIN_TYPE_UART_RX = AF_PIN_TYPE_USART_RX, - AF_PIN_TYPE_UART_CTS = AF_PIN_TYPE_USART_CTS, - AF_PIN_TYPE_UART_RTS = AF_PIN_TYPE_USART_RTS, - - AF_PIN_TYPE_SPI_MOSI = 0, - AF_PIN_TYPE_SPI_MISO, - AF_PIN_TYPE_SPI_SCK, - AF_PIN_TYPE_SPI_NSS, - - AF_PIN_TYPE_I2S_CK = 0, - AF_PIN_TYPE_I2S_MCK, - AF_PIN_TYPE_I2S_SD, - AF_PIN_TYPE_I2S_WS, - AF_PIN_TYPE_I2S_EXTSD, - - AF_PIN_TYPE_SDMMC_CK = 0, - AF_PIN_TYPE_SDMMC_CMD, - AF_PIN_TYPE_SDMMC_D0, - AF_PIN_TYPE_SDMMC_D1, - AF_PIN_TYPE_SDMMC_D2, - AF_PIN_TYPE_SDMMC_D3, -}; - -// The HAL uses a slightly different naming than we chose, so we provide -// some #defines to massage things. Also I2S and SPI share the same -// peripheral. - -#define GPIO_AF5_I2S2 GPIO_AF5_SPI2 -#define GPIO_AF5_I2S3 GPIO_AF5_I2S3ext -#define GPIO_AF6_I2S2 GPIO_AF6_I2S2ext -#define GPIO_AF6_I2S3 GPIO_AF6_SPI3 -#define GPIO_AF7_I2S2 GPIO_AF7_SPI2 -#define GPIO_AF7_I2S3 GPIO_AF7_I2S3ext - -#define I2S2 SPI2 -#define I2S3 SPI3 - -enum { - PIN_ADC1 = (1 << 0), - PIN_ADC2 = (1 << 1), - PIN_ADC3 = (1 << 2), -}; - -// Note that SPI and I2S are really the same peripheral as far as the HAL -// is concerned, so there is no I2S_TypeDef. -// We use void* for SDMMC because not all MCUs have the SDMMC_TypeDef type. -#define PIN_DEFS_PORT_AF_UNION \ - TIM_TypeDef *TIM; \ - I2C_TypeDef *I2C; \ - USART_TypeDef *USART; \ - USART_TypeDef *UART; \ - SPI_TypeDef *SPI;\ - SPI_TypeDef *I2S; \ - void *SDMMC; \ - -typedef GPIO_TypeDef pin_gpio_t; - diff --git a/ports/teensy/Makefile b/ports/teensy/Makefile index 944e281a4..08ecf0f91 100644 --- a/ports/teensy/Makefile +++ b/ports/teensy/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h $(BUILD)/pins_qstr.h @@ -31,7 +31,7 @@ CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -mfloat INC += -I. INC += -I$(TOP) -INC += -I$(TOP)/stmhal +INC += -I$(TOP)/ports/stm32 INC += -I$(BUILD) INC += -Icore @@ -91,14 +91,14 @@ SRC_C = \ uart.c \ usb.c \ -STM_SRC_C = $(addprefix stmhal/,\ +STM_SRC_C = $(addprefix ports/stm32/,\ gccollect.c \ irq.c \ pin.c \ pin_named_pins.c \ ) -STM_SRC_S = $(addprefix stmhal/,\ +STM_SRC_S = $(addprefix ports/stm32/,\ gchelper.s \ ) diff --git a/ports/teensy/lcd.c b/ports/teensy/lcd.c index e79b7d5ac..e5d6115d7 100644 --- a/ports/teensy/lcd.c +++ b/ports/teensy/lcd.c @@ -1,5 +1,5 @@ #include "py/obj.h" -#include "../stmhal/lcd.h" +#include "../stm32/lcd.h" void lcd_init(void) { } diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 08bd4db30..1a1ea01f7 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -1,5 +1,5 @@ -include mpconfigport.mk -include ../py/mkenv.mk +include ../../py/mkenv.mk FROZEN_DIR = scripts FROZEN_MPY_DIR = modules @@ -188,7 +188,7 @@ include $(TOP)/py/mkrules.mk .PHONY: test test: $(PROG) $(TOP)/tests/run-tests - $(eval DIRNAME=$(notdir $(CURDIR))) + $(eval DIRNAME=ports/$(notdir $(CURDIR))) cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests # install micropython in /usr/local/bin @@ -253,7 +253,7 @@ coverage: BUILD=build-coverage PROG=micropython_coverage coverage_test: coverage - $(eval DIRNAME=$(notdir $(CURDIR))) + $(eval DIRNAME=ports/$(notdir $(CURDIR))) cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests -d thread cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --emit native diff --git a/ports/unix/modules/upip.py b/ports/unix/modules/upip.py index 20d52a4ab..130eb6901 120000 --- a/ports/unix/modules/upip.py +++ b/ports/unix/modules/upip.py @@ -1 +1 @@ -../../tools/upip.py \ No newline at end of file +../../../tools/upip.py \ No newline at end of file diff --git a/ports/unix/modules/upip_utarfile.py b/ports/unix/modules/upip_utarfile.py index 149886291..d9653d6a6 120000 --- a/ports/unix/modules/upip_utarfile.py +++ b/ports/unix/modules/upip_utarfile.py @@ -1 +1 @@ -../../tools/upip_utarfile.py \ No newline at end of file +../../../tools/upip_utarfile.py \ No newline at end of file diff --git a/ports/windows/.appveyor.yml b/ports/windows/.appveyor.yml index 84060a116..a82cf5adc 100644 --- a/ports/windows/.appveyor.yml +++ b/ports/windows/.appveyor.yml @@ -15,7 +15,7 @@ platform: - x64 build: - project: windows/micropython.vcxproj + project: ports/windows/micropython.vcxproj verbosity: normal test_script: diff --git a/ports/windows/Makefile b/ports/windows/Makefile index a39d34826..b6433300f 100644 --- a/ports/windows/Makefile +++ b/ports/windows/Makefile @@ -1,4 +1,4 @@ -include ../py/mkenv.mk +include ../../py/mkenv.mk -include mpconfigport.mk # define main target @@ -28,13 +28,13 @@ endif # source files SRC_C = \ - unix/main.c \ - unix/file.c \ - unix/input.c \ - unix/modos.c \ - unix/modmachine.c \ - unix/modtime.c \ - unix/gccollect.c \ + ports/unix/main.c \ + ports/unix/file.c \ + ports/unix/input.c \ + ports/unix/modos.c \ + ports/unix/modmachine.c \ + ports/unix/modtime.c \ + ports/unix/gccollect.c \ windows_mphal.c \ realpath.c \ init.c \ diff --git a/ports/windows/README.md b/ports/windows/README.md index 6d3249903..f1bd40551 100644 --- a/ports/windows/README.md +++ b/ports/windows/README.md @@ -50,8 +50,8 @@ __Stack usage__ The msvc compiler is quite stack-hungry which might result in a "maximum recursion depth exceeded" RuntimeError for code with lots of nested function calls. There are several ways to deal with this: -- increase the threshold used for detection by altering the argument to `mp_stack_set_limit` in `unix/main.c` -- disable detection all together by setting `MICROPY_STACK_CHECK` to "0" in `windows/mpconfigport.h` +- increase the threshold used for detection by altering the argument to `mp_stack_set_limit` in `ports/unix/main.c` +- disable detection all together by setting `MICROPY_STACK_CHECK` to "0" in `ports/windows/mpconfigport.h` - disable the /GL compiler flag by setting `WholeProgramOptimization` to "false" See [issue 2927](https://github.com/micropython/micropython/issues/2927) for more information. diff --git a/ports/windows/msvc/genhdr.targets b/ports/windows/msvc/genhdr.targets index cac3e3ddc..ee030c906 100644 --- a/ports/windows/msvc/genhdr.targets +++ b/ports/windows/msvc/genhdr.targets @@ -10,7 +10,7 @@ $(PyBuildDir)genhdr\ $(PyBaseDir)py\ - $(PyBaseDir)unix\qstrdefsport.h + $(PyBaseDir)ports\unix\qstrdefsport.h $(PySrcDir)qstrdefs.h $(DestDir)qstrdefscollected.h $(DestDir)qstrdefs.generated.h diff --git a/ports/windows/msvc/paths.props b/ports/windows/msvc/paths.props index 716698243..db3af4c0f 100644 --- a/ports/windows/msvc/paths.props +++ b/ports/windows/msvc/paths.props @@ -3,28 +3,28 @@ True - - $([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..\..`))\ - $(PyBaseDir)windows\ + $([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..\..\..`))\ + $(PyBaseDir)ports\windows\ $(PyWinDir)build\ diff --git a/ports/windows/msvc/sources.props b/ports/windows/msvc/sources.props index a97686cdc..b85295ebc 100644 --- a/ports/windows/msvc/sources.props +++ b/ports/windows/msvc/sources.props @@ -3,16 +3,16 @@ - - + + - - - - - - - + + + + + + + @@ -31,7 +31,7 @@ - - + + diff --git a/ports/windows/windows_mphal.h b/ports/windows/windows_mphal.h index 5a93d4e18..2b7aab44a 100644 --- a/ports/windows/windows_mphal.h +++ b/ports/windows/windows_mphal.h @@ -25,7 +25,7 @@ */ #include "sleep.h" -#include "unix/mphalport.h" +#include "ports/unix/mphalport.h" #define MICROPY_HAL_HAS_VT100 (0) diff --git a/ports/zephyr/Makefile b/ports/zephyr/Makefile index 5840cc47e..8b7cb76c3 100644 --- a/ports/zephyr/Makefile +++ b/ports/zephyr/Makefile @@ -26,7 +26,7 @@ ifneq ($(MAKECMDGOALS), clean) include $(Z_EXPORTS) endif -include ../py/mkenv.mk +include ../../py/mkenv.mk include $(TOP)/py/py.mk INC += -I. diff --git a/py/mkrules.mk b/py/mkrules.mk index bf6ad2941..13545eb6f 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -103,7 +103,7 @@ endif ifneq ($(FROZEN_MPY_DIR),) # to build the MicroPython cross compiler -$(TOP)/mpy-cross/mpy-cross: $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/windows/fmode.c +$(TOP)/mpy-cross/mpy-cross: $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/ports/windows/fmode.c $(Q)$(MAKE) -C $(TOP)/mpy-cross # make a list of all the .py files that need compiling and freezing diff --git a/tests/run-tests b/tests/run-tests index f9c26283d..14df1e986 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -13,10 +13,10 @@ from glob import glob # to the correct executable. if os.name == 'nt': CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3.exe') - MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../windows/micropython.exe') + MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../ports/windows/micropython.exe') else: CPYTHON3 = os.getenv('MICROPY_CPYTHON3', 'python3') - MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../unix/micropython') + MICROPYTHON = os.getenv('MICROPY_MICROPYTHON', '../ports/unix/micropython') # mpy-cross is only needed if --via-mpy command-line arg is passed MPYCROSS = os.getenv('MICROPY_MPYCROSS', '../mpy-cross/mpy-cross') diff --git a/tools/check_code_size.sh b/tools/check_code_size.sh index c5f0c6ffd..2925ff168 100755 --- a/tools/check_code_size.sh +++ b/tools/check_code_size.sh @@ -10,7 +10,7 @@ REFERENCE=$HOME/persist/firmware.bin if [ -f $REFERENCE ]; then size_old=$(stat -c%s $REFERENCE) - size_new=$(stat -c%s minimal/build/firmware.bin) + size_new=$(stat -c%s ports/minimal/build/firmware.bin) echo "Old size: $size_old new size: $size_new" if [ $size_new -gt $size_old ]; then echo "Validation failure: Core code size increased" diff --git a/tools/codestats.sh b/tools/codestats.sh index 5272f3e9c..09284a30d 100755 --- a/tools/codestats.sh +++ b/tools/codestats.sh @@ -9,7 +9,7 @@ # executing because it does not exist in old revisions of the repository. # check that we are in the root directory of the repository -if [ ! -d py -o ! -d unix -o ! -d stmhal ]; then +if [ ! -d py -o ! -d ports/unix -o ! -d ports/stm32 ]; then echo "script must be run from root of the repository" exit 1 fi @@ -23,18 +23,18 @@ AWK=awk MAKE="make -j2" # these are the binaries that are built; some have 2 or 3 depending on version -bin_unix=unix/micropython -bin_stmhal=stmhal/build-PYBV10/firmware.elf -bin_barearm_1=bare-arm/build/flash.elf -bin_barearm_2=bare-arm/build/firmware.elf -bin_minimal=minimal/build/firmware.elf -bin_cc3200_1=cc3200/build/LAUNCHXL/application.axf -bin_cc3200_2=cc3200/build/LAUNCHXL/release/application.axf -bin_cc3200_3=cc3200/build/WIPY/release/application.axf +bin_unix=ports/unix/micropython +bin_stm32=ports/stm32/build-PYBV10/firmware.elf +bin_barearm_1=ports/bare-arm/build/flash.elf +bin_barearm_2=ports/bare-arm/build/firmware.elf +bin_minimal=ports/minimal/build/firmware.elf +bin_cc3200_1=ports/cc3200/build/LAUNCHXL/application.axf +bin_cc3200_2=ports/cc3200/build/LAUNCHXL/release/application.axf +bin_cc3200_3=ports/cc3200/build/WIPY/release/application.axf # start at zero size; if build fails reuse previous valid size size_unix="0" -size_stmhal="0" +size_stm32="0" size_barearm="0" size_minimal="0" size_cc3200="0" @@ -86,7 +86,7 @@ function get_size3() { if [ -r $output ]; then last_rev=$(tail -n1 $output | $AWK '{print $1}') else - echo "# hash size_unix size_stmhal size_barearm size_minimal size_cc3200 pystones" > $output + echo "# hash size_unix size_stm32 size_barearm size_minimal size_cc3200 pystones" > $output last_rev="v1.0" fi @@ -132,37 +132,37 @@ EOF #### unix #### $RM $bin_unix - $MAKE -C unix CFLAGS_EXTRA=-DNDEBUG + $MAKE -C ports/unix CFLAGS_EXTRA=-DNDEBUG size_unix=$(get_size $size_unix $bin_unix) # undo patch if it was applied git checkout unix/modtime.c - #### stmhal #### + #### stm32 #### - $RM $bin_stmhal - $MAKE -C stmhal board=PYBV10 - size_stmhal=$(get_size $size_stmhal $bin_stmhal) + $RM $bin_stm32 + $MAKE -C ports/stm32 board=PYBV10 + size_stm32=$(get_size $size_stm32 $bin_stm32) #### bare-arm #### $RM $bin_barearm_1 $bin_barearm_2 - $MAKE -C bare-arm + $MAKE -C ports/bare-arm size_barearm=$(get_size2 $size_barearm $bin_barearm_1 $bin_barearm_2) #### minimal #### - if [ -r minimal/Makefile ]; then + if [ -r ports/minimal/Makefile ]; then $RM $bin_minimal - $MAKE -C minimal CROSS=1 + $MAKE -C ports/minimal CROSS=1 size_minimal=$(get_size $size_minimal $bin_minimal) fi #### cc3200 #### - if [ -r cc3200/Makefile ]; then + if [ -r ports/cc3200/Makefile ]; then $RM $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3 - $MAKE -C cc3200 BTARGET=application + $MAKE -C ports/cc3200 BTARGET=application size_cc3200=$(get_size3 $size_cc3200 $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3) fi @@ -178,7 +178,7 @@ EOF #### output data for this commit #### - echo "$hash $size_unix $size_stmhal $size_barearm $size_minimal $size_cc3200 $pystones" >> $output + echo "$hash $size_unix $size_stm32 $size_barearm $size_minimal $size_cc3200 $pystones" >> $output done -- cgit v1.2.3 From da1c80d8509062f155450f09a7112e57e2e14f42 Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Thu, 31 Aug 2017 11:14:13 +0100 Subject: docs/reference/isr_rules.rst Add tutorial on use of micropython.schedule(). --- docs/reference/isr_rules.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'docs') diff --git a/docs/reference/isr_rules.rst b/docs/reference/isr_rules.rst index 23dcfd01f..5009f30f7 100644 --- a/docs/reference/isr_rules.rst +++ b/docs/reference/isr_rules.rst @@ -21,6 +21,7 @@ This summarises the points detailed below and lists the principal recommendation * Keep the code as short and simple as possible. * Avoid memory allocation: no appending to lists or insertion into dictionaries, no floating point. +* Consider using ``micropython.schedule`` to work around the above constraint. * Where an ISR returns multiple bytes use a pre-allocated ``bytearray``. If multiple integers are to be shared between an ISR and the main program consider an array (``array.array``). * Where data is shared between the main program and an ISR, consider disabling interrupts prior to accessing @@ -158,6 +159,26 @@ On platforms with hardware floating point (such as the Pyboard) the inline ARM T round this limitation. This is because the processor stores float values in a machine word; values can be shared between the ISR and main program code via an array of floats. +Using micropython.schedule +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This function enables an ISR to schedule a callback for execution "very soon". The callback is queued for +execution which will take place at a time when the heap is not locked. Hence it can create Python objects +and use floats. The callback is also guaranteed to run at a time when the main program has completed any +update of Python objects, so the callback will not encounter partially updated objects. + +Typical usage is to handle sensor hardware. The ISR acquires data from the hardware and enables it to +issue a further interrupt. It then schedules a callback to process the data. + +Scheduled callbacks should comply with the principles of interrupt handler design outlined below. This is to +avoid problems resulting from I/O activity and the modification of shared data which can arise in any code +which pre-empts the main program loop. + +Execution time needs to be considered in relation to the frequency with which interrupts can occur. If an +interrupt occurs while the previous callback is executing, a further instance of the callback will be queued +for execution; this will run after the current instance has completed. A sustained high interrupt repetition +rate therefore carries a risk of unconstrained queue growth and eventual failure with a ``RuntimeError``. + Exceptions ---------- -- cgit v1.2.3 From d42b89bc3a9b85488a272235b1cc5fb342ab2536 Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Tue, 12 Sep 2017 16:48:39 +0100 Subject: docs/library/framebuf.rst: Generalise constructor to all colour formats. --- docs/library/framebuf.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/library/framebuf.rst b/docs/library/framebuf.rst index b92bd08ef..74c9f8564 100644 --- a/docs/library/framebuf.rst +++ b/docs/library/framebuf.rst @@ -38,9 +38,9 @@ Constructors - *width* is the width of the FrameBuffer in pixels - *height* is the height of the FrameBuffer in pixels - *format* specifies the type of pixel used in the FrameBuffer; - valid values are ``framebuf.MVLSB``, ``framebuf.RGB565`` - and ``framebuf.GS4_HMSB``. MVLSB is monochrome 1-bit color, - RGB565 is RGB 16-bit color, and GS4_HMSB is grayscale 4-bit color. + permissible values are listed under Constants below. These set the + number of bits used to encode a color value and the layout of these + bits in *buffer*. Where a color value c is passed to a method, c is a small integer with an encoding that is dependent on the format of the FrameBuffer. - *stride* is the number of pixels between each horizontal line @@ -110,8 +110,9 @@ Other methods corresponding color will be considered transparent: all pixels with that color value will not be drawn. - This method works between FrameBuffer's utilising different formats, but the - resulting colors may be unexpected due to the mismatch in color formats. + This method works between FrameBuffer instances utilising different formats, + but the resulting colors may be unexpected due to the mismatch in color + formats. Constants --------- -- cgit v1.2.3 From 72491b3e40db75e7edf5831e8914a1ca5c8e9937 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 17 Sep 2017 21:34:34 +0300 Subject: docs/btree: Describe page caching policy of the underlying implementation. --- docs/library/btree.rst | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/library/btree.rst b/docs/library/btree.rst index 9322d32e6..8fac67e8d 100644 --- a/docs/library/btree.rst +++ b/docs/library/btree.rst @@ -76,20 +76,24 @@ Example:: Functions --------- -.. function:: open(stream, \*, flags=0, cachesize=0, pagesize=0, minkeypage=0) +.. function:: open(stream, \*, flags=0, pagesize=0, cachesize=0, minkeypage=0) Open a database from a random-access `stream` (like an open file). All other parameters are optional and keyword-only, and allow to tweak advanced parameters of the database operation (most users will not need them): * *flags* - Currently unused. - * *cachesize* - Suggested maximum memory cache size in bytes. For a - board with enough memory using larger values may improve performance. - The value is only a recommendation, the module may use more memory if - values set too low. * *pagesize* - Page size used for the nodes in BTree. Acceptable range - is 512-65536. If 0, underlying I/O block size will be used (the best - compromise between memory usage and performance). + is 512-65536. If 0, a port-specific default will be used, optimized for + port's memory usage and/or performance. + * *cachesize* - Suggested memory cache size in bytes. For a + board with enough memory using larger values may improve performance. + Cache policy is as follows: entire cache is not allocated at once; + instead, accessing a new page in database will allocate a memory buffer + for it, until value specified by *cachesize* is reached. Then, these + buffers will be managed using LRU (least recently used) policy. More + buffers may still be allocated if needed (e.g., if a database contains + big keys and/or values). Allocated cache buffers aren't reclaimed. * *minkeypage* - Minimum number of keys to store per page. Default value of 0 equivalent to 2. -- cgit v1.2.3 From 9e0cdb22f1a549d5e542418a3007c756cd594b84 Mon Sep 17 00:00:00 2001 From: Gabe Date: Wed, 27 Sep 2017 15:49:51 -0400 Subject: docs/esp8266/tutorial: Update neopixel with example of using 4 bbp. --- docs/esp8266/tutorial/neopixel.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'docs') diff --git a/docs/esp8266/tutorial/neopixel.rst b/docs/esp8266/tutorial/neopixel.rst index 245aed6d4..a1537526f 100644 --- a/docs/esp8266/tutorial/neopixel.rst +++ b/docs/esp8266/tutorial/neopixel.rst @@ -20,6 +20,20 @@ To set the colour of pixels use:: >>> np[1] = (0, 128, 0) # set to green, half brightness >>> np[2] = (0, 0, 64) # set to blue, quarter brightness +For LEDs with more than 3 colours, such as RGBW pixels or RGBY pixels, the +NeoPixel class takes a ``bpp`` parameter. To setup a NeoPixel object for an +RGBW Pixel, do the following:: + + >>> import machine, neopixel + >>> np = neopixel.NeoPixel(machine.Pin(4), 8, bpp=4) + +In a 4-bpp mode, remember to use 4-tuples instead of 3-tuples to set the colour. +For example to set the first three pixels use:: + + >>> np[0] = (255, 0, 0, 128) # Orange in an RGBY Setup + >>> np[1] = (0, 255, 0, 128) # Yellow-green in an RGBY Setup + >>> np[2] = (0, 0, 255, 128) # Green-blue in an RGBY Setup + Then use the ``write()`` method to output the colours to the LEDs:: >>> np.write() -- cgit v1.2.3