Merge tag 'v1.9.1' into parse-bytecode
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
This commit is contained in:
commit
25e24b2c3c
|
@ -138,7 +138,7 @@ If `WIPY_IP`, `WIPY_USER` or `WIPY_PWD` are omitted the default values (the ones
|
|||
## Regarding old revisions of the CC3200-LAUNCHXL
|
||||
|
||||
First silicon (pre-release) revisions of the CC3200 had issues with the ram blocks, and MicroPython cannot run
|
||||
there. Make sure to use a **v4.1 (or higer) LAUNCHXL board** when trying this port, otherwise it won't work.
|
||||
there. Make sure to use a **v4.1 (or higher) LAUNCHXL board** when trying this port, otherwise it won't work.
|
||||
|
||||
### Note regarding FileZilla
|
||||
|
||||
|
|
|
@ -151,7 +151,6 @@ APP_LIB_SRC_C = $(addprefix lib/,\
|
|||
|
||||
APP_STM_SRC_C = $(addprefix stmhal/,\
|
||||
bufhelper.c \
|
||||
input.c \
|
||||
irq.c \
|
||||
pybstdio.c \
|
||||
)
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#define MICROPY_VFS_FAT (1)
|
||||
#define MICROPY_PY_ASYNC_AWAIT (0)
|
||||
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
|
||||
#define MICROPY_PY_BUILTINS_INPUT (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP_TEXT cc3200_help_text
|
||||
#ifndef DEBUG
|
||||
|
@ -142,7 +143,6 @@
|
|||
|
||||
// extra built in names to add to the global namespace
|
||||
#define MICROPY_PORT_BUILTINS \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, \
|
||||
|
||||
// extra built in modules to add to the list of known ones
|
||||
|
|
|
@ -99,7 +99,7 @@ copyright = '2014-2017, Damien P. George, Paul Sokolovsky, and contributors'
|
|||
# The short X.Y version.
|
||||
version = '1.9'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '1.9'
|
||||
release = '1.9.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
|
|
@ -107,9 +107,9 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
|
|||
from machine import Pin
|
||||
|
||||
p0 = Pin(0, Pin.OUT) # create output pin on GPIO0
|
||||
p0.high() # set pin to high
|
||||
p0.low() # set pin to low
|
||||
p0.value(1) # set pin to high
|
||||
p0.on() # set pin to "on" (high) level
|
||||
p0.off() # set pin to "off" (low) level
|
||||
p0.value(1) # set pin to on/high
|
||||
|
||||
p2 = Pin(2, Pin.IN) # create input pin on GPIO2
|
||||
print(p2.value()) # get value, 0 or 1
|
||||
|
|
|
@ -35,8 +35,8 @@ Then set its value using::
|
|||
|
||||
Or::
|
||||
|
||||
>>> pin.low()
|
||||
>>> pin.high()
|
||||
>>> pin.off()
|
||||
>>> pin.on()
|
||||
|
||||
External interrupts
|
||||
-------------------
|
||||
|
|
|
@ -101,11 +101,12 @@ turn it on and off using the following code::
|
|||
|
||||
>>> import machine
|
||||
>>> pin = machine.Pin(2, machine.Pin.OUT)
|
||||
>>> pin.high()
|
||||
>>> pin.low()
|
||||
>>> pin.on()
|
||||
>>> pin.off()
|
||||
|
||||
Note that ``high`` might turn the LED off and ``low`` might turn it on (or vice
|
||||
versa), depending on how the LED is wired on your board.
|
||||
Note that ``on`` method of a Pin might turn the LED off and ``off`` might
|
||||
turn it on (or vice versa), depending on how the LED is wired on your board.
|
||||
To resolve this, machine.Signal class is provided.
|
||||
|
||||
Line editing
|
||||
~~~~~~~~~~~~
|
||||
|
|
|
@ -69,7 +69,7 @@ Functions
|
|||
|
||||
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
|
||||
paramters of the database operation (most users will not need them):
|
||||
parameters of the database operation (most users will not need them):
|
||||
|
||||
* `flags` - Currently unused.
|
||||
* `cachesize` - Suggested maximum memory cache size in bytes. For a
|
||||
|
|
|
@ -146,18 +146,20 @@ Methods
|
|||
|
||||
When setting the value this method returns ``None``.
|
||||
|
||||
.. method:: Pin.out_value()
|
||||
|
||||
Return the value stored in the output buffer of a pin, regardless of its mode.
|
||||
|
||||
Not all ports implement this method.
|
||||
|
||||
.. method:: Pin.__call__([x])
|
||||
|
||||
Pin objects are callable. The call method provides a (fast) shortcut to set
|
||||
and get the value of the pin. It is equivalent to Pin.value([x]).
|
||||
See :meth:`Pin.value` for more details.
|
||||
|
||||
.. method:: Pin.on()
|
||||
|
||||
Set pin to "1" output level.
|
||||
|
||||
.. method:: Pin.off()
|
||||
|
||||
Set pin to "0" output level.
|
||||
|
||||
.. method:: Pin.mode([mode])
|
||||
|
||||
Get or set the pin mode.
|
||||
|
|
|
@ -34,7 +34,7 @@ Methods
|
|||
|
||||
.. method:: SD.init(id=0, pins=('GP10', 'GP11', 'GP15'))
|
||||
|
||||
Enable the SD card. In order to initalize the card, give it a 3-tuple:
|
||||
Enable the SD card. In order to initialize the card, give it a 3-tuple:
|
||||
``(clk_pin, cmd_pin, dat0_pin)``.
|
||||
|
||||
.. method:: SD.deinit()
|
||||
|
|
|
@ -16,7 +16,7 @@ UART objects can be created and initialised using::
|
|||
uart = UART(1, 9600) # init with given baudrate
|
||||
uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters
|
||||
|
||||
Supported paramters differ on a board:
|
||||
Supported parameters differ on a board:
|
||||
|
||||
Pyboard: Bits can be 7, 8 or 9. Stop can be 1 or 2. With `parity=None`,
|
||||
only 8 and 9 bits are supported. With parity enabled, only 7 and 8 bits
|
||||
|
|
|
@ -145,13 +145,13 @@ Classes
|
|||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
machine.I2C.rst
|
||||
machine.Pin.rst
|
||||
machine.Signal.rst
|
||||
machine.RTC.rst
|
||||
machine.SPI.rst
|
||||
machine.Timer.rst
|
||||
machine.UART.rst
|
||||
machine.SPI.rst
|
||||
machine.I2C.rst
|
||||
machine.RTC.rst
|
||||
machine.Timer.rst
|
||||
machine.WDT.rst
|
||||
|
||||
.. only:: port_wipy
|
||||
|
@ -159,12 +159,12 @@ Classes
|
|||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
machine.ADC.rst
|
||||
machine.I2C.rst
|
||||
machine.Pin.rst
|
||||
machine.RTC.rst
|
||||
machine.SD.rst
|
||||
machine.SPI.rst
|
||||
machine.Timer.rst
|
||||
machine.UART.rst
|
||||
machine.SPI.rst
|
||||
machine.I2C.rst
|
||||
machine.RTC.rst
|
||||
machine.Timer.rst
|
||||
machine.WDT.rst
|
||||
machine.ADC.rst
|
||||
machine.SD.rst
|
||||
|
|
|
@ -14,14 +14,20 @@ module.
|
|||
|
||||
For example::
|
||||
|
||||
# configure a specific network interface
|
||||
# connect/ show IP config a specific network interface
|
||||
# see below for examples of specific drivers
|
||||
import network
|
||||
import utime
|
||||
nic = network.Driver(...)
|
||||
if not nic.isconnected():
|
||||
nic.connect()
|
||||
print("Waiting for connection...")
|
||||
while not nic.isconnected():
|
||||
utime.sleep(1)
|
||||
print(nic.ifconfig())
|
||||
|
||||
# now use socket as usual
|
||||
import socket
|
||||
# now use usocket as usual
|
||||
import usocket as socket
|
||||
addr = socket.getaddrinfo('micropython.org', 80)[0][-1]
|
||||
s = socket.socket()
|
||||
s.connect(addr)
|
||||
|
@ -29,51 +35,102 @@ For example::
|
|||
data = s.recv(1000)
|
||||
s.close()
|
||||
|
||||
.. only:: port_wipy
|
||||
Common network adapter interface
|
||||
================================
|
||||
|
||||
.. _network.Server:
|
||||
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
|
||||
in the following sections, implements methods as described here.
|
||||
|
||||
class Server
|
||||
============
|
||||
.. class:: AbstractNIC(id=None, ...)
|
||||
|
||||
The ``Server`` class controls the behaviour and the configuration of the FTP and telnet
|
||||
services running on the WiPy. Any changes performed using this class' methods will
|
||||
affect both.
|
||||
Instantiate a network interface object. Parameters are network interface
|
||||
dependent. If there are more than one interface of the same type, the first
|
||||
parameter should be `id`.
|
||||
|
||||
Example::
|
||||
.. method:: active([is_active])
|
||||
|
||||
import network
|
||||
server = network.Server()
|
||||
server.deinit() # disable the server
|
||||
# enable the server again with new settings
|
||||
server.init(login=('user', 'password'), timeout=600)
|
||||
Activate ("up") or deactivate ("down") the network interface, if
|
||||
a boolean argument is passed. Otherwise, query current state if
|
||||
no argument is provided. Most other methods require an active
|
||||
interface (behavior of calling them on inactive interface is
|
||||
undefined).
|
||||
|
||||
Constructors
|
||||
------------
|
||||
.. method:: connect([service_id, key=None, \*, ...])
|
||||
|
||||
.. class:: network.Server(id, ...)
|
||||
Connect the interface to a network. This method is optional, and
|
||||
available only for interfaces which are not "always connected".
|
||||
If no parameters are given, connect to the default (or the only)
|
||||
service. If a single parameter is given, it is the primary identifier
|
||||
of a service to connect to. It may be accompanied by a key
|
||||
(password) required to access said service. There can be further
|
||||
arbitrary keyword-only parameters, depending on the networking medium
|
||||
type and/or particular device. Parameters can be used to: a)
|
||||
specify alternative service identifer types; b) provide additional
|
||||
connection parameters. For various medium types, there are different
|
||||
sets of predefined/recommended parameters, among them:
|
||||
|
||||
Create a server instance, see ``init`` for parameters of initialization.
|
||||
* WiFi: `bssid` keyword to connect by BSSID (MAC address) instead
|
||||
of access point name
|
||||
|
||||
Methods
|
||||
-------
|
||||
.. method:: disconnect()
|
||||
|
||||
.. method:: server.init(\*, login=('micro', 'python'), timeout=300)
|
||||
Disconnect from network.
|
||||
|
||||
Init (and effectively start the server). Optionally a new ``user``, ``password``
|
||||
and ``timeout`` (in seconds) can be passed.
|
||||
.. method:: isconnected()
|
||||
|
||||
.. method:: server.deinit()
|
||||
Returns ``True`` if connected to network, otherwise returns ``False``.
|
||||
|
||||
Stop the server
|
||||
.. method:: scan(\*, ...)
|
||||
|
||||
.. method:: server.timeout([timeout_in_seconds])
|
||||
Scan for the available network services/connections. Returns a
|
||||
list of tuples with discovered service parameters. For various
|
||||
network media, there are different variants of predefined/
|
||||
recommended tuple formats, among them:
|
||||
|
||||
Get or set the server timeout.
|
||||
* WiFi: (ssid, bssid, channel, RSSI, authmode, hidden). There
|
||||
may be further fields, specific to a particular device.
|
||||
|
||||
.. method:: server.isrunning()
|
||||
The function may accept additional keyword arguments to filter scan
|
||||
results (e.g. scan for a particular service, on a particular channel,
|
||||
for services of a particular set, etc.), and to affect scan
|
||||
duration and other parameters. Where possible, parameter names
|
||||
should match those in connect().
|
||||
|
||||
Returns ``True`` if the server is running, ``False`` otherwise.
|
||||
.. method:: status()
|
||||
|
||||
Return detailed status of the interface, values are dependent
|
||||
on the network medium/technology.
|
||||
|
||||
.. method:: ifconfig([(ip, subnet, gateway, dns)])
|
||||
|
||||
Get/set IP-level network interface parameters: IP address, subnet mask,
|
||||
gateway and DNS server. When called with no arguments, this method returns
|
||||
a 4-tuple with the above information. To set the above values, pass a
|
||||
4-tuple with the required information. For example::
|
||||
|
||||
nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
|
||||
|
||||
.. method:: config('param')
|
||||
config(param=value, ...)
|
||||
|
||||
Get or set general network interface parameters. These methods allow to work
|
||||
with additional parameters beyond standard IP configuration (as dealt with by
|
||||
``ifconfig()``). These include network-specific and hardware-specific
|
||||
parameters and status values. For setting parameters, the keyword argument
|
||||
syntax should be used, and multiple parameters can be set at once. For
|
||||
querying, a parameter name should be quoted as a string, and only one
|
||||
parameter can be queried at a time::
|
||||
|
||||
# Set WiFi access point name (formally known as ESSID) and WiFi channel
|
||||
ap.config(essid='My AP', channel=11)
|
||||
# Query params one by one
|
||||
print(ap.config('essid'))
|
||||
print(ap.config('channel'))
|
||||
# Extended status information also available this way
|
||||
print(sta.config('rssi'))
|
||||
|
||||
.. only:: port_pyboard
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@ be implemented:
|
|||
|
||||
* SHA1 - A previous generation algorithm. Not recommended for new usages,
|
||||
but SHA1 is a part of number of Internet standards and existing
|
||||
applications, so boards targetting network connectivity and
|
||||
applications, so boards targeting network connectivity and
|
||||
interoperatiability will try to provide this.
|
||||
|
||||
* MD5 - A legacy algorithm, not considered cryptographically secure. Only
|
||||
selected boards, targetting interoperatibility with legacy applications,
|
||||
selected boards, targeting interoperatibility with legacy applications,
|
||||
will offer this.
|
||||
|
||||
Constructors
|
||||
|
|
|
@ -4,28 +4,9 @@
|
|||
.. module:: uos
|
||||
:synopsis: basic "operating system" services
|
||||
|
||||
The ``os`` module contains functions for filesystem access and ``urandom``
|
||||
The ``uos`` module contains functions for filesystem access and ``urandom``
|
||||
function.
|
||||
|
||||
Port specifics
|
||||
--------------
|
||||
|
||||
The filesystem has ``/`` as the root directory and the
|
||||
available physical drives are accessible from here. They are currently:
|
||||
|
||||
``/flash`` -- the internal flash filesystem
|
||||
|
||||
``/sd`` -- the SD card (if it exists)
|
||||
|
||||
.. only:: port_pyboard
|
||||
|
||||
On boot up, the current directory is ``/flash`` if no SD card is inserted,
|
||||
otherwise it is ``/sd``.
|
||||
|
||||
.. only:: port_wipy
|
||||
|
||||
On boot up, the current directory is ``/flash``.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
|
@ -106,26 +87,8 @@ Functions
|
|||
Return a bytes object with n random bytes. Whenever possible, it is
|
||||
generated by the hardware random number generator.
|
||||
|
||||
.. only:: port_wipy
|
||||
.. function:: dupterm(stream_object)
|
||||
|
||||
.. function:: mount(block_device, mount_point, \*, readonly=False)
|
||||
|
||||
Mounts a block device (like an ``SD`` object) in the specified mount
|
||||
point. Example::
|
||||
|
||||
os.mount(sd, '/sd')
|
||||
|
||||
.. function:: unmount(path)
|
||||
|
||||
Unmounts a previously mounted block device from the given path.
|
||||
|
||||
.. function:: mkfs(block_device or path)
|
||||
|
||||
Formats the specified path, must be either ``/flash`` or ``/sd``.
|
||||
A block device can also be passed like an ``SD`` object before
|
||||
being mounted.
|
||||
|
||||
.. function:: dupterm(stream_object)
|
||||
|
||||
Duplicate the terminal (the REPL) on the passed stream-like object.
|
||||
The given object must at least implement the ``.read()`` and ``.write()`` methods.
|
||||
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.
|
||||
|
|
|
@ -146,8 +146,8 @@ Functions
|
|||
too distant inbetween, see below). The function returns **signed** value in the range
|
||||
[``-TICKS_PERIOD/2`` .. ``TICKS_PERIOD/2-1``] (that's a typical range definition for
|
||||
two's-complement signed binary integers). If the result is negative, it means that
|
||||
``ticks1`` occured earlier in time than ``ticks2``. Otherwise, it means that
|
||||
``ticks1`` occured after ``ticks2``. This holds ``only`` if ``ticks1`` and ``ticks2``
|
||||
``ticks1`` occurred earlier in time than ``ticks2``. Otherwise, it means that
|
||||
``ticks1`` occurred after ``ticks2``. This holds ``only`` if ``ticks1`` and ``ticks2``
|
||||
are apart from each other for no more than ``TICKS_PERIOD/2-1`` ticks. If that does
|
||||
not hold, incorrect result will be returned. Specifically, if two tick values are
|
||||
apart for ``TICKS_PERIOD/2-1`` ticks, that value will be returned by the function.
|
||||
|
|
|
@ -10,7 +10,9 @@ is inserted into the slot, it is available as ``/sd``.
|
|||
|
||||
When the pyboard boots up, it needs to choose a filesystem to boot from. If
|
||||
there is no SD card, then it uses the internal filesystem ``/flash`` as the boot
|
||||
filesystem, otherwise, it uses the SD card ``/sd``.
|
||||
filesystem, otherwise, it uses the SD card ``/sd``. After the boot, the current
|
||||
directory is set to one of the directories above.
|
||||
|
||||
If needed, you can prevent the use of the SD card by creating an empty file
|
||||
called ``/flash/SKIPSD``. If this file exists when the pyboard boots
|
||||
up then the SD card will be skipped and the pyboard will always boot from the
|
||||
|
|
|
@ -66,7 +66,7 @@ index for PDF, just the same as for HTML.
|
|||
search_auto_exclude
|
||||
-------------------
|
||||
|
||||
Even if you exclude soem documents from toctree:: using only::
|
||||
Even if you exclude some documents from toctree:: using only::
|
||||
directive, they will be indexed for full-text search, so user may
|
||||
find them and get confused. This plugin follows very simple idea
|
||||
that if you didn't include some documents in the toctree, then
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# This is a Sphinx documentation tool extension which allows to
|
||||
# exclude some Python modules from the generated indexes. Modules
|
||||
# are excluded both from "modindex" and "genindex" index tables
|
||||
# (in the latter case, all members of a module are exlcuded).
|
||||
# (in the latter case, all members of a module are excluded).
|
||||
# To control exclusion, set "modindex_exclude" variable in Sphinx
|
||||
# conf.py to the list of modules to exclude. Note: these should be
|
||||
# modules (as defined by py:module directive, not just raw filenames).
|
||||
|
|
|
@ -53,7 +53,7 @@ which is stored within the external serial flash memory. If a micro SD card
|
|||
is hooked-up and mounted, it will be available as well.
|
||||
|
||||
When the WiPy starts up, it always boots from the ``boot.py`` located in the
|
||||
``/flash`` file system.
|
||||
``/flash`` file system. On boot up, the current directory is ``/flash``.
|
||||
|
||||
The file system is accessible via the native FTP server running in the WiPy.
|
||||
Open your FTP client of choice and connect to:
|
||||
|
@ -323,3 +323,63 @@ Unrelated function in machine module
|
|||
this function is not called then the default file main.py will be executed.
|
||||
|
||||
It only makes sense to call this function from within boot.py.
|
||||
|
||||
Adhoc way to control telnet/FTP server via network module
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``Server`` class controls the behaviour and the configuration of the FTP and telnet
|
||||
services running on the WiPy. Any changes performed using this class' methods will
|
||||
affect both.
|
||||
|
||||
Example::
|
||||
|
||||
import network
|
||||
server = network.Server()
|
||||
server.deinit() # disable the server
|
||||
# enable the server again with new settings
|
||||
server.init(login=('user', 'password'), timeout=600)
|
||||
|
||||
.. class:: network.Server(id, ...)
|
||||
|
||||
Create a server instance, see ``init`` for parameters of initialization.
|
||||
|
||||
.. method:: server.init(\*, login=('micro', 'python'), timeout=300)
|
||||
|
||||
Init (and effectively start the server). Optionally a new ``user``, ``password``
|
||||
and ``timeout`` (in seconds) can be passed.
|
||||
|
||||
.. method:: server.deinit()
|
||||
|
||||
Stop the server
|
||||
|
||||
.. method:: server.timeout([timeout_in_seconds])
|
||||
|
||||
Get or set the server timeout.
|
||||
|
||||
.. method:: server.isrunning()
|
||||
|
||||
Returns ``True`` if the server is running, ``False`` otherwise.
|
||||
|
||||
Adhoc VFS-like support
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
WiPy doesn't implement full MicroPython VFS support, instead following
|
||||
functions are defined in ``uos`` module:
|
||||
|
||||
.. function:: mount(block_device, mount_point, \*, readonly=False)
|
||||
|
||||
Mounts a block device (like an ``SD`` object) in the specified mount
|
||||
point. Example::
|
||||
|
||||
os.mount(sd, '/sd')
|
||||
|
||||
.. function:: unmount(path)
|
||||
|
||||
Unmounts a previously mounted block device from the given path.
|
||||
|
||||
.. function:: mkfs(block_device or path)
|
||||
|
||||
Formats the specified path, must be either ``/flash`` or ``/sd``.
|
||||
A block device can also be passed like an ``SD`` object before
|
||||
being mounted.
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ SRC_C = \
|
|||
|
||||
STM_SRC_C = $(addprefix stmhal/,\
|
||||
pybstdio.c \
|
||||
input.c \
|
||||
)
|
||||
|
||||
EXTMOD_SRC_C = $(addprefix extmod/,\
|
||||
|
@ -233,7 +232,11 @@ axtls: $(BUILD)/libaxtls.a
|
|||
|
||||
$(BUILD)/libaxtls.a:
|
||||
cd ../lib/axtls; cp config/upyconfig config/.config
|
||||
cd ../lib/axtls; make oldconfig -B
|
||||
cd ../lib/axtls; make clean
|
||||
cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)" AR="$(AR)" CFLAGS_EXTRA="$(CFLAGS_XTENSA) -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=3072"
|
||||
cd ../lib/axtls; $(MAKE) oldconfig -B
|
||||
cd ../lib/axtls; $(MAKE) clean
|
||||
cd ../lib/axtls; $(MAKE) all CC="$(CC)" LD="$(LD)" AR="$(AR)" CFLAGS_EXTRA="$(CFLAGS_XTENSA) -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=3072"
|
||||
cp ../lib/axtls/_stage/libaxtls.a $@
|
||||
|
||||
clean-modules:
|
||||
git clean -f -d modules
|
||||
rm -f build/frozen*.c
|
||||
|
|
|
@ -100,7 +100,7 @@ programming).
|
|||
|
||||
__WiFi__
|
||||
|
||||
Initally, the device configures itself as a WiFi access point (AP).
|
||||
Initially, the device configures itself as a WiFi access point (AP).
|
||||
- ESSID: MicroPython-xxxxxx (x’s are replaced with part of the MAC address).
|
||||
- Password: micropythoN (note the upper-case N).
|
||||
- IP address of the board: 192.168.4.1.
|
||||
|
|
|
@ -93,7 +93,7 @@ void pyb_rtc_set_us_since_2000(uint64_t nowus) {
|
|||
int64_t delta = nowus - (((uint64_t)rtc_last_ticks * cal) >> 12);
|
||||
|
||||
// As the calibration value jitters quite a bit, to make the
|
||||
// clock at least somewhat practially usable, we need to store it
|
||||
// clock at least somewhat practically usable, we need to store it
|
||||
system_rtc_mem_write(MEM_CAL_ADDR, &cal, sizeof(cal));
|
||||
system_rtc_mem_write(MEM_DELTA_ADDR, &delta, sizeof(delta));
|
||||
};
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#define MICROPY_PY_BUILTINS_SLICE (1)
|
||||
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
|
||||
#define MICROPY_PY_BUILTINS_PROPERTY (1)
|
||||
#define MICROPY_PY_BUILTINS_INPUT (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP_TEXT esp_help_text
|
||||
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
|
||||
|
@ -147,7 +148,6 @@ void *esp_native_code_commit(void*, size_t);
|
|||
|
||||
// extra built in names to add to the global namespace
|
||||
#define MICROPY_PORT_BUILTINS \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
|
||||
|
||||
// extra built in modules to add to the list of known ones
|
||||
|
|
|
@ -8,7 +8,7 @@ lcd.light(1)
|
|||
def conway_step():
|
||||
for x in range(128): # loop over x coordinates
|
||||
for y in range(32): # loop over y coordinates
|
||||
# count number of neigbours
|
||||
# count number of neighbours
|
||||
num_neighbours = (lcd.get(x - 1, y - 1) +
|
||||
lcd.get(x, y - 1) +
|
||||
lcd.get(x + 1, y - 1) +
|
||||
|
@ -25,7 +25,7 @@ def conway_step():
|
|||
if self and not (2 <= num_neighbours <= 3):
|
||||
lcd.pixel(x, y, 0) # not enough, or too many neighbours: cell dies
|
||||
elif not self and num_neighbours == 3:
|
||||
lcd.pixel(x, y, 1) # exactly 3 neigbours around an empty cell: cell is born
|
||||
lcd.pixel(x, y, 1) # exactly 3 neighbours around an empty cell: cell is born
|
||||
|
||||
# randomise the start
|
||||
def conway_rand():
|
||||
|
|
|
@ -170,7 +170,7 @@ SRC_QSTR_AUTO_DEPS +=
|
|||
include $(MPTOP)/py/mkrules.mk
|
||||
|
||||
# Value of configure's --host= option (required for cross-compilation).
|
||||
# Deduce it from CROSS_COMPILE by default, but can be overriden.
|
||||
# Deduce it from CROSS_COMPILE by default, but can be overridden.
|
||||
ifneq ($(CROSS_COMPILE),)
|
||||
CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE))
|
||||
else
|
||||
|
|
|
@ -18,7 +18,7 @@ Building the example is as simple as running:
|
|||
It's worth to trace what's happening behind the scenes though:
|
||||
|
||||
1. As a first step, a MicroPython library is built. This is handled by a
|
||||
seperate makefile, Makefile.upylib. It is more or less complex, but the
|
||||
separate makefile, Makefile.upylib. It is more or less complex, but the
|
||||
good news is that you won't need to change anything in it, just use it
|
||||
as is, the main Makefile shows how. What may require editing though is
|
||||
a MicroPython configuration file. MicroPython is highly configurable, so
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#define MICROPY_MEM_STATS (0)
|
||||
#define MICROPY_DEBUG_PRINTERS (0)
|
||||
#define MICROPY_READER_POSIX (1)
|
||||
#define MICROPY_KBD_EXCEPTION (1)
|
||||
#define MICROPY_HELPER_REPL (1)
|
||||
#define MICROPY_HELPER_LEXER_UNIX (1)
|
||||
#define MICROPY_ENABLE_SOURCE_LINE (0)
|
||||
|
@ -91,7 +92,6 @@ extern const struct _mp_obj_module_t mp_module_os;
|
|||
{ MP_OBJ_NEW_QSTR(MP_QSTR_uos), (mp_obj_t)&mp_module_os }, \
|
||||
|
||||
#define MICROPY_PORT_ROOT_POINTERS \
|
||||
mp_obj_t keyboard_interrupt_obj;
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Do not change anything beyond this line
|
||||
|
|
|
@ -449,7 +449,7 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
|
|||
int cx1 = x1;
|
||||
for (int cx0 = x0; cx0 < x0end; ++cx0) {
|
||||
color = getpixel(source, cx1, y1);
|
||||
if (color != key) {
|
||||
if (color != (uint32_t)key) {
|
||||
setpixel(self, cx0, y0, color);
|
||||
}
|
||||
++cx1;
|
||||
|
|
|
@ -373,7 +373,7 @@ STATIC err_t _lwip_tcp_recv(void *arg, struct tcp_pcb *tcpb, struct pbuf *p, err
|
|||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
// Functions for socket send/recieve operations. Socket send/recv and friends call
|
||||
// Functions for socket send/receive operations. Socket send/recv and friends call
|
||||
// these to do the work.
|
||||
|
||||
// Helper function for send/sendto to handle UDP packets.
|
||||
|
@ -732,7 +732,9 @@ STATIC mp_obj_t lwip_socket_accept(mp_obj_t self_in) {
|
|||
|
||||
// accept incoming connection
|
||||
if (socket->incoming.connection == NULL) {
|
||||
if (socket->timeout != -1) {
|
||||
if (socket->timeout == 0) {
|
||||
mp_raise_OSError(MP_EAGAIN);
|
||||
} else if (socket->timeout != -1) {
|
||||
for (mp_uint_t retries = socket->timeout / 100; retries--;) {
|
||||
mp_hal_delay_ms(100);
|
||||
if (socket->incoming.connection != NULL) break;
|
||||
|
@ -800,12 +802,12 @@ STATIC mp_obj_t lwip_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
|
|||
case MOD_NETWORK_SOCK_STREAM: {
|
||||
if (socket->state != STATE_NEW) {
|
||||
if (socket->state == STATE_CONNECTED) {
|
||||
mp_raise_OSError(MP_EALREADY);
|
||||
mp_raise_OSError(MP_EISCONN);
|
||||
} else {
|
||||
mp_raise_OSError(MP_EINPROGRESS);
|
||||
mp_raise_OSError(MP_EALREADY);
|
||||
}
|
||||
}
|
||||
// Register our recieve callback.
|
||||
// Register our receive callback.
|
||||
tcp_recv(socket->pcb.tcp, _lwip_tcp_recv);
|
||||
socket->state = STATE_CONNECTING;
|
||||
err = tcp_connect(socket->pcb.tcp, &dest, port, _lwip_tcp_connected);
|
||||
|
@ -822,7 +824,7 @@ STATIC mp_obj_t lwip_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
|
|||
if (socket->state != STATE_CONNECTING) break;
|
||||
}
|
||||
if (socket->state == STATE_CONNECTING) {
|
||||
mp_raise_OSError(MP_ETIMEDOUT);
|
||||
mp_raise_OSError(MP_EINPROGRESS);
|
||||
}
|
||||
} else {
|
||||
while (socket->state == STATE_CONNECTING) {
|
||||
|
|
|
@ -132,7 +132,7 @@ STATIC mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
|
|||
|
||||
self->buf_pos = 0;
|
||||
self->to_recv = to_recv;
|
||||
self->msg_sz = sz; // May be overriden by FRAME_OPT
|
||||
self->msg_sz = sz; // May be overridden by FRAME_OPT
|
||||
if (to_recv != 0) {
|
||||
self->state = FRAME_OPT;
|
||||
} else {
|
||||
|
|
29
extmod/vfs.c
29
extmod/vfs.c
|
@ -228,11 +228,14 @@ mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_umount_obj, mp_vfs_umount);
|
||||
|
||||
// Note: buffering and encoding args are currently ignored
|
||||
mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_file, ARG_mode, ARG_encoding };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
|
||||
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
|
||||
{ MP_QSTR_buffering, MP_ARG_INT, {.u_int = -1} },
|
||||
{ MP_QSTR_encoding, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
|
||||
};
|
||||
|
||||
// parse args
|
||||
|
@ -421,6 +424,32 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_stat_obj, mp_vfs_stat);
|
|||
mp_obj_t mp_vfs_statvfs(mp_obj_t path_in) {
|
||||
mp_obj_t path_out;
|
||||
mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
|
||||
if (vfs == MP_VFS_ROOT) {
|
||||
// statvfs called on the root directory, see if there's anything mounted there
|
||||
for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
|
||||
if (vfs->len == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If there's nothing mounted at root then return a mostly-empty tuple
|
||||
if (vfs == NULL) {
|
||||
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL));
|
||||
|
||||
// fill in: bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flags
|
||||
for (int i = 0; i <= 8; ++i) {
|
||||
t->items[i] = MP_OBJ_NEW_SMALL_INT(0);
|
||||
}
|
||||
|
||||
// Put something sensible in f_namemax
|
||||
t->items[9] = MP_OBJ_NEW_SMALL_INT(MICROPY_ALLOC_PATH_MAX);
|
||||
|
||||
return MP_OBJ_FROM_PTR(t);
|
||||
}
|
||||
|
||||
// VFS mounted at root so delegate the call to it
|
||||
path_out = MP_OBJ_NEW_QSTR(MP_QSTR__slash_);
|
||||
}
|
||||
return mp_vfs_proxy_call(vfs, MP_QSTR_statvfs, 1, &path_out);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj, mp_vfs_statvfs);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
float value; int exp;
|
||||
#endif
|
||||
{
|
||||
if(!finitef(value)||value==(float)0.0) return value;
|
||||
if(!isfinite(value)||value==(float)0.0) return value;
|
||||
value = scalbnf(value,exp);
|
||||
//if(!finitef(value)||value==(float)0.0) errno = ERANGE;
|
||||
return value;
|
||||
|
|
|
@ -165,7 +165,7 @@ mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday,
|
|||
//
|
||||
// tm_tomorrow = list(time.localtime())
|
||||
// tm_tomorrow[2] += 1 # Adds 1 to mday
|
||||
// tomorrow = time.mktime(tm_tommorrow)
|
||||
// tomorrow = time.mktime(tm_tomorrow)
|
||||
//
|
||||
// And not have to worry about all the weird overflows.
|
||||
//
|
||||
|
|
|
@ -27,28 +27,24 @@
|
|||
#include "py/obj.h"
|
||||
#include "py/mpstate.h"
|
||||
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
|
||||
int mp_interrupt_char;
|
||||
|
||||
void mp_hal_set_interrupt_char(int c) {
|
||||
if (c != -1) {
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
|
||||
#else
|
||||
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
|
||||
#endif
|
||||
}
|
||||
mp_interrupt_char = c;
|
||||
}
|
||||
|
||||
void mp_keyboard_interrupt(void) {
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
|
||||
#else
|
||||
MP_STATE_VM(mp_pending_exception) = MP_STATE_PORT(mp_kbd_exception);
|
||||
#endif
|
||||
#if MICROPY_ENABLE_SCHEDULER
|
||||
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
|
||||
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* implementation below can be used.
|
||||
*/
|
||||
|
||||
// Send "cooked" string of given length, where every occurance of
|
||||
// Send "cooked" string of given length, where every occurrence of
|
||||
// LF character is replaced with CR LF.
|
||||
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
|
||||
while (len--) {
|
||||
|
|
|
@ -52,7 +52,7 @@ void asm_thumb_end_pass(asm_thumb_t *as) {
|
|||
|
||||
#if defined(MCU_SERIES_F7)
|
||||
if (as->base.pass == MP_ASM_PASS_EMIT) {
|
||||
// flush D-cache, so the code emited is stored in memory
|
||||
// flush D-cache, so the code emitted is stored in memory
|
||||
SCB_CleanDCache_by_Addr((uint32_t*)as->base.code_base, as->base.code_size);
|
||||
// invalidate I-cache
|
||||
SCB_InvalidateICache();
|
||||
|
|
10
py/bc.c
10
py/bc.c
|
@ -64,6 +64,14 @@ mp_uint_t mp_decode_uint_value(const byte *ptr) {
|
|||
return mp_decode_uint(&ptr);
|
||||
}
|
||||
|
||||
// This function is used to help reduce stack usage at the caller, for the case when
|
||||
// the caller doesn't need the actual value and just wants to skip over it.
|
||||
const byte *mp_decode_uint_skip(const byte *ptr) {
|
||||
while ((*ptr++) & 0x80) {
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
|
||||
// generic message, used also for other argument issues
|
||||
|
@ -115,7 +123,7 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
|
|||
|
||||
// get params
|
||||
size_t n_state = mp_decode_uint(&code_state->ip);
|
||||
mp_decode_uint(&code_state->ip); // skip n_exc_stack
|
||||
code_state->ip = mp_decode_uint_skip(code_state->ip); // skip n_exc_stack
|
||||
size_t scope_flags = *code_state->ip++;
|
||||
size_t n_pos_args = *code_state->ip++;
|
||||
size_t n_kwonly_args = *code_state->ip++;
|
||||
|
|
1
py/bc.h
1
py/bc.h
|
@ -92,6 +92,7 @@ typedef struct _mp_code_state_t {
|
|||
|
||||
mp_uint_t mp_decode_uint(const byte **ptr);
|
||||
mp_uint_t mp_decode_uint_value(const byte *ptr);
|
||||
const byte *mp_decode_uint_skip(const byte *ptr);
|
||||
|
||||
mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp_obj_t inject_exc);
|
||||
mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
|
|
|
@ -271,7 +271,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
|
|||
if (level != 0) {
|
||||
// What we want to do here is to take name of current module,
|
||||
// chop <level> trailing components, and concatenate with passed-in
|
||||
// module name, thus resolving relative import name into absolue.
|
||||
// module name, thus resolving relative import name into absolute.
|
||||
// This even appears to be correct per
|
||||
// http://legacy.python.org/dev/peps/pep-0328/#relative-imports-and-name
|
||||
// "Relative imports use a module's __name__ attribute to determine that
|
||||
|
@ -441,7 +441,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
|
|||
#if MICROPY_CPYTHON_COMPAT
|
||||
// Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules).
|
||||
mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)), MP_OBJ_NEW_QSTR(MP_QSTR___main__), module_obj);
|
||||
// Store real name in "__main__" attribute. Choosen semi-randonly, to reuse existing qstr's.
|
||||
// Store real name in "__main__" attribute. Chosen semi-randonly, to reuse existing qstr's.
|
||||
mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___main__), MP_OBJ_NEW_QSTR(mod_name));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -939,7 +939,7 @@ STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// some arbitrary statment that we can't delete (eg del 1)
|
||||
// some arbitrary statement that we can't delete (eg del 1)
|
||||
goto cannot_delete;
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ STATIC void compile_import_name(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
|||
STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
mp_parse_node_t pn_import_source = pns->nodes[0];
|
||||
|
||||
// extract the preceeding .'s (if any) for a relative import, to compute the import level
|
||||
// extract the preceding .'s (if any) for a relative import, to compute the import level
|
||||
uint import_level = 0;
|
||||
do {
|
||||
mp_parse_node_t pn_rel;
|
||||
|
|
|
@ -5,8 +5,10 @@ qstr. Each qstr is transformed into a qstr definition of the form 'Q(...)'.
|
|||
This script works with Python 2.6, 2.7, 3.3 and 3.4.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import re
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Blacklist of qstrings that are specially handled in further
|
||||
|
@ -84,18 +86,18 @@ def cat_together():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='Generates qstr definitions from a specified source')
|
||||
if len(sys.argv) != 5:
|
||||
print('usage: %s command input_filename output_dir output_file' % sys.argv[0])
|
||||
sys.exit(2)
|
||||
|
||||
parser.add_argument('command',
|
||||
help='Command (split/cat)')
|
||||
parser.add_argument('input_filename',
|
||||
help='Name of the input file (when not specified, the script reads standard input)')
|
||||
parser.add_argument('output_dir',
|
||||
help='Output directory to store individual qstr files')
|
||||
parser.add_argument('output_file',
|
||||
help='Name of the output file with collected qstrs')
|
||||
class Args:
|
||||
pass
|
||||
args = Args()
|
||||
args.command = sys.argv[1]
|
||||
args.input_filename = sys.argv[2]
|
||||
args.output_dir = sys.argv[3]
|
||||
args.output_file = sys.argv[4]
|
||||
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
os.makedirs(args.output_dir)
|
||||
except OSError:
|
||||
|
|
|
@ -198,7 +198,7 @@ int DEBUG_printf(const char *fmt, ...);
|
|||
extern mp_uint_t mp_verbose_flag;
|
||||
|
||||
// This is useful for unicode handling. Some CPU archs has
|
||||
// special instructions for efficient implentation of this
|
||||
// special instructions for efficient implementation of this
|
||||
// function (e.g. CLZ on ARM).
|
||||
// NOTE: this function is unused at the moment
|
||||
#ifndef count_lead_ones
|
||||
|
|
|
@ -32,7 +32,7 @@ ifeq ($(BUILD_VERBOSE),0)
|
|||
$(info Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.)
|
||||
endif
|
||||
|
||||
# default settings; can be overriden in main Makefile
|
||||
# default settings; can be overridden in main Makefile
|
||||
|
||||
PY_SRC ?= $(TOP)/py
|
||||
BUILD ?= build
|
||||
|
|
|
@ -259,6 +259,35 @@ STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
|
||||
|
||||
#if MICROPY_PY_BUILTINS_INPUT
|
||||
|
||||
#include "py/mphal.h"
|
||||
#include "lib/mp-readline/readline.h"
|
||||
|
||||
// A port can define mp_hal_readline if they want to use a custom function here
|
||||
#ifndef mp_hal_readline
|
||||
#define mp_hal_readline readline
|
||||
#endif
|
||||
|
||||
STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
|
||||
if (n_args == 1) {
|
||||
mp_obj_print(args[0], PRINT_STR);
|
||||
}
|
||||
vstr_t line;
|
||||
vstr_init(&line, 16);
|
||||
int ret = mp_hal_readline(&line, "");
|
||||
if (ret == CHAR_CTRL_C) {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_KeyboardInterrupt));
|
||||
}
|
||||
if (line.len == 0 && ret == CHAR_CTRL_D) {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_EOFError));
|
||||
}
|
||||
return mp_obj_new_str_from_vstr(&mp_type_str, &line);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input);
|
||||
|
||||
#endif
|
||||
|
||||
STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
|
||||
return mp_getiter(o_in, NULL);
|
||||
}
|
||||
|
@ -676,6 +705,9 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
|
|||
#endif
|
||||
{ MP_ROM_QSTR(MP_QSTR_hex), MP_ROM_PTR(&mp_builtin_hex_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_id), MP_ROM_PTR(&mp_builtin_id_obj) },
|
||||
#if MICROPY_PY_BUILTINS_INPUT
|
||||
{ MP_ROM_QSTR(MP_QSTR_input), MP_ROM_PTR(&mp_builtin_input_obj) },
|
||||
#endif
|
||||
{ MP_ROM_QSTR(MP_QSTR_isinstance), MP_ROM_PTR(&mp_builtin_isinstance_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_issubclass), MP_ROM_PTR(&mp_builtin_issubclass_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_iter), MP_ROM_PTR(&mp_builtin_iter_obj) },
|
||||
|
|
|
@ -74,12 +74,12 @@ STATIC MP_DEFINE_ATTRTUPLE(
|
|||
MP_ROM_PTR(&mp_sys_implementation_version_info_obj)
|
||||
);
|
||||
#else
|
||||
STATIC const mp_obj_tuple_t mp_sys_implementation_obj = {
|
||||
STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
|
||||
{&mp_type_tuple},
|
||||
2,
|
||||
{
|
||||
MP_OBJ_NEW_QSTR(MP_QSTR_micropython),
|
||||
(mp_obj_t)&mp_sys_implementation_version_info_obj,
|
||||
MP_ROM_QSTR(MP_QSTR_micropython),
|
||||
MP_ROM_PTR(&mp_sys_implementation_version_info_obj),
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
// mpconfigport.h is a file containing configuration settings for a
|
||||
// particular port. mpconfigport.h is actually a default name for
|
||||
// such config, and it can be overriden using MP_CONFIGFILE preprocessor
|
||||
// such config, and it can be overridden using MP_CONFIGFILE preprocessor
|
||||
// define (you can do that by passing CFLAGS_EXTRA='-DMP_CONFIGFILE="<file.h>"'
|
||||
// argument to make when using standard MicroPython makefiles).
|
||||
// This is useful to have more than one config per port, for example,
|
||||
|
@ -791,6 +791,12 @@ typedef double mp_float_t;
|
|||
#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0)
|
||||
#endif
|
||||
|
||||
// Whether to provide the built-in input() function. The implementation of this
|
||||
// uses mp-readline, so can only be enabled if the port uses this readline.
|
||||
#ifndef MICROPY_PY_BUILTINS_INPUT
|
||||
#define MICROPY_PY_BUILTINS_INPUT (0)
|
||||
#endif
|
||||
|
||||
// Whether to support min/max functions
|
||||
#ifndef MICROPY_PY_BUILTINS_MIN_MAX
|
||||
#define MICROPY_PY_BUILTINS_MIN_MAX (1)
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#define MP_ECONNABORTED (103) // Software caused connection abort
|
||||
#define MP_ECONNRESET (104) // Connection reset by peer
|
||||
#define MP_ENOBUFS (105) // No buffer space available
|
||||
#define MP_EISCONN (106) // Transport endpoint is already connected
|
||||
#define MP_ENOTCONN (107) // Transport endpoint is not connected
|
||||
#define MP_ETIMEDOUT (110) // Connection timed out
|
||||
#define MP_ECONNREFUSED (111) // Connection refused
|
||||
|
@ -127,6 +128,7 @@
|
|||
#define MP_ECONNABORTED ECONNABORTED
|
||||
#define MP_ECONNRESET ECONNRESET
|
||||
#define MP_ENOBUFS ENOBUFS
|
||||
#define MP_EISCONN EISCONN
|
||||
#define MP_ENOTCONN ENOTCONN
|
||||
#define MP_ETIMEDOUT ETIMEDOUT
|
||||
#define MP_ECONNREFUSED ECONNREFUSED
|
||||
|
|
2
py/obj.c
2
py/obj.c
|
@ -401,7 +401,7 @@ mp_obj_t mp_obj_id(mp_obj_t o_in) {
|
|||
return MP_OBJ_NEW_SMALL_INT(id);
|
||||
} else {
|
||||
// If that didn't work, well, let's return long int, just as
|
||||
// a (big) positve value, so it will never clash with the range
|
||||
// a (big) positive value, so it will never clash with the range
|
||||
// of small int returned in previous case.
|
||||
return mp_obj_new_int_from_uint((mp_uint_t)id);
|
||||
}
|
||||
|
|
22
py/objfun.c
22
py/objfun.c
|
@ -141,11 +141,11 @@ const mp_obj_type_t mp_type_fun_builtin_var = {
|
|||
/* byte code functions */
|
||||
|
||||
qstr mp_obj_code_get_name(const byte *code_info) {
|
||||
mp_decode_uint(&code_info); // skip code_info_size entry
|
||||
code_info = mp_decode_uint_skip(code_info); // skip code_info_size entry
|
||||
#if MICROPY_PERSISTENT_CODE
|
||||
return code_info[0] | (code_info[1] << 8);
|
||||
#else
|
||||
return mp_decode_uint(&code_info);
|
||||
return mp_decode_uint_value(code_info);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -163,8 +163,8 @@ qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) {
|
|||
#endif
|
||||
|
||||
const byte *bc = fun->bytecode;
|
||||
mp_decode_uint(&bc); // skip n_state
|
||||
mp_decode_uint(&bc); // skip n_exc_stack
|
||||
bc = mp_decode_uint_skip(bc); // skip n_state
|
||||
bc = mp_decode_uint_skip(bc); // skip n_exc_stack
|
||||
bc++; // skip scope_params
|
||||
bc++; // skip n_pos_args
|
||||
bc++; // skip n_kwonly_args
|
||||
|
@ -205,12 +205,9 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t self_in, size_t n_args
|
|||
MP_STACK_CHECK();
|
||||
mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
// get start of bytecode
|
||||
const byte *ip = self->bytecode;
|
||||
|
||||
// bytecode prelude: state size and exception stack size
|
||||
size_t n_state = mp_decode_uint(&ip);
|
||||
size_t n_exc_stack = mp_decode_uint(&ip);
|
||||
size_t n_state = mp_decode_uint_value(self->bytecode);
|
||||
size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode));
|
||||
|
||||
// allocate state for locals and stack
|
||||
size_t state_size = n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t);
|
||||
|
@ -243,12 +240,9 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
|
|||
mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
DEBUG_printf("Func n_def_args: %d\n", self->n_def_args);
|
||||
|
||||
// get start of bytecode
|
||||
const byte *ip = self->bytecode;
|
||||
|
||||
// bytecode prelude: state size and exception stack size
|
||||
size_t n_state = mp_decode_uint(&ip);
|
||||
size_t n_exc_stack = mp_decode_uint(&ip);
|
||||
size_t n_state = mp_decode_uint_value(self->bytecode);
|
||||
size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self->bytecode));
|
||||
|
||||
#if VM_DETECT_STACK_OVERFLOW
|
||||
n_state += 1;
|
||||
|
|
|
@ -54,12 +54,9 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
|
|||
mp_obj_fun_bc_t *self_fun = (mp_obj_fun_bc_t*)self->fun;
|
||||
assert(self_fun->base.type == &mp_type_fun_bc);
|
||||
|
||||
// get start of bytecode
|
||||
const byte *ip = self_fun->bytecode;
|
||||
|
||||
// bytecode prelude: get state size and exception stack size
|
||||
mp_uint_t n_state = mp_decode_uint(&ip);
|
||||
mp_uint_t n_exc_stack = mp_decode_uint(&ip);
|
||||
size_t n_state = mp_decode_uint_value(self_fun->bytecode);
|
||||
size_t n_exc_stack = mp_decode_uint_value(mp_decode_uint_skip(self_fun->bytecode));
|
||||
|
||||
// allocate the generator object, with room for local stack and exception stack
|
||||
mp_obj_gen_instance_t *o = m_new_obj_var(mp_obj_gen_instance_t, byte,
|
||||
|
|
13
py/objstr.c
13
py/objstr.c
|
@ -602,6 +602,11 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) {
|
|||
GET_STR_DATA_LEN(args[0], s, len);
|
||||
|
||||
mp_int_t splits = mp_obj_get_int(args[2]);
|
||||
if (splits < 0) {
|
||||
// Negative limit means no limit, so delegate to split().
|
||||
return mp_obj_str_split(n_args, args);
|
||||
}
|
||||
|
||||
mp_int_t org_splits = splits;
|
||||
// Preallocate list to the max expected # of elements, as we
|
||||
// will fill it from the end.
|
||||
|
@ -798,7 +803,7 @@ STATIC mp_obj_t str_uni_strip(int type, size_t n_args, const mp_obj_t *args) {
|
|||
}
|
||||
|
||||
assert(last_good_char_pos >= first_good_char_pos);
|
||||
//+1 to accomodate the last character
|
||||
//+1 to accommodate the last character
|
||||
size_t stripped_len = last_good_char_pos - first_good_char_pos + 1;
|
||||
if (stripped_len == orig_str_len) {
|
||||
// If nothing was stripped, don't bother to dup original string
|
||||
|
@ -1811,7 +1816,7 @@ STATIC mp_obj_t str_islower(mp_obj_t self_in) {
|
|||
}
|
||||
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
// These methods are superfluous in the presense of str() and bytes()
|
||||
// These methods are superfluous in the presence of str() and bytes()
|
||||
// constructors.
|
||||
// TODO: should accept kwargs too
|
||||
STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) {
|
||||
|
@ -2130,7 +2135,7 @@ typedef struct _mp_obj_str8_it_t {
|
|||
|
||||
#if !MICROPY_PY_BUILTINS_STR_UNICODE
|
||||
STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
|
||||
mp_obj_str8_it_t *self = self_in;
|
||||
mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
GET_STR_DATA_LEN(self->str, str, len);
|
||||
if (self->cur < len) {
|
||||
mp_obj_t o_out = mp_obj_new_str((const char*)str + self->cur, 1, true);
|
||||
|
@ -2148,7 +2153,7 @@ STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_bu
|
|||
o->iternext = str_it_iternext;
|
||||
o->str = str;
|
||||
o->cur = 0;
|
||||
return o;
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -68,10 +68,23 @@ STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
|
|||
return size;
|
||||
}
|
||||
|
||||
STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) {
|
||||
const void *buf = o->vstr->buf;
|
||||
o->vstr->buf = m_new(char, o->vstr->len);
|
||||
memcpy(o->vstr->buf, buf, o->vstr->len);
|
||||
o->vstr->fixed_buf = false;
|
||||
o->ref_obj = MP_OBJ_NULL;
|
||||
}
|
||||
|
||||
STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
|
||||
(void)errcode;
|
||||
mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
|
||||
check_stringio_is_open(o);
|
||||
|
||||
if (o->vstr->fixed_buf) {
|
||||
stringio_copy_on_write(o);
|
||||
}
|
||||
|
||||
mp_uint_t new_pos = o->pos + size;
|
||||
if (new_pos < size) {
|
||||
// Writing <size> bytes will overflow o->pos beyond limit of mp_uint_t.
|
||||
|
@ -155,11 +168,11 @@ STATIC mp_obj_t stringio___exit__(size_t n_args, const mp_obj_t *args) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stringio___exit___obj, 4, 4, stringio___exit__);
|
||||
|
||||
STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type, mp_uint_t alloc) {
|
||||
STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) {
|
||||
mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t);
|
||||
o->base.type = type;
|
||||
o->vstr = vstr_new(alloc);
|
||||
o->pos = 0;
|
||||
o->ref_obj = MP_OBJ_NULL;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -170,17 +183,28 @@ STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, s
|
|||
bool initdata = false;
|
||||
mp_buffer_info_t bufinfo;
|
||||
|
||||
mp_obj_stringio_t *o = stringio_new(type_in);
|
||||
|
||||
if (n_args > 0) {
|
||||
if (MP_OBJ_IS_INT(args[0])) {
|
||||
sz = mp_obj_get_int(args[0]);
|
||||
} else {
|
||||
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);
|
||||
|
||||
if (MP_OBJ_IS_STR_OR_BYTES(args[0])) {
|
||||
o->vstr = m_new_obj(vstr_t);
|
||||
vstr_init_fixed_buf(o->vstr, bufinfo.len, bufinfo.buf);
|
||||
o->vstr->len = bufinfo.len;
|
||||
o->ref_obj = args[0];
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
sz = bufinfo.len;
|
||||
initdata = true;
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_stringio_t *o = stringio_new(type_in, sz);
|
||||
o->vstr = vstr_new(sz);
|
||||
|
||||
if (initdata) {
|
||||
stringio_write(MP_OBJ_FROM_PTR(o), bufinfo.buf, bufinfo.len, NULL);
|
||||
|
|
|
@ -33,6 +33,8 @@ typedef struct _mp_obj_stringio_t {
|
|||
vstr_t *vstr;
|
||||
// StringIO has single pointer used for both reading and writing
|
||||
mp_uint_t pos;
|
||||
// Underlying object buffered by this StringIO
|
||||
mp_obj_t ref_obj;
|
||||
} mp_obj_stringio_t;
|
||||
|
||||
#endif // MICROPY_INCLUDED_PY_OBJSTRINGIO_H
|
||||
|
|
|
@ -286,11 +286,13 @@ STATIC void save_obj(mp_print_t *print, mp_obj_t o) {
|
|||
byte obj_type;
|
||||
if (MP_OBJ_IS_TYPE(o, &mp_type_int)) {
|
||||
obj_type = 'i';
|
||||
} else if (mp_obj_is_float(o)) {
|
||||
obj_type = 'f';
|
||||
} else {
|
||||
assert(MP_OBJ_IS_TYPE(o, &mp_type_complex));
|
||||
#if MICROPY_PY_BUILTINS_COMPLEX
|
||||
} else if (MP_OBJ_IS_TYPE(o, &mp_type_complex)) {
|
||||
obj_type = 'c';
|
||||
#endif
|
||||
} else {
|
||||
assert(mp_obj_is_float(o));
|
||||
obj_type = 'f';
|
||||
}
|
||||
vstr_t vstr;
|
||||
mp_print_t pr;
|
||||
|
|
2
py/py.mk
2
py/py.mk
|
@ -25,7 +25,7 @@ ifeq ($(MICROPY_SSL_AXTLS),1)
|
|||
CFLAGS_MOD += -DMICROPY_SSL_AXTLS=1 -I../lib/axtls/ssl -I../lib/axtls/crypto -I../lib/axtls/config
|
||||
LDFLAGS_MOD += -Lbuild -laxtls
|
||||
else ifeq ($(MICROPY_SSL_MBEDTLS),1)
|
||||
# Can be overriden by ports which have "builtin" mbedTLS
|
||||
# Can be overridden by ports which have "builtin" mbedTLS
|
||||
MICROPY_SSL_MBEDTLS_INCLUDE ?= ../lib/mbedtls/include
|
||||
CFLAGS_MOD += -DMICROPY_SSL_MBEDTLS=1 -I$(MICROPY_SSL_MBEDTLS_INCLUDE)
|
||||
LDFLAGS_MOD += -L../lib/mbedtls/library -lmbedx509 -lmbedtls -lmbedcrypto
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef struct _ringbuf_t {
|
|||
uint16_t iput;
|
||||
} ringbuf_t;
|
||||
|
||||
// Static initalization:
|
||||
// Static initialization:
|
||||
// byte buf_array[N];
|
||||
// ringbuf_t buf = {buf_array, sizeof(buf_array)};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in);
|
|||
#define STREAM_CONTENT_TYPE(stream) (((stream)->is_text) ? &mp_type_str : &mp_type_bytes)
|
||||
|
||||
// Returns error condition in *errcode, if non-zero, return value is number of bytes written
|
||||
// before error condition occured. If *errcode == 0, returns total bytes written (which will
|
||||
// before error condition occurred. If *errcode == 0, returns total bytes written (which will
|
||||
// be equal to input size).
|
||||
mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode, byte flags) {
|
||||
byte *buf = buf_;
|
||||
|
|
17
py/vm.c
17
py/vm.c
|
@ -947,7 +947,7 @@ unwind_jump:;
|
|||
DECODE_UINT;
|
||||
// unum & 0xff == n_positional
|
||||
// (unum >> 8) & 0xff == n_keyword
|
||||
// We have folowing stack layout here:
|
||||
// We have following stack layout here:
|
||||
// fun arg0 arg1 ... kw0 val0 kw1 val1 ... seq dict <- TOS
|
||||
sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 2;
|
||||
#if MICROPY_STACKLESS
|
||||
|
@ -1018,7 +1018,7 @@ unwind_jump:;
|
|||
DECODE_UINT;
|
||||
// unum & 0xff == n_positional
|
||||
// (unum >> 8) & 0xff == n_keyword
|
||||
// We have folowing stack layout here:
|
||||
// We have following stack layout here:
|
||||
// fun self arg0 arg1 ... kw0 val0 kw1 val1 ... seq dict <- TOS
|
||||
sp -= (unum & 0xff) + ((unum >> 7) & 0x1fe) + 3;
|
||||
#if MICROPY_STACKLESS
|
||||
|
@ -1363,22 +1363,25 @@ unwind_loop:
|
|||
// TODO need a better way of not adding traceback to constant objects (right now, just GeneratorExit_obj and MemoryError_obj)
|
||||
if (nlr.ret_val != &mp_const_GeneratorExit_obj && nlr.ret_val != &mp_const_MemoryError_obj) {
|
||||
const byte *ip = code_state->fun_bc->bytecode;
|
||||
mp_decode_uint(&ip); // skip n_state
|
||||
mp_decode_uint(&ip); // skip n_exc_stack
|
||||
ip = mp_decode_uint_skip(ip); // skip n_state
|
||||
ip = mp_decode_uint_skip(ip); // skip n_exc_stack
|
||||
ip++; // skip scope_params
|
||||
ip++; // skip n_pos_args
|
||||
ip++; // skip n_kwonly_args
|
||||
ip++; // skip n_def_pos_args
|
||||
size_t bc = code_state->ip - ip;
|
||||
size_t code_info_size = mp_decode_uint(&ip);
|
||||
size_t code_info_size = mp_decode_uint_value(ip);
|
||||
ip = mp_decode_uint_skip(ip); // skip code_info_size
|
||||
bc -= code_info_size;
|
||||
#if MICROPY_PERSISTENT_CODE
|
||||
qstr block_name = ip[0] | (ip[1] << 8);
|
||||
qstr source_file = ip[2] | (ip[3] << 8);
|
||||
ip += 4;
|
||||
#else
|
||||
qstr block_name = mp_decode_uint(&ip);
|
||||
qstr source_file = mp_decode_uint(&ip);
|
||||
qstr block_name = mp_decode_uint_value(ip);
|
||||
ip = mp_decode_uint_skip(ip);
|
||||
qstr source_file = mp_decode_uint_value(ip);
|
||||
ip = mp_decode_uint_skip(ip);
|
||||
#endif
|
||||
size_t source_line = 1;
|
||||
size_t c;
|
||||
|
|
|
@ -34,15 +34,15 @@ endif
|
|||
## - gcc-arm-none-eabi-4_8-2014q1/share/gcc-arm-none-eabi/samples/src/qemu/Makefile
|
||||
LDFLAGS= --specs=nano.specs --specs=rdimon.specs -Wl,--gc-sections -Wl,-Map=$(@:.elf=.map)
|
||||
|
||||
SRC_C = \
|
||||
main.c \
|
||||
SRC_COMMON_C = \
|
||||
moduos.c \
|
||||
modmachine.c \
|
||||
|
||||
SRC_RUN_C = \
|
||||
main.c \
|
||||
|
||||
SRC_TEST_C = \
|
||||
test_main.c \
|
||||
moduos.c \
|
||||
modmachine.c \
|
||||
|
||||
LIB_SRC_C = $(addprefix lib/,\
|
||||
libm/math.c \
|
||||
|
@ -69,25 +69,24 @@ STM_SRC_C = $(addprefix stmhal/,\
|
|||
pybstdio.c \
|
||||
)
|
||||
|
||||
SRC_S = \
|
||||
OBJ_COMMON =
|
||||
OBJ_COMMON += $(PY_O)
|
||||
OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_COMMON_C:.c=.o))
|
||||
OBJ_COMMON += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
||||
OBJ_COMMON += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
|
||||
|
||||
OBJ =
|
||||
OBJ += $(PY_O)
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
|
||||
OBJ_RUN =
|
||||
OBJ_RUN += $(addprefix $(BUILD)/, $(SRC_RUN_C:.c=.o))
|
||||
|
||||
OBJ_TEST =
|
||||
OBJ_TEST += $(PY_O)
|
||||
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_TEST_C:.c=.o))
|
||||
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
||||
OBJ_TEST += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
||||
OBJ_TEST += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
|
||||
OBJ_TEST += $(BUILD)/tinytest.o
|
||||
|
||||
# All object files, needed to get dependencies correct
|
||||
OBJ = $(OBJ_COMMON) $(OBJ_RUN) $(OBJ_TEST)
|
||||
|
||||
# List of sources for qstr extraction
|
||||
SRC_QSTR += $(SRC_C) $(STM_SRC_C)
|
||||
SRC_QSTR += $(SRC_COMMON_C) $(SRC_RUN_C) $(STM_SRC_C)
|
||||
|
||||
all: run
|
||||
|
||||
|
@ -109,11 +108,11 @@ $(BUILD)/tinytest.o:
|
|||
$(Q)$(CC) $(CFLAGS) -DNO_FORKING -o $@ -c ../tools/tinytest/tinytest.c
|
||||
|
||||
## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here.
|
||||
$(BUILD)/firmware.elf: $(OBJ)
|
||||
$(BUILD)/firmware.elf: $(OBJ_COMMON) $(OBJ_RUN)
|
||||
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
$(BUILD)/firmware-test.elf: $(OBJ_TEST)
|
||||
$(BUILD)/firmware-test.elf: $(OBJ_COMMON) $(OBJ_TEST)
|
||||
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ provided by QEMU (http://qemu.org).
|
|||
The purposes of this port are to enable:
|
||||
|
||||
1. Continuous integration
|
||||
- run tests agains architecture-specific parts of code base
|
||||
- run tests against architecture-specific parts of code base
|
||||
2. Experimentation
|
||||
- simulation & prototyping of anything that has architecture-specific
|
||||
code
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
#define MICROPY_EMIT_X64 (0)
|
||||
#define MICROPY_EMIT_THUMB (1)
|
||||
#define MICROPY_EMIT_INLINE_THUMB (1)
|
||||
#define MICROPY_MEM_STATS (0)
|
||||
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
|
||||
#define MICROPY_MEM_STATS (1)
|
||||
#define MICROPY_DEBUG_PRINTERS (0)
|
||||
#define MICROPY_ENABLE_GC (1)
|
||||
#define MICROPY_STACK_CHECK (1)
|
||||
|
@ -34,6 +35,7 @@
|
|||
#define MICROPY_PY_UHEAPQ (1)
|
||||
#define MICROPY_PY_UHASHLIB (1)
|
||||
#define MICROPY_PY_MACHINE (1)
|
||||
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
|
||||
#define MICROPY_USE_INTERNAL_PRINTF (0)
|
||||
#define MICROPY_VFS (1)
|
||||
|
||||
|
|
|
@ -147,7 +147,6 @@ SRC_C = \
|
|||
gccollect.c \
|
||||
pybstdio.c \
|
||||
help.c \
|
||||
input.c \
|
||||
machine_i2c.c \
|
||||
modmachine.c \
|
||||
modpyb.c \
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
#elif defined(STM32F427xx) || defined(STM32F429xx) || \
|
||||
defined(STM32F437xx) || defined(STM32F439xx) || \
|
||||
defined(STM32F746xx) || defined(STM32F767xx) || \
|
||||
defined(STM32F769xx)
|
||||
defined(STM32F769xx) || defined(STM32F446xx)
|
||||
#define VBAT_DIV (4)
|
||||
#elif defined(STM32L476xx)
|
||||
#define VBAT_DIV (3)
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#define MICROPY_HW_BOARD_NAME "NUCLEO-F446RE"
|
||||
#define MICROPY_HW_MCU_NAME "STM32F446xx"
|
||||
|
||||
#define MICROPY_HW_HAS_SWITCH (1)
|
||||
#define MICROPY_HW_HAS_FLASH (1)
|
||||
#define MICROPY_HW_ENABLE_RTC (1)
|
||||
|
||||
// HSE is 8MHz, CPU freq set to 168MHz. Using PLLQ for USB this gives a nice
|
||||
// 48 MHz clock for USB. To goto 180 MHz, I think that USB would need to be
|
||||
// configured to use PLLSAI
|
||||
#define MICROPY_HW_CLK_PLLM (8)
|
||||
#define MICROPY_HW_CLK_PLLN (336)
|
||||
#define MICROPY_HW_CLK_PLLP (RCC_PLLP_DIV2)
|
||||
#define MICROPY_HW_CLK_PLLQ (7)
|
||||
|
||||
// UART config
|
||||
#define MICROPY_HW_UART2_TX (pin_A2)
|
||||
#define MICROPY_HW_UART2_RX (pin_A3)
|
||||
#define MICROPY_HW_UART6_TX (pin_C6)
|
||||
#define MICROPY_HW_UART6_RX (pin_C7)
|
||||
// UART 2 connects to the STM32F103 (STLINK) on the Nucleo board
|
||||
// and this is exposed as a USB Serial port.
|
||||
#define MICROPY_HW_UART_REPL PYB_UART_2
|
||||
#define MICROPY_HW_UART_REPL_BAUD 115200
|
||||
|
||||
// I2C busses
|
||||
#define MICROPY_HW_I2C1_SCL (pin_B6) // Arduino D10, pin 17 on CN10
|
||||
#define MICROPY_HW_I2C1_SDA (pin_B7) // pin 21 on CN7
|
||||
#define MICROPY_HW_I2C2_SCL (pin_B10) // Arduino D6, pin 25 on CN10
|
||||
#define MICROPY_HW_I2C2_SDA (pin_B3) // Arduino D3, pin 31 on CN10
|
||||
#define MICROPY_HW_I2C3_SCL (pin_A8) // Arduino D7, pin 23 on CN10
|
||||
#define MICROPY_HW_I2C3_SDA (pin_C9) // pin 1 on CN10
|
||||
|
||||
// SPI busses
|
||||
#define MICROPY_HW_SPI1_NSS (pin_A15) // pin 17 on CN7
|
||||
#define MICROPY_HW_SPI1_SCK (pin_A5) // Arduino D13, pin 11 on CN10
|
||||
#define MICROPY_HW_SPI1_MISO (pin_A6) // Arduino D12, pin 13 on CN10
|
||||
#define MICROPY_HW_SPI1_MOSI (pin_A7) // Arduino D11, pin 15 on CN10
|
||||
|
||||
#define MICROPY_HW_SPI2_NSS (pin_B12) // pin 16 on CN10
|
||||
#define MICROPY_HW_SPI2_SCK (pin_B13) // pin 30 on CN10
|
||||
#define MICROPY_HW_SPI2_MISO (pin_B14) // pin 28 on CN10
|
||||
#define MICROPY_HW_SPI2_MOSI (pin_B15) // pin 26 on CN10
|
||||
|
||||
#define MICROPY_HW_SPI3_NSS (pin_A4) // Arduino A2, pin 32 on CN7
|
||||
#define MICROPY_HW_SPI3_SCK (pin_B3) // Arduino D3, pin 31 on CN10
|
||||
#define MICROPY_HW_SPI3_MISO (pin_B4) // Arduino D5, pin 27 on CN10
|
||||
#define MICROPY_HW_SPI3_MOSI (pin_B5) // Arduino D4, pin 29 on CN10
|
||||
|
||||
#define MICROPY_HW_SPI4_NSS (pin_B12) // pin 16 on CN10
|
||||
#define MICROPY_HW_SPI4_SCK (pin_B13) // pin 30 on CN10
|
||||
#define MICROPY_HW_SPI4_MISO (pin_A1) // pin 30 on CN7
|
||||
#define MICROPY_HW_SPI4_MOSI (pin_A11) // pin 14 on CN10
|
||||
|
||||
// USRSW is pulled low. Pressing the button makes the input go high.
|
||||
#define MICROPY_HW_USRSW_PIN (pin_C13)
|
||||
#define MICROPY_HW_USRSW_PULL (GPIO_NOPULL)
|
||||
#define MICROPY_HW_USRSW_EXTI_MODE (GPIO_MODE_IT_FALLING)
|
||||
#define MICROPY_HW_USRSW_PRESSED (0)
|
||||
|
||||
// LEDs
|
||||
#define MICROPY_HW_LED1 (pin_A5) // Green LD2 LED on Nucleo
|
||||
#define MICROPY_HW_LED_ON(pin) (mp_hal_pin_high(pin))
|
||||
#define MICROPY_HW_LED_OFF(pin) (mp_hal_pin_low(pin))
|
|
@ -0,0 +1,4 @@
|
|||
MCU_SERIES = f4
|
||||
CMSIS_MCU = STM32F446xx
|
||||
AF_FILE = boards/stm32f429_af.csv
|
||||
LD_FILE = boards/stm32f411.ld
|
|
@ -0,0 +1,72 @@
|
|||
D0,PA3
|
||||
D1,PA2
|
||||
D2,PA10
|
||||
D3,PB3
|
||||
D4,PB5
|
||||
D5,PB4
|
||||
D6,PB10
|
||||
D7,PA8
|
||||
D8,PA9
|
||||
D9,PC7
|
||||
D10,PB6
|
||||
D11,PA7
|
||||
D12,PA6
|
||||
D13,PA5
|
||||
D14,PB9
|
||||
D15,PB8
|
||||
A0,PA0
|
||||
A1,PA1
|
||||
A2,PA4
|
||||
A3,PB0
|
||||
A4,PC1
|
||||
A5,PC0
|
||||
PA0,PA0
|
||||
PA1,PA1
|
||||
PA2,PA2
|
||||
PA3,PA3
|
||||
PA4,PA4
|
||||
PA5,PA5
|
||||
PA6,PA6
|
||||
PA7,PA7
|
||||
PA8,PA8
|
||||
PA9,PA9
|
||||
PA10,PA10
|
||||
PA11,PA11
|
||||
PA12,PA12
|
||||
PA15,PA15
|
||||
PB0,PB0
|
||||
PB1,PB1
|
||||
PB2,PB2
|
||||
PB3,PB3
|
||||
PB4,PB4
|
||||
PB5,PB5
|
||||
PB6,PB6
|
||||
PB7,PB7
|
||||
PB8,PB8
|
||||
PB9,PB9
|
||||
PB10,PB10
|
||||
PB12,PB12
|
||||
PB13,PB13
|
||||
PB14,PB14
|
||||
PB15,PB15
|
||||
PC0,PC0
|
||||
PC1,PC1
|
||||
PC2,PC2
|
||||
PC3,PC3
|
||||
PC4,PC4
|
||||
PC5,PC5
|
||||
PC6,PC6
|
||||
PC7,PC7
|
||||
PC8,PC8
|
||||
PC9,PC9
|
||||
PC10,PC10
|
||||
PC11,PC11
|
||||
PC12,PC12
|
||||
PC13,PC13
|
||||
PC14,PC14
|
||||
PC15,PC15
|
||||
PD2,PD2
|
||||
PH0,PH0
|
||||
PH1,PH1
|
||||
LED,PA5
|
||||
SW,PC13
|
|
|
@ -0,0 +1,413 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f4xx_hal_conf.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-June-2014
|
||||
* @brief HAL configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F4xx_HAL_CONF_H
|
||||
#define __STM32F4xx_HAL_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
// This board doesn't really have USB, but the stmhal codebase doesn't build
|
||||
// without some USB defined, so we leave this on for now.
|
||||
#define USE_USB_FS
|
||||
|
||||
/* ########################## Module Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of modules to be used in the HAL driver
|
||||
*/
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
#define HAL_CAN_MODULE_ENABLED
|
||||
/* #define HAL_CRC_MODULE_ENABLED */
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
#define HAL_DAC_MODULE_ENABLED
|
||||
/* #define HAL_DCMI_MODULE_ENABLED */
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
/* #define HAL_DMA2D_MODULE_ENABLED */
|
||||
/* #define HAL_ETH_MODULE_ENABLED */
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
/* #define HAL_NAND_MODULE_ENABLED */
|
||||
/* #define HAL_NOR_MODULE_ENABLED */
|
||||
/* #define HAL_PCCARD_MODULE_ENABLED */
|
||||
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||
/* #define HAL_HASH_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_I2C_MODULE_ENABLED
|
||||
/* #define HAL_I2S_MODULE_ENABLED */
|
||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||
/* #define HAL_LTDC_MODULE_ENABLED */
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
/* #define HAL_RNG_MODULE_ENABLED */
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
/* #define HAL_SAI_MODULE_ENABLED */
|
||||
#define HAL_SD_MODULE_ENABLED
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/* #define HAL_USART_MODULE_ENABLED */
|
||||
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||
/* #define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/* #define HAL_WWDG_MODULE_ENABLED */
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
#define HAL_PCD_MODULE_ENABLED
|
||||
/* #define HAL_HCD_MODULE_ENABLED */
|
||||
|
||||
|
||||
/* ########################## HSE/HSI Values adaptation ##################### */
|
||||
/**
|
||||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSE is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||
#define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
|
||||
#endif /* HSE_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief Internal High Speed oscillator (HSI) value.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSI is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Internal Low Speed oscillator (LSI) value.
|
||||
*/
|
||||
#if !defined (LSI_VALUE)
|
||||
#define LSI_VALUE ((uint32_t)40000)
|
||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||
The real value may vary depending on the variations
|
||||
in voltage and temperature. */
|
||||
/**
|
||||
* @brief External Low Speed oscillator (LSE) value.
|
||||
*/
|
||||
#if !defined (LSE_VALUE)
|
||||
#define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */
|
||||
#endif /* LSE_VALUE */
|
||||
|
||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
|
||||
#endif /* LSE_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief External clock source for I2S peripheral
|
||||
* This value is used by the I2S HAL module to compute the I2S clock source
|
||||
* frequency, this source is inserted directly through I2S_CKIN pad.
|
||||
*/
|
||||
#if !defined (EXTERNAL_CLOCK_VALUE)
|
||||
#define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000) /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* EXTERNAL_CLOCK_VALUE */
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
||||
|
||||
/* ########################### System Configuration ######################### */
|
||||
/**
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY ((uint32_t)0x00) /*!< tick interrupt priority */
|
||||
#define USE_RTOS 0
|
||||
#define PREFETCH_ENABLE 1
|
||||
#define INSTRUCTION_CACHE_ENABLE 1
|
||||
#define DATA_CACHE_ENABLE 1
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
/**
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
/* #define USE_FULL_ASSERT 1 */
|
||||
|
||||
/* ################## Ethernet peripheral configuration ##################### */
|
||||
|
||||
/* Section 1 : Ethernet peripheral configuration */
|
||||
|
||||
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
|
||||
#define MAC_ADDR0 2
|
||||
#define MAC_ADDR1 0
|
||||
#define MAC_ADDR2 0
|
||||
#define MAC_ADDR3 0
|
||||
#define MAC_ADDR4 0
|
||||
#define MAC_ADDR5 0
|
||||
|
||||
/* Definition of the Ethernet driver buffers size and count */
|
||||
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
|
||||
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
||||
#define ETH_RXBUFNB ((uint32_t)4) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
||||
#define ETH_TXBUFNB ((uint32_t)4) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
||||
|
||||
/* Section 2: PHY configuration section */
|
||||
|
||||
/* DP83848 PHY Address*/
|
||||
#define DP83848_PHY_ADDRESS 0x01
|
||||
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
|
||||
#define PHY_RESET_DELAY ((uint32_t)0x000000FF)
|
||||
/* PHY Configuration delay */
|
||||
#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
|
||||
|
||||
#define PHY_READ_TO ((uint32_t)0x0000FFFF)
|
||||
#define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
|
||||
|
||||
/* Section 3: Common PHY Registers */
|
||||
|
||||
#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
|
||||
#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
|
||||
|
||||
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
|
||||
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
|
||||
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
|
||||
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
|
||||
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
|
||||
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
|
||||
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
|
||||
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
|
||||
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
|
||||
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
|
||||
|
||||
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
|
||||
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
|
||||
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
|
||||
|
||||
/* Section 4: Extended PHY Registers */
|
||||
|
||||
#define PHY_SR ((uint16_t)0x10) /*!< PHY status register Offset */
|
||||
#define PHY_MICR ((uint16_t)0x11) /*!< MII Interrupt Control Register */
|
||||
#define PHY_MISR ((uint16_t)0x12) /*!< MII Interrupt Status and Misc. Control Register */
|
||||
|
||||
#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
|
||||
#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
|
||||
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
|
||||
|
||||
#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
|
||||
#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
|
||||
|
||||
#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
|
||||
#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include module's header file
|
||||
*/
|
||||
|
||||
#ifdef HAL_RCC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_rcc.h"
|
||||
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_gpio.h"
|
||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dma.h"
|
||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_cortex.h"
|
||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_adc.h"
|
||||
#endif /* HAL_ADC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CAN_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_can.h"
|
||||
#endif /* HAL_CAN_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_crc.h"
|
||||
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRYP_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_cryp.h"
|
||||
#endif /* HAL_CRYP_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA2D_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dma2d.h"
|
||||
#endif /* HAL_DMA2D_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DAC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dac.h"
|
||||
#endif /* HAL_DAC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DCMI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_dcmi.h"
|
||||
#endif /* HAL_DCMI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ETH_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_eth.h"
|
||||
#endif /* HAL_ETH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_flash.h"
|
||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SRAM_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_sram.h"
|
||||
#endif /* HAL_SRAM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_NOR_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_nor.h"
|
||||
#endif /* HAL_NOR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_NAND_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_nand.h"
|
||||
#endif /* HAL_NAND_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCCARD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_pccard.h"
|
||||
#endif /* HAL_PCCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SDRAM_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_sdram.h"
|
||||
#endif /* HAL_SDRAM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_HASH_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_hash.h"
|
||||
#endif /* HAL_HASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_i2c.h"
|
||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2S_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_i2s.h"
|
||||
#endif /* HAL_I2S_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IWDG_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_iwdg.h"
|
||||
#endif /* HAL_IWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_LTDC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_ltdc.h"
|
||||
#endif /* HAL_LTDC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PWR_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_pwr.h"
|
||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RNG_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_rng.h"
|
||||
#endif /* HAL_RNG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RTC_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_rtc.h"
|
||||
#endif /* HAL_RTC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SAI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_sai.h"
|
||||
#endif /* HAL_SAI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_sd.h"
|
||||
#endif /* HAL_SD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_spi.h"
|
||||
#endif /* HAL_SPI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_tim.h"
|
||||
#endif /* HAL_TIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_uart.h"
|
||||
#endif /* HAL_UART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_USART_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_usart.h"
|
||||
#endif /* HAL_USART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IRDA_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_irda.h"
|
||||
#endif /* HAL_IRDA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SMARTCARD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_smartcard.h"
|
||||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_WWDG_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_wwdg.h"
|
||||
#endif /* HAL_WWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_pcd.h"
|
||||
#endif /* HAL_PCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_HCD_MODULE_ENABLED
|
||||
#include "stm32f4xx_hal_hcd.h"
|
||||
#endif /* HAL_HCD_MODULE_ENABLED */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr: If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F4xx_HAL_CONF_H */
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -16,7 +16,7 @@
|
|||
#define MICROPY_HW_ENABLE_RTC (1)
|
||||
#define MICROPY_HW_ENABLE_TIMER (1)
|
||||
#define MICROPY_HW_ENABLE_SERVO (0)
|
||||
#define MICROPY_HW_ENABLE_DAC (0)
|
||||
#define MICROPY_HW_ENABLE_DAC (1)
|
||||
#define MICROPY_HW_ENABLE_CAN (1)
|
||||
|
||||
// HSE is 25MHz
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
/* #define HAL_CEC_MODULE_ENABLED */
|
||||
/* #define HAL_CRC_MODULE_ENABLED */
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
/* #define HAL_DAC_MODULE_ENABLED */
|
||||
#define HAL_DAC_MODULE_ENABLED
|
||||
/* #define HAL_DCMI_MODULE_ENABLED */
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
/* #define HAL_DMA2D_MODULE_ENABLED */
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* This file is part of the Micro Python 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.
|
||||
*/
|
||||
|
||||
#include "py/nlr.h"
|
||||
#include "py/obj.h"
|
||||
#include "lib/mp-readline/readline.h"
|
||||
|
||||
STATIC mp_obj_t mp_builtin_input(uint n_args, const mp_obj_t *args) {
|
||||
if (n_args == 1) {
|
||||
mp_obj_print(args[0], PRINT_STR);
|
||||
}
|
||||
vstr_t line;
|
||||
vstr_init(&line, 16);
|
||||
int ret = readline(&line, "");
|
||||
if (line.len == 0 && ret == CHAR_CTRL_D) {
|
||||
nlr_raise(mp_obj_new_exception(&mp_type_EOFError));
|
||||
}
|
||||
return mp_obj_new_str_from_vstr(&mp_type_str, &line);
|
||||
}
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input);
|
|
@ -87,6 +87,7 @@
|
|||
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
|
||||
#define MICROPY_PY_BUILTINS_COMPILE (1)
|
||||
#define MICROPY_PY_BUILTINS_EXECFILE (1)
|
||||
#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
|
||||
|
@ -159,7 +160,6 @@
|
|||
|
||||
// extra built in names to add to the global namespace
|
||||
#define MICROPY_PORT_BUILTINS \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
|
||||
|
||||
// extra built in modules to add to the list of known ones
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
#define FLASH_MEM_SEG2_NUM_BLOCKS (128) // sector 11: 128k
|
||||
#endif
|
||||
|
||||
#elif defined(STM32F401xE) || defined(STM32F411xE)
|
||||
#elif defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
|
||||
|
||||
STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k
|
||||
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
mp_uint_t pyb_usb_flags = 0;
|
||||
|
||||
#ifdef USE_DEVICE_MODE
|
||||
USBD_HandleTypeDef hUSBDDevice;
|
||||
STATIC USBD_HandleTypeDef hUSBDDevice;
|
||||
pyb_usb_storage_medium_t pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_NONE;
|
||||
#endif
|
||||
|
||||
|
@ -568,7 +568,7 @@ STATIC mp_obj_t pyb_usb_hid_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_
|
|||
mp_obj_t o_ret = pyb_buf_get_for_recv(vals[0].u_obj, &vstr);
|
||||
|
||||
// receive the data
|
||||
int ret = USBD_HID_Rx((uint8_t*)vstr.buf, vstr.len, vals[1].u_int);
|
||||
int ret = USBD_HID_Rx(&hUSBDDevice, (uint8_t*)vstr.buf, vstr.len, vals[1].u_int);
|
||||
|
||||
// return the received data
|
||||
if (o_ret != MP_OBJ_NULL) {
|
||||
|
|
|
@ -47,7 +47,6 @@ typedef enum {
|
|||
} USB_PHY_ID;
|
||||
|
||||
extern mp_uint_t pyb_usb_flags;
|
||||
extern struct _USBD_HandleTypeDef hUSBDDevice;
|
||||
extern pyb_usb_storage_medium_t pyb_usb_storage_medium;
|
||||
extern const struct _mp_obj_tuple_t pyb_usb_hid_mouse_obj;
|
||||
extern const struct _mp_obj_tuple_t pyb_usb_hid_keyboard_obj;
|
||||
|
|
|
@ -82,10 +82,10 @@ static uint8_t UserTxBufPtrWaitCount = 0; // used to implement a timeout waiting
|
|||
static uint8_t UserTxNeedEmptyPacket = 0; // used to flush the USB IN endpoint if the last packet was exactly the endpoint packet size
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static int8_t CDC_Itf_Init (void);
|
||||
static int8_t CDC_Itf_Init (USBD_HandleTypeDef *pdev);
|
||||
static int8_t CDC_Itf_DeInit (void);
|
||||
static int8_t CDC_Itf_Control (uint8_t cmd, uint8_t* pbuf, uint16_t length);
|
||||
static int8_t CDC_Itf_Receive (uint8_t* pbuf, uint32_t *Len);
|
||||
static int8_t CDC_Itf_Receive (USBD_HandleTypeDef *pdev, uint8_t* pbuf, uint32_t *Len);
|
||||
|
||||
const USBD_CDC_ItfTypeDef USBD_CDC_fops = {
|
||||
CDC_Itf_Init,
|
||||
|
@ -102,7 +102,7 @@ const USBD_CDC_ItfTypeDef USBD_CDC_fops = {
|
|||
* @param None
|
||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t CDC_Itf_Init(void)
|
||||
static int8_t CDC_Itf_Init(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
#if 0
|
||||
/*##-1- Configure the UART peripheral ######################################*/
|
||||
|
@ -141,8 +141,8 @@ static int8_t CDC_Itf_Init(void)
|
|||
#endif
|
||||
|
||||
/*##-5- Set Application Buffers ############################################*/
|
||||
USBD_CDC_SetTxBuffer(&hUSBDDevice, UserTxBuffer, 0);
|
||||
USBD_CDC_SetRxBuffer(&hUSBDDevice, cdc_rx_packet_buf);
|
||||
USBD_CDC_SetTxBuffer(pdev, UserTxBuffer, 0);
|
||||
USBD_CDC_SetRxBuffer(pdev, cdc_rx_packet_buf);
|
||||
|
||||
cdc_rx_buf_put = 0;
|
||||
cdc_rx_buf_get = 0;
|
||||
|
@ -288,9 +288,9 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
|
|||
|
||||
buffptr = UserTxBufPtrOutShadow;
|
||||
|
||||
USBD_CDC_SetTxBuffer(&hUSBDDevice, (uint8_t*)&UserTxBuffer[buffptr], buffsize);
|
||||
USBD_CDC_SetTxBuffer(hpcd->pData, (uint8_t*)&UserTxBuffer[buffptr], buffsize);
|
||||
|
||||
if (USBD_CDC_TransmitPacket(&hUSBDDevice) == USBD_OK) {
|
||||
if (USBD_CDC_TransmitPacket(hpcd->pData) == USBD_OK) {
|
||||
UserTxBufPtrOutShadow += buffsize;
|
||||
if (UserTxBufPtrOutShadow == APP_TX_DATA_SIZE) {
|
||||
UserTxBufPtrOutShadow = 0;
|
||||
|
@ -317,7 +317,7 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
|
|||
* @note The buffer we are passed here is just cdc_rx_packet_buf, so we are
|
||||
* free to modify it.
|
||||
*/
|
||||
static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
|
||||
static int8_t CDC_Itf_Receive(USBD_HandleTypeDef *pdev, uint8_t* Buf, uint32_t *Len) {
|
||||
#if 0
|
||||
// this sends the data over the UART using DMA
|
||||
HAL_UART_Transmit_DMA(&UartHandle, Buf, *Len);
|
||||
|
@ -339,8 +339,8 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
|
|||
}
|
||||
|
||||
// initiate next USB packet transfer
|
||||
USBD_CDC_SetRxBuffer(&hUSBDDevice, cdc_rx_packet_buf);
|
||||
USBD_CDC_ReceivePacket(&hUSBDDevice);
|
||||
USBD_CDC_SetRxBuffer(pdev, cdc_rx_packet_buf);
|
||||
USBD_CDC_ReceivePacket(pdev);
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ static uint32_t last_read_len = 0; // length of last read
|
|||
static int8_t current_write_buffer = 0; // which buffer to write to
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static int8_t HID_Itf_Init (void);
|
||||
static int8_t HID_Itf_Receive (uint8_t* pbuf, uint32_t Len);
|
||||
static int8_t HID_Itf_Init (USBD_HandleTypeDef *pdev);
|
||||
static int8_t HID_Itf_Receive (USBD_HandleTypeDef *pdev, uint8_t* pbuf, uint32_t Len);
|
||||
|
||||
const USBD_HID_ItfTypeDef USBD_HID_fops = {
|
||||
HID_Itf_Init,
|
||||
|
@ -65,12 +65,12 @@ const USBD_HID_ItfTypeDef USBD_HID_fops = {
|
|||
* @param None
|
||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t HID_Itf_Init(void)
|
||||
static int8_t HID_Itf_Init(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
current_read_buffer = 0;
|
||||
last_read_len = 0;
|
||||
current_write_buffer = 0;
|
||||
USBD_HID_SetRxBuffer(&hUSBDDevice, buffer[current_write_buffer]);
|
||||
USBD_HID_SetRxBuffer(pdev, buffer[current_write_buffer]);
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
@ -83,14 +83,14 @@ static int8_t HID_Itf_Init(void)
|
|||
* @note The buffer we are passed here is just UserRxBuffer, so we are
|
||||
* free to modify it.
|
||||
*/
|
||||
static int8_t HID_Itf_Receive(uint8_t* Buf, uint32_t Len) {
|
||||
static int8_t HID_Itf_Receive(USBD_HandleTypeDef *pdev, uint8_t* Buf, uint32_t Len) {
|
||||
current_write_buffer = !current_write_buffer;
|
||||
last_read_len = Len;
|
||||
// initiate next USB packet transfer, to append to existing data in buffer
|
||||
USBD_HID_SetRxBuffer(&hUSBDDevice, buffer[current_write_buffer]);
|
||||
USBD_HID_ReceivePacket(&hUSBDDevice);
|
||||
USBD_HID_SetRxBuffer(pdev, buffer[current_write_buffer]);
|
||||
USBD_HID_ReceivePacket(pdev);
|
||||
// Set NAK to indicate we need to process read buffer
|
||||
USBD_HID_SetNAK(&hUSBDDevice);
|
||||
USBD_HID_SetNAK(pdev);
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ int USBD_HID_RxNum(void) {
|
|||
|
||||
// timout in milliseconds.
|
||||
// Returns number of bytes read from the device.
|
||||
int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout) {
|
||||
int USBD_HID_Rx(USBD_HandleTypeDef *pdev, uint8_t *buf, uint32_t len, uint32_t timeout) {
|
||||
// Wait until we have buffer to read
|
||||
uint32_t start = HAL_GetTick();
|
||||
while (current_read_buffer == current_write_buffer) {
|
||||
|
@ -127,7 +127,7 @@ int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout) {
|
|||
current_read_buffer = !current_read_buffer;
|
||||
|
||||
// Clear NAK to indicate we are ready to read more data
|
||||
USBD_HID_ClearNAK(&hUSBDDevice);
|
||||
USBD_HID_ClearNAK(pdev);
|
||||
|
||||
// Success, return number of bytes read
|
||||
return last_read_len;
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
extern const USBD_HID_ItfTypeDef USBD_HID_fops;
|
||||
|
||||
int USBD_HID_RxNum(void);
|
||||
int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout);
|
||||
int USBD_HID_Rx(USBD_HandleTypeDef *pdev, uint8_t *buf, uint32_t len, uint32_t timeout);
|
||||
|
|
|
@ -28,10 +28,10 @@ typedef struct {
|
|||
} USBD_CDC_LineCodingTypeDef;
|
||||
|
||||
typedef struct _USBD_CDC_Itf {
|
||||
int8_t (* Init) (void);
|
||||
int8_t (* Init) (USBD_HandleTypeDef *pdev);
|
||||
int8_t (* DeInit) (void);
|
||||
int8_t (* Control) (uint8_t, uint8_t * , uint16_t);
|
||||
int8_t (* Receive) (uint8_t *, uint32_t *);
|
||||
int8_t (* Receive) (USBD_HandleTypeDef *pdev, uint8_t *, uint32_t *);
|
||||
} USBD_CDC_ItfTypeDef;
|
||||
|
||||
typedef struct {
|
||||
|
@ -48,8 +48,8 @@ typedef struct {
|
|||
} USBD_CDC_HandleTypeDef;
|
||||
|
||||
typedef struct _USBD_HID_Itf {
|
||||
int8_t (* Init) (void);
|
||||
int8_t (* Receive)(uint8_t *, uint32_t);
|
||||
int8_t (* Init) (USBD_HandleTypeDef *pdev);
|
||||
int8_t (* Receive)(USBD_HandleTypeDef *pdev, uint8_t *, uint32_t);
|
||||
} USBD_HID_ItfTypeDef;
|
||||
|
||||
typedef struct _USBD_STORAGE {
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
#define SCSI_MODE_SENSE6 0x1A
|
||||
#define SCSI_MODE_SENSE10 0x5A
|
||||
#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1E
|
||||
#define SCSI_SYNCHRONIZE_CACHE10 0x35
|
||||
#define SCSI_SYNCHRONIZE_CACHE16 0x91
|
||||
#define SCSI_READ6 0x08
|
||||
#define SCSI_READ10 0x28
|
||||
#define SCSI_READ12 0xA8
|
||||
|
|
|
@ -669,7 +669,7 @@ static uint8_t USBD_CDC_MSC_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) {
|
|||
CDC_CMD_PACKET_SIZE);
|
||||
|
||||
// Init physical Interface components
|
||||
CDC_fops->Init();
|
||||
CDC_fops->Init(pdev);
|
||||
|
||||
// Init Xfer states
|
||||
CDC_ClassData.TxState =0;
|
||||
|
@ -724,7 +724,7 @@ static uint8_t USBD_CDC_MSC_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) {
|
|||
USBD_EP_TYPE_INTR,
|
||||
mps_out);
|
||||
|
||||
HID_fops->Init();
|
||||
HID_fops->Init(pdev);
|
||||
|
||||
// Prepare Out endpoint to receive next packet
|
||||
USBD_LL_PrepareReceive(pdev, hid_out_ep, HID_ClassData.RxBuffer, mps_out);
|
||||
|
@ -963,7 +963,7 @@ static uint8_t USBD_CDC_MSC_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
|
||||
/* USB data will be immediately processed, this allow next USB traffic being
|
||||
NAKed till the end of the application Xfer */
|
||||
CDC_fops->Receive(CDC_ClassData.RxBuffer, &CDC_ClassData.RxLength);
|
||||
CDC_fops->Receive(pdev, CDC_ClassData.RxBuffer, &CDC_ClassData.RxLength);
|
||||
|
||||
return USBD_OK;
|
||||
} else if ((usbd_mode & USBD_MODE_MSC) && epnum == (MSC_OUT_EP & 0x7f)) {
|
||||
|
@ -971,7 +971,7 @@ static uint8_t USBD_CDC_MSC_HID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
return USBD_OK;
|
||||
} else if ((usbd_mode & USBD_MODE_HID) && epnum == (hid_out_ep & 0x7f)) {
|
||||
HID_ClassData.RxLength = USBD_LL_GetRxDataSize(pdev, epnum);
|
||||
HID_fops->Receive(HID_ClassData.RxBuffer, HID_ClassData.RxLength);
|
||||
HID_fops->Receive(pdev, HID_ClassData.RxBuffer, HID_ClassData.RxLength);
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
|
|
|
@ -89,6 +89,7 @@ static int8_t SCSI_StartStopUnit(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||
static int8_t SCSI_AllowMediumRemoval(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_SynchronizeCache(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||
static int8_t SCSI_Write10(USBD_HandleTypeDef *pdev, uint8_t lun , uint8_t *params);
|
||||
static int8_t SCSI_Read10(USBD_HandleTypeDef *pdev, uint8_t lun , uint8_t *params);
|
||||
static int8_t SCSI_Verify10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params);
|
||||
|
@ -151,6 +152,10 @@ int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev,
|
|||
case SCSI_MODE_SENSE10:
|
||||
return SCSI_ModeSense10 (pdev, lun, params);
|
||||
|
||||
case SCSI_SYNCHRONIZE_CACHE10:
|
||||
case SCSI_SYNCHRONIZE_CACHE16:
|
||||
return SCSI_SynchronizeCache(pdev, lun, params);
|
||||
|
||||
case SCSI_READ_FORMAT_CAPACITIES:
|
||||
return SCSI_ReadFormatCapacity(pdev, lun, params);
|
||||
|
||||
|
@ -374,6 +379,13 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int8_t SCSI_SynchronizeCache(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params) {
|
||||
// nothing to synchronize, so just return "success"
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = pdev->pClassData;
|
||||
hmsc->bot_data_length = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SCSI_RequestSense
|
||||
* Process Request Sense command
|
||||
|
|
|
@ -93,7 +93,6 @@ SRC_C = \
|
|||
|
||||
STM_SRC_C = $(addprefix stmhal/,\
|
||||
gccollect.c \
|
||||
input.c \
|
||||
irq.c \
|
||||
pin.c \
|
||||
pin_named_pins.c \
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
|
||||
#define MICROPY_OPT_COMPUTED_GOTO (1)
|
||||
|
||||
#define MICROPY_PY_BUILTINS_INPUT (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP (1)
|
||||
#define MICROPY_PY_BUILTINS_HELP_TEXT teensy_help_text
|
||||
|
||||
|
@ -31,7 +32,6 @@
|
|||
|
||||
// extra built in names to add to the global namespace
|
||||
#define MICROPY_PORT_BUILTINS \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
|
||||
|
||||
// extra built in modules to add to the list of known ones
|
||||
extern const struct _mp_obj_module_t os_module;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
a = array.array('B', [1, 2, 3])
|
||||
print(a, len(a))
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
a1 = array.array('I', [1])
|
||||
a2 = array.array('I', [2])
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# tuple, list
|
||||
print(array('b', (1, 2)))
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# construct from something with unknown length (requires generators)
|
||||
print(array('i', (i for i in range(10))))
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# raw copy from bytes, bytearray
|
||||
print(array('h', b'12'))
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
try:
|
||||
from array import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(array('L', [0, 2**32-1]))
|
||||
print(array('l', [-2**31, 0, 2**31-1]))
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
import array
|
||||
except ImportError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# arrays of objects
|
||||
a = array.array('O')
|
||||
|
|
|
@ -8,9 +8,8 @@ t = sys.implementation
|
|||
try:
|
||||
t.name
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
|
||||
# test printing of attrtuple
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
delattr
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
class A: pass
|
||||
a = A()
|
||||
|
|
|
@ -4,8 +4,7 @@ try:
|
|||
help
|
||||
except NameError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
help() # no args
|
||||
help(help) # help for a function
|
||||
|
|
|
@ -3,9 +3,8 @@ try:
|
|||
min
|
||||
max
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(min(0,1))
|
||||
print(min(1,0))
|
||||
|
|
|
@ -6,9 +6,8 @@ import builtins
|
|||
try:
|
||||
builtins.abs = lambda x: x + 1
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(abs(1))
|
||||
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
try:
|
||||
print(pow(3, 4, 7))
|
||||
except NotImplementedError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# 3 arg pow is defined to only work on integers
|
||||
try:
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
try:
|
||||
print(pow(3, 4, 7))
|
||||
except NotImplementedError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
print(pow(555557, 1000002, 1000003))
|
||||
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
try:
|
||||
property
|
||||
except:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# create a property object explicitly
|
||||
property()
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
try:
|
||||
range(0).start
|
||||
except AttributeError:
|
||||
import sys
|
||||
print("SKIP")
|
||||
sys.exit()
|
||||
raise SystemExit
|
||||
|
||||
# attrs
|
||||
print(range(1, 2, 3).start)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue