Commit Graph

556 Commits

Author SHA1 Message Date
Jeff Epler abec199c19 Enable high-quality float hash
This appears to have a relatively small impact on flash usage but
fixes some pathological slow behavior putting floats in dicts or sets.

Closes: #704
2018-03-27 21:56:30 -05:00
Jeff Epler fe7f405fc7 Add VfsFat.label property
These allow accessing the filesystem label.  For instance,
in boot.py, you can set the label on the built-in storage with:
   storage.remount('/', False)
   storage.getmount('/').label = "NEWLABEL"
   storage.remount('/', True)

Users with multiple CIRCUITPY boards may find it desirable to
choose a different label for each board they own.
2018-03-27 21:28:18 -05:00
Dan Halbert 4c2f729a7a
Merge pull request #713 from jepler/lto-type-diagnostic-bis
Allow building on gcc 5.4, while preserving ability to build with 7.2
2018-03-27 09:28:41 -04:00
Kattni 77938db8c8
Merge pull request #719 from tannewt/fix_i2c_hang
Fix I2C init hang when the SCL pin is pulled low.
2018-03-26 20:08:14 -04:00
Dan Halbert 4190aa2eed
Merge pull request #715 from jepler/array-operation-restrictions-bis
Remove 'O', 'P' support in arrays
2018-03-26 20:01:34 -04:00
Scott Shawcroft cebcec5e63 Check for floating pins by pulling them low briefly before testing their values. 2018-03-26 16:32:16 -07:00
Jeff Epler 355bf8b553 Conditionally compile out nonstandard array/struct typecodes
.. defaulting to off for circuitpython-supported boards, on for others.

.. fixing up the tests that fail when it is turned off, so that they skip
instead of failing
2018-03-26 18:13:49 -05:00
Scott Shawcroft 25ba8ee489 Add an s because grammar. 2018-03-26 15:21:08 -07:00
Scott Shawcroft 37538fc0e7 Fix I2C init hang when the SCL pin is pulled low.
We added a check to make sure the pins are in a high state before
initing the bus. This leads to a friendly error message when someone
forgets to add the pull up resistors to their circuit.
2018-03-26 15:13:52 -07:00
Scott Shawcroft ea39f4378e
Merge pull request #698 from sommersoft/repl_fix
Fix 128 Character Max Paste Into REPL
2018-03-26 13:02:43 -07:00
sommersoft 9bd55cf4c7
minor cleanup 2018-03-26 08:14:37 -05:00
sommersoft 23009fdd63 future-proof for buffer size changes 2018-03-26 06:25:04 +00:00
Dan Halbert 8b6aeb9e19
Merge pull request #702 from jepler/issue689bis
correct typo in filename
2018-03-25 23:58:00 -04:00
Jeff Epler d57397f9c8 Remove an unneeded -Wno-error=lto-type-mismtach 2018-03-25 22:04:15 -05:00
Jeff Epler c0029e1d97 Don't lose half of the processor's serial number
Before this change, `microcontroller.cpu.uid` returned values
where the top 4 bits of each byte were zero, because of
an incorrect bitmask used in this function.
2018-03-25 13:01:04 -05:00
Dan Halbert 31f5b6a238 WIP: simple working HID 2018-03-24 18:29:12 -04:00
Jeff Epler d80e54458d correct typo in filename 2018-03-24 10:44:24 -05:00
sommersoft 6205ed9a0c updated cdc_enabled; now more dynamic status return 2018-03-24 03:42:58 +00:00
sommersoft ef16109c5d updated with requested changes 2018-03-24 00:55:48 +00:00
sommersoft f237657e5e extended buffer check to usb_cdc_background 2018-03-23 18:41:27 +00:00
Scott Shawcroft 63d826a52a
Update USB PID 2018-03-23 09:34:02 -07:00
sommersoft ccbe557e30 removed leftover debugging bits 2018-03-23 15:45:30 +00:00
sommersoft d434635822 add buffer check before triggering new usb read 2018-03-23 15:07:02 +00:00
Scott Shawcroft fd7dcff4e9 Add Feather M4 Express support.
* Also fixed detection of SPI flash chip to correct look in the 2+
spots.
* Added support for using QSPI in dual read mode.
2018-03-23 00:00:13 -07:00
Scott Shawcroft 06b4c83f59 Add reminder to remove Saleae when going fast. 2018-03-22 17:44:44 -07:00
Scott Shawcroft 3bf4d69f67 Update Metro M4 to rev F and make flash reset on start. 2018-03-22 16:42:47 -07:00
Jeff Epler a7e3c74fed Autocreate files that prevent MacOS indexing of the CIRCUITPYTHON dive
.. the price of this appears to be about 112 bytes of flash and 12
bytes of RAM, according to the stats printed during the build.

It also uses up 4 directory entries (out of 128), but does not reduce
the number of blocks usable for storing file contents.

These are the same items noted in the Adafruit README for Trinket M0
as preventing MacOS indexing.

Closes: #689
2018-03-22 08:07:32 -05:00
Scott Shawcroft 9ab39eb2d2
Merge pull request #688 from jepler/atsamd-build-reqs
Better document build requirements and steps
2018-03-20 10:03:01 -07:00
Scott Shawcroft 0f90f35606
Merge pull request #685 from jepler/uart-diagnostic
UART: Fix maybe-uninitialized diagnostic
2018-03-20 09:59:31 -07:00
Jeff Epler 3f82fe8da9 README.rst: document mpy-cross gotcha
This was biting me, leading to an odd error later on.
2018-03-20 07:53:30 -05:00
Jeff Epler fa491b4c32 README.rst: spell out gcc version requirements
.. the text was adapted from ports/stm32 and a conversation with
Dan Halbert.
2018-03-20 07:53:30 -05:00
Jeff Epler dddfad6594 UART: Fix maybe-uninitialized diagnostic
The following error occurs when building with gcc 5.4.1 (debian stretch):

common-hal/busio/UART.c:104:83: error: 'sercom_index' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                   sercom_insts[rx->sercom[j].index]->USART.CTRLA.bit.ENABLE == 0) ||

It may be related to the addition of rx-only UARTs; gcc is unable
to infer the intended relationship between have_tx and sercom_index
being set (I am still not entirely confident of it myself)
2018-03-19 20:40:04 -05:00
Kattni 05e2a7d1ac Added digital pin assignments 2018-03-15 20:28:09 -04:00
jerryneedell 04b4026666
fix dotstar for Gemma_M0 in CP3.0
Uncomment lines in mpconfigport.h for gemma_m0 to allow dotstar access.  same issue as #514 for trinket_m0
2018-03-14 21:28:56 -04:00
Dan Halbert f173d45941
Merge pull request #678 from tannewt/m0_no_timer_fix
Correct NO_TIMER index value for SAMD21.
2018-03-14 15:04:39 -04:00
Scott Shawcroft 88aa0e2660 Remove SERCOM pointers from pin data structure because index is
enough.

This saves 380 bytes on the Arduino Zero build. (More pins ==
more savings.)
2018-03-14 11:14:32 -07:00
Scott Shawcroft 7a3f86d184 Check usb_busy up front in usb background function.
Waiting to do so risks accidentally queueing another response.

Hopefully fixes #655 but we'll let @jerryneedell confirm.
2018-03-14 10:32:41 -07:00
Scott Shawcroft c37ade9aeb Correct NO_TIMER index value for SAMD21.
We check validity by ensuring it's lower than the total number of
timers. 0 is a terrible number for the NO_TIMER value because its
valid even though it shouldn't be.

Fixes https://github.com/adafruit/Adafruit_CircuitPython_SimpleIO/issues/29
2018-03-13 12:44:00 -07:00
Dan Halbert b64d568267
Merge pull request #677 from tannewt/usb_active_read
Move usb read finish into interrupt.
2018-03-13 15:16:40 -04:00
Scott Shawcroft 8157248189 Move usb read finish into interrupt.
Having the `active_read = false` in the background function left
a chance that a new_write occurs before active_read is set to false.

In that case, we'll read the appropriate data rather than write it
and never clear the active write.

