Commit Graph

244 Commits

Author SHA1 Message Date
Scott Shawcroft 2fbab8067a Prevent freezing USB during high frequency PulseIn.
We now track the last time the background task ran and bail on the
PulseIn if it starves the background work. In practice, this
happens after the numbers from pulsein are no longer accurate.

This also adjusts interrupt priorities so most are the lowest level
except for the tick and USB interrupts.

Fixes #516 and #876
2018-06-08 12:56:32 -07:00
Kattni Rembor 3a38172627 Fixed documentation formatting for RTD 2018-06-06 18:28:01 -04:00
Scott Shawcroft 717199018b Adapt for feedback and hack around pIRkey size constraint. 2018-06-01 15:08:52 -07:00
Scott Shawcroft d0fb6e7a2f atmel-samd: Add rotary encoder support.
Fixes #283
2018-06-01 15:08:48 -07:00
Scott Shawcroft fd71e56891 atmel-samd: Re-org helper peripheral files into their own subdirectory.
Ideally in the future they won't depend on ASF4 or MicroPython.
2018-06-01 15:07:31 -07:00
Radomir Dopieralski b219ce6d37 Add gamepad_singleton to root pointers 2018-05-30 23:11:22 +02:00
Radomir Dopieralski c37b69e1a5 Make the gamepad singleton long-lived
So that it is not later moved.
2018-05-30 23:11:22 +02:00
Radomir Dopieralski 42e36a883b Remove volatile from the gamepad struct 2018-05-23 21:49:20 +02:00
Radomir Dopieralski f17a235b40 Raise an error if more than 8 buttons passed to gamepad 2018-05-23 21:41:56 +02:00
Radomir Dopieralski 240678e714 Avoid uninitialized gamepad on exception
Raise exceptions before the gamepad_singleton is created.
Also, use mp_raise for creating the exceptions.
2018-05-23 21:39:06 +02:00
Radomir Dopieralski edf2935ab1 Make gamepad.get_pressed work when gamepad was created from frozen code
For some reason, when the GamePad is created from frozen code, the
get_pressed method would always return 0. This fixes it, and makes it
work properly no matter how the object was created.
2018-05-23 12:44:22 +02:00
Radomir Dopieralski 52d05bbc37 Cache pullup state in gamepad
Don't check the pin's pull direction on every tick, instead cache it
at the beginning. Also avoid a "can't get pull of output pin" error
when one of the pins passed is in output mode.
2018-05-23 11:26:16 +02:00
Scott Shawcroft be12e07d74
Merge pull request #846 from notro/epoch1970
time: Use 1970 epoch
2018-05-19 12:30:34 -05:00
jerryneedell 1d9bcc5ddf
fix doc error in audioOut.c
fixes #851
2018-05-19 10:41:36 -04:00
Noralf Trønnes 95e70cd0ea time: Use 1970 epoch
Use UNIX epoch to match CPython.
This overflows small int so time.{time,localtime,mktime} is only supported with long int.
Also remove some comment cruft in time_time().
2018-05-18 12:35:33 +02:00
Scott Shawcroft 6a8db03ade
Merge pull request #838 from rhooper/master
add supervisor.reload() to soft reboot from code
2018-05-16 17:52:16 -04:00
Scott Shawcroft 918d30cb97
Rephrase the doc 2018-05-16 16:28:43 -05:00
Roy Hooper 92b1cb5743 move reload exception to reload.c 2018-05-14 17:41:17 -04:00
Roy Hooper 698912633f Rename reload_next_character to reload_requested to make it match it's intended use 2018-05-14 17:00:38 -04:00
Roy Hooper 567f3e30a7 Initial implementation of supervisor.reload() 2018-05-14 16:57:50 -04:00
Jerry Needell d6c26942a5 add timeout keyword to I2C - for bitbangio - ignored for busio 2018-05-13 21:54:44 -04:00
dean 82b5efa7bc remove unnecessary comment 2018-05-09 15:14:26 -04:00
dean fba1e221c6 DM: add kwargs to bitbangio spi 2018-05-09 15:12:42 -04:00
Scott Shawcroft fc7c25af6d Make resume idempotent (allowing you to call it twice without complaining.) 2018-05-08 13:00:05 -07:00
Scott Shawcroft 24116eff23 Tweak exception message. 2018-05-08 12:44:27 -07:00
Scott Shawcroft 50fc90bc5f Add pause/resume control to AudioOut and I2SOut
Fixes #808
2018-05-08 11:53:13 -07:00
Jeff Epler 2955ada22f docs: fix references to uhashlib 2018-05-06 12:31:54 -05:00
Jeff Epler 647ff387d9 docs: fix references to ubinascii 2018-05-03 09:34:43 -05:00
Scott Shawcroft cfea51ec68 Re-enable PDMIn without ASF and using the helpers added with
I2SOut.

