Commit Graph

273 Commits

Author SHA1 Message Date
Scott Shawcroft 736a63e85a atmel-samd: Set up the tcc_instance when using an already active TCC.
This fixes a hard lock that happens when using a second channel on an
in use TCC. The lock occurred when setting the duty cycle on the channel
because the hw address was not available to ASF.

Thanks to @ladyada for finding the bug.
2017-06-09 17:16:33 -07:00
Scott Shawcroft 3658c92270 atmel-samd: Reset TCC channel in use array on reset.
This fixes spurious "All timers in use" exceptions. Thanks to
@ladyada for finding this issue.
2017-06-09 17:15:31 -07:00
Scott Shawcroft 9434db07b2 atmel-samd: Handle TCC2 correctly. Unlike the other TCCs its 16bit
rather than 24bit. Setting the period for more than a 16bit number
caused the TCC to be in a weird state where resetting it would hard
crash.

Fixes #153
2017-06-09 15:29:02 -07:00
Scott Shawcroft a884acc7f6 atmel-samd: Fix PWMOut duty_cycle when used with TCC peripherals.
Fixes #148. Fixes #151
2017-06-08 18:56:13 -07:00
Scott Shawcroft b5f50fadf9 atmel-samd: Change Metro PID to 0x8014 so it doesn't conflict with Arduino's PID. 2017-06-06 16:18:34 -07:00
Scott Shawcroft 66c421f401 atmel-samd: Correct the USB PID of the CircuitPlayground Express. 2017-05-29 14:35:38 -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 3cad7b7b03 atmel-samd: correctly reset the REPL history on reload. Fixes #141 2017-05-24 10:53:52 -07:00
Scott Shawcroft b444788451 Merge pull request #135 from robomike/pins
Renamed spi flash to ext flash not to confuse with the actual spi flash
2017-05-23 11:43:20 -07:00
robomike 517590a58a atmel-samd:renamed spi flash to confuse with the actual spi flash 2017-05-23 14:09:28 -04:00
Dan Halbert 5c7071e92a Merge branch 'master' into add-ure-et-al 2017-05-21 23:20:47 -04:00
Dan Halbert 253bdf7739 Enable ure, center, partition, frozenset, splitlines, reversed for Express builds. 2017-05-20 14:02:37 -04:00
Scott Shawcroft 0a6bed491f atmel-samd: Enable autoreload by default again. 2017-05-20 08:11:06 -07:00
Scott Shawcroft b1925b1bd8 atmel-samd: Fixup autoreset after switching boot to running once. 2017-05-15 20:21:26 -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 e0f931afd3 atmel-samd: Fix pin reset to ensure USB and SWD are not reset. 2017-05-12 16:09:13 -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 7ea76e0889 atmel-samd: Pin reset improvements.
* Reset SWD lines to SWD rather than GPIO. This makes OpenOCD happier.
* Default speaker enable lines to False for CircuitPlayground to prevent
  the speaker from buzzing when no sound is playing. Fixes #126
2017-05-12 13:14:01 -07:00
Scott Shawcroft 6984425f5d atmel-samd: Correctly wait for the SPI DMA transaction to finish. 2017-05-12 13:13:50 -07:00
Nicholas H.Tollervey f3152571c6
Rename LEFT_BUTTON -> BUTTON_A, RIGHT_BUTTON -> BUTTON_B. 2017-05-11 14:48:17 +01:00
Scott Shawcroft c6d539ace3 atmel-samd: Fix sporadic "syntax errors"
The GC was deleting memory that was in use because its scan of the
stack missed the very top. Switching to _estack fixes this by relying
on the location from the linker.

Fixes #124
2017-05-05 12:04:20 -07:00
Scott Shawcroft 5ad426124b atmel-samd: Move heap objects into MICROPY_PORT_ROOT_POINTERS so they don't get garbage collected while we are using them. 2017-05-04 11:57:51 -07:00
Scott Shawcroft 6512ccf32e atmel-samd: Use DMA for user SPI.
Also replace use of PINMUX_DEFAULT with PINMUX_UNUSED to prevent any
accidental pin changes. This caused user SPI to break internal SPI
flash on the Feather M0 Express.

