Commit Graph

32 Commits

Author SHA1 Message Date
Dan Halbert e2ce87e250 Merge pull request #336 from tannewt/2.x
esp8266: Correct SPI functionality when write_value is provided.
2017-10-16 18:43:28 -04:00
Scott Shawcroft c216c2876f esp8266: Actually disable pins when reset on reload. 2017-10-16 15:13:09 -07:00
Scott Shawcroft 6c7d35c40c esp8266: Correct SPI functionality when write_value is provided.
It used to introduce extra clocks to the bus rather than changing the
value output.

This fixes SD cards.
2017-10-16 14:54:23 -07:00
Dan Halbert c478c10923 Do not allow a *io object to be used after deinit().
Fixes #278, #277, #276, #275.
2017-10-03 12:07:17 -07:00
Dan Halbert fdb97eda09 Add microcontroller.cpu.temperature, for use as a simple sensor on minimal boards. (#211)
* Add microcontroller.cpu, the sole instance of microcontroller.Processor.
microcontroller.cpu.frequency is the clock frequency, in Hz.
microcontroller.cpu.temperature is the reading from the internal temperature sensor, in Celsius. None if not available.

* Squeeze firmware size by using -finline-limit. Otherwise non-Express builds were slightly too big.

* Update submodules.

* Fix documentation glitches
2017-08-31 13:48:30 -04:00
Dan Halbert c679c80c71 Modernize module and class static dicts; update freetouch 2017-08-27 15:02:50 -04:00
Dan Halbert ef61b5ecb5 Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master.
cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
2017-08-25 22:17:07 -04:00
Scott Shawcroft 6ace744667 esp8266: Introduce `multiterminal` module for managing a secondary
serial connection such as WebREPL.

Fixes #181.
2017-08-07 14:30:11 -07:00
Scott Shawcroft 725d715a1b shared-bindings: Introduce storage.remount() so you can set root as
writeable and prevent USB from editing it.
2017-06-28 16:18:13 -07:00
Scott Shawcroft a0058e6712 Introduce a random module that is a subset of CPython's random. It
also initializes in the same way where it takes from a true random
source when available through os.urandom(). After initializing, it
produces deterministic results until the seed is set.

This replaces urandom!

Fixes #139.
2017-06-27 17:37:24 -07:00
Scott Shawcroft 778e975936 Split uos module into os and storage.
os is a subset of CPython's os. storage contains additional
file system mounting functionality based on UNIX's mount
management.

Fixes #140
2017-06-27 15:17:30 -07:00
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 ca176535a9 esp8266: Fix busio.SPI to take both MOSI and MISO. 2017-04-18 09:44:04 -07:00
Scott Shawcroft d1b15cf1a3 esp8266: Don't reset TX and RX lines. The pullup is required for
the Adafruit Huzzah Breakout because it has a diode to protect
against 5v logic which effectively blocks 1s and relies on the
pull up to produce them.
2017-04-13 14:15:06 -07:00
Scott Shawcroft 4a4f29b8f9 atmel-samd: Rework status LED implementation
* Track status pin use by user code separately so it can take over the pins and then give them back.
* Switch to hardware SPI for APA102 on Gemma and Trinket.
* Merge microcontroller/types.h into microcontroller/Pin.h to better match approach going forwards.
2017-04-12 15:24:50 -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 4810722064 esp8266: Change nativeio.I2C to use bitbangio under the hood rather than throwing an error. 2017-03-28 18:54:16 +01: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 f0b62a2b0e Save space by only supporting 800khz neopixels. 2017-02-19 17:22:42 +01:00
Scott Shawcroft 710b5d8aff Two I2C fixes:
1) Bus error will be thrown on read/write errors with errno set. (Read didn't used to fail at all.)
2) try_lock correctly returns boolean whether lock was grabbed.

Fixes #87
2017-02-19 17:02:29 +01:00
Scott Shawcroft b7ded4c934 esp8266: Allow for MOSI or MISO only SPI. Fixes #65 2017-02-19 13:15:23 +01:00
Scott Shawcroft f511c263a0 ESP8266: Make sure SPI write finishes before returning.
Fixes #62.
2017-02-15 17:25:41 +01:00
Scott Shawcroft 370d1dec88 SPI tweaks for SD Cards:
* Always init SPI to 250k to start for SD cards.
* Add ability to configure byte written during read.
* Add ability to read and write to portions of buffers like existing I2C API.
2017-02-10 05:09:17 -08:00
Scott Shawcroft e3f9ee839a Add frequency changing support to PWMOut.
You can either set it once up front, or set variable_frequency on custruction to
indicate that the frequency must be able to change. This informs whether a timer
can be shared amongst pins.

This also adds persistent clock calibration on atmel-samd. Once the device has
synced its clock frequency over USB it will remember that config value until USB
is used again. This helps ensure the clock frequency is similar on and off USB.

Lastly, this also corrects time.sleep() when on USB by correcting the tick counter.
2017-01-30 15:02:01 -08:00
Scott Shawcroft e8db23d241 esp8266: Add limited (untested) UART support. 2016-12-19 17:32:40 -08:00
Scott Shawcroft 781633c716 Fix up Analog classes: unify them at 16 bits and adds reference_voltage member
to make for easy conversion. Fixes #14.
2016-12-13 16:09:00 -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 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 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