Hopefully fixes #655.
2018-03-13 11:29:29 -07:00
vesperk38 945f2f5aa1
line 172 has a typo correct 2MB to 4MB 2018-03-13 13:42:29 -04:00
Radomir Dopieralski 81ab2526e4 gamepad: Enable the gamepad module for express boards in 3.x 2018-03-11 13:39:54 +01:00
sommersoft 8c9cc6b7c0 nrf: changed Status to Runtime; instituted runtime singleton 2018-03-10 01:07:17 +00:00
Scott Shawcroft e7fc0b6aa7 Use DMA for long SPI transactions including those to the SPI Flash.
QSPI is not currently working so its commented out.

This is progress on #652.
2018-03-09 12:45:46 -08:00
Bryan Siepert 942b7ffbe0 fixes hardware dotstar support for 3.0 and addresses issue #514 2018-03-08 20:39:47 -08:00
sommersoft c1c3a79ec4 atmel-samd: changed Status to Runtime; instituted runtime singleton 2018-03-09 02:19:51 +00:00
Scott Shawcroft 01aceaae50 Support all boards and remove erase and page sizes because they never change. 2018-03-01 12:45:12 -08:00
Scott Shawcroft 2ab923862b Structify flash device definitions. 2018-02-28 19:15:54 -08:00
Dan Halbert 568c04e6af
Merge pull request #650 from tannewt/merge_2x
Merge in commits from 2.x branch.
2018-02-27 22:03:52 -05:00
Scott Shawcroft bf05183158 Merge remote-tracking branch 'adafruit/2.x' into merge_2x 2018-02-27 15:24:16 -08:00
Dan Halbert 5c24023240 use CONF_GCLK_DAC_SRC and refactor a bit 2018-02-27 17:21:03 -05:00
Dan Halbert 4895a9d1d8 Use safe clock freqs for AnalogOut; use DAC REFRESH on SAMD51. 2018-02-27 15:44:27 -05:00
Bryan Siepert e42209a6b2 fixes timer number assumptions for samd51s for issue #646 2018-02-27 00:42:40 -08:00
Scott Shawcroft 586be2eb22
Merge pull request #643 from dhalbert/3.0_esp8266_uart1
Add .baudrate support to ESP8266.
2018-02-26 17:40:13 -08:00
Dan Halbert cc7acfd491 consistently brand Itsy Bitsy M0 as 'Express' 2018-02-26 17:37:03 -05:00
Dan Halbert 907b4417c0 Add .baudrate support to ESP8266.
busio.UART on ESP8266 provides a TX-only UART on GPIO2.
Fixed some bugs in the implementation.
2018-02-24 15:45:15 -05:00
Dan Halbert 957a82b592 add board.RX and .TX pins to metro_m4_express_revb 2018-02-23 09:54:39 -05:00
Kattni 7399a1a5c7
Merge pull request #634 from dhalbert/3.0_UART
Implement UART for 3.0 + related fixes.
2018-02-21 23:07:27 -05:00
Dan Halbert 5f101f3535 Add dummy UART implementation to nrf so it builds with UART turned on. Also add OneWire. 2018-02-21 22:53:17 -05: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
James Devine 9c5a9e3411
Update boards URL in README.rst
Corrected a (probably) old URL in the read me.
2018-02-21 16:14:46 +00:00
Scott Shawcroft d02251f8cd Add a new board for Metro M4 Express Rev B. This is the board
send to community members for testing.

Also tweaked and commented reset pin list for main Metro M4 Express
which is currently unreleased and is Rev D.
2018-02-20 12:34:07 -08:00
Scott Shawcroft 653fc8877d Remove breakpoint instruction used for debugging. 2018-02-19 21:38:14 -08:00
sommersoft 60d6ccc731 changed spaced supervisor/Status.c line to tabbed 2018-02-20 03:44:45 +00:00
sommersoft 5de8df7997 added Status submodule to ports/nrf/common-hal/supervisor; issue #544 2018-02-19 22:27:16 +00:00
Scott Shawcroft 15f626be58 m4 qspi works. m0 compiles 2018-02-19 14:02:04 -08:00
Scott Shawcroft f20d5723aa Reorganize things. Reading jdec works. 2018-02-19 14:02:04 -08:00
Scott Shawcroft 4710a2adba Compiles for m4. Untested on m0.
This introduces a new spi_flash_api.h that works for both SPI and
QSPI. The previous spi_flash functions are now called external_flash
to minimize confusion.
2018-02-19 14:02:04 -08:00
Scott Shawcroft a2bd772d5c Begin rework to add qspi support. 2018-02-19 14:02:04 -08:00
sommersoft 9ee4d13756 added Status submodule to ports/atmel-samd/common-hal/supervisor; issue #544 2018-02-19 20:49:18 +00:00
Dan Halbert cb39bfcad9
Merge pull request #625 from tannewt/pulseio3
Re-enable pulseio for SAMD21 and SAMD51
2018-02-16 14:08:01 -05:00
Scott Shawcroft a2b18b75d4 Fix loops and comma style. 2018-02-16 10:05:28 -08:00
Scott Shawcroft eb2b41810a Turn on lto 2018-02-15 16:12:58 -08:00
Scott Shawcroft 538081528d pulsein works on m0 2018-02-15 16:04:39 -08:00
Scott Shawcroft fcde138ea3 pulsein works on m4 2018-02-15 15:12:58 -08:00
Kevin Townsend fce0b0858f Removed leftover build option 2018-02-15 21:46:14 +01:00
Kevin Townsend 10497d1db0 Update for style consistency 2018-02-15 21:44:05 +01:00
Kevin Townsend 6544f4cb5c Cleanup minor typos 2018-02-15 21:42:24 +01:00
Kevin Townsend da15053e0a Fixed pin P0_00 2018-02-15 21:41:21 +01:00
Kevin Townsend d4356f9416 Added second 'P0_00' 2018-02-15 17:00:58 +01:00
Kevin Townsend cd7baed14d Added note nrfutil and flashing 2018-02-15 16:00:34 +01:00
Kevin Townsend 70596b6641 Added note on MSDDisable 2018-02-15 15:51:10 +01:00
hathach f989db25b5 more bootloader feather52840 update 2018-02-15 21:43:27 +07:00
hathach 2e0edd5a63 Merge branch 'nrf52840' of github.com:microbuilder/circuitpython into nrf52840 2018-02-15 15:19:47 +07:00
hathach 2c9cd38547 update bootloader for feather52840 2018-02-15 15:12:30 +07:00
Scott Shawcroft 07230f2637 pulsein compiles but doesn't work 2018-02-14 16:59:04 -08:00
Scott Shawcroft c7af17525b m4 pulseout works 2018-02-14 11:38:52 -08:00
Scott Shawcroft 6a7d889dd4 m0 pulseout works. Factored out shared timer code. 2018-02-13 18:17:20 -08:00
Scott Shawcroft 8479eef578 m0 tc and tcc work 2018-02-13 16:44:04 -08:00
Scott Shawcroft 6c3075bec6 m4 tc and tcc works. multi-tcc channels ok too. 2018-02-13 14:22:55 -08:00
Kevin Townsend 0981c579f0 Fixed pin names 2018-02-13 18:26:28 +01:00
Kevin Townsend b65e97bdb3 Update pin names 2018-02-13 18:17:31 +01:00
Kevin Townsend 5160dda473 Merge branch 'master' into nrf52840 2018-02-13 18:13:47 +01:00
Kevin Townsend 7b1cc9985b Merge branch 'master' of github.com:adafruit/circuitpython 2018-02-13 18:11:20 +01:00
Kevin Townsend fac488fbf8
Merge pull request #617 from arturo182/nrf_gpio_cleanup
nrf: Change pin names on DKs to match silkscreen
2018-02-13 17:54:25 +01:00
Kevin Townsend 283be4f58e Added note on installing nrfutil 2018-02-13 11:55:24 +01:00
Kevin Townsend 7b6d1052d9 Improved README 2018-02-13 11:50:51 +01:00
Kevin Townsend 6a8bafc91b Updated FATFS to 256KB 2018-02-13 11:50:29 +01:00
Kevin Townsend fc28fc4f0b Added notes on flashing bootloader 2018-02-13 11:26:10 +01:00
Kevin Townsend 4745272d6c Added feather52840 readme 2018-02-13 09:34:09 +01:00
Kevin Townsend 76eacad27b
Updated board detection macro 2018-02-13 08:52:17 +01:00
Kevin Townsend 9f1cd41d77
Update to S140 2018-02-13 08:44:35 +01:00
Kevin Townsend d2b8ae66cb
Update mpconfigboard.h 2018-02-13 08:42:44 +01:00
Scott Shawcroft cc616aea4e m4 tc output works. Watch out for the PAC! 2018-02-12 23:41:26 -08:00
Kevin Townsend 59f25fb7a5
Update to S140 2018-02-13 08:40:40 +01:00
hathach 3a54a67f3d add 52840 serial bootloader 2018-02-13 13:32:47 +07:00
hathach 3bb45511fa add feather52840 board 2018-02-13 12:26:34 +07:00
arturo182 7579057ee2 nrf: Use -O1 for debug builds
While O0 is great for debugging, the produced binary doesn't fit on the
feather52 anymore.
2018-02-12 22:50:07 +01:00
arturo182 9962ea6449 nrf: Change pin names on DKs to match silkscreen
Quite a big revamp of the make-pins script, it is now used on each
build to generate the pin files, so the static ones are not needed
anymore.
2018-02-12 22:41:19 +01:00
Kevin Townsend 0388a57f77
Merge pull request #614 from arturo182/nrf_pca10040
nrf: Fix pca10040 support
2018-02-12 16:31:14 +01:00
Kevin Townsend 5d99cd0a20
Merge pull request #601 from arturo182/nrf_cleanup
Nrf cleanup
2018-02-12 11:28:47 +01:00
arturo182 f1d8a2d149 nrf: Fix memory misalignment during flash write 2018-02-10 14:43:58 +01:00
Scott Shawcroft 0397202288 m4 compiles, pwmout implemented but TC0 (A1) doesn't run 2018-02-09 17:21:06 -08:00
Scott Shawcroft 0398f308fa m4 compiles, pwmout implemented 2018-02-09 16:37:27 -08:00
Scott Shawcroft 190e7d629e WIP 2018-02-09 16:37:27 -08:00
Dan Halbert b001c0711b Correct _etext location; clean up .ld files
1. Make _extext and _sidata coincide. Old _etext location did not include
.ARM.exidx sections, which were usually absent but not always. So flash
data was copied to RAM in wrong place.
2. Use decimal constants with "K" and "M" suffixes in .ld files instead
of hex constants, to make them easier to read and check for accuracy.
2018-02-09 11:31:18 -05:00
Dan Halbert 6be6df6ae4
Merge pull request #609 from tannewt/bitbangio
Enable bitbangio now that we have digitalio.
2018-02-08 21:24:32 -05:00
Scott Shawcroft 3e63f59867 Use write instead of set because it clears the bits before setting them. 2018-02-08 16:12:33 -08:00
Scott Shawcroft aeae0090af Enable bitbangio now that we have digitalio.
Also remove a rogue neopixel_write.
2018-02-08 16:03:05 -08:00
Scott Shawcroft 82bc11585e ports/atmel-samd: Re-enable analogio
This introduces SAMD51 support and re-enables SAMD21 support.

