Commit Graph

12081 Commits

Author SHA1 Message Date
Dan Halbert de61bd0d05
Merge pull request #887 from tannewt/rotaryio
Add rotary encoder support.
2018-06-01 18:50:00 -04:00
Scott Shawcroft 717199018b Adapt for feedback and hack around pIRkey size constraint. 2018-06-01 15:08:52 -07:00
Dan Halbert f386144428 redo state algorithm 2018-06-01 15:08:52 -07:00
Scott Shawcroft 9920f0a5de atmel-samd: Make ticks more atomic.
Always use current_tick when sub millisecond precision is required.
Otherwise getting the ms/us to correspond is tricky.
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
Dan Halbert ae31c4ac18
Merge pull request #889 from tannewt/audioio_timers_in_use
Turn off timer on AudioOut deinit.
2018-06-01 18:03:29 -04:00
Dan Halbert ea95eb730a
Merge pull request #890 from tannewt/brownout3
Support brownout to safe mode. Fixes #870
2018-06-01 18:02:13 -04:00
Scott Shawcroft 317bb6d2ce
Merge pull request #888 from notro/samd51_clock_rework
atmel-samd/samd51: Refactor clock setup + implement samd.clock
2018-06-01 14:10:24 -07:00
Scott Shawcroft f38ce1060c Support brownout to safe mode. Fixes #870 2018-06-01 13:45:28 -07:00
Scott Shawcroft bf1f0b3d11 Turn off timer on AudioOut deinit.
Thanks to @sommersoft for spotting the error.

Fixes #850
2018-06-01 13:32:45 -07:00
Noralf Trønnes e158702a68 atmel-samd/samd51: Use crystal for RTC
This uses the crystal to clock the RTC on boards which have a crystal.

Disable clock generator 2 which was enabled in commit
8e2080411f ("atmel-samd: Add rtc module support").
samd51 differs from samd21 when it comes to the RTC clock. samd51 doesn't
have an explicit clock peripheral so no need for a clock generator.

The same commit didn't even setup XOSC32K correctly, it missed EN1K and XTALEN.

The RTC uses the 1k clock output, so enable it on the OSCULP32K even if it works without it.
2018-06-01 18:03:23 +02:00
Noralf Trønnes ab7ddfddd5 atmel-samd/samd51: Refactor clock setup
Refactor the convoluted asf4 clock setup into something more readable.

enable_clock_generator() has 2 changes:
- Set 'Output enabled' to match the current clock setup
- Handle divisors above 511

Add an enable_clock_generator_sync() version which makes it possible to setup
clocks without waiting for syncing. The bootup would hang without this.

I have checked these registers:

 NVMCTRL->CTRLA = 0x00000004

 Peripheral clocks (only non-zero shown):
 PCHCTRL[1]=0x00000045
 PCHCTRL[10]=0x00000041

 Generator clocks (only non-zero shown):
 GENCTRL[0] = 0x00010907
 GENCTRL[1] = 0x00010906
-GENCTRL[2] = 0x00041104
+GENCTRL[2] = 0x00200904
 GENCTRL[4] = 0x00010907
 GENCTRL[5] = 0x00180906

 DFLL clock:
 OSCCTRL->DFLLCTRLA = 0x00000082
 OSCCTRL->DFLLCTRLB = 0x00000000
 OSCCTRL->DFLLVAL = 0x00008082
 OSCCTRL->DFLLMUL = 0x00000000

 DPLL clocks:
 OSCCTRL->Dpll[0].DPLLCTRLA=0x00000002
 OSCCTRL->Dpll[0].DPLLCTRLB=0x00000000
 OSCCTRL->Dpll[0].DPLLRATIO=0x0000003b
 OSCCTRL->Dpll[1].DPLLCTRLA=0x00000080
 OSCCTRL->Dpll[1].DPLLCTRLB=0x00000020
 OSCCTRL->Dpll[1].DPLLRATIO=0x00000000

 OSC32KCTRL clock:
 OSC32KCTRL->RTCCTRL = 0x00000000
 OSC32KCTRL->XOSC32K = 0x00002082
 OSC32KCTRL->CFDCTRL = 0x00000000
 OSC32KCTRL->EVCTRL = 0x00000000
 OSC32KCTRL->OSCULP32K = 0x00002300

