Wykres commitów

138 Commity (parse-bytecode)

Autor SHA1 Wiadomość Data
Damien George 4ec803a42a all: Make static dicts use mp_rom_map_elem_t type and MP_ROM_xxx macros. 2017-08-21 21:34:23 +10:00
Alexander Steffen 299bc62586 all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.

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

The rules are as follows.

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

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

py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-07-18 11:57:39 +10:00
Damien George f1d260d878 stmhal: Reduce size of ESPRUINO_PICO build so it fits in flash.
The default frozen modules are no longer included (but users can still
specify their own via FROZEN_MPY_DIR), complex numbers are disabled and so
are the native, viper and asm_thumb emitters.  Users needing these features
can tune the build to disable other things.
2017-07-12 12:51:37 +10:00
Damien George 346f5d4cce stmhal/mpconfigport.h: Allow MICROPY_PY_THREAD to be overridden. 2017-06-28 15:45:04 +10:00
Damien George ebfdd96cb2 stmhal: Add possibility to build with double-precision floating point.
By default the firmware is built with single-precision floating point.
To build a particular board using double precision instead, put the
following line in the mpconfigboard.mk file:

    FLOAT_IMPL = double
2017-06-28 15:12:04 +10:00
Damien George b19138e82e stmhal: Make available the _onewire module, for low-level bus control. 2017-06-22 16:20:22 +10:00
Damien George c064f0a36a stmhal/mpconfigport.h: Remove config of PY_THREAD_GIL to use default.
The default for the GIL is to enable it if threading is enabled, and this
is the recommended way to use threading with the stmhal port.
2017-06-14 14:47:53 +10:00
Damien George 6ff0ecfffc ports: Convert from using stmhal's input() to core provided version. 2017-06-01 16:02:49 +10:00
Damien George 03053f82db mpy-cross, unix, windows, stmhal: Enable return-if-else optimisation.
Prior to making this a config option it was previously available on these
(and all other) ports, and it makes sense to keep it enabled for mpy-cross
as well as ports that have a decent amount of space for the code.
2017-04-22 15:12:48 +10:00
Damien George 9156c8b460 stmhal: Enable parsing of all Pin constructor args by machine.Signal. 2017-04-11 13:12:54 +10:00
Damien George 4c307bfba1 all: Move BYTES_PER_WORD definition from ports to py/mpconfig.h
It can still be overwritten by a port in mpconfigport.h but for almost
all cases one can use the provided default.
2017-04-01 11:39:38 +11:00
Damien George a5159edc20 stmhal: Enable micropython.schedule().
ExtInt, Timer and CAN IRQ callbacks are made to work with the scheduler.
They are still hard IRQs by default, but one can now call
micropython.schedule within the hard IRQ to schedule a soft callback.
2017-03-20 15:20:26 +11:00
Damien George 05a4859585 stmhal: Implement a proper thread scheduler.
This patch changes the threading implementation from simple round-robin
with busy waits on mutexs, to proper scheduling whereby threads that are
waiting on a mutex are only scheduled when the mutex becomes available.
2017-02-15 13:28:48 +11:00
Damien George 904732cdc9 stmhal/mpconfigport.h: Enable MICROPY_PY_BUILTINS_POW3 option. 2017-02-03 12:39:33 +11:00
Damien George 882ec01e42 stmhal: Initial implementation of multithreading, currently disabled.
This patch brings the _thread module to stmhal/pyboard.  There is a very
simple round-robin thread scheduler, which is disabled if there is only
one thread (for efficiency when threading is not used).

The scheduler currently switches threads at a rate of 250Hz using the
systick timer and the pend-SV interrupt.

The GIL is disabled so one must be careful to use lock objects to prevent
concurrent access of objects.