Fixes #263
2018-02-08 14:48:08 -08:00
Scott Shawcroft 3e79638b9c
Merge pull request #603 from siddacious/SAMD51G_support
Added SAMD51G support as per issue #597
2018-02-08 09:55:48 -08:00
Kevin Townsend e5f0cfcf20
Merge pull request #604 from arturo182/nrf_bitbangio
nrf: Use the shared bitbangio module
2018-02-08 09:57:44 +01:00
Bryan Siepert dfc2b82ede Added SAMD51G support as per issue #597 2018-02-07 21:23:25 -08:00
Kevin Townsend 71128b575f
Merge pull request #602 from arturo182/nrf_struct
nrf: Use the shared struct module
2018-02-08 00:56:31 +01:00
arturo182 a7cde0e49a nrf: Fix pca10040 support
Works with no SD, or s132 2.0.1 and 5.0.0.
2018-02-07 23:41:21 +01:00
arturo182 381f47bfb0 nrf: Only support SD 132 v2.0.1 and v5.0.0 and SD 140 v6.0.0 2018-02-07 22:44:27 +01:00
arturo182 8bfdaa89b9 nrf: Remove SAMD mentions carried over while copying files 2018-02-07 22:44:27 +01:00
arturo182 05bd5d4ee6 nrf: Remove nRF51 boards and files, update README 2018-02-07 22:44:13 +01:00
arturo182 29ae4cdd1c nrf: Fix building pca10056 without SD 2018-02-07 22:41:26 +01:00
arturo182 47c8e20e5a nrf: Make sure to not use SD functions when SD not available 2018-02-07 22:41:20 +01: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
arturo182 afaee7f782 nrf: Use the shared bitbangio module 2018-02-07 00:03:23 +01:00
arturo182 021df5d3d3 nrf: Cleanup AnalogOut and throw an exception in constructor
The nRF MCUs do not support analog output. Throwing an exception
in the constructor will stop users from creating an instance of
the AnalogOut class.

In the future we can ifdef-out the whole class so it is not available
in the module at all.
2018-02-06 21:15:49 +01:00
Kevin Townsend c433a82082
Merge pull request #573 from arturo182/master
nRF port improvements and pca10056 support
2018-02-06 15:26:40 +01:00
arturo182 d1b2f69771 nrf: Use the shared struct module 2018-02-05 20:50:06 +01:00
arturo182 1de2ee6884 nrf: Implement ticks, add gamepad module and example 2018-02-05 20:48:25 +01:00
arturo182 76f5c01798 nrf: Get the port working on pca10056 (nRF52840) 2018-02-05 20:38:41 +01:00
arturo182 a64b5c84de nrf: Fix missing LED GPIO initialization
led_init was never called, which means the GPIOs were never set to
output and the LEDs didn't work.
2018-02-03 13:51:11 +01:00
arturo182 6731b47d5a nrf: Implement MCU temperature reading
If softdevice is available and enabled the SD function will be used,
otherwise use MCU registers.
2018-02-02 20:33:21 +01:00
arturo182 c6a542d166 nrf: Add SD 6.0.0-6.alpha to the download script 2018-02-02 20:31:47 +01:00
arturo182 fed9087274 nrf: Add flash section for fatfs for no SD pca10056 2018-02-02 20:31:47 +01:00
arturo182 616cbc6271 nrf: Use more generic header
It will include the mcu-specific header based on defines.
2018-02-02 20:31:47 +01:00
arturo182 d0b451be94 nrf: Use the right SPI registers on nRF52840 2018-02-02 20:31:47 +01:00
arturo182 a776c2a51c nrf: Fix errorneous indent
Otherwise we get the "recipe commences before first target" messsage.
2018-02-02 20:31:47 +01:00
Dan Halbert eb49359aec CPX: typo in mpconfigboard.h broke CIRCUITPY 2018-01-30 15:48:22 -05:00
Dan Halbert 64831f4e7d add SPI.frequency to nRF 2018-01-30 13:23:00 -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
Dan Halbert a1e279a9d8
Merge pull request #556 from python-ugame/ugame10-3.0
Update ugame port for the final ugame10 version
2018-01-29 13:35:06 -08:00
Radomir Dopieralski d595a03bbd Update ugame port for the final ugame10 version
There have been multiple uGame prototypes with differences in the pins
and other details. This updates the board definition to fit the final
uGame 10 design.
2018-01-29 22:19:09 +01:00
Radomir Dopieralski 189c62ac7d Bring back the _stage library
I have tested the _stage module, and it works fine, so I'm including it
in he sources again. It's still disabled by default in the
mpconfigport.h.
2018-01-29 21:24:46 +01:00
Dan Halbert efbf08266b make _estack be double-word aligned 2018-01-24 19:24:36 -05:00
Scott Shawcroft 6560596864 Switch to m_malloc_maybe and m_free to reduce our dependence on gc_alloc.
gc_alloc's API is changing and we shouldn't need to care about it.
So, we switch to m_malloc which has the default behavior we expect.
2018-01-23 16:45:07 -08:00
sommersoft fe851fc15e re-added header inlcusion for system_get_chip_id 2018-01-23 13:50:24 -08:00
brentrubell ab1f133667 issue #536 CPX change SPI pin designations to externally available pins (#540)
* issue #536 CPX