Only gen2 changed which is due to samd51 having more bits in the simple
division register so DIVSEL wasn't necessary, and it didn't have OE set.
2018-06-01 18:02:35 +02:00
Noralf Trønnes 5c6aea9fd8 atmel-samd/samd51: Implement samd.clock
Fill out the dummy implementation.
2018-06-01 18:01:08 +02:00
Damien George 7d86ac6c01 stm32: Add network driver for Wiznet5k using MACRAW mode and lwIP.
The Wiznet5k series of chips support a MACRAW mode which allows the host to
send and receive Ethernet frames directly.  This can be hooked into the
lwIP stack to provide a full "socket" implementation using this Wiznet
Ethernet device.  This patch adds support for this feature.

To enable the feature one must add the following to mpconfigboard.mk, or
mpconfigport.mk:

    MICROPY_PY_WIZNET5K = 5500

and the following to mpconfigboard.h, or mpconfigport.h:

    #define MICROPY_PY_LWIP (1)

After wiring up the module (X5=CS, X4=RST), usage on a pyboard is:

    import time, network
    nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)
    nic.active(1)
    while not nic.isconnected():
        time.sleep_ms(50) # needed to poll the NIC
    print(nic.ifconfig())

Then use the socket module as usual.

Compared to using the built-in TCP/IP stack on the Wiznet module, some
performance is lost in MACRAW mode: with a lot of memory allocated to lwIP
buffers, lwIP gives Around 750,000 bytes/sec max TCP download, compared
with 1M/sec when using the TCP/IP stack on the Wiznet module.
2018-06-01 14:21:38 +10:00
Damien George 5a5bc4a61f drivers/wiznet5k: Fix bug with MACRAW socket calculating packet size. 2018-06-01 13:44:09 +10:00
Damien George d9f1ecece2 stm32/modnetwork: Provide generic implementation of ifconfig method.
All it needs is a lwIP netif to function.
2018-06-01 13:33:14 +10:00
Damien George 7437215ad7 stm32/modnetwork: Change base entry of NIC object from type to base.
mod_network_nic_type_t doesn't need to be an actual uPy type, it just needs
to be an object.
2018-06-01 13:31:28 +10:00
Damien George 6d87aa54d6 stm32/modnetwork: Don't take netif's down when network is deinited.
It should be up to the NIC itself to decide if the network interface is
removed upon soft reset.  Some NICs can keep the interface up over a soft
reset, which improves usability of the network.
2018-06-01 13:27:06 +10:00
Damien George ea22406f76 extmod/modussl_mbedtls: Use mbedtls_entropy_func for CTR-DRBG entropy.
If mbedtls_ctr_drbg_seed() is available in the mbedtls bulid then so should
be mbedtls_entropy_func().  Then it's up to the port to configure a valid
entropy source, eg via MBEDTLS_ENTROPY_HARDWARE_ALT.
2018-05-31 21:52:29 +10:00
Damien George 98b9f0fc9d extmod/modussl_mbedtls: Populate sock member right away in wrap_socket.
Otherwise the "sock" member may have an undefined value if wrap_socket
fails with an exception and exits early, and then if the finaliser runs it
will try to close an invalid stream object.

Fixes issue #3828.
2018-05-31 21:47:26 +10:00
Scott Shawcroft 6479cb0806
Merge pull request #868 from pewpew-game/gamepad-longlive
Make the gamepad singleton long-living and add it to root pointers
2018-05-30 17:19:12 -07:00
Radomir Dopieralski d02899f822 Add gamepad_singleto to root pointers for the nrf port 2018-05-30 23:11:23 +02: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
Dan Halbert 1897ce478b restore I2C and UART. Don't do port.c resets and inits for modules that are not available. 2018-05-30 23:11:00 +02:00
Scott Shawcroft 09504159b8
Merge pull request #885 from dhalbert/feather_m4_reve
rev E feather M4 express; remove named AREF pins
2018-05-30 10:40:06 -07:00
Jeff Epler c60589c02b py/objtype: Fix assertion failures in super_attr by checking type.
Fixes assertion failures and segmentation faults when making calls like:

    super(1, 1).x
2018-05-30 11:14:07 +10:00
Jeff Epler 05b13fd292 py/objtype: Fix assertion failures in mp_obj_new_type by checking types.
Fixes assertion failures when the arguments to type() were not of valid
types, e.g., when making calls like:

    type("", (), 3)
    type("", 3, {})
