Commit Graph

60 Commits

Author SHA1 Message Date
Scott Shawcroft c7efd2cae9 shared-bindings: Move enum-like classes out of DigitalInOut into digitalio.
Also, rename Direction.IN to Direction.INPUT and Direction.OUT to Direction.OUTPUT.

This simplifies using them. Prior to the nativeio split this would have led to
clutter in the top-level namespace but having digitalio prevents this.

Fixes #152
2017-06-16 13:47:01 -07:00
Scott Shawcroft aaf01481aa Change the approach for input so that its not included in every single build. Put it next to readline instead. 2017-05-25 12:14:42 -07:00
Scott Shawcroft 32a4eb2c53 atmel-samd: Add input support. Fixes #143 2017-05-25 11:55:38 -07:00
Scott Shawcroft 3f5028c666 atmel-samd: Support wav file playback. Tested up to 16bit 22.1khz. Must be mono file!
SD card support may work but likely needs buffer tuning. Its untested.

Fixes #105
2017-05-15 19:52:38 -07:00
Scott Shawcroft 974847ac8d atmel-samd: Add a safe mode which detects hard faults and reboots without running user code again. 2017-05-15 15:29:04 -07:00
Scott Shawcroft 790c38e18c atmel-samd: Rework boot, main and REPL order.
Boot will only run once now before USB is started. Its output goes to
boot_out.txt. After main and REPL will run with VM and hardware resets
between each.
2017-05-12 18:26:14 -07:00
Scott Shawcroft 7672bf7736 atmel-samd: Rename auto-reset to auto-reload to reduce confusion with physical reset buttons. 2017-05-12 16:45:38 -07:00
Scott Shawcroft e1a6f6d584 atmel-samd: Rework SPI flash defines for clarity.
Also add sector protection support for the SAMD Xplained board.
2017-05-12 14:47:39 -07:00
Scott Shawcroft 58b9789d0c atmel-samd: Introduce audio sample playback via audioio.AudioOut. 2017-05-01 13:10:03 -07:00
Scott Shawcroft 939c0045db Switch to a shared piece of code to compute start and length of a
buffer from start, end and length. The old code miscomputed length
leading to writing and reading from memory past the end of the buffer.
Consolidating the code should make it easier to get right everywhere.
2017-04-20 11:24:05 -07:00
Scott Shawcroft 8d0d5defc7 atmel-samd: Use LTO for all builds to get 5000 bytes back on express boards. 2017-04-18 09:44:04 -07:00
Scott Shawcroft 67ec52d7a9 atmel-samd: Swap out pulseio for touchio based on FreeTouch. 2017-04-18 09:44:04 -07:00
Scott Shawcroft f28f8ba568 Split up nativeio.
This was done to allow greatly granularity when deciding what functionality
is built into each board's build. For example, this way pulseio can be
omitted to allow for something else such as touchio.
2017-04-10 13:32:19 -07:00
Scott Shawcroft ff208d7677 Add low-level OneWire support class.
This class focuses on the timing sensitive parts of the protocol.
Everything else will be done by Python code.

This also establishes that its OK to back a nativeio class with a
bitbang implementation when no hardware acceleration exists. When
it does, then bitbangio should be used to explicitly bitbang a
protocol.
2017-03-25 12:04:49 +00:00
Scott Shawcroft 7cb54864aa Add PulseIn support which can be used to measure a series of pulse widths.
This is useful for infrared input and DHT sensors.
2017-03-24 10:30:15 +00:00
Scott Shawcroft d200a62164 Add PulseOut which can pulse a PWMOut for IR remote transmission. 2017-03-10 19:17:54 +01:00
Scott Shawcroft d598c2a919 atmel-samd: Add USB HID mouse and keyboard support. 2017-02-27 15:43:58 +01:00
Scott Shawcroft 062fac1d43 atmel-samd: Use link time optimization to reduce code size of builds which
share space with the file system.

