Commit Graph

1015 Commits

Author SHA1 Message Date
Paul Sokolovsky c4a6d9c631 zephyr: Switch back to enabling I2C in board-specific configs.
I2C can't be enabled in prj_base.conf because it's a board-specific
feature.  For example, if a board doesn't have I2C but CONFIG_I2C=y then
the build will fail (on Zephyr build system side).  The patch here gets the
qemu_cortex_m3 build working again.
2019-05-24 15:33:02 +10:00
Paul Sokolovsky b88bf42793 zephyr/README: Reorder content related to recently added I2C.
So it fits better with existing narrative.
2019-05-24 15:29:29 +10:00
stijn 2762f323bf windows: Fix line wrapping behaviour on the REPL.
This enables going back to previous wrapped lines using backspace or left
arrow: instead of just sticking to the beginning of a line, the cursor will
move a line up.
2019-05-23 22:11:11 +10:00
Andrew Leech 4f44778728 stm32/sdcard: Add switch break to ensure only correct SD/MMC IRQ is run. 2019-05-23 21:55:31 +10:00
Damien George 9cf1cbb057 nrf/mphalport: Use wfi to save power while waiting at the UART REPL. 2019-05-22 12:47:48 +10:00
Damien George 456c89f749 nrf/uart: Make UART print output something, and add write method. 2019-05-22 12:47:48 +10:00
Damien George 50d5114fcd nrf/mpconfigport.h: Enable MICROPY_KBD_EXCEPTION by default. 2019-05-22 12:47:48 +10:00
Damien George 302ffdba7f nrf/uart: Change UART driver to be non-blocking and use IRQs.
As part of this, ctrl-C is now able to interrupt a running program.
2019-05-22 12:47:19 +10:00
Glenn Ruben Bakke d80abd035e nrf/nrfx_glue: Adapt to nrfx v.1.7.1.
Defining NRFX_STATIC_ASSERT macro to be empty, but available
to nrfx.
2019-05-21 23:16:20 +02:00
Damien George c769da1aaa stm32/i2c: Support setting the I2C TIMINGR value via keyword arg.
On MCUs that have an I2C TIMINGR register, this can now be explicitly set
via the "timingr" keyword argument to the I2C constructor, for both
machine.I2C and pyb.I2C.  This allows to configure precise timing values
when the defaults are inadequate.
2019-05-21 13:45:17 +10:00
Damien George ddc657658a stm32/machine_i2c: Simplify ROM initialisation of static HW I2C objects. 2019-05-21 12:38:34 +10:00
Andrew Leech ed2b6ea0a8 stm32/i2c: Make timeout for hardware I2C configurable.
Previously the hardware I2C timeout was hard coded to 50ms which isn't
guaranteed to be enough depending on the clock stretching specs of the I2C
device(s) in use.

This patch ensures the hardware I2C implementation honors the existing
timeout argument passed to the machine.I2C constructor.  The default
timeout for software and hardware I2C is now 50ms.
2019-05-21 12:20:19 +10:00
Damien George 647b27d028 zephyr/machine_i2c: Update to support new C-level I2C API. 2019-05-20 15:04:29 +10:00
Damien George bb29bde102 nrf/machine/i2c: Update to support new C-level I2C API. 2019-05-20 15:04:29 +10:00
Damien George 38ac697b45 stm32/machine_i2c: Update to support new C-level I2C API. 2019-05-20 15:04:29 +10:00
Damien George 1f63e9b701 stm32/adc: Fix VBAT_DIV to be 4 for STM32F411.
Fixes issue #4794.
2019-05-20 14:37:28 +10:00
Damien George 653e1756c0 various: Update early copyright years to match actual edit history. 2019-05-17 18:06:11 +10:00
Paul Sokolovsky 016d9a40fe various: Add and update my copyright line based on git history.
For modules I initially created or made substantial contributions to.
2019-05-17 18:04:15 +10:00
Damien George e1e3704aa1 stm32/modmachine: Create dedicated asm function to branch to bootloader.
Recent gcc versions (at least 9.1) give a warning about using "sp" in the
clobber list.  Such code is removed by this patch.  A dedicated function is
instead used to set SP and branch to the bootloader so the code has full
control over what happens.

Fixes issue #4785.
2019-05-17 17:20:43 +10:00
Damien George 0557f0b74b esp32/network_ppp: Add a timeout for closing PPP connection.
This also fixes deleting the PPP task, since eTaskGetState() never returns
eDeleted.

