Commit Graph

1101 Commits

Author SHA1 Message Date
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
12d0731b91 extmod/vfs_fat: Remove obsolete and unused str/len members. 2017-03-10 19:09:42 +11:00
Damien George
8236d18338 stmhal/main: Allocate flash's VFS struct on the heap to trace root ptrs. 2017-03-10 19:02:20 +11:00
Damien George
4351d16e62 stmhal/mphalport: Get ticks_cpu() working on F7 MCUs. 2017-03-10 14:58:26 +11:00
Damien George
4f3c1b3fc1 stmhal/modnwcc3k: Add include for mp_hal_delay_ms. 2017-03-02 16:17:34 +11:00
Damien George
78185e6a6c stmhal/modpyb: Use utime ticks ms/us functions instead of custom ones. 2017-03-02 15:43:14 +11:00
Damien George
89738e8240 stmhal: Rename sys_tick ticks/delay functions to corresp. mp_hal ones.
The renames are:
HAL_Delay -> mp_hal_delay_ms
sys_tick_udelay -> mp_hal_delay_us
sys_tick_get_microseconds -> mp_hal_ticks_us

And mp_hal_ticks_ms is added to provide the full set of timing functions.

Also, a separate HAL_Delay function is added which differs slightly from
mp_hal_delay_ms and is intended for use only by the ST HAL functions.
2017-03-02 15:32:32 +11:00
Damien George
6ab5512132 stmhal: Use mp_hal_delay_ms instead of HAL_Delay. 2017-03-02 15:02:57 +11:00
Damien George
c9b0f0b248 stmhal/main: Remove unnecessary header includes. 2017-02-17 13:07:42 +11:00
Damien George
ae8d867586 py: Add iter_buf to getiter type method.
Allows to iterate over the following without allocating on the heap:
- tuple
- list
- string, bytes
- bytearray, array
- dict (not dict.keys, dict.values, dict.items)
- set, frozenset

Allows to call the following without heap memory:
- all, any, min, max, sum

TODO: still need to allocate stack memory in bytecode for iter_buf.
2017-02-16 18:38:06 +11:00
Damien George
e5cc681cb1 stmhal: Use generic interrupt char code. 2017-02-15 16:39:30 +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
Johannes Wågen
f92f7dd2bc stmhal/boards: For STM32F411DISC, change I2C pin according to datasheet.
The pin had to be changed to get the I2C sensors on board to work.
2017-02-13 11:32:27 +11:00
Damien George
7ae9bee790 stmhal/Makefile: Drop use of -mabi=aapcs-linux; link libgcc by default.
The aapcs-linux ABI is not required, instead the default aapcs ABI is
enough.  And using the default ABI means that the provided libgcc will now
link with the firmware without warnings about variable vs fixed enums.

Although the binary size increases by about 1k, RAM usage is slightly
decreased.  And libgcc may prove useful in the future for things like
long-long division.
2017-02-08 11:50:22 +11:00
Damien George
9779c99317 stmhal: Add ability to skip booting from SD card via /flash/SKIPSD file. 2017-02-07 12:35:39 +11:00
Damien George
8400351d5a stmhal: Use MICROPY_EVENT_POLL_HOOK instead of __WFI where appropriate. 2017-02-06 15:10:03 +11:00
Damien George
27c149efe0 stmhal: Add pyb.fault_debug() function, to control hard-fault behaviour.
This new function controls what happens on a hard-fault:
- debugging disabled: board will do a reset
- debugging enabled: board will print registers and stack and flash LEDs

