Commit Graph

129 Commits

Author SHA1 Message Date
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
Damien George daa1a455c6 stmhal: Remove custom mod_machine_mem_get_{read,write}_addr functions.
They are no longer needed because stm constants can now be 32 bits wide.
2016-01-07 16:34:11 +00:00
Dave Hylands b61336483b stmhal: Add mem8/mem16/mem32 operations to machine module.
This uses the newly factored machine_mem functions.
2015-12-19 01:05:44 +00:00
Paul Sokolovsky 0e1b5faad5 stmhal, cc3200: Actually implement machine -> umachine module weak link. 2015-12-18 22:22:43 +02:00
Paul Sokolovsky 2eb844e0b4 ports: Rename "machine" module to "umachine".
To let unix port implement "machine" functionality on Python level, and
keep consistent naming in other ports (baremetal ports will use magic
module "symlinking" to still load it on "import machine").

Fixes #1701.
2015-12-18 02:39:52 +02:00
neilh10 1be0fde45c stmhal: Enable two USB phys to be supported together.
This is refactoring to enable support for the two USB PHYs available on
some STM32F4 processors to be used at the same time. The F405/7 & F429
have two USB PHYs, others such as the F411 only have one PHY.

This has been tested separately on a pyb10 (USB_FS PHY) and F429DISC
(USB_HS PHY) to be able to invoke a REPL/USB.  I have modified a PYBV10
to support two PHYs.

The long term objective is to support a 2nd USB PHY to be brought up as a
USB HOST, and possibly a single USB PHY to be OTG.
2015-12-09 09:56:36 +00:00
Paul Sokolovsky f0fbab7ca7 extmod/fsusermount: Make configurable with MICROPY_FSUSERMOUNT. 2015-11-25 13:19:36 +02:00
Alex March 748509a93c stmhal: FatFS configuration moved to the library folder.
Port specific settings defined in mpconfigport.
2015-11-08 22:21:17 +00:00
Damien George 731f359292 all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
2015-10-31 19:14:30 +03:00
Damien George 9d0192de4a stmhal: Enable "all special methods" configuration option. 2015-10-20 23:55:27 +01:00