2018-05-30 11:11:24 +10:00
Dan Halbert eab8e43188 rev E feather M4 express; remove named AREF pins 2018-05-29 20:25:28 -04:00
Damien George a1acbad27a stm32/flash: Increase H7 flash size to full 2MiB. 2018-05-30 09:54:51 +10:00
rolandvs 958fa74521 stm32/boards: Ensure USB OTG power is off for NUCLEO_F767ZI.
And update the GPIO init for NUCLEO_H743ZI to consistently use the mphal
functions.
2018-05-30 09:51:19 +10:00
rolandvs 50bc34d4a4 stm32/boards: Split combined alt-func labels and fix some other errors.
Pins with multiple alt-funcs for the same peripheral (eg USART_CTS_NSS)
need to be split into individual alt-funcs for make-pins.py to work
correctly.

This patch changes the following:
- Split `..._CTS_NSS` into `..._CTS/..._NSS`
- Split `..._RTS_DE` into `..._RTS/..._DE`
- Split `JTDO_SWO` into `JTDO/TRACESWO` for consistency
- Fixed `TRACECK` to `TRACECLK` for consistency
2018-05-29 21:37:49 +10:00
Damien George 98d1609358 stm32/README: Update to include STM32F0 in list of supported MCUs. 2018-05-28 22:04:08 +10:00
Damien George e681372017 stm32/boards: Add NUCLEO_F091RC board configuration files. 2018-05-28 21:49:49 +10:00
Damien George 1163400039 stm32/boards: Add alt-func CSV list and linker script for STM32F091. 2018-05-28 21:49:49 +10:00
Damien George ea7e747979 stm32: Add support for STM32F0 MCUs. 2018-05-28 21:49:49 +10:00
Damien George 4a7d157a5b stm32/boards: Add startup_stm32f0.s for STM32F0 MCUs.
Sourced from STM32Cube_FW_F0_V1.9.0.
2018-05-28 21:49:49 +10:00
Damien George 191e2cf90a lib/stm32lib: Update library to include support for STM32F0 MCUs.
Now points to branch: work-F0-1.9.0+F4-1.16.0+F7-1.7.0+H7-1.2.0+L4-1.8.1
2018-05-28 21:46:20 +10:00
Damien George 6d83468a30 stm32: Allow a board to disable MICROPY_VFS_FAT. 2018-05-28 21:46:20 +10:00
Damien George 5c0685912f stm32/timer: Make timer_get_source_freq more efficient by using regs.
Use direct register access to get the APB clock divider.  This reduces code
size and makes the code more efficient.
2018-05-28 21:46:20 +10:00
Damien George 070937fe93 stm32: Add support for Cortex-M0 CPUs. 2018-05-28 21:46:20 +10:00
Damien George f497723802 stm32: Allow to have no storage support if there are no block devices.
If no block devices are defined by a board then storage support will be
disabled.  This means there is no filesystem provided by either the
internal flash or external SPI flash.  But the VFS system can still be
enabled and filesystems provided on external devices like an SD card.
2018-05-28 21:45:46 +10:00
Damien George aa4a7a8732 stm32/usb: Guard USB device code with #if for whether USB is enabled.
With this change, all the USB source code can now be passed through the
compiler even if the MCU does not have a USB peripheral.
2018-05-28 21:45:46 +10:00
Nick Moore ef4c8e6e97 esp32: Silence ESP-IDF log messages when in raw REPL mode.
This prevents clients such as ampy, mpy-utils, etc getting confused by
extraneous data.
2018-05-28 20:15:08 +10:00
Dan Halbert 754c36bb37
Merge pull request #867 from dhalbert/fix_pirkey_apa102
3.0 pirkey build including appropriate frozen modules
2018-05-24 22:07:14 -04:00
Dan Halbert 052a9ff378 update cpx lib 2018-05-24 21:40:49 -04:00
Dan Halbert e1762f5bf1
Merge pull request #873 from dhalbert/travis-cpx-crickit-build
add cpx-crickit build to travis
2018-05-24 21:35:37 -04:00
Dan Halbert a5e1174926 add cpx-crickit build to travis 2018-05-24 21:18:56 -04:00
Damien George dfeaea1441 py/objtype: Remove TODO comment about needing to check for property.
Instance members are always treated as values, even if they are properties.
A test is added to show this is the case.
2018-05-25 10:59:40 +10:00