The default is disabled, ie to do a reset.  This is different to previous
behaviour which flashed the LEDs and waited indefinitely.
2017-02-06 13:22:17 +11:00
Damien George
bffda45154 stmhal: On HardFault, print stack pointer and do a stack dump. 2017-02-06 13:22:17 +11:00
Damien George
904732cdc9 stmhal/mpconfigport.h: Enable MICROPY_PY_BUILTINS_POW3 option. 2017-02-03 12:39:33 +11:00
Damien George
8e00844929 stmhal: Fix build issue when MICROPY_PY_THREAD is disabled. 2017-01-31 19:52:50 +11:00
Damien George
00e7176624 stmhal/main: Use _estack value to initialise stack extents. 2017-01-31 18:43:46 +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
a6386f74b8 stmhal/pendsv: Fill in comments about what the stack contains. 2017-01-31 13:58:34 +11:00
Damien George
7d8c79ab6d stmhal/main: Guard init_sdcard_fs with MICROPY_HW_HAS_SDCARD. 2017-01-31 13:04:32 +11:00
Damien George
e0381424cc stmhal/modmachine: Add machine.Signal type. 2017-01-31 12:36:20 +11:00
Damien George
e24e03b415 stmhal/pin: Add C-level pin ioctl method. 2017-01-31 12:36:04 +11:00
Damien George
80dfd65090 stmhal/main: Put /sd directory before /flash in sys.path.
If the SD card is mounted then its libraries (ie those that are imported)
should override any in /flash.
2017-01-31 12:30:18 +11:00
Damien George
3667ee1b88 stmhal: On boot, mount all available partitions of the SD card.
The first partition is mounted as "/sd" and subsequent partitions are
mounted as "/sd<part_num>".  This is backwards compatible with the previous
behaviour, which just mounted the first partition on "/sd".

At this point, only FatFs filesystems are mounted.
2017-01-31 12:18:08 +11:00
Damien George
326343feeb stmhal/README: Add paragraph about building mpy-cross. 2017-01-31 09:32:31 +11:00
Damien George
6b12934fec stmhal: Fix stack pointer initialisation for F411 and F429 boards.
The stack pointer should start pointing 1 byte past the top of the end of
RAM.
2017-01-30 17:47:11 +11:00
Damien George
a526352454 stmhal: Set the FatFs partition number when initialising VFS object.
stmhal has MULTI_PARTITION enabled for FatFs and so these values need to be
initialised.
2017-01-30 13:02:10 +11:00
Damien George
220abca311 stmhal: Use LED constants from PYBv4 onwards. 2017-01-30 13:01:21 +11:00
Damien George
b697c89009 extmod: Merge old fsusermount.h header into vfs.h and vfs_fat.h.
vfs.h is for generic VFS declarations, and vfs_fat.h is for VfsFat
specific things.
2017-01-30 12:26:08 +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
9d3ad75b39 stmhal/moduos: Remove duplicated chdir. 2017-01-29 15:10:09 +11:00
Damien George
c3cd46e5c2 stmhal: Fix name of automatically created boot.py. 2017-01-29 15:09:36 +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
3242cf2d36 stmhal/usbd_msc_storage: Use storage functions instead of disk ones. 2017-01-27 23:22:15 +11:00
Damien George
6c23c7587f extmod/vfs: Add ability for VFS sub-system to import using VfsFat. 2017-01-27 17:21:45 +11:00
Damien George
32a1138b9f extmod: Rename vfs_fat_file.h to vfs_fat.h.
And move declaration of mp_fat_vfs_type to this file.
2017-01-27 15:04:17 +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
f8a022bc11 stmhal/boards/STM32L476DISC: Use external SPI flash for filesystem. 2017-01-24 17:01:53 +11:00
Damien George
d6a2d00167 stmhal: Add ability to have filesystem stored on external SPI flash.
To use this feature a port should define MICROPY_HW_SPIFLASH_SIZE_BITS
along with x_CS, x_SCK, x_MOSI, x_MISO (x=MICROPY_HW_SPIFLASH).  This will
then use external SPI flash on those pins instead of the internal flash.

The SPI is done using the software implementation.  There is currently only
support for standard SPI (ie not dual or quad mode).
2017-01-24 16:58:50 +11:00
Pavol Rusnak
bdcca42390 stmhal: Fix examples in openocd configs to include addresses. 2017-01-24 00:34:36 +11:00
Damien George
cffe00d6ab stmhal: Add default frozen-bytecode directory and link lcd160cr driver.
stmhal will now be built by default with frozen bytecode from scripts
stored in the stmhal/modules/ directory.  This can be disabled or
changed to another directory by overridding the make variable
FROZEN_MPY_DIR.
2017-01-23 14:37:49 +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
Pavol Rusnak
0883a7e72f stmhal: Implement SNAK/CNAK mechanism for USB HID receive.
This implements flow control in case user does not call recv method often
enough (it tells host side to stop sending more data).
2017-01-19 12:35:09 +11:00
Pavol Rusnak
6ace84b089 stmhal: Implement ioctl for USB HID read. 2017-01-19 12:34:58 +11:00
Pavol Rusnak
89f2b62016 stmhal: Fix USB HID receive not receiving the first packet. 2017-01-19 12:34:45 +11:00