A limitation with this patch: once the PPP is deactivated (ppp.active(0))
it cannot be used again. A new PPP instance must be created instead.
2019-05-17 17:14:45 +10:00
Damien George 2630d3e51f esp32/machine_uart: Implement UART.deinit() method. 2019-05-15 17:01:54 +10:00
iabdalkader 746fcea7f8 stm32/boards/NUCLEO_H743ZI: Enable SPI3 on this board. 2019-05-15 16:08:10 +10:00
iabdalkader 1646eff864 stm32/irq: Fix IRQ_ENABLE_STATS stats config to work on all MCUs.
Only the M4 and M7 MCUs have an FPU and FPU_IRQn, and FPU_IRQn is not
always the last entry/IRQ number.
2019-05-15 16:04:01 +10:00
iabdalkader 07af74daef stm32/spi: Enable SPI IRQs and add IRQHandlers for H7 MCUs.
The H7 HAL uses SPI IRQs when the SPI is running in DMA mode.
2019-05-15 15:59:25 +10:00
iabdalkader 123c065131 stm32/dma: Always reset and configure the H7 DMA peripheral.
This is required for the H7 DMA to work.
2019-05-15 15:55:41 +10:00
stijn 90fae9172a py/objarray: Add support for memoryview.itemsize attribute.
This allows figuring out the number of bytes in the memoryview object as
len(memview) * memview.itemsize.

The feature is enabled via MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE and is
disabled by default.
2019-05-14 17:15:17 +10:00
iabdalkader 7359a9e2f2 stm32/dma: Initialise all members of DMA structs for H7 MCUs. 2019-05-13 12:57:44 +10:00
Damien George 7e21cf723a nrf: Change types to size_t for all uses of mp_obj_str_get_data. 2019-05-13 12:39:56 +10:00
Damien George 8586afa6f5 esp32/modnetwork: Change type to size_t for uses of mp_obj_str_get_data. 2019-05-13 12:39:03 +10:00
Damien George 99a8fa7940 esp8266/modmachine: Handle overflow of timer to get longer periods.
Can now handle up to about 298 days maximum for millisecond periods.

Fixes issue #4664.
2019-05-10 15:50:35 +10:00
Andrew Leech 29865e3e58 stm32/rtc: Allow overriding startup timeouts from mpconfigboard. 2019-05-09 12:08:43 +10:00
Elad Namdar 3f54462add unix/modusocket: Fix use of setsockopt in usocket.settimeout impl.
The original code called setsockopt(SO_RCVTIMEO/SO_SNDTIMEO) with NULL
timeout structure argument, which is an illegal usage of that function.
The old code also didn't validate the return value of setsockopt, missing
the bug completely.
2019-05-08 13:12:30 +10:00
Damien George b8c74014e4 stm32/usbd_cdc_interface: Don't retransmit chars if USB is reconnected.
Before this change, if the USB was reconnected it was possible that some
characters in the TX buffer were retransmitted because tx_buf_ptr_out and
tx_buf_ptr_out_shadow were reset while tx_buf_ptr_in wasn't.  That
behaviour is fixed here by retaining the TX buffer state across reconnects.

Fixes issue #4761.
2019-05-08 12:45:24 +10:00
Damien George 97753a1bbc stm32: Move factory reset files and code to separate source file.
The new function factory_reset_make_files() populates the given filesystem
with the default factory files.  It is defined with weak linkage so it can
be overridden by a board.

This commit also brings some minor user-facing changes:

- boot.py is now no longer created unconditionally if it doesn't exist, it
  is now only created when the filesystem is formatted and the other files
  are populated (so, before, if the user deleted boot.py it would be
  recreated at next boot; now it won't be).

- pybcdc.inf and README.txt are only created if the board has USB, because
  they only really make sense if the filesystem is exposed via USB.
2019-05-07 13:59:51 +10:00
Damien George 34942d0a72 stm32/machine_uart: Change default UART timeout to 0, for non blocking.
It's more common to need non-blocking behaviour when reading from a UART,
rather than having a large timeout like 1000ms (the original behaviour).
With a large timeout it's 1) likely that the function will read forever if
characters keep trickling it; or 2) the function will unnecessarily wait
when characters come sporadically, eg at a REPL prompt.
2019-05-07 13:56:42 +10:00
Yonatan Goldschmidt ef9843653b extmod/moducryptolib: Add AES-CTR support.
Selectable at compile time via MICROPY_PY_UCRYPTOLIB_CTR.  Disabled by
default.
2019-05-06 18:09:48 +10:00
Damien George 906fb89fd7 unix/coverage: Add test for printing literal % character. 2019-05-03 23:21:28 +10:00
Nguyen Hoan Hoang 9a6f6fd68d nrf/boards: Add support for BLYST Nano module based boards.
- IBK-BLYST-NANO: Breakout board
- IDK-BLYST-NANO: DevKit board with builtin IDAP-M CMSIS-DAP Debug JTAG,
  RGB led
- BLUEIO-TAG-EVIM: Sensor tag board (environmental sensor
  (T, H, P, Air quality) + 9 axis motion sensor)