The API is almost the same except the frequency attribute has been
renamed to sample_rate so that its less likely to be confused with
frequencies within the audio itself.

Fixes #263.
2018-05-01 14:35:43 -07:00
Scott Shawcroft 81d395d825
Merge pull request #745 from notro/time_rtc
RFC: Add rtc module
2018-04-16 15:26:54 -07:00
Scott Shawcroft 301479cd44
Remove "Get or set" 2018-04-16 15:00:58 -07:00
Scott Shawcroft 84d4be279e
Add a table of contents reference to RTC 2018-04-16 15:00:01 -07:00
Noralf Trønnes 8d1719f190 Add rtc module
Add an rtc module that provides a singleton RTC class with
- a datetime property to set and get time if the board supports it.
- a calbration property to adjust the clock.

There's also an rtc.set_time_source() method to override this RTC object using pure python.

The time module gets 3 methods:
- time.time()
- time.localtime()
- time.mktime()

The rtc timesource is used to provide time to the time module.

lib/timeutils is used for time conversions and thus only supports dates after 2000.
2018-04-16 12:49:10 +02:00
Scott Shawcroft 5af4e79ed3 Correct example. Thanks @jepler! 2018-04-13 16:43:21 -07:00
Scott Shawcroft 812fe0c93f Turn on nvm in 3.0.
Its 256b on M0 and 8k on M4 to match flash erase sizes.

Fixes #758
2018-04-13 16:22:28 -07:00
Scott Shawcroft 22194d5977 Tweaks based on dhalbert's feedback. 2018-04-13 10:51:01 -07:00
Scott Shawcroft 28642ab10d Add audio output support!
This evolves the API from 2.x (and breaks it). Playback devices are now
separate from the samples themselves. This allows for greater playback
flexibility. Two sample sources are audioio.RawSample and audioio.WaveFile.
They can both be mono or stereo. They can be output to audioio.AudioOut or
audiobusio.I2SOut.

Internally, the dma tracking has changed from a TC counting block transfers
to an interrupt generated by the block event sent to the EVSYS. This reduces
the overhead of each DMA transfer so multiple can occure without using up TCs.