The threading is disabled by default, one can enabled it with the config
option MICROPY_PY_THREAD to test it out.
2017-01-31 18:42:35 +11:00
Damien George 0bd61d23b9 extmod/vfs_fat: Remove MICROPY_FATFS_OO config option.
Everyone should now be using the new ooFatFs library.  The old one is no
longer supported and will be removed.
2017-01-30 12:26:07 +11:00
Damien George 84c614e729 stmhal: Convert to use VFS sub-system and new ooFatFs component.
This patch makes the following configuration changes:
- MICROPY_FSUSERMOUNT is disabled, removing old mounting infrastructure
- MICROPY_VFS is enabled, giving new VFS sub-system
- MICROPY_VFS_FAT is enabled, giving uos.VfsFat type
- MICROPY_FATFS_OO is enabled, to use new ooFatFs lib, R0.12b

User facing API should be almost unchanged.  Most notable changes are
removal of os.mkfs (use os.VfsFat.mkfs instead) and pyb.mount doesn't
allow unmounting by passing None as the device.
2017-01-27 23:22:15 +11:00
Damien George 246f607a92 stmhal/mpconfigport.h: Reorganise the config options into groups.
The order now follows that in py/mpconfig.h and is a bit cleaner and easier
to maintain.  No options were changed/added/removed with this patch, it's
just a reordering.
2017-01-24 23:51:54 +11:00
Damien George c594cf12ed stmhal: Enable help('modules') feature. 2017-01-22 12:30:53 +11:00
Damien George 8678e3edfd stmhal: Convert to use builtin help function. 2017-01-22 11:56:16 +11:00
Paul Sokolovsky 1328833663 stmhal, esp8266: Enable utimeq module. 2016-12-23 14:49:13 +03:00
Damien George a770ba147e stmhal: Use core-provided keyboard exception object. 2016-12-15 15:51:34 +11:00
Damien George f254cfd3c4 stmhal: Rename mp_const_vcp_interrupt to mp_kbd_exception.
mp_kbd_exception is now considered the standard variable name to hold the
singleton KeyboardInterrupt exception.