Fixes #100
2017-05-03 10:50:29 -07:00
Scott Shawcroft 24a5752f94 atmel-samd: Use DMA for SPI flash block transfers.
Fixes #99
2017-05-02 15:25:06 -07:00
Limor "Ladyada" Fried a2c463deb0 Update AudioOut.c
fiiiiiiiiiiiiiiiiiiiiiiiiix
2017-05-01 23:32:37 -04:00
Scott Shawcroft 58b9789d0c atmel-samd: Introduce audio sample playback via audioio.AudioOut. 2017-05-01 13:10:03 -07:00
Scott Shawcroft 30b8091df0 atmel-samd: Clean up leftovers from QTouch. 2017-05-01 11:32:15 -07:00
Scott Shawcroft 4ad22144b0 atmel-samd: Rename metro M0 Express and add NEOPIXEL pin. 2017-05-01 11:29:51 -07:00
Scott Shawcroft bc152da3a6 atmel-samd: Remove debug prints from TouchIn 2017-04-20 16:48:04 -07:00
Scott Shawcroft a9d25bfae4 atmel-samd: Update CircuitPlayground Express pins for Rev G. 2017-04-20 11:25:57 -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 b97edd4465 atmel-samd: Turn on framebuf for Express boards because they have space. 2017-04-18 09:44:04 -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
Dan Halbert 2fe6b74e90 atmel-samd: HID report descriptor for mouse had to be COMPILER_WORD_ALIGNED. 2017-04-15 10:18:56 -04:00
Scott Shawcroft f37ce1c595 atmel-samd: Turn off PulseIn interrupts on reset. Can hardfault otherwise. 2017-04-13 17:50:06 -07:00
Scott Shawcroft f0e24bd812 atmel-samd: Account for pending ticks in PulseIn. Fixes #116. 2017-04-13 14:47:34 -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 8505de1ced atmel-samd: rename cplay_m0_flash to circuitplayground_express and update for new rev (F). 2017-04-11 17:59:02 -07:00
Scott Shawcroft 45dfaa835f atmel-samd: Reset PulseIn correctly on soft reset. 2017-04-11 16:56:06 -07:00
Scott Shawcroft 1e8fc15a41 atmel-samd: Fix PulseIn duration math to handle case when current us time is after the last one but more than a ms has passed. 2017-04-11 16:55:42 -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 3afa09b2fe atmel-samd: Update Feather M0 Express USB pid. 2017-03-27 20:30:02 +01:00
Scott Shawcroft f5caf86870 atmel-samd: Add message for when auto reset is off. Fixes #112 2017-03-27 20:12:30 +01:00
Scott Shawcroft be1ed7aae4 Change to official Feather M0 Express branding. 2017-03-27 19:45:44 +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 fcd60915e2 atmel-samd: Turn on stack checking so infinite recursion doesn't completely crash. 2017-03-09 16:09:13 +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 75d6abe3bb Correct name of mp_raise_NotImplementedError to make error name. 2017-02-24 16:46:38 +01:00
Scott Shawcroft 35071b3681 Make the build quieter by default. 2017-02-24 15:59:59 +01:00
Scott Shawcroft e0ef7e3092 Add indices() support to slice. 2017-02-24 15:13:56 +01:00
Scott Shawcroft 12fa5b3a66 Switch exception throwing to mp_raise helpers. It saves a little code space each time to share the call. 2017-02-24 15:13:07 +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 261a6ff0bb atmel-samd: Fix build by correcting internal neopixel writes. 2017-02-19 17:39:34 +01:00
Scott Shawcroft a5a41d7163 atmel-samd: Save a little space by tweaking error messages. 2017-02-19 17:24:15 +01:00
Scott Shawcroft 8584f5fece atmel-samd: Remove support for UART REPL from Arduino Zero. 2017-02-19 17:23:31 +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 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 c4ee6d5716 atmel-samd: Remove pin reference from AnalogOut error. Fixes #83 2017-02-19 14:38:24 +01:00
Scott Shawcroft c81052a256 atmel-samd: Stop calibrating the crystal for Gemma and Trinket. We need the space for other code. 2017-02-19 14:11:24 +01:00
Scott Shawcroft 9ed3e11aec atmel-samd: Clean up I2C correctly when an initialization error occurs. Fixes #95. 2017-02-13 16:46:57 +01:00
Scott Shawcroft ae715a827b atmel-samd: Rework the clock configs to only be crystalless when needed by the hardware. 2017-02-10 05:09:17 -08: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 597777e80b atmel-samd: Update internal pins for Feather M0 Express Rev B 2017-02-02 12:12:05 -08:00
Scott Shawcroft 1da14b0eec atmel-samd: Switch Metro back to including bootloader space. 2017-02-01 13:16:48 -08:00
Scott Shawcroft 8569395b5d atmel-samd: Turn down the brightness of the status colors. 2017-02-01 13:15:46 -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 749d22b5e6 atmel-samd: stop overwriting the flash FS. 2017-01-19 14:26:57 -08:00
Scott Shawcroft 79024f3fb9 atmel-samd: Change new flash FS name to CIRCUITPY
Fixes #79
2017-01-19 11:47:06 -08:00
Scott Shawcroft dad33e6ad0 atmel-samd: Reset the DAC on soft reset. Fixes #80. 2017-01-19 11:42:33 -08:00
Scott Shawcroft f74e477966 atmel-samd: Fully reset the ADC state on reset to prevent a crash. 2017-01-19 11:26:41 -08:00
Scott Shawcroft d29915ca3d atmel-samd: Fix two more SERCOM configs, PA07 and PA06. 2017-01-18 15:04:35 -08:00
Scott Shawcroft 76a2178bd7 atmel-samd: Fix PA00 and PA01 sercoms. New CircuitPlayground prototype pinout. 2017-01-18 14:51:36 -08:00
Scott Shawcroft 1a86968912 atmel-samd: Fix neopixel timing by forcing the NVM cache to be deterministicly timed. Otherwise, bit order changes code timing. Fixes #74 2017-01-17 19:27:48 -08:00
Scott Shawcroft 42926c6159 atmel-samd: Fix whitespace. 2017-01-17 19:26:28 -08:00
Scott Shawcroft 179413aec2 atmel-samd: Support multiple ADC channels at once.
Fixes #61
2017-01-17 14:40:43 -08:00
Scott Shawcroft d239dbdc28 More fixes to pin pull thanks to jerryn:
* Correct atmel-samd pin pull state.
* Correct conversion from python pull objects to C enum.
2017-01-16 15:32:23 -08:00
Scott Shawcroft 35a5d44399 atmel-samd: Ensure pin state for first script run because we don't
know the post-bootloader state.

Also, color the status LED purple for ValueErrors which are used to
indicate a pin in use.
2017-01-13 15:39:50 -08:00
Scott Shawcroft f6cf8ae208 atmel-samd: Split UART pin names into two so that all names start
with a letter and are therefore valid Python.

Fixes #73.
2017-01-12 13:53:47 -08:00
Scott Shawcroft 9ece7c907d Add persistent VFS shares so that the devices can be used with USB
that is present across soft-reset.
2017-01-12 12:46:44 -08:00
Scott Shawcroft 0d408488c5 atmel-samd: Turn off FRAMEBUF because it takes a lot of space. 2017-01-12 12:46:43 -08: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 24765929ea atmel-samd: Update pinouts for prototypes. 2017-01-08 22:11:27 -08:00
Scott Shawcroft 7c302c395e Improve docs and update to CircuitPython. 2017-01-05 16:20:46 -08:00
Scott Shawcroft 89f4a5597b atmel-samd: New revs which isolate the SPI for the external flash. 2017-01-05 14:36:33 -08:00
Scott Shawcroft a9087fbaa2 atmel-samd: Change cplay pins to rev B. 2016-12-21 15:29:25 -08:00
Scott Shawcroft 7ce69959f9 atmel-samd: Tweaks for rev B of the prototype circuit playground. 2016-12-21 14:07:50 -08:00
Scott Shawcroft f48d2df634 atmel-samd: Improve TouchIn to allow for multiple simultaneous touch pads. 2016-12-20 16:39:32 -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
Scott Shawcroft 576373552a atmel-samd: Run the VM hook while waiting for the UART read to timeout in case nothing is received. 2016-12-19 16:36:32 -08:00
Scott Shawcroft f2bfbab6a0 atmel-samd: Save space by not creating default files on the FS and by only keeping LED flashing code when LEDs are present. 2016-12-19 13:03:50 -08:00