Also, the LED module has been updated to support individual base level
configuration of each LED. If set, this will be used instead of the
common configuration, MICROPY_HW_LED_PULLUP. The new configuration,
MICROPY_HW_LEDX_LEVEL, where X is the LED number can be used to set
the base level of the specific LED.
2019-05-02 22:33:44 +02:00
Chris Mason 2a791170ce stm32/boards: Add NUCLEO_F413ZH board configuration.
The alternate function pin allocations are different to other NUCLEO-144
boards.  This is because the STM32F413 has a very high peripheral count:
10x UART, 5x SPI, 3x I2C, 3x CAN.  The pinout was chosen to expose all
these devices on separate pins except CAN3 which shares a pin with UART1
and SPI1 which shares pins with DAC.
2019-05-02 16:33:30 +10:00
Chris Mason 1b956ec817 stm32: Add support for F413 MCUs.
Includes:
- Support for CAN3.
- Support for UART9 and UART10.
- stm32f413xg.ld and stm32f413xh.ld linker scripts.
- stm32f413_af.csv alternate function mapping.
- startup_stm32f413xx.s because F413 has different interrupt vector table.
- Memory configuration with: 240K filesystem, 240K heap, 16K stack.
2019-05-02 16:26:53 +10:00
Damien George a974f2dc6e stm32/flash: Fix bug computing page number for L432 page erase. 2019-05-02 14:53:26 +10:00
Damien George 3fbf32b947 stm32/powerctrl: Support changing frequency when HSI is clock source.
This patch makes pllvalues.py generate two tables: one for when HSI is used
and one for when HSE is used.  The correct table is then selected at
compile time via the existing MICROPY_HW_CLK_USE_HSI.
2019-05-02 13:00:00 +10:00
stijn 34a7d7ebeb unix/gcollect: Make sure stack/regs get captured properly for GC.
When building with link time optimization enabled it is possible both
gc_collect() and gc_collect_regs_and_stack() get inlined into gc_alloc()
which can result in the regs variable being pushed on the stack earlier
than some of the registers. Depending on the calling convention, those
registers might however contain pointers to blocks which have just been
allocated in the caller of gc_alloc(). Then those pointers end up higher on
the stack than regs, aren't marked by gc_collect_root() and hence get
sweeped, even though they're still in use.

As reported in #4652 this happened for in 32-bit msvc release builds:
mp_lexer_new() does two consecutive allocations and the latter triggered a
gc_collect() which would sweep the memory of the first allocation again.
2019-05-01 15:06:21 +10:00
Damien George cbeac903e8 stm32/main: Increase default UART REPL rx buffer from 64 to 260 bytes.
This allows the UART to buffer at least 256 bytes (taking into account the
extra byte needed by the ring buffer, and word alignment).
2019-05-01 14:53:21 +10:00
Damien George ff0306dfa5 stm32/usb: Remove mp_hal_set_interrupt_char now that it's reset at boot. 2019-05-01 13:08:05 +10:00
Krono fbd4e61e57 esp32/machine_wdt: Add timeout arg to select interval, make WDT panic.
The machine.WDT() now accepts the "timeout" keyword argument to select the
WDT interval.  And the WDT is changed to panic mode which means it will
reset the device if the interval expires (instead of just printing an error
message).
2019-04-30 16:53:05 +10:00
Damien George 8031b7a25c stm32/powerctrl: Deselect PLLSAI as 48MHz src before turning off PLLSAI.
On the STM32F722 (at least, but STM32F767 is not affected) the CK48MSEL bit
must be deselected before PLLSAION is turned off, or else the 48MHz
peripherals (RNG, SDMMC, USB) may get stuck without a clock source.

In such "lock up" cases it seems that these peripherals are still being
clocked from the PLLSAI even though the CK48MSEL bit is turned off.  A hard
reset does not get them out of this stuck state.  Enabling the PLLSAI and
then disabling it does get them out.  A test case to see this is:

    import machine, pyb
    for i in range(100):
        machine.freq(122_000000)
        machine.freq(120_000000)
        print(i, [pyb.rng() for _ in range(4)])

On occasion the RNG will just return 0's, but will get fixed again on the
next loop (when PLLSAI is enabled by the change to a SYSCLK of 122MHz).

Fixes issue #4696.
2019-04-29 16:31:32 +10:00
Damien George d1dea4f577 javascript/library: Print data as raw bytes to stdout so unicode works. 2019-04-28 22:39:41 +10:00
Damien George bd6fed8201 javascript/Makefile: Fix unrepresentable float error by using clamp.
Otherwise converting large floats to ints will fail (as seen by the
builtin_float_hash.py test).
2019-04-28 22:17:42 +10:00
Damien George 93f5f80216 javascript: Pass (error) exit value out from script to process caller. 2019-04-28 22:16:27 +10:00