This patch also moves the creation of this object from pyb_usb_init() to
main().
2016-12-15 12:32:00 +11:00
Damien George 1b02565316 stmhal/mpconfigport: Add weak-module links for io, collections, random. 2016-12-15 11:23:20 +11:00
Damien George 0f408bc1ff stmhal: Move PY_SYS_PLATFORM config from board to general config file.
It can be overridden by a board if needed.
2016-12-13 16:26:45 +11:00
Damien George 1b6d94bccd stmhal: Refactor to use extmod implementation of software SPI class.
This is a pure refactoring (and simplification) of code so that stmhal
uses the software SPI class provided in extmod, for the machine.SPI
implementation.
2016-12-08 13:58:10 +11:00
Damien George 1eb3c66e91 extmod/machine_spi: Provide reusable software SPI class.
So long as a port defines relevant mp_hal_pin_xxx functions (and delay) it
can make use of this software SPI class without the need for additional
code.
2016-12-08 13:47:01 +11:00
Damien George aaab6a9921 stmhal/uart: Add support for UART7 and UART8 on F7 MCUs. 2016-12-05 15:14:22 +11:00
Damien George 2d329c4a56 extmod/moduselect: Use configurable EVENT_POLL_HOOK instead of WFI.
To make moduselect be usable by any port.
2016-12-02 16:40:39 +11:00
Damien George 3053748987 stmhal: Add beginnings of port-specific machine.I2C implementation.
This allows one to construct an I2C object using ids that are specific
to the stmhal port, eg machine.I2C('X').  Right now the implementation
of I2C uses software I2C but the idea is to just change the C-level I2C
protocol functions to hardware implementations later on.
2016-11-24 00:20:51 +11:00
Paul Sokolovsky 8f5bc3ffc0 stmhal/moduselect: Move to extmod/ for reuse by other ports. 2016-11-21 00:05:56 +03:00
Damien George 6b239c271c py: Factor out persistent-code reader into separate files.
Implementations of persistent-code reader are provided for POSIX systems
and systems using FatFS.  Macros to use these are MICROPY_READER_POSIX and
MICROPY_READER_FATFS respectively.  If an alternative implementation is
needed then a port can define the function mp_reader_new_file.
2016-11-16 18:13:50 +11:00
Damien George 48feb8ac6e stmhal: Enable str.center(), str.[r]partition() and builtin compile().
Also adds "machine" to the list of modules that the parser can search for
constants.
2016-10-17 13:17:19 +11:00
Paul Sokolovsky f059563507 stmhal/modutime: Refactor to use extmod/utime_mphal.c.
This includes making sure that utime_mphal's sleep_ms() and sleep_us()
don't sleep on negative arguments.
2016-10-14 20:42:42 +03:00
Damien George 0bb3c7d3b7 stmhal: Enable machine.time_pulse_us() function. 2016-10-06 12:12:20 +11:00
Dave Hylands c08f50bcf7 stmhal: Disable network and usocket for ESPRUINO_PICO 2016-10-06 11:47:45 +11:00
Damien George bd925b59c3 stmhal/spi: Enable use of fast software SPI. 2016-10-04 13:51:30 +11:00
Damien George 49406b0ac6 stmhal/spi: Support new machine SPI methods in legacy SPI object. 2016-09-01 16:40:35 +10:00
Damien George 675d1c9c60 ports: Remove typedef of machine_ptr_t, it's no longer needed.
This type was used only for the typedef of mp_obj_t, which is now defined
by the object representation.  So we can now remove this unused typedef,
to simplify the mpconfigport.h file.
2016-08-15 11:02:59 +10:00
Matt Brejza afd4909a0f stmhal: fixing malloc when used with external libraries 2016-07-30 21:24:35 +03:00
Damien George 5ab98d5c41 stmhal: Convert to use internal errno symbols; enable uerrno module. 2016-05-10 23:30:39 +01:00
Paul Sokolovsky 9b0714b24c py: Declare help, input, open builtins in core.
These are *defined* per-port, but why redeclare them again and again.
2016-04-15 00:07:56 +03:00
Damien George 67a327cb9b stmhal: Enable framebuf module. 2016-04-12 14:06:54 +01:00
Damien George e4f963a351 stmhal: Use new generic I2C object in machine module. 2016-04-12 14:06:54 +01:00
Damien George 476c15290d stmhal: Enabled importing of persistent bytecode (.mpy files). 2016-02-25 10:12:30 +00:00
Paul Sokolovsky 72085a669b py/mpstate.h: fs_user_mount is now standard, reusable uPy functionality. 2016-02-15 00:02:03 +02:00
Damien George b33a770596 extmod/fsusermount: Support mounting of multiple block devices.
This patch adds support to fsusermount for multiple block devices
(instead of just one).  The maximum allowed is fixed at compile time by
the size of the fs_user_mount array accessed via MP_STATE_PORT, which
in turn is set by MICROPY_FATFS_VOLUMES.

With this patch, stmhal (which is still tightly coupled to fsusermount)
is also modified to support mounting multiple devices   And the flash and
SD card are now just two block devices that are mounted at start up if
they exist (and they have special native code to make them more
efficient).
2016-02-10 23:40:10 +00:00
Doug Currie 2e2e15cec2 py/mpz: Complete implementation of mpz_{and,or,xor} for negative args.
For these 3 bitwise operations there are now fast functions for
positive-only arguments, and general functions for arbitrary sign
arguments (the fast functions are the existing implementation).

By default the fast functions are not used (to save space) and instead
the general functions are used for all operations.

Enable MICROPY_OPT_MPZ_BITWISE to use the fast functions for positive
arguments.
2016-02-03 22:13:39 +00:00
Damien George a53af6c875 extmod/modurandom: Add some extra random functions.
Functions added are:
- randint
- randrange
- choice
- random
- uniform

They are enabled with configuration variable
MICROPY_PY_URANDOM_EXTRA_FUNCS, which is disabled by default.  It is
enabled for unix coverage build and stmhal.
2016-01-26 15:27:00 +00:00
Paul Sokolovsky a58a91eb04 extmod/modurandom: Add "urandom" module.
Seedable and reproducible pseudo-random number generator. Implemented
functions are getrandbits(n) (n <= 32) and seed().

The algorithm used is Yasmarang by Ilya Levin:
http://www.literatecode.com/yasmarang
2016-01-17 12:13:01 +02:00