"Express" builds with SPI flash crash the compiler for some reason so its
currently disabled for them.
2017-02-26 01:00:33 +01:00
Scott Shawcroft 48d7fca25e atmel-samd: Fix linking by providing cpu info. 2017-02-24 17:45:33 +01:00
Scott Shawcroft 35071b3681 Make the build quieter by default. 2017-02-24 15:59:59 +01:00
Scott Shawcroft efd429464e atmel-samd: Switch to nano newlib and add size script to build. 2017-02-24 14:55:34 +01:00
Scott Shawcroft e9659e61f8 Switch enum-like attributes to all caps and add print support for them. Make room for this functionality by adding a shared __enter__ function object. #76 2017-02-19 16:11:33 +01:00
Scott Shawcroft cea5503ca0 Fixup warnings from merge about undefined macro values, switch to
VM keyboard exception and switch to FATFS reader.
2017-01-12 12:46:18 -08:00
Scott Shawcroft 427d33c706 atmel-samd: Add help() and remove mem_info functions from smallest builds to make room. 2016-12-19 16:38:35 -08:00
Sebastian Plamauer 1598e44231 atmel-samd: Add preliminary support for UART 2016-12-19 13:03:50 -08:00
Scott Shawcroft af17b64a58 atmel-samd: Add samd module for atmel-samd specific configuration.
Fixes #49
2016-12-13 18:04:50 -08:00
Scott Shawcroft 3972bc19c7 atmel-samd: Basic capacitive touch button support.
Currently only works on a single channel and is only enabled for boards with
SPI flash. Only really designed for hardware testing at this point.
2016-12-12 15:11:25 -08:00
Scott Shawcroft b6f1eebab3 atmel-samd: Add APA102 support and flash more advanced status.
The new sequence is as follows:
* Solid blue during the boot/settings script.
* Solid green during the main/code script.
* After main while waiting to enter repl or reset:
  * Fading green once main is done successfully.
  * On error produce a series of flashes:
    * Long flash color of script.
    * Long flash color of error:
      * Green = IndentationError
      * Cyan = SyntaxError
      * White = NameError
      * Orange = OSError
      * Yellow = Other error
    * Line number of the exception by digit. Number of flashes represents value.
      * Thousands = White
      * Hundreds = Blue
      * Tens = Yellow
      * Ones = Cyan
    * Off for a period and then repeats.

At any point a write to the flash storage will flicker red.

Fixes #63
2016-12-09 19:35:56 -08:00
Scott Shawcroft ea1320bee7 Add uheap for debugging the size of objects. Still not perfect though. 2016-11-22 17:32:28 -08:00
Scott Shawcroft cc412a80ad atmel-samd: Support Trinket and Gemma M0 prototypes. 2016-11-22 12:03:42 -08:00
Scott Shawcroft ccbb5e84f9 This introduces an alternative hardware API called nativeio structured around different functions that are typically accelerated by native hardware. Its not meant to reflect the structure of the hardware.
Docs are here: http://tannewt-micropython.readthedocs.io/en/microcontroller/

It differs from upstream's machine in the following ways:

* Python API is identical across ports due to code structure. (Lives in shared-bindings)
* Focuses on abstracting common functionality (AnalogIn) and not representing structure (ADC).
* Documentation lives with code making it easy to ensure they match.
* Pin is split into references (board.D13 and microcontroller.pin.PA17) and functionality (DigitalInOut).
* All nativeio classes claim underlying hardware resources when inited on construction, support Context Managers (aka with statements) and have deinit methods which release the claimed hardware.
* All constructors take pin references rather than peripheral ids. Its up to the implementation to find hardware or throw and exception.
2016-11-21 14:11:52 -08:00
Scott Shawcroft bd36873362 Merge tag 'v1.8.6'
ESP8266 port uses SDK 2.0, has more heap, has support for 512k devices

This release brings some code size reductions to the core as well as
more tests and improved coverage which is now at 94.3%.

The time.ticks_diff(a, b) function has changed: the order of the arguments
has been swapped so that it behaves like "a - b", and it can now return a
negative number if "a" came before "b" (modulo the period of the ticks
functions).

