Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ESP32_PCNT_Encode…
Browse files Browse the repository at this point in the history
…r_Counter
  • Loading branch information
IhorNehrutsa committed Aug 18, 2023
2 parents a6d25ca + a18d62e commit 0df47d5
Show file tree
Hide file tree
Showing 230 changed files with 1,856 additions and 1,332 deletions.
4 changes: 2 additions & 2 deletions docs/develop/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ For the stm32 port, the ARM cross-compiler is required:

.. code-block:: bash
$ sudo apt-get install arm-none-eabi-gcc arm-none-eabi-binutils arm-none-eabi-newlib
$ sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi
See the `ARM GCC
toolchain <https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads>`_
Expand Down Expand Up @@ -228,7 +228,7 @@ You can also specify which board to use:
.. code-block:: bash
$ cd ports/stm32
$ make submodules
$ make BOARD=<board> submodules
$ make BOARD=<board>
See `ports/stm32/boards <https://github.com/micropython/micropython/tree/master/ports/stm32/boards>`_
Expand Down
11 changes: 9 additions & 2 deletions docs/library/esp32.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@ Functions
buffers and other data. This data is useful to get a sense of how much memory
is available to ESP-IDF and the networking stack in particular. It may shed
some light on situations where ESP-IDF operations fail due to allocation failures.
The information returned is *not* useful to troubleshoot Python allocation failures,
use `micropython.mem_info()` instead.

The capabilities parameter corresponds to ESP-IDF's ``MALLOC_CAP_XXX`` values but the
two most useful ones are predefined as `esp32.HEAP_DATA` for data heap regions and
`esp32.HEAP_EXEC` for executable regions as used by the native code emitter.

Free IDF heap memory in the `esp32.HEAP_DATA` region is available to be
automatically added to the MicroPython heap to prevent a MicroPython
allocation from failing. However, the information returned here is otherwise
*not* useful to troubleshoot Python allocation failures, use
`micropython.mem_info()` instead. The "max new split" value in
`micropython.mem_info()` output corresponds to the largest free block of
ESP-IDF heap that could be automatically added on demand to the MicroPython
heap.

The return value is a list of 4-tuples, where each 4-tuple corresponds to one heap
and contains: the total bytes, the free bytes, the largest free block, and
the minimum free seen over time.
Expand Down
4 changes: 4 additions & 0 deletions examples/asmled.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# flash LED #1 using inline assembler
# this version is overly verbose and uses word stores
#
# ruff: noqa: F821 - @asm_thumb decorator adds names to function scope


@micropython.asm_thumb
def flash_led(r0):
movw(r1, (stm.GPIOA + stm.GPIO_BSRRL) & 0xFFFF)
Expand Down
3 changes: 3 additions & 0 deletions examples/asmsum.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ruff: noqa: F821 - @asm_thumb decorator adds names to function scope


@micropython.asm_thumb
def asm_sum_words(r0, r1):
# r0 = len
Expand Down
1 change: 1 addition & 0 deletions examples/bluetooth/ble_uart_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
import os
import micropython
from micropython import const
import machine

from ble_uart_peripheral import BLEUART
Expand Down
2 changes: 1 addition & 1 deletion examples/hwapi/hwconfig_z_96b_carbon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from machine import Signal
from machine import Pin, Signal

# 96Boards Carbon board
# USR1 - User controlled led, connected to PD2
Expand Down
4 changes: 4 additions & 0 deletions examples/natmod/btree/btree_py.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Implemented in Python to support keyword arguments

# ruff: noqa: F821 - this file is evaluated with C-defined names in scope


def open(stream, *, flags=0, cachesize=0, pagesize=0, minkeypage=0):
return _open(stream, flags, cachesize, pagesize, minkeypage)
2 changes: 2 additions & 0 deletions examples/natmod/features2/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This Python code will be merged with the C code in main.c

# ruff: noqa: F821 - this file is evaluated with C-defined names in scope

import array


Expand Down
2 changes: 2 additions & 0 deletions examples/rp2/pio_1hz.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Example using PIO to blink an LED and raise an IRQ at 1Hz.
# Note: this does not work on Pico W because it uses Pin(25) for LED output.

# ruff: noqa: F821 - @asm_pio decorator adds names to function scope

import time
from machine import Pin
import rp2
Expand Down
2 changes: 2 additions & 0 deletions examples/rp2/pio_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# - using set_init and set_base
# - using StateMachine.exec

# ruff: noqa: F821 - @asm_pio decorator adds names to function scope

import time
from machine import Pin
import rp2
Expand Down
2 changes: 2 additions & 0 deletions examples/rp2/pio_pinchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# - setting an irq handler for a StateMachine
# - instantiating 2x StateMachine's with the same program and different pins

# ruff: noqa: F821 - @asm_pio decorator adds names to function scope

import time
from machine import Pin
import rp2
Expand Down
2 changes: 2 additions & 0 deletions examples/rp2/pio_pwm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Example of using PIO for PWM, and fading the brightness of an LED