Fixes #652. Fixes #522. Huge progress on #263
2018-04-12 16:35:13 -07:00
Dan Halbert 5f98953ed8 esp8266 and nrf: raise NotImplementedError 2018-04-10 12:08:41 -04:00
Dan Halbert aa8c262d14 add storage.erase_filesystem() to erase and reformat CIRCUITPY 2018-04-09 12:52:42 -04:00
Scott Shawcroft 4e053cea0d
Merge pull request #628 from sommersoft/super_status
Added Function To Check the Serial Connection From CircuitPython Layer
2018-04-08 22:06:09 -07:00
Dan Halbert 726d5e52a3 Merge branch 'master' into 3.0_hid 2018-04-08 09:52:29 -04:00
sommersoft cc644032ea Merge branch 'super_status' of https://github.com/sommersoft/circuitpython into super_status 2018-04-06 01:58:29 +00:00
sommersoft d1974e0038 supervisor/Runtime: updated documentation for 'no disconnect' 2018-04-06 01:56:51 +00:00
Jeff Epler 92853e611d RunMode: Fix repr(RunMode.BOOTLOADER) 2018-04-05 08:16:53 -05:00
Dan Halbert 435e894fa0 Merge branch 'master' into 3.0_hid 2018-04-02 19:19:43 -04:00
Radomir Dopieralski 6ca4fd82ed Add a type check to the gamepad module
Make sure that all the arguments passed are indeed DigitalInOut.
This avoids crashes when the users pass something else.
2018-03-31 20:41:16 +02:00
Dan Halbert df91878d2e WIP: works with just keyboard but not complex report descriptor 2018-03-30 23:24:00 -04:00
sommersoft 6ee573c7c9
Merge branch 'master' into super_status 2018-03-30 14:27:39 -05:00
Jeff Epler 34f5498760 Document storage.VfsFat more thoroughly 2018-03-27 21:28:19 -05:00
Jeff Epler c08f5a3a00 Add storage.getmount to retrieve the mount object associated with a path 2018-03-27 21:28:18 -05:00
Dan Halbert 31f5b6a238 WIP: simple working HID 2018-03-24 18:29:12 -04:00
Jeff Epler 002797a3b4 Fix array vs pointer error in declaration of circuitpython_help_text
Building with gcc 5.4.1 (Debian Stretch) with the unsupported
-Wno-error=lto-type-mismatch flag removed, the following diagnostic
occurs:

../../py/builtin.h:121:19: error: type of 'circuitpython_help_text' does not match original declaration [-Werror]
 extern const char MICROPY_PY_BUILTINS_HELP_TEXT[];
                   ^
../../shared-bindings/help.c:38:13: note: previously declared here
 const char *circuitpython_help_text =
             ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/arm-none-eabi-gcc returned 1 exit status
2018-03-19 22:11:40 -05:00
Radomir Dopieralski 493c1452f3 _stage: use 16 bit for coordinates to support larger screens 2018-03-11 12:07:23 +01:00
sommersoft 2569b33c84 1 more sphinx fix; added '.. class::' constructor 2018-03-09 21:00:15 +00:00
sommersoft f21038b913 sphinx fix; incorrect currentmodule ref 2018-03-09 20:24:07 +00:00
sommersoft 01471e1e22 sphinx fix; added toctree to include 'runtime' 2018-03-09 03:22:00 +00:00
sommersoft c1c3a79ec4 atmel-samd: changed Status to Runtime; instituted runtime singleton 2018-03-09 02:19:51 +00:00
Scott Shawcroft bf05183158 Merge remote-tracking branch 'adafruit/2.x' into merge_2x 2018-02-27 15:24:16 -08:00
Dan Halbert 9b4477e1dc Implement UART for 3.0 + related fixes.
1. UART: ported to ASF4. Allow rx-only and tx-only. Add .baudrate r/w property.

2. Make NeoPixel timing deterministic by turning off caches during NeoPixel writes.
3. Incorporate asf4 updates:
  a. async USART driver
  b. bringing Atmel START configuration closer to what we use
  c. Clock initialization order now specified by CIRCUITPY_GCLK_INIT_1ST and _LAST.
4. supervisor/port.c: Move commented-out clock-test pin setting to correct location.
2018-02-21 17:18:49 -05:00
Scott Shawcroft 20dd3b1e43 Delete a bunch of docs, drivers and examples not relevant to CircuitPython.
This fixes #345 and fixes #215.
2018-02-20 17:34:59 -08:00
sommersoft fca9c66c27 added Status submodule to shared-bindings/supervisor; issue #544 2018-02-19 20:40:17 +00:00
Kattni 446a31302c
Merge pull request #600 from tannewt/clarify_property_comments
Clarify style of attribute comments in the Design Guide.
2018-02-14 22:03:37 -05:00
Kevin Townsend 9d191f7f9f
Merge pull request #589 from arturo182/nrf_gamepad
nrf: Implement ticks, add gamepad module and example
2018-02-07 22:17:05 +01:00
Scott Shawcroft 15db02664d Clarify style of attribute comments in the Design Guide.
And update the core attributes to match the style.
2018-02-07 13:08:42 -08:00
arturo182 ff041caa52 shared-bindings: Fix incorrect code comments
Most likely caused by copy-paste.
2018-02-06 22:03:17 +01:00
Scott Shawcroft 6c5cb01b4a
Merge pull request #564 from deanm1278/master
DM: added write_readinto to bitbangio
2018-02-06 09:38:17 -08:00
arturo182 1de2ee6884 nrf: Implement ticks, add gamepad module and example 2018-02-05 20:48:25 +01:00
dean 68309c3fac replace tabs with spaces 2018-02-05 10:44:29 -05:00
dean 0e13aba2fe DM: fix sytling 2018-01-30 17:45:04 -05:00
dean a7f72eb2d8 DM: added write_readinto to bitbangio 2018-01-30 17:18:57 -05:00
Dan Halbert cc87363234 documentation: caution on SPI clock speed for SAMD21 2018-01-30 14:31:20 -05:00
Dan Halbert e550b024c5 atmel-samd: Correct computation of SPI baud rate.
all: Add .frequency read-only property for busio.SPI to return actual frequency.