For the ESP8266 port the Espressif SDK has been updated to 2.0.0, the
heap has been increased from 28k to 36k, and there is support for 512k
devices via "make 512k".  upip is included by default as frozen bytecode.
The network module now allows access-point reconnection without WiFi
credentials, and exposes configuration for the station DHCP hostname.  The
DS18B20 driver now handles negative temperatures, and NeoPixel and APA102
drivers handle 4 bytes-per-pixel LEDs.

For the CC3200 port there is now support for loading of precompiled .mpy
files and threading now works properly with interrupts.

A detailed list of changes follows.

py core:
- py.mk: automatically add frozen.c to source list if FROZEN_DIR is defined
- be more specific with MP_DECLARE_CONST_FUN_OBJ macros
- specialise builtin funcs to use separate type for fixed arg count
- {modbuiltins,obj}: use MP_PYTHON_PRINTER where possible
- modbuiltins: add builtin "slice", pointing to existing slice type
- add "delattr" builtin, conditional on MICROPY_CPYTHON_COMPAT
- sequence: fix reverse slicing of lists
- fix null pointer dereference in mpz.c, fix missing va_end in warning.c
- remove asserts that are always true in emitbc.c
- fix wrong assumption that m_renew will not move if shrinking
- change config default so m_malloc0 uses memset if GC not enabled
- add MICROPY_FLOAT_CONST macro for defining float constants
- move frozen bytecode Makefile rules from ports to common mk files
- strip leading dirs from frozen mpy files, so any path can be used

extmod:
- vfs_fat_file: check fatfs f_sync() and f_close() returns for errors
- vfs_fat_file: make file.close() a no-op if file already closed
- utime_mphal: ticks_diff(): switch arg order, return signed value
- utime_mphal: add MP_THREAD_GIL_EXIT/ENTER warppers for sleep functions
- utime_mphal: implement ticks_add(), add to all maintained ports
- utime_mphal: allow ticks functions period be configurable by a port

lib:
- utils/pyhelp.c: use mp_printf() instead of printf()
- utils/pyexec: add mp_hal_set_interrupt_char() prototype
- libm: move Thumb-specific sqrtf function to separate file

drivers:
- add "from micropython import const" when const is used

tools:
- upgrade upip to 1.1.4: fix error on unix when installing to non-existing
  absolute path
- pip-micropython: remove deprecated wrapper tool
- check_code_size.sh: code size validation script for CI
- replace upip tarball with just source file, to make its inclusion as
  frozen modules in multiple ports less magic

tests:
- extmod/vfs_fat: improve VFS test coverage
- basics/builtin_slice: add test for "slice" builtin name
- basics: add test for builtin "delattr"
- extmod/vfs_fat_fsusermount: improve fsusermount test coverage
- extmod/vfs_fat_oldproto: test old block device protocol
- basics/gc1: garbage collector threshold() coverage
- extmod/uhashlib_sha1: coverage for SHA1 algorithm
- extmod/uhashlib_sha256: rename sha256.py test
- btree1: fix out of memory error running on esp8266
- extmod/ticks_diff: test for new semantics of ticks_diff()
- extmod/framebuf1: test framebuffer pixel clear, and text function

minimal port:
- Makefile: split rule for firmware.bin generation

unix port:
- Makefile: remove references to deprecated pip-micropython
- modtime: use ticks_diff() implementation from extmod/utime_mphal.c
- mphalport.h: add warning of mp_hal_delay_ms() implementation
- modtime: switch ticks/sleep_ms/us() to utime_mphal
- fix symbol references for x86 Mac
- replace upip tarball with just source file

windows port:
- enable utime_mphal following unix, define mp_hal_ticks_*
- fix utime_mphal compilation for msvc
- implement mp_hal_ticks_cpu in terms of QueryPerformanceCounter

qemu-arm port:
- exclude ticks_diff test for qemu-arm port
- exclude extmod/vfs_fat_fileio.py test
- exclude new vfs_fat tests
- enable software floating point support, and float tests

