Commit Graph

1092 Commits

Author SHA1 Message Date
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
Pavol Rusnak b82fc8dcef
stmhal: fix wrong usage of gcc -print-libgcc-file-name 2017-01-12 20:32:43 +01:00
Dave Hylands aa53496391 stmhal: Support PortG on STM32L476 and STM32L486. 2017-01-12 17:27:28 +11:00
Paul Sokolovsky eac22e29a5 all: Consistently update signatures of .make_new and .call methods.
Otherwise, they serve reoccurring source of copy-paste mistakes and
breaking nanbox build.
2017-01-04 16:10:42 +03:00
Damien George e81116d07d stmhal/uart: Increase inter-character timeout by 1ms.
Sys-tick resolution is 1ms and a value of 2 will give a delay between 1ms
and 2ms (whereas a value of 1 gives a delay between 0ms and 1ms, which is
too short).
2016-12-28 17:32:18 +11:00
Damien George 16a584d7cf stmhal/uart: Provide a custom function to transmit over UART.
The HAL_UART_Transmit function has changed in the latest HAL version such
that the Timeout is a timeout for the entire function, rather than a
timeout between characters as it was before.  The HAL function also does
not allow one to reliably tell how many characters were sent before the
timeout (if a timeout occurred).

This patch provides a custom function to do UART transmission, completely
replacing the HAL version, to fix the above-mentioned issues.
2016-12-28 17:18:59 +11:00
Paul Sokolovsky 1328833663 stmhal, esp8266: Enable utimeq module. 2016-12-23 14:49:13 +03:00
sergiuszm ea426dd9ef stmhal: Add support for STM32 Nucleo64 L476RG. 2016-12-22 17:45:50 +11:00
Damien George e202b6f586 stmhal/sdcard: Use mp_hal_pin_config function instead of HAL_GPIO_Init.
There is a minor functional change with this patch, that the GPIO are now
configured in fast mode, whereas they were in high speed mode before.  But
the SDIO should still work because SD CK frequency is at most 25MHz.
2016-12-22 14:55:26 +11:00
Damien George ed559de063 stmhal/led: Use mp_hal_pin_config function instead of HAL_GPIO_Init. 2016-12-22 14:55:26 +11:00