Fix esp8266/posix_helpers.c, which was not up to date for the new
long-lived/short-lived heap allocation scheme.
2018-01-30 12:08:41 -05:00
sommersoft 44bc1711aa Added Unique ID Functions/Updated Support Matrix (#527)
shared_bindings/index.rst: updated Support Matrix format as discussed in PR #503 & Issue #448.

shared-bindings/microcontroller/Processor.c & .h: added UID lookup functionality for use with all ports. Fixes #462.
2018-01-18 11:39:11 -08:00
Radomir Dopieralski 0ff128ec03 Fix example for gamepad
The example code for the gamepad module would skip detected
button presses in the code that waits for a button to be released,
because it would run it even when no button is pressed.

Also updated the example pin names to not use RX and TX.
2018-01-11 17:06:53 +01:00
Dan Halbert 065e82015f merge from 2.2.0 + fix up board defs 2018-01-02 21:25:41 -05:00
sommersoft 881fa8e2b9 shared-bindings/index.rst: added audiobusio
shared-bindings/index.rst: added `aduiobusio` to Support Matrix. Used `audiobusio/_init_.c` to verify applicable ports; SAMD21 was the only one listed...ESP8266 wasn't. This fixes issue #448.
2017-12-30 01:36:23 -06:00
sommersoft 36ec29d4e8 Documentation Updates (mcu.delay() and Design Guide) (#481)
/docs/design_guide: added links to firmware build learning guides for SAMD21 & ESP8266. Changes were placed in the "Adding native modules" section, since that seemed to me the best place based on target audience.

Updated documentation for `delay()` which fixes #243.
2017-12-14 10:02:43 -08:00
Dan Halbert 43650b6896 Fix PDMIn MEMS microphone support (#479)
Changes:

    * New faster filter loop, by @ladyada. New filter coefficients as well.
    * Turn on microphone clock when PDMIn object is created, and run it all the time, so the user code doesn't have to wait for microphone startup, which can be 10ms or even 100ms.
    * Wait for microphone startup when PDMIn is first created, based on new optional parameter microphone_startup in seconds (takes a float).
    * record() returns number of samples actually recorded, so you can see if it's not keeping up.
    * Fix buffer overflow errors when buffer size was not a multiple of 16 or something like that.
    * Tweak a few peripheral settings.
    * Minimum sampling frequency is now 16kHZ or so, because 8kHz runs microphone at only 0.5MHz, which is too slow for many mics.

Note: I tried 128x oversampling instead of 64x, but the code cannot keep up at 24kHz or above sampling. 128x would reduce the high-frequency noise by 6db.
2017-12-13 10:12:49 -08:00
Scott Shawcroft a91e1cb682 Fix a couple spelling errors. 2017-12-05 16:04:47 -08:00
Scott Shawcroft b4d3699047 Introduce reset mechanics to microcontroller.
This allows one to configure how a subsequent reset will behave and
also trigger a reset.

Fixes #350 and fixes #173
2017-12-05 14:50:58 -08:00
Dan Halbert e75fd0e166 add SPI.write_readinto() - bidirectional SPI 2017-12-05 11:17:16 -08:00
Dan Halbert 72c911be97 Support SPI flash chips for CIRCUITPY, using non-DMA SPI for now. 2017-11-27 21:00:24 -05:00
Kattni 4902f0937f Resolved formatting issue in doc 2017-11-22 21:44:18 -05:00
Kattni 1d6bf8e04a Updated frequency minimum requirements in docs and examples (#444)
Updated frequency minimum requirements in docs and examples
2017-11-19 22:19:22 -08:00
Dan Halbert a9f75a71c5
Merge pull request #443 from dhalbert/3.0_spi
non-DMA SPI working; adding this now for testing; will continue with DMA
2017-11-16 19:28:24 -05:00
Dan Halbert 312444bbd2 non-DMA SPI working; adding this now for testing; will continue with DMA
Also, fixed pin mappings for rev B Metro M4:
swap PA12 and PA13 on SPI 2x3 header
swap A3 and A5

Comment out all frozen modules in CPX again to make room while waiting
for SPI flash.
2017-11-16 19:09:35 -05:00
Scott Shawcroft ecc47d5258 Create supervisor module.
It can control autoreload and the rgb status led.
2017-11-16 09:04:17 -08:00
Radomir Dopieralski 216fcedfbb Add a _stage module (#398)
This is a C module with some low-level functions required for the
CircuitPython "stage" library. It provides support for fast
rendering of tile grids and sprites on SPI-based RGB displays.
2017-11-07 10:05:25 -08:00
Dan Halbert 7292984204 Implement busio.I2c.
* Added asf4_conf/samd*/hpl_sercom_config.h
* Adjusted clocks in peripheral_clk_config.h.
* Put some frozen libs back in CPX for testing.
* Implement common-hal I2C
* Add samd*_peripherals.h in parallel with samd*_pins.h for common
  functions and data.
* Store SERCOM index in pins table for convenience.
* Canonicalize some #include guard names in various .h files.

simpler reset of SERCOMs; remove unused routine
2017-11-07 09:59:54 -08:00
Radomir Dopieralski 78f6c2232c Allow empty reads and writes for busio.SPI
This is mostly for convenience, so that user code doesn't
need to add additional checks.

Also, bring the bitbangio into compatibility with busio wrt. empty
buffers.
2017-11-03 17:33:37 +01:00
Scott Shawcroft 8c1f5427bc atmel-samd: Add empty line for RST docs
Right now calcsize is being grouped with the doc above: https://circuitpython.readthedocs.io/en/latest/shared-bindings/struct/__init__.html
2017-10-30 18:57:28 -07:00
Dan Halbert f738996164 Allow writing buffer of length zero to I2C device; it can be used to poll for existence. 2017-10-30 18:32:36 -07:00
mrmcwethy 1893669833 calcsize90 should be documented now 2017-10-27 23:25:00 -07:00
Scott Shawcroft bd7abcda97 shared-bindings: Check that I2C and SPI reads and writes are given a buffer of at least 1. (#370)
Fixes #358
2017-10-25 17:28:23 -04:00
Scott Shawcroft d2ddf36c1d shared-bindings: Use unary_op type. 2017-10-25 10:52:03 -07:00
Dan Halbert 6df99b5d0e Merge 2.1.0 changes into master. 2017-10-23 15:26:36 -07:00
mrmcwethy bb008cdbc9 First attempt to move py/modmath.c to shared-bindings/math 2017-10-21 10:34:25 -07:00
Josh Gadeken 3ba5ba6e66 shared-bindings/storage/__init__.c: Change remount() readonly to kw arg (#286).
The readonly arg to storage.remount() is now a keyword arg that
defaults to False. To maintain backwards compatibility, readonly
can be passed as a positional arg or keyword arg.
2017-10-19 17:11:30 -07:00
Michael McWethy b41cbe9256 CircuitPython now has struct instead of ustruct (#302)
Added struct module to shared-bindings and shared-module.  removed ustruct
2017-10-18 12:50:20 -07:00
Dan Halbert a1409d1432 redo time.monotonic() to avoid double precision 2017-10-17 10:02:16 -07:00