stmhal port:
- modutime: refactor to use extmod's version of ticks_cpu
- refactor pin usage to use mp_hal_pin API
- led: refactor LED to use mp_hal_pin_output() init function
- Makefile: use standard rules for frozen module generation
- modutime: consistently convert to MP_ROM_QSTR/MP_ROM_PTR
- enable SD power save (disable CLK on idle)

cc3200 port:
- use mp_raise_XXX helper functions to reduce code size
- mods/pybspi: allow "write" arg of read/readinto to be positional
- enable loading of precompiled .mpy files
- fix thread mutex's so threading works with interrupts

teensy port:
- update to provide new mp_hal_pin_XXX functions following stmhal

esp8266 port:
- Makefile: use latest esptool.py flash size auto-detection
- esp_init_data: auto-initialize system params with vendor SDK 2.0.0
- esp8266.ld: move help.o to iROM
- esp8266.ld: move modmachine.o to iROM
- esp8266.ld: move main.o to iROM
- add MP_FASTCODE modifier to put a function to iRAM
- main: mark nlr_jump_fail() as MP_FASTCODE
- modules/webrepl: enforce only one concurrent WebREPL connection
- etshal.h: add few more ESP8266 vendor lib prototypes
- modesp: add flash_user_start() function
- add support for building firmware version for 512K modules
- scripts: make neopixel/apa102 handle 4bpp LEDs with common code
- modutime: consistently convert to MP_ROM_QSTR/MP_ROM_PTR
- modnetwork: config(): fix copy-paste error in setting "mac"
- scripts/port_diag: add descriptions for esf_buf types
- modnetwork.c: allows AP reconnection without WiFi credentials
- main: bump heap size to 36K
- etshal.h: add prototypes for SPIRead/SPIWrite/SPIEraseSector
- etshal.h: adjust size of MD5_CTX structure
- modules: fix negative temperature in ds18x20 driver
- rename "machine" module implementation to use contemporary naming
- rework webrepl_setup to run over wired REPL
- espneopixel.c: solve glitching LED issues with cpu at 80MHz
- include upip as a standard frozen bytecode module
- update docs for esptool 1.2.1/SDK 2.0 (--flash_size=detect)
- modnetwork.c: expose configuration for station DHCP hostname

zephyr port:
- implement utime module
- use board/SoC values for startup banner based on Zephyr config
- initial implementation of machine.Pin
- zephyr_getchar: update for recent Zephyr refactor of console hooks
- support time -> utime module "weaklink"
- README: update for the current featureset, add more info
- mpconfigport.h: move less important params to the bottom
- Makefile: allow to adjust heap size from make command line
- Makefile: update comments to the current state of affairs
- Makefile: allow to override Zephyr config from make command line
- Makefile: add minimal port
- Makefile: add -fomit-frame-pointer to reduce code size
- mphalport.h: update for new "unified" kernal API (sleep functions)

docs:
- machine.SPI: bring up to date with Hardware API, make vendor-neutral
- machine.SPI: improve descriptions of xfer methods
- library/builtins: add docs for delattr and slice
- library/network: reword intro paragraph
- library/network: typo fixes, consistent acronym capitalization
- library/index: update TOCs so builtins sorted before modules
- utime: document ticks_cpu() in more detail
- utime: describe new semantics of ticks_diff() (signed ring arithmetics)
- utime: add docs for ticks_add(), improvements for other ticks_*()
- esp8266: update for new WebREPL setup procedure
- */quickref.rst: use new semantics of ticks_diff()
- library/machine.Pin: update Pin docs to align with new HW API

travis:
- integrate tools/check_code_size.sh
- minimal: Use CROSS=1, for binary size check

examples:
- http_server_simplistic: add "not suitable for real use" note
- hwapi: example showing best practices for HW API usage in apps
- hwapi: add hwconfig for DragonBoard 410c
2016-11-14 11:10:07 -08:00
Scott Shawcroft 5b3a143ffe atmel-samd: Rework tick timer to use TC5 and support neopixel status LED.
The tick timer needed to be reworked because the ASF delay functions also
use the SysTick timer. Now, it uses TC5 and calls out to the autoreset
logic every tick. Fixes #43.

Added neopixel status colors and corrected the latch time from ms to us.
Fixes #42.
2016-10-28 20:16:39 -07:00
Scott Shawcroft 2098515f6a atmel-samd: Rework pin definitions to share most of the data structures and included based on ASF defines. 2016-10-26 17:57:47 -07:00
Scott Shawcroft d189a3f3cf atmel-samd: Support auto-reset based on USB write activity.
It will soft-reboot micropython after a burst of writes to the
file system. This means that after you save files on your computer
they will be automatically rerun.

This can be disabled in the build by unsetting AUTORESET_TIMER in
mpconfigboard.h.

Using the REPL will also prevent the soft resets until you reset
with CTRL-D manually.
2016-10-25 18:36:37 -07:00
Scott Shawcroft 306c921ed1 atmel-samd: Rework mass storage interaction with underlying block
storage to use micropython's VFS interface.

This makes mass storage work with any VFS implementation rather
than a single one.
2016-10-21 15:36:59 -07:00
Tony DiCola fffc6d1a17 atmel-samd: Add modules directory with frozen bytecode support (like ESP8266 port), and NeoPixel python wrapper module. 2016-10-14 11:39:42 +00:00
Scott Shawcroft 011056af15 atmel-samd: Add support for SPI.
Also separate out the ASF config headers that are shared across all boards.
2016-10-11 15:48:43 -07:00
Scott Shawcroft 284d3414e1 atmel-samd: Make UART REPL Arduino Zero specific. Most will use USB REPL. 2016-10-07 15:06:07 -07:00
Tony DiCola 9c67605233 atmel-samd: Add low level neopixel_write module & function for WS281x/neopixel RGB LEDs. 2016-10-05 12:35:23 -07:00
Scott Shawcroft 7e08347d5c atmel-samd: Support composite CDC and mass storage USB device.
Be careful to not use the flash file system while using mass storage
because both pieces of code attempting to change the fs can corrupt it.
2016-10-05 11:07:29 -07:00
Scott Shawcroft 1fa4c20c27 atmel-samd: Add Micro Trace Buffer support to the debug build.
The Micro Trace Buffer records the history of the pc and can be used
to debug hard faults even when the stack trace is useless.
2016-10-04 16:13:33 -07:00
Scott Shawcroft 0e1fd9a12c atmel-samd: Support ampy get and fix USB dropping characters.
Fixes #2.
2016-09-21 15:13:37 -07:00
Scott Shawcroft 005122e581 atmel-samd: Remove path specific to me. 2016-09-20 15:16:12 -07:00
Scott Shawcroft 0f4f4c7544 atmel-samd: Add sys, fix import and increase the size of the heap. 2016-09-19 16:56:42 -07:00
Scott Shawcroft 7fd84e93f4 atmel-samd: Support raw repl and soft reset to support ampy.
Closes #1. Also adds TX and RX led support on the Arduino Zero.
2016-09-15 17:01:19 -07:00
Scott Shawcroft 7d8929c470 atmel-samd: Add I2C support.
This commit also introduces a new shared-bindings directory which is used to store the common Python -> C binding code. By having a shared directory we can ensure that the Python API across ports is the same. Each port will have a corresponding common-hal directory which provides definitions for the C api used in the shared-bindings code. That way the compiler can enforce the C api.

To migrate to this new shared API create a common-hal directory within your port and change the Makefile to compile both the shared-bindings and common-hal files. See atmel-samd/Makefile SRC_BINDINGS for an example.
2016-09-13 11:46:22 -07:00
Scott Shawcroft 09be96a6aa atmel/samd: Add filesystem support. 64k is stored in flash. 2016-09-02 17:00:30 -07:00
Scott Shawcroft 559434afca atmel-samd: Support floats. 2016-08-31 13:37:43 -07:00
Scott Shawcroft a6bc701917 atmel-samd: Re-enable -Os (size) optimizations. 2016-08-31 00:16:39 -07:00