# ruff: noqa: F821 - @asm_pio decorator adds names to function scope

from machine import Pin
from rp2 import PIO, StateMachine, asm_pio
from time import sleep
Expand Down
2 changes: 2 additions & 0 deletions examples/rp2/pio_uart_rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# - PIO irq handler
# - using the second core via _thread

# ruff: noqa: F821 - @asm_pio decorator adds names to function scope

import _thread
from machine import Pin, UART
from rp2 import PIO, StateMachine, asm_pio
Expand Down
2 changes: 2 additions & 0 deletions examples/rp2/pio_uart_tx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Example using PIO to create a UART TX interface

# ruff: noqa: F821 - @asm_pio decorator adds names to function scope

from machine import Pin
from rp2 import PIO, StateMachine, asm_pio

Expand Down
2 changes: 2 additions & 0 deletions examples/rp2/pio_ws2812.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Example using PIO to drive a set of WS2812 LEDs.

# ruff: noqa: F821 - @asm_pio decorator adds names to function scope

import array, time
from machine import Pin
import rp2
Expand Down
2 changes: 2 additions & 0 deletions examples/rp2/pwm_fade.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Example using PWM to fade an LED.
# Note: this does not work on Pico W because it uses Pin(25) for LED output.

# ruff: noqa: F821 - @asm_pio decorator adds names to function scope

import time
from machine import Pin, PWM

Expand Down
87 changes: 49 additions & 38 deletions extmod/extmod.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,51 +60,62 @@ set(MICROPY_SOURCE_EXTMOD

if(MICROPY_PY_BTREE)
set(MICROPY_LIB_BERKELEY_DIR "${MICROPY_DIR}/lib/berkeley-db-1.xx")
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/berkeley-db-1.xx)

add_library(micropy_extmod_btree OBJECT
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_close.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_conv.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_debug.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_delete.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_get.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_open.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_overflow.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_page.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_put.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_search.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_seq.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_split.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_utils.c
${MICROPY_LIB_BERKELEY_DIR}/mpool/mpool.c
)
if(ECHO_SUBMODULES)
# No-op, we're just doing submodule/variant discovery.
# Cannot run the add_library/target_include_directories rules (even though
# the build won't run) because IDF will attempt verify the files exist.
elseif(NOT EXISTS ${MICROPY_LIB_BERKELEY_DIR}/README)
# Regular build, submodule not initialised -- fail with a clear error.
message(FATAL_ERROR " MICROPY_PY_BTREE is enabled but the berkeley-db submodule is not initialised.\n Run 'make BOARD=${MICROPY_BOARD} submodules'")
else()
# Regular build, we have the submodule.
add_library(micropy_extmod_btree OBJECT
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_close.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_conv.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_debug.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_delete.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_get.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_open.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_overflow.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_page.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_put.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_search.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_seq.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_split.c
${MICROPY_LIB_BERKELEY_DIR}/btree/bt_utils.c
${MICROPY_LIB_BERKELEY_DIR}/mpool/mpool.c
)

target_include_directories(micropy_extmod_btree PRIVATE
${MICROPY_LIB_BERKELEY_DIR}/PORT/include
)
target_include_directories(micropy_extmod_btree PRIVATE
${MICROPY_LIB_BERKELEY_DIR}/PORT/include
)

target_compile_definitions(micropy_extmod_btree PRIVATE
__DBINTERFACE_PRIVATE=1
mpool_error=printf
abort=abort_
"virt_fd_t=void*"
)
target_compile_definitions(micropy_extmod_btree PRIVATE
__DBINTERFACE_PRIVATE=1
mpool_error=printf
abort=abort_
"virt_fd_t=void*"
)

# The include directories and compile definitions below are needed to build
# modbtree.c and should be added to the main MicroPython target.
# The include directories and compile definitions below are needed to build
# modbtree.c and should be added to the main MicroPython target.

list(APPEND MICROPY_INC_CORE
"${MICROPY_LIB_BERKELEY_DIR}/PORT/include"
)
list(APPEND MICROPY_INC_CORE
"${MICROPY_LIB_BERKELEY_DIR}/PORT/include"
)

list(APPEND MICROPY_DEF_CORE
MICROPY_PY_BTREE=1
__DBINTERFACE_PRIVATE=1
"virt_fd_t=void*"
)
list(APPEND MICROPY_DEF_CORE
MICROPY_PY_BTREE=1
__DBINTERFACE_PRIVATE=1
"virt_fd_t=void*"
)

list(APPEND MICROPY_SOURCE_EXTMOD
${MICROPY_EXTMOD_DIR}/modbtree.c
)
list(APPEND MICROPY_SOURCE_EXTMOD
${MICROPY_EXTMOD_DIR}/modbtree.c
)
endif()
endif()

# Library for mbedtls
Expand Down
Loading

0 comments on commit 0df47d5

Please sign in to comment.