Commit Graph

1067 Commits

Author SHA1 Message Date
Scott Shawcroft 0ae344841f atmel-samd & esp8266: Make sure pins are not already in use.
This prevents corrupting previous functional objects by stealing their pins
out from under them. It prevents this by ensuring that pins are in default
state before claiming them. It also verifies pins are released correctly and
reset on soft reset.

Fixes #4, instantiating a second class will fail.
Fixes #29, pins are now reset too.
2016-12-07 15:21:14 -08:00
Scott Shawcroft 26229efe78 Add try_lock and unlock to I2C and SPI classes to make sure things
are shared well between threads and underlying MicroPython (SPI Flash
for example.)

It is recommended to use the bus device classes to manage the locks
and other transaction state.

https://github.com/adafruit/Adafruit_MicroPython_BusDevice

Fixed #58
Fixed #59
Fixed #60
2016-12-02 15:46:12 -08:00
Scott Shawcroft 8ef0dd095a Fix two bugs found by clang:
* PWMOut enter and exit weren't hooked up.
* end couldn't be negative in I2C.
2016-12-01 10:33:50 -08:00
Scott Shawcroft 9b3afc7b37 shared-bindings: Make MOSI and MISO optional for SPI. 2016-11-29 16:54:20 -08:00
Scott Shawcroft 4933fa1c27 shared-bindings: Ensure pin objects are actually pins.
Fixes #12
2016-11-29 15:50:01 -08:00
Scott Shawcroft 16764dfa31 shared-bindings: Fix blinky example. Fixes #55 2016-11-29 14:37:25 -08:00
Scott Shawcroft d2aa05a9fe shared-bindings: Stop using negative length at all. Having uint and int mixed is confusing. 2016-11-28 19:57:05 -08:00
Scott Shawcroft bda6ee9a14 shared-bindings: Stop using max and min because C doesn't define them. 2016-11-28 19:48:48 -08:00
Scott Shawcroft 78f8565270 Add start and end kwargs to writeto and readfrom_into so a single buffer can be used to save memory. 2016-11-28 18:35:19 -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 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 23112a6434 atmel-samd: Merge init into the constructor and check all available
SERCOMs during initialization.

Fixes #16. It was broken because the MISO pin used the second SERCOM.
2016-11-01 17:30:01 -07:00
Scott Shawcroft 0cb0bd0f25 atmel-samd: More updates to the docs including the in-code docs. 2016-10-19 16:49:35 -07:00
Scott Shawcroft 46e7f8e4fb Documentation rework to unify the docs together rather than having them
on a per port basis.

Also enables generating docs from inline RST in C code. Simply omits all
lines except those that start with //|. Indentation after "//| " will be
preserved.
2016-10-18 17:42:47 -07: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 afedba5c2f atmel-samd: Support with statements for I2C class.
Also add init/deinit if you want to init/deinit manually.
2016-10-05 18:44:55 -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