* switched pin assignment
2018-01-22 19:31:55 -08:00
Tony DiCola 4bd1d09d74 Add missing Feather M0 RadioFruit boards: RFM69, RFM9x (#539) 2018-01-19 11:53:47 -08: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
hathach dfa6b6e9c5 add Ctrl+C for REPL over bleuart 2018-01-18 11:32:47 -08:00
Kevin Townsend d5af898999 Added note on REPL over NUS 2018-01-18 11:32:47 -08:00
hathach 5e6f113779 add REPL via bleuart 2018-01-18 11:32:47 -08:00
microbuilder fda065ea89 Minor scan example cleanup 2018-01-18 11:32:47 -08:00
microbuilder e2ebcbe514 Simple BLE scanner example 2018-01-18 11:32:47 -08:00
microbuilder 1276c12097 Enable SD132v2.0.1 BLE and UBLUEPY support by default 2018-01-18 11:32:47 -08:00
Dan Halbert 23eb79ca8f turn on MICROPY_ENABLE_SOURCE_LINE in nrf 2018-01-16 18:11:54 -08:00
Dan Halbert 01443a9619 Make chosen features consistent across all boards and ports atmel-samd, esp8266, and nrf.
1. Turn off MICROPY_CPYTHON_COMPAT, which includes a number of minor CPython compatibility features,
most of which have workarounds, but uses up significant flash.
2. Turn on MICROPY_PY_SYS_MAXSIZE, which implements sys.maxsize.
3. Turn on MICROPY_CAN_OVERRIDE_BUILTINS, which implements "_" as the most recent value in the REPL,
and also enables redefining builtins.
2018-01-16 18:11:54 -08:00
Dan Halbert 2d5483082d Checked wrong RCAUSE bit for system_reset 2018-01-08 15:45:07 -08:00
Dan Halbert 1805bcac76 enable use of CIRCUITPY_CANARY_WORD (needed for 2.2 merge) (#513)
enable use of CIRCUITPY_CANARY_WORD (needed for 2.2 merge)

RCAUSE (reset cause) is fetched differently in SAMD21 vs SAMD51
2018-01-08 09:44:06 -08:00
Dan Halbert d0cc8abd31 revise boards/ files for 3.0. All now compiled (but I don't have all to test). 2018-01-04 14:16:53 -05:00
Dan Halbert 19d353ccd9 nrf: fixups for changes from 2.2
1. bidirectional SPI support (@microbuilder please check)
2. slight changes in DigitalIO types
3. placeholders (not implemented yet) for single/double-click bootloader support
2018-01-03 16:50:57 -05:00
Dan Halbert d8686cc002 use correct LD_FILE in mpconfigboard.mk for boards with external flash 2018-01-03 16:49:38 -05:00
Dan Halbert 065e82015f merge from 2.2.0 + fix up board defs 2018-01-02 21:25:41 -05:00
Dan Halbert ce81c8dda9 Avoid gcc 7.2.1 compiler issues in nlr_push() (#506)
Avoid gcc 7.2.1 compiler issues in nlr_push()
2018-01-02 13:41:34 -08:00
hathach a997ab258e spacing clean up 2017-12-29 23:07:32 +07:00
hathach 7f79a0e78c added Ctrl+C interrupt 2017-12-29 22:43:31 +07:00
hathach a021a9e5f0 update uart to remove dependency on machine uart module 2017-12-29 21:25:43 +07:00
microbuilder 178925640b Moved comment to avoid abbreviation 2017-12-27 21:13:39 +01:00
microbuilder a14bfeba64 Merge branch 'nrf52_3.x' of github.com:microbuilder/circuitpython into nrf52_3.x 2017-12-22 12:03:41 +01:00
microbuilder 60feb1a9aa Added .gitattributes for ZIP bin support 2017-12-22 12:03:25 +01:00
Kevin Townsend b3928288f0
Add files via upload 2017-12-22 12:02:15 +01:00
Kevin Townsend 8dcd9cc35c
Delete feather52_bootloader_5.0.0_s132_single.zip 2017-12-22 12:00:41 +01:00
Kevin Townsend de72f7fabb
Delete feather52_bootloader_2.0.1_s132_single.zip 2017-12-22 12:00:34 +01:00
microbuilder ad7cd0399d Added 'mp_raise_NotImplementedError(NULL)' 2017-12-22 11:48:07 +01:00
microbuilder b9e229f739 Removed old code snippets 2017-12-22 11:47:15 +01:00
microbuilder ace872bf11 Added 'mp_raise_NotImplementedError(NULL)' 2017-12-22 11:45:51 +01:00
microbuilder a3289c3c2f Added D13 for standard LED examples 2017-12-22 11:42:33 +01:00
microbuilder 393bc9bce9 Removed leftover code snippet 2017-12-22 11:39:40 +01:00
microbuilder c868b66f5b Minor typo removed in path 2017-12-22 11:33:17 +01:00
microbuilder 99dd0a61ff Spaces to tabs 2017-12-22 11:29:39 +01:00
microbuilder 60a23f0fb6 nRF52 update with internal file system support 2017-12-21 13:49:14 +01:00
Dan Halbert 72c911be97 Support SPI flash chips for CIRCUITPY, using non-DMA SPI for now. 2017-11-27 21:00:24 -05:00
Stewart fb1dcd326d ports/atmel-samd: feather_m0_adalogger readme updates (#460)
- Added D4 and moved associated SD_CS so that they are paired within list
- Added D7 and SD_CD which is the SD Card Detect pin
- Added D8 and GREEN_LED
- Added RED_LED associated with D13
- Added Setup information regarding arm complier packages
- README - Updated to reflect that feather_m0_adalogger microSD is supported
2017-11-26 21:10:01 -08:00
Stewart Colborne 5eb7958425 ports/atmel-samd/boards/feather_m0_adalogger/pins: Added missing pins
- Added D4 and moved associated SD_CS so that they are paired within list
- Added D7 and SD_CD which is the SD Card Detect pin
- Added D8 and GREEN_LED
- Added RED_LED associated with D13
2017-11-25 22:00:32 -08:00
Kevin Townsend ce75a21e50 Revert "Supervisor REPL support for ports/nrf/boards/feather52"
This reverts commit 92113dde81.
2017-11-23 13:38:38 +01:00
Kevin Townsend 92113dde81 Supervisor REPL support for ports/nrf/boards/feather52 2017-11-23 09:22:11 +01:00
mrmcwethy e0eae5cb2a Enable the Neopixel status light on Metro M0 Express and Feather M0 Express boards 2017-11-21 14:39:56 -08:00
Dan Halbert 6f662e9bbc samd51 peripheral clocks were defined as 12MHz, but were really 120MHz 2017-11-20 21:11:30 -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
Kevin Townsend 237cc954e3 Fixed feather52 DFU support 2017-11-10 09:17:24 +01:00
Scott Shawcroft ef9a7f262a atmel-samd: Turn off nvmctl cache and rework active_read. 2017-11-08 16:01:38 -08:00
Scott Shawcroft 971bd7e9a6 atmel-samd: Improve MSC reliability.
* Be more liberal with critical sections to ensure ordering.
* Correct usb_busy so that it is busy when no errors occur on
  transfer. I believe it worked before because it would be false
  momentarily until a second transfer was attempted and a busy
  error was returned, therefore setting usb_busy to true. That
  risks the first "failed" transfer completing before a second one
  is attempted.
2017-11-08 12:42:50 -08:00
Scott Shawcroft 7a901cfccd atmel-samd: Align SCSI responses. 2017-11-08 10:47:22 -08:00
Scott Shawcroft 3cb5e7ea58 atmel-samd: Update Feather M0 Express USB PID
This makes it different from the bootloaders and Arduino.
2017-11-07 14:26:37 -08:00
Dan Halbert 9060df5af6 DigitalInOut: Use pin value % 32 to accomodate PORTB and up.
Fixes #407.
2017-11-07 10:08:34 -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
Scott Shawcroft 182a946b0e atmel-samd: Tweak mass storage code to finish read sooner. 2017-11-06 16:30:11 -08:00
Scott Shawcroft a8ee0012d7 atmel-samd: Enable -Os for SAMD51 and update neopixel accordingly. 2017-11-06 16:30:11 -08:00
Jerry Needell e2867eb4e9 enable framebuf for ESP8266 2017-11-06 14:54:54 -08:00
Scott Shawcroft 4140b3b944 atmel-samd: Stop double CSW after MSC reads
This explicit zero length xfer leads to a second CSW packet. If
another read was started between the two CSWs then the host gets
confused and resets the device.

On reads, the CSW is automatically sent when we reply with the
total length. Writes must do it manually so they can wait for the
disk to flush the data.
2017-11-03 15:08:55 -07:00
Scott Shawcroft c90a2d9b42 atmel-samd: Fix SAMD51 SWCLK reset so we can connect the JLink
while CircuitPython is running.
2017-11-02 14:00:38 -07:00
Scott Shawcroft a49200d5cb tools: Switch to using separate usb_descriptor repo. 2017-11-02 13:00:50 -07:00
Scott Shawcroft 7b393bc406 Merge tag 'v1.9.3'
Introduction of ports subdirectory where all ports are moved to

The main change in this release is the introduction of a "ports/"
subdirectory at the top-level of the repository, and all of the ports are
moved here.  In the process the "stmhal" port is renamed to "stm32" to
better reflect the MCU that it targets.  In addition, the STM32 CMSIS and
HAL sources are moved to a new submodule called "stm32lib".

The bytecode has changed in this release, compared to the previous release,
and as a consequence the .mpy version number has increased to version 3.
This means that scripts compiled with the previous mpy-cross must be
recompiled to work with this new version.

There have also been various enhancements and optimisations, such as:
check for valid UTF-8 when creating str objects, support for reverse
special binary operations like __radd__, full domain checking in the math
module, support for floor-division and modulo in the viper emitter,
and addition of stack overflow checking when executing a regex.

The stm32 port sees improved support for F7 MCUs, addition of a new board
B_L475E_IOT01A based on the STM32L475, and support for the Wiznet W5500
chipset along with improved socket behaviour.

A detailed list of changes follows.

py core:
- objstr: startswith, endswith: check arg to be a string
- nlrx86,x64: replace #define of defined() with portable macro usage
- objtype: handle NotImplemented return from binary special methods
- objtype: mp_obj_class_lookup: improve debug logging
- map: remove unused new/free functions
- make m_malloc_fail() have void return type, since it doesn't return
- modstruct: in struct.pack, stop converting if there are no args left
- modstruct: check and prevent buffer-read overflow in struct unpacking
- modstruct: check and prevent buffer-write overflow in struct packing
- nlrthumb: get working again on standard Thumb arch (ie not Thumb2)
- objfloat: fix binary ops with incompatible objects
- obj: fix comparison of float/complex NaN with itself
- objtype: implement fallback for instance inplace special methods
- objtuple: properly implement comparison with incompatible types
- objstr: add check for valid UTF-8 when making a str from bytes
- objlist: properly implement comparison with incompatible types
- runtime0.h: move relational ops to the beginning of mp_binary_op_t
- runtime0.h: move MP_BINARY_OP_DIVMOD to the end of mp_binary_op_t
- objtype: make sure mp_binary_op_method_name has full size again
- runtime0.h: put inplace arith ops in front of normal operations
- builtinhelp: simplify code slightly by extracting object type
- runtime: implement dispatch for "reverse op" special methods
- nlrx86: fix building for Android/x86
- builtinhelp: change signature of help text var from pointer to array
- runtime.h: change empty mp_warning macro so var-args are non empty
- modbuiltins: implement abs() by dispatching to MP_UNARY_OP_ABS
- {objfloat,objcomplex}: optimise MP_UNARY_OP_ABS by reusing variables
- mpconfig.h: add note that using computed gotos in VM is not C99
- objstr: strip: don't strip "\0" by default
- objexcept: prevent infinite recursion when allocating exceptions
- stream: remove unnecessary checks for NULL return from vstr_add_len
- vstr: raise a RuntimeError if fixed vstr buffer overflows
- vm: use lowercase letter at start of exception message
- persistentcode: define mp_raw_code_save_file() for any unix target
- add config option to print warnings/errors to stderr
- objfloat: support raising a negative number to a fractional power
- objset: simplify set and frozenset by separating their locals dicts
- objset: check that RHS of a binary op is a set/frozenset
- objset: include the failed key in a KeyError raised from set.remove
- objtype: change type of enum-to-qstr table to uint16_t to save space
- objstr: make empty bytes object have a null-terminating byte
- mpprint: only check for null string printing when NDEBUG not defined
- objtype: clean up unary- and binary-op enum-to-qstr mapping tables
- persistentcode: bump .mpy version number to version 3
- bc: update opcode_format_table to match the bytecode
- modmath: add full checks for math domain errors
- modmath: convert log2 macro into a function
- formatfloat: don't print the negative sign of a NaN value
- formatfloat: use standard isinf, isnan funcs instead of custom ones
- modbuiltins: use existing utf8_get_char helper in builtin ord func
- emitnative: implement floor-division and modulo for viper emitter
- objtype: use CPython compatible method name for sizeof
- objtype: fit qstrs for special methods in byte type
- objtype: define all special methods if requested
- objtype: introduce MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS

extmod:
- modubinascii: only include uzlib/tinf.h when it's really needed
- modussl_mbedtls: allow to compile with MBEDTLS_DEBUG_C disabled
- machine_pinbase: put PinBase singleton in ROM
- re1.5: upgrade to v0.8.2, adds hook for stack overflow checking
- modure: add stack overflow checking when executing a regex
- uos_dupterm: update uos.dupterm() and helper funcs to have index
- uos_dupterm: swallow any errors from dupterm closing the stream
- vfs: replace VLA in proxy func with small, static sized array
- modussl: add finaliser support for ussl objects
- modussl_mbedtls: allow to compile with unix coverage build

lib:
- add new submodule, stm32lib containing STM32 CMSIS and HAL source
- embed/abort_: use mp_raise_msg helper function
- libm: fix tanhf so that it correctly handles +/- infinity args
- libm: remove implementation of log2f, use MP_NEED_LOG2 instead
- axtls: update, support for SSL_EAGAIN return code
- berkeley-db-1.xx: update, allow to override MINCACHE, DEFPSIZE

drivers:
- memory/spiflash: change from hard-coded soft SPI to generic SPI
- display/ssd1306.py: improve performance of graphics methods
- nrf24l01: make nRF24L01 test script more portable
- display/ssd1306: implement SSD1306_I2C poweron method
- display/ssd1306: make poweron() work the same with SSD1306_SPI
- wiznet5k: improve the performance of socket ops with threading
- wiznet5k: get low-level W5500 driver working

tools:
- upip: upgrade to 1.2.2
- pyboard: use repr() when quoting data in error messages
- pyboard: update docstring for additional device support

tests:
- object_new: better messages, check user __new__() method
- class_new: add checks for __init__ being called and other improvements
- class_new: add another testcase for __new__/__init__ interaction
- class_inplace_op: test for inplace op fallback to normal one
- run-bench-tests: update locations of executables, now in ports/
- class_reverse_op: test for reverse arith ops special methods
- run-tests: skip class_inplace_op for minimal profile
- run-tests: fix copy-paste mistake in var name
- cpydiff: add cases for locals() discrepancies
- extmod: add test for ure regexes leading to infinite recursion
- extmod: add test for '-' in character class in regex
- run-tests: close device under test using "finally"
- net_inet: update tls test to work with CPython and incl new site

unix port:
- rename modsocket.c to modusocket.c
- modusocket: remove #if MICROPY_SOCKET_EXTRA code blocks
- enable MICROPY_PY_REVERSE_SPECIAL_METHODS

stm32 port:
- modmachine: make machine.bootloader() work when MPU is enabled
- modmachine: improve support for sleep/deepsleep on F7 MCUs
- compute PLL freq table during build instead of at run time
- modmachine: for F7 MCU, save power by reducing internal volt reg
- boards/pllvalues.py: make script work with both Python 2 and 3
- Makefile: use lib/stm32lib instead of local cmsis and hal files
- remove cmsis and hal files, they are now a submodule
- Makefile: automatically fetch stm32lib submodule if needed
- update to new STM Cube HAL library
- fix clock initialisation of L4 MCUs
- rename stmhal port directory to stm32
- remove unused usbd_msc.c file
- boards: change remaining stm32f4xx_hal_conf.h to unix line ending
- boards: change linker scripts to use "K" instead of hex byte size
- boards: fix I2C1 pin mapping on NUCLEO_F401RE/F411RE boards
- i2c: when scanning for I2C devices only do 1 probe per address
- modnwwiznet5k: release the GIL on blocking network operations
- boards: add new board B_L475E_IOT01A based on STM32L475
- make-stmconst.py: make sure mpz const data lives in ROM
- timer: make pyb.Timer() instances persistent
- mpconfigport.h: add configuration for max periphs on L4 series
- usbdev: make the USBD callback struct const so it can go in ROM
- usbdev: change static function variable to non-static
- usbdev: put all CDC state in a struct
- usbdev: put all HID state in a struct
- usbdev: simplify CDC tx/rx buffer passing
- usbdev: simplify HID tx/rx buffer passing
- usbdev/core: add state parameter to all callback functions
- usbdev: put all state for the USB device driver in a struct
- usbdev: simplify pointers to MSC state and block dev operations
- usbdev: merge all global USB device state into a single struct
- usbdev: make device descriptor callbacks take a state pointer
- usbdev: move all the USB device descriptor state into its struct
- timer: enable ARPE so that timer freq can be changed smoothly
- modnwwiznet5k: get the IP address of an established socket
- boards: fix typos in stm32f767_af.csv table
- usbd_cdc_interface: don't reset CDC output buf on initialisation
- modnwwiznet5k: implement WIZNET5K.isconnected() method
- modusocket: make getaddrinfo() work when passed an IP address
- modusocket: return OSError(-2) if getaddrinfo fails
- mpconfigport.h: add MICROPY_THREAD_YIELD() macro
- modnwwiznet5k: add support for W5500 Ethernet chip
- modnwwiznet5k: increase SPI bus speed to 42MHz
- modnwwiznet5k: implement stream ioctl for the Wiznet driver
- mphalport: improve efficiency of mp_hal_stdout_tx_strn_cooked
- make uos.dupterm() conform to specs by using extmod version

cc3200 port:
- enable micropython.kbd_intr() method
- use standard implementation of keyboard interrupt

esp8266 port:
- rename axtls_helpers.c to posix_helpers.c
- posix_helpers: set ENOMEM on memory alloc failure
- set DEFPSIZE=1024, MINCACHE=3 for "btree" module
- esp_mphal: send data in chunks to mp_uos_dupterm_tx_strn
- modnetwork: add "bssid" keyword arg to WLAN.connect() method
- modules/webrepl_setup: add info about allowed password length

zephyr port:
- Makefile: revamp "test" target after ports were moved to ports/
- use CONFIG_NET_APP_SETTINGS to setup initial network addresses
- switch to interrupt-driven pull-style console

pic16bit port:
- add definition of SEEK_SET to unistd.h

docs:
- pyboard/tutorial: add "timeout=0" to UART in pass-through example
- more xrefs to "MicroPython port" in glossary
- library/network: fix ref to "socket" module (should be "usocket")
- machine.Signal: improve style/grammar and add usage example
- library: add description of "index" parameter to uos.dupterm()
- library/micropython: fix typo in RST formatting
- library/framebuf.rst: generalise constructor to all colour formats
- btree: describe page caching policy of the underlying implementation
- esp8266/tutorial: update neopixel with example of using 4 bbp
- library/network: clarify usage of "bssid" arg in connect() method
- pyboard/quickref: add info for Switch, RTC, CAN, Accel classes
- pyboard/tutorial: update now that yellow LED also supports PWM
- esp8266/quickref: add quickref info for RTC class
- library: add missing cross-ref links for classes in pyb module
- library/network: update docs to state that W5500 is supported
- uselect: document one-shot polling mode
- usocket: elaborate descriptions
- usocket: document inet_ntop(), inet_pton()
- library/network: add dhcp_hostname parameter
- reference/isr_rules: minor typo correction
- ussl: fix module name refs and use "MicroPython port" term
- esp8266/general: add section on TLS limitations
- usocket: document that settimeout() isn't supported by all ports
- ure: add "|" (alternative) to the list of supported operators
- reference/isr_rules.rst: add tutorial on use of micropython.schedule()

travis:
- use --upgrade when pip is installing cpp-coveralls
- update build command now that stm32 Wiznet config has changed

examples:
- hwconfig_console: add .on()/.off() methods

all:
- convert mp_uint_t to mp_unary_op_t/mp_binary_op_t where appropriate
- convert remaining "mp_uint_t n_args" to "size_t n_args"
- make new ports/ sub-directory and move all ports there
- update Makefiles and others to build with new ports/ dir layout
- remove inclusion of internal py header files
- use NULL instead of "" when calling mp_raise exception helpers

README:
- update "Dependencies" section
- add explicit section on contributing
- add gcc and arm-none-eabi-newlib to list of required components

.gitattributes:
- remove obsolete entries for stmhal/hal, stmhal/cmsis
- add entries for files that will move to ports/ dir
2017-11-02 12:41:50 -07:00
Scott Shawcroft 3cfb06042e atmel-samd: update to October 2017 ASF4. 2017-11-02 12:19:50 -07:00
Scott Shawcroft a8dae22ae9 atmel-samd: Fix the neopixel delay method so it handles overflow better. 2017-11-01 11:56:54 -07:00
Dan Halbert 3b17980822
Merge pull request #391 from tannewt/longint_usb_fix
Enable LONGINT on M4 + usb fix
2017-11-01 14:19:17 -04:00
Scott Shawcroft cfbb74ffe7 atmel-samd: Reorder mpconfigport.mk and mpconfigboard.mk includes.
This allows mpconfigport.mk to set this conditionally based on
$(CHIP_FAMILY).
2017-11-01 11:01:34 -07:00
Dan Halbert 0076a3c868
Merge pull request #393 from tannewt/m4_neopixel
Now with more blinky!!!
2017-11-01 08:17:41 -04:00
Scott Shawcroft f4c8256345 atmel-samd: Add TX/RX led support for Metro M4. 2017-10-31 22:39:16 -07:00
Scott Shawcroft 54f2b698ce atmel-samd: remove infinite loop if USB MSC read fails. 2017-10-31 22:38:52 -07:00
Scott Shawcroft 3177e10e9e atmel-samd: Add samd21 neopixel support.
Also, fix and enable the status neopixel.

Fixes #264
2017-10-31 22:38:09 -07:00
Damien George 5ae9586541 teensy: Get port compiling without any warnings. 2017-11-01 11:00:30 +11:00
Tony DiCola d023879bea atmel-samd: Update and enable neopixel_write for ASF4, tested on SAMD21 only. 2017-10-31 16:06:36 -07:00
Scott Shawcroft 15dcc7011c atmel-samd: Turn on slice assignment in all builds.
This costs 376 bytes on a Trinket M0 leaving 33412 bytes free.

Fixes #193
2017-10-31 15:57:56 -07:00
Scott Shawcroft 9db321d505 atmel-samd: Enable longints for M4 builds.
Fixes #110
2017-10-31 15:46:42 -07:00
Scott Shawcroft 268bf6f99e atmel-samd: Fix non-DEBUG USB cdc.
I believe the issue was that LTO exacerbates a problem where a CDC
read is initiated but fails and leaves pending_read true
preventing further reads.
2017-10-31 15:43:45 -07:00
Radomir Dopieralski 8c7571a75d Create the build directory before running gen_usb_descriptor
Otherwise it fails to create the file in that directory.
2017-10-31 13:35:22 -07:00
Scott Shawcroft 4aeef100f6 atmel-samd: More USB polish
* Introduce a python script to generate the USB descriptor instead of
  a bunch of C macros. In the future, we can use this dynamically in
  CircuitPython.
* Add support for detecting read-only mass storage mounts.

Fixes #377
2017-10-30 18:29:20 -07:00
Paul Sokolovsky 24c8eda744 unix: Enable MICROPY_PY_REVERSE_SPECIAL_METHODS.
With inplace methods now disabled by default, it makes sense to enable
reverse methods, as they allow for more useful features, e.g. allow
for datetime module to implement both 2 * HOUR and HOUR * 2 (where
HOUR is e.g. timedelta object).
2017-10-28 13:05:57 +03:00
Dan Halbert 8e45dc041f Read serial input as a background task so we can check for the interrupt character. 2017-10-27 17:32:13 -04:00
Dan Halbert 10b3a90189 Check INTERNAL_LIBM make flag in a safer way. 2017-10-27 17:32:13 -04:00
Dan Halbert 7f88ba3b26 Revert "Allow main.py to be interrupted by ctrl-C" (#381)
* Revert "Read serial input as a background task so we can check for the interrupt character."

This reverts commit 046092e8a2.

* Revert "Check INTERNAL_LIBM make flag in a safer way."

This reverts commit 2b80add22f.
2017-10-27 17:32:13 -04:00
Dan Halbert 2487226dff Read serial input as a background task so we can check for the interrupt character. 2017-10-27 17:32:13 -04:00
Dan Halbert f0a12d9620 Check INTERNAL_LIBM make flag in a safer way. 2017-10-27 17:32:13 -04:00
Dan Halbert 4232a0a196 Sync with https://github.com/adafruit/asf4/pull/3 2017-10-26 09:30:59 -04:00
Scott Shawcroft ee18b5cbab Don't use ERR_ABORTED. (#375) 2017-10-26 09:08:29 -04:00
Scott Shawcroft d613776f0d atmel-samd: Add support for ERR_ABORTED to indicate medium not present. 2017-10-25 21:02:01 -04:00
Scott Shawcroft ab7da9353a atmel-samd: Stop hanging on usb write when a terminal isn't connected by checking DTR status. 2017-10-25 21:02:01 -04:00
Scott Shawcroft 00766e43a0 Merge commit 'f57be61' into nrf2_merge 2017-10-24 23:26:41 -07:00
Scott Shawcroft d665334e94 esp8266: Fix includes 2017-10-24 23:05:20 -07:00
Scott Shawcroft 73c15dcf8b Merge commit 'f869d6b2e339c04469c6c9ea3fb2fabd7bbb2d8c' into nrf2_merge
This is prep for merging in the NRF5 pull request.
2017-10-24 22:31:16 -07:00
Paul Sokolovsky 9a7e3469b2 unix/modusocket: Remove #if MICROPY_SOCKET_EXTRA code blocks.
These defined couple of functions added during initial experimentation,
which aren't part of MicroPython API and no longer used or needed.
2017-10-24 23:13:19 +03:00
Damien George f4059dcc0c all: Use NULL instead of "" when calling mp_raise exception helpers.
This is the established way of doing it and reduces code size by a little
bit.
2017-10-24 22:39:36 +11:00
Paul Sokolovsky cfff12612f unix: Rename modsocket.c to modusocket.c.
Unix naming is historical, before current conventions were established.
All other ports however have it as "modusocket.c", so rename for
consistency and to avoid confusion.
2017-10-23 12:09:37 +03:00
Damien George d6bf3658f4 stm32: Make uos.dupterm() conform to specs by using extmod version.
The legacy function pyb.repl_uart() is still provided and retains its
original behaviour (it only accepts a UART object).  uos.dupterm() will now
accept any object with write/readinto methods.  At the moment there is just
1 dupterm slot.
2017-10-19 14:16:42 +11:00
Damien George 0eb333e3cf stm32/mphalport: Improve efficiency of mp_hal_stdout_tx_strn_cooked.
Also simplifies the code by removing the specialised (and inefficient)
cooked functions from UART and USB_VCP.
2017-10-19 14:15:32 +11:00
Damien George 8fa3d2996c stm32/modnwwiznet5k: Implement stream ioctl for the Wiznet driver.
Now supports polling for read and write ability.
2017-10-17 16:34:10 +11:00
Damien George 285ac58532 stm32/modnwwiznet5k: Increase SPI bus speed to 42MHz.
The W5200 and W5500 can support up to 80MHz so 42MHz (the maximum the
pyboard can do in its standard configuration) should be safe.

Tested to give around 1050000 kbytes/sec TCP download speed on a W5500,
which is about 10% more than with the previous SPI speed of 21MHz.
2017-10-17 16:31:12 +11:00
Damien George e36821a766 stm32/modnwwiznet5k: Add support for W5500 Ethernet chip.
Which Wiznet chip to use is a compile-time option: MICROPY_PY_WIZNET5K
should be set to either 5200 or 5500 to support either one of these
Ethernet chips.  The driver is called network.WIZNET5K in both cases.

Note that this commit introduces a breaking-change at the build level
because previously the valid values for MICROPY_PY_WIZNET5K were 0 and 1
but now they are 0, 5200 and 5500.
2017-10-16 15:36:57 +11:00
Li Weiwei 5c437963d7 stm32/mpconfigport.h: Add MICROPY_THREAD_YIELD() macro. 2017-10-16 13:32:26 +11:00
Damien George 0a30ad96c8 stm32/modusocket: Return OSError(-2) if getaddrinfo fails.
This matches the behaviour of getaddrinfo in extmod/modlwip.c.
2017-10-16 13:19:11 +11:00
Damien George 5d7b0b237b stm32/modusocket: Make getaddrinfo() work when passed an IP address. 2017-10-16 13:17:15 +11:00
Damien George 65ba481cb0 stm32/modnwwiznet5k: Implement WIZNET5K.isconnected() method. 2017-10-16 13:16:00 +11:00
Ayke van Laethem f57be619fc ports/nrf: Add compile switch to disable VFS.
This saves about 17kB.
2017-10-13 18:29:41 +02:00
Damien George 37282f8fc1 extmod/uos_dupterm: Update uos.dupterm() and helper funcs to have index.
The uos.dupterm() signature and behaviour is updated to reflect the latest
enhancements in the docs.  It has minor backwards incompatibility in that
it no longer accepts zero arguments.

The dupterm_rx helper function is moved from esp8266 to extmod and
generalised to support multiple dupterm slots.

A port can specify multiple slots by defining the MICROPY_PY_OS_DUPTERM
config macro to an integer, being the number of slots it wants to have;
0 means to disable the dupterm feature altogether.

The unix and esp8266 ports are updated to work with the new interface and
are otherwise unchanged with respect to functionality.
2017-10-13 20:01:57 +11:00
Li Weiwei e39fcda8eb stm32/usbd_cdc_interface.h: Fix code comments after recent refactor. 2017-10-13 12:45:16 +11:00
Damien George 7c7c7b161d stm32/usbd_cdc_interface: Don't reset CDC output buf on initialisation.
So that characters can be buffered before the USB device is connected
(restoring behviour of the driver before recent state refactoring).
2017-10-13 12:00:47 +11:00
Ayke van Laethem 61b6faed15 ports/nrf: Use --gc-sections to reduce code size
This saves about 6-7kB.
2017-10-12 21:44:55 +02:00
Vitor Massaru Iha 1b7d6a7951 esp8266/modules/webrepl_setup: Add info about allowed password length.
This patch also makes the code more concise by combining the checks for the
password length.
2017-10-11 11:37:01 +11:00
Damien George 81a06d2c9c lib/libm: Remove implementation of log2f, use MP_NEED_LOG2 instead. 2017-10-10 16:01:13 +11:00
Damien George 6db132e130 esp8266/modnetwork: Add "bssid" keyword arg to WLAN.connect() method. 2017-10-09 23:09:06 +11:00
Ayke van Laethem d18bf876e3 ports/nrf: Add WT51822-S4AT board. 2017-10-08 23:23:11 +02:00
Paul Sokolovsky 4514f073c1 zephyr: Switch to interrupt-driven pull-style console.
While this console API improves handling on real hardware boards
(e.g. clipboard paste is much more reliable, as well as programmatic
communication), it vice-versa poses problems under QEMU, apparently
because it doesn't emulate UART interrupt handling faithfully. That
leads to inability to run the testsuite on QEMU at all. To work that
around, we have to suuport both old and new console routines, and use
the old ones under QEMU.
2017-10-07 17:36:16 +03:00
Paul Sokolovsky 58ea239510 zephyr: Use CONFIG_NET_APP_SETTINGS to setup initial network addresses.
Ideally, these should be configurable from Python (using network module),
but as that doesn't exist, we better off using Zephyr's native bootstrap
configuration facility.
2017-10-07 14:08:50 +03:00
Damien George 6f1a615427 stm32/boards: Fix typos in stm32f767_af.csv table. 2017-10-06 14:32:42 +11:00
Li Weiwei 8c7db42ee3 stm32/modnwwiznet5k: Get the IP address of an established socket.
When wiznet5k_socket_accept is called, if a socket is established, get the
IP address of the socket.
2017-10-05 11:09:07 +11:00
Damien George ff93fd4f50 py/persistentcode: Bump .mpy version number to version 3.
The binary and unary ops have changed bytecode encoding.
2017-10-05 10:49:44 +11:00
Glenn Ruben Bakke a414199793 ports/nrf: Update Makefile and README.md after moving port to new directory 2017-10-04 21:54:01 +02:00
Glenn Ruben Bakke 831759faaa ports/nrf: Align help.c builtin help text to use correct type after upmerge with upstream master. 2017-10-04 21:52:08 +02:00
Glenn Ruben Bakke 44e2cb415f ports/nrf: Moving nrf51/52 port to new ports directory 2017-10-04 21:46:48 +02:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George b00040c43c esp8266/esp_mphal: Send data in chunks to mp_uos_dupterm_tx_strn.
Sending byte-by-byte is inefficient and leads to errors in the WebSocket
protocol when sending utf-8 encoded characters.
2017-10-03 23:24:24 +11:00
David Lechner 62849b7010 py: Add config option to print warnings/errors to stderr.
This adds a new configuration option to print runtime warnings and errors to
stderr. On Unix, CPython prints warnings and unhandled exceptions to stderr,
so the unix port here is configured to use this option.

The unix port already printed unhandled exceptions on the main thread to
stderr. This patch fixes unhandled exceptions on other threads and warnings
(issue #2838) not printing on stderr.

Additionally, a couple tests needed to be fixed to handle this new behavior.
This is done by also capturing stderr when running tests.
2017-09-26 11:59:11 +10:00
Damien George d29b709642 stm32/timer: Enable ARPE so that timer freq can be changed smoothly.
The timer prescaler is buffered by default, and this patch enables ARPE
which buffers the auto-reload register.  With both of these registers
buffered it's now possible to smoothly change the timer's frequency and
have a smoothly varying PWM output.
2017-09-25 15:25:08 +10:00
Damien George f7f4bf0321 stm32/usbdev: Move all the USB device descriptor state into its struct. 2017-09-22 10:57:21 +10:00
Damien George db7f4aa2cb stm32/usbdev: Make device descriptor callbacks take a state pointer. 2017-09-22 10:28:56 +10:00
Damien George dbff0164b3 stm32/usbdev: Merge all global USB device state into a single struct.
This is the final piece of USB device refactoring to support multiple
USB device instances.
2017-09-21 21:51:15 +10:00
Damien George 0ea73d2da7 stm32/usbdev: Simplify pointers to MSC state and block dev operations. 2017-09-21 21:51:12 +10:00
Damien George f8f17f48c5 stm32/usbdev: Put all state for the USB device driver in a struct. 2017-09-21 21:51:04 +10:00
Damien George 35e3435f6e stm32/usbdev/core: Add state parameter to all callback functions. 2017-09-21 21:51:02 +10:00
Damien George b3b922f177 stm32/usbdev: Simplify HID tx/rx buffer passing. 2017-09-21 21:50:56 +10:00
Damien George e04b478050 stm32/usbdev: Simplify CDC tx/rx buffer passing. 2017-09-21 21:50:48 +10:00
Damien George 77e1da40e2 stm32/usbdev: Put all HID state in a struct. 2017-09-21 21:50:37 +10:00
Damien George 980b33177b stm32/usbdev: Put all CDC state in a struct. 2017-09-21 21:48:28 +10:00
Damien George ede8a0235b py/vstr: Raise a RuntimeError if fixed vstr buffer overflows.
Current users of fixed vstr buffers (building file paths) assume that there
is no overflow and do not check for overflow after building the vstr.  This
has the potential to lead to NULL pointer dereferences
(when vstr_null_terminated_str returns NULL because it can't allocate RAM
for the terminating byte) and stat'ing and loading invalid path names (due
to the path being truncated).  The safest and simplest thing to do in these
cases is just raise an exception if a write goes beyond the end of a fixed
vstr buffer, which is what this patch does.  It also simplifies the vstr
code.
2017-09-21 20:29:41 +10:00
Damien George 347de3e218 stm32/usbdev: Change static function variable to non-static.
It's written straight away in the function on every call so it doesn't need
to be static.
2017-09-20 17:45:21 +10:00
Damien George 78602a217f stm32/usbdev: Make the USBD callback struct const so it can go in ROM. 2017-09-20 17:44:16 +10:00
Damien George aca498c2b0 stm32/mpconfigport.h: Add configuration for max periphs on L4 series. 2017-09-13 17:03:57 +10:00
Damien George d7cd1d2027 stm32/timer: Make pyb.Timer() instances persistent.
Prior to this patch calling pyb.Timer(id) would always create a new timer
instance, even if there was an existing one.  This patch fixes this
behaviour to match other peripherals, like UART, such that constructing a
timer with just the id will retrieve any existing instances.

The patch also refactors the way timers are validated on construction to
simplify and reduce code size.
2017-09-13 16:20:42 +10:00
Damien George da8c4c2653 py/builtinhelp: Change signature of help text var from pointer to array.
As a pointer (const char *) it takes up an extra word of storage which is
in RAM.
2017-09-12 16:03:52 +10:00
Damien George eea5fcc442 stm32/make-stmconst.py: Make sure mpz const data lives in ROM. 2017-09-12 15:31:43 +10:00
Paul Sokolovsky c46d480adc zephyr/Makefile: Revamp "test" target after ports were moved to ports/. 2017-09-10 22:25:43 +03:00
Paul Sokolovsky d6f9d64d97 tests/class_reverse_op: Test for reverse arith ops special methods.
This test should be run only if support for reverse ops is enabled, so
the corresponding feature_check is added to run-tests.
2017-09-10 17:05:57 +03:00
Paul Sokolovsky eb84a830df py/runtime: Implement dispatch for "reverse op" special methods.
If, for class X, X.__add__(Y) doesn't exist (or returns NotImplemented),
try Y.__radd__(X) instead.

This patch could be simpler, but requires undoing operand swap and
operation switch to get non-confusing error message in case __radd__
doesn't exist.
2017-09-10 17:05:57 +03:00
Paul Sokolovsky 9355cca610 esp8266: Set DEFPSIZE=1024, MINCACHE=3 for "btree" module.
Defaults of 4096 and 5 respectively are too high to esp8266, causing
out of memory with a database beyond couple of pages.
2017-09-10 13:54:00 +03:00
Paul Sokolovsky 9b4666dad5 esp8266/posix_helpers: Set ENOMEM on memory alloc failure.
POSIX requires malloc(), etc. to set ENOMEM on the failure, and e.g.
BerkeleyDB relies on this:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html

This should fix confusing OSError exceptions with 0 error code when
working with btree module.
2017-09-10 09:55:18 +03:00
Paul Sokolovsky 5671a11b81 esp8266: Rename axtls_helpers.c to posix_helpers.c.
As it's used by BerkeleyDB, etc.
2017-09-10 09:47:20 +03:00
Tobias Badertscher bd71b3252a stm32/boards: Add new board B_L475E_IOT01A based on STM32L475. 2017-09-10 16:02:39 +10:00
Damien George cc7fece309 stm32/modnwwiznet5k: Release the GIL on blocking network operations.
connect, send, recv, sendto and recvfrom now release the GIL.  accept
already releases the GIL because it calls mp_hal_delay_ms() within its
busy-wait loop.
2017-09-08 12:23:33 +10:00
Damien George 19f1b39d6f stm32/i2c: When scanning for I2C devices only do 1 probe per address.
Previous to this patch the i2c.scan() method would do up to 100 probes per
I2C address, to detect the devices on the bus.  This repeated probing was a
relic from when the code was copied from the accelerometer initialisation,
which requires to do repeated probes while waiting for the accelerometer
chip to turn on.

But I2C devices shouldn't need more than 1 probe to detect their presence,
and the generic software I2C implementation uses 1 probe successfully.  So
this patch changes the implementation to use 1 probe per address, which
significantly speeds up the scan operation.
2017-09-08 11:19:40 +10:00
Damien George 069fc48bf6 stm32/boards: Fix I2C1 pin mapping on NUCLEO_F401RE/F411RE boards.
This patch makes it consistent with the STM document describing the Arduino
layout.

Thanks to @shaoziyang for the original patch.
2017-09-06 15:41:12 +10:00