Skip to content

Add busio support for ADI MAX32xxx port #10413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ecc4320
Setup files for busio
Brandon-Hurst Dec 26, 2024
c854e2b
Add default build for analog ports for apard32690 board.
Brandon-Hurst Jan 14, 2025
62f5a15
Add preliminary busio.UART support
Brandon-Hurst Jan 14, 2025
b1b67e8
Add tools files for debugging
Brandon-Hurst Jan 14, 2025
fc16109
Fixed most UART write issues.
Brandon-Hurst Jan 24, 2025
9a469e5
Fix issues with UART reads and unreliable UART writes.
Brandon-Hurst Jan 25, 2025
d6e6af9
Add pre-commit changes to UART
Brandon-Hurst Jan 27, 2025
cee102c
Resolve UART ISR naming issues
Brandon-Hurst Feb 1, 2025
0de0041
Add BUSIO.I2C and MAX32690 I2C structure
Brandon-Hurst Mar 7, 2025
66fb1cc
Add hardware mapping for BUSIO.SPI for MAX32690
Brandon-Hurst Mar 7, 2025
b4b4d0d
Add complete BUSIO driver structure for SPI & I2C.
Brandon-Hurst Mar 7, 2025
aab1c42
Add call to MXC_DelayHandler in SysTick ISR
Brandon-Hurst Mar 7, 2025
52e5130
Corrected I2C & SPI. Tested with example scripts; works with real per…
Brandon-Hurst Mar 7, 2025
30ade22
Add extra I2C options for MAX32690 non-TQFN packages
Brandon-Hurst Mar 18, 2025
751ba1b
Clean up MAX32 BUSIO drivers
Brandon-Hurst May 2, 2025
fcfdd1e
Cleanup copy-paste comments in MAX32 busio files
Brandon-Hurst May 2, 2025
95c820b
Correct ringbuffer code for ports/analog BUSIO
Brandon-Hurst May 5, 2025
f0f1056
Update jlink script for ports/analog
Brandon-Hurst May 5, 2025
69befc2
Refactor ports/analog/common-hal/busio i2c probe function.
Brandon-Hurst May 6, 2025
613c268
Expand command in ports/analog/tools/flash_max32.jlink for clarity.
Brandon-Hurst May 6, 2025
52bda3d
Fix i2c scan bug with ports/analog/ BUSIO.
Brandon-Hurst May 6, 2025
0ab3700
Add translations for ports/analog/busio
Brandon-Hurst May 6, 2025
64599c1
Fix error reporting on ports/analog BUSIO for PR 10413
Brandon-Hurst Jul 5, 2025
b654195
Minor changes in ports/analog/ busio UART.
Brandon-Hurst Jul 5, 2025
d62d129
Fix UART malloc for ports/analog BUSIO
Brandon-Hurst Jul 5, 2025
25ab593
Commit locale changes from ports/analog BUSIO updates
Brandon-Hurst Jul 5, 2025
bf4cc28
Reuse more existing error messages in ports/analog BUSIO
Brandon-Hurst Jul 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ update-frozen-libraries:

one-of-each: samd21 litex mimxrt10xx nordic stm

analog:
$(MAKE) -C ports/analog/ BOARD=apard32690

samd21:
$(MAKE) -C ports/atmel-samd BOARD=trinket_m0

Expand Down
42 changes: 40 additions & 2 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ msgstr ""
msgid "%q indices must be integers, not %s"
msgstr ""

#: ports/analog/common-hal/busio/SPI.c ports/analog/common-hal/busio/UART.c
#: shared-module/bitbangio/SPI.c
msgid "%q init failed"
msgstr ""
Expand Down Expand Up @@ -158,6 +159,10 @@ msgstr ""
msgid "%q length must be >= %d"
msgstr ""

#: py/runtime.c
msgid "%q moved from %q to %q"
msgstr ""

#: py/argcheck.c
msgid "%q must be %d"
msgstr ""
Expand Down Expand Up @@ -237,6 +242,7 @@ msgstr ""
msgid "%q out of bounds"
msgstr ""

#: ports/analog/common-hal/busio/SPI.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nordic/common-hal/pulseio/PulseIn.c
Expand Down Expand Up @@ -498,7 +504,8 @@ msgstr ""
msgid "All SPI peripherals are in use"
msgstr ""

#: ports/espressif/common-hal/busio/UART.c ports/nordic/common-hal/busio/UART.c
#: ports/analog/common-hal/busio/UART.c ports/espressif/common-hal/busio/UART.c
#: ports/nordic/common-hal/busio/UART.c
msgid "All UART peripherals are in use"
msgstr ""

Expand Down Expand Up @@ -649,6 +656,7 @@ msgstr ""
msgid "Boot device must be first (interface #0)."
msgstr ""

#: ports/analog/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "Both RX and TX required for flow control"
msgstr ""
Expand Down Expand Up @@ -987,7 +995,7 @@ msgid ""
"Failed to add service TXT record; non-string or bytes found in txt_records"
msgstr ""

#: shared-module/rgbmatrix/RGBMatrix.c
#: ports/analog/common-hal/busio/UART.c shared-module/rgbmatrix/RGBMatrix.c
msgid "Failed to allocate %q buffer"
msgstr ""

Expand Down Expand Up @@ -1045,6 +1053,10 @@ msgstr ""
msgid "Failed to release mutex, err 0x%04x"
msgstr ""

#: ports/analog/common-hal/busio/SPI.c
msgid "Failed to set SPI Clock Mode"
msgstr ""

#: ports/zephyr-cp/common-hal/wifi/Radio.c
msgid "Failed to set hostname"
msgstr ""
Expand Down Expand Up @@ -1247,6 +1259,10 @@ msgstr ""
msgid "Interrupted by output function"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
#: ports/analog/peripherals/max32690/max32_i2c.c
#: ports/analog/peripherals/max32690/max32_spi.c
#: ports/analog/peripherals/max32690/max32_uart.c
#: ports/espressif/common-hal/_bleio/Service.c
#: ports/espressif/common-hal/espulp/ULP.c
#: ports/espressif/common-hal/microcontroller/Processor.c
Expand Down Expand Up @@ -1339,6 +1355,7 @@ msgstr ""
msgid "Invalid socket for TLS"
msgstr ""

#: ports/analog/common-hal/busio/SPI.c
#: ports/espressif/common-hal/espidf/__init__.c
#: ports/nordic/common-hal/_bleio/__init__.c
msgid "Invalid state"
Expand Down Expand Up @@ -1894,6 +1911,7 @@ msgstr ""
msgid "ROS topic failed to initialize"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
#: ports/nordic/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "RS485"
Expand Down Expand Up @@ -1986,6 +2004,10 @@ msgstr ""
msgid "SPI init error"
msgstr ""

#: ports/analog/common-hal/busio/SPI.c
msgid "SPI needs MOSI, MISO, and SCK"
msgstr ""

#: ports/raspberrypi/common-hal/busio/SPI.c
msgid "SPI peripheral in use"
msgstr ""
Expand Down Expand Up @@ -2117,6 +2139,10 @@ msgstr ""
msgid "Timeout is too long: Maximum timeout length is %d seconds"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "Timeout must be < 100 seconds"
msgstr ""

#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Too many channels in sample"
msgstr ""
Expand Down Expand Up @@ -2160,6 +2186,10 @@ msgstr ""
msgid "UART init"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "UART needs TX & RX"
msgstr ""

#: ports/raspberrypi/common-hal/busio/UART.c
msgid "UART peripheral in use"
msgstr ""
Expand All @@ -2168,6 +2198,14 @@ msgstr ""
msgid "UART re-init"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "UART read error"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "UART transaction timeout"
msgstr ""

#: ports/stm/common-hal/busio/UART.c
msgid "UART write"
msgstr ""
Expand Down
29 changes: 23 additions & 6 deletions ports/analog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
#
# SPDX-License-Identifier: MIT

BOARD ?= apard32690
CROSS_COMPILE = arm-none-eabi-

# Includes mpconfigboard.mk & mpconfigport.mk,
# along with numerous other shared environment makefiles.
include ../../py/circuitpy_mkenv.mk

CROSS_COMPILE = arm-none-eabi-

# MCU_SERIES e.g. "max32"
# MCU_VARIANT e.g. "max32690"
# defined in mpconfigboard.mk
Expand All @@ -20,6 +21,7 @@ MCU_SERIES_UPPER := $(shell echo $(MCU_SERIES) | tr '[:lower:]' '[:upper:]')
MCU_VARIANT_LOWER := $(shell echo $(MCU_VARIANT) | tr '[:upper:]' '[:lower:]')
MCU_VARIANT_UPPER := $(shell echo $(MCU_VARIANT) | tr '[:lower:]' '[:upper:]')


# *******************************************************************************
#### MSDK INCLUDES ####
# Necessary for msdk makefiles
Expand Down Expand Up @@ -59,6 +61,7 @@ DIE_TYPE=me18
endif

PERIPH_SRC = $(ADI_PERIPH)/Source
PERIPH_INC = $(ADI_PERIPH)/Include/$(MCU_VARIANT_UPPER)

INC += -I.
INC += -I../..
Expand All @@ -75,7 +78,7 @@ INC += \
-I$(TOP)/lib/cmsis/inc \
-I$(CMSIS_ROOT)/Include \
-I$(CMSIS_ROOT)/Device/Maxim/$(MCU_VARIANT_UPPER)/Include \
-I$(ADI_PERIPH)/Include/$(MCU_VARIANT_UPPER) \
-I$(PERIPH_INC) \
-I$(PERIPH_SRC)/SYS \
-I$(PERIPH_SRC)/CTB \
-I$(PERIPH_SRC)/DMA \
Expand All @@ -85,7 +88,9 @@ INC += \
-I$(PERIPH_SRC)/TMR \
-I$(PERIPH_SRC)/RTC \
-I$(PERIPH_SRC)/UART \
-I$(PERIPH_SRC)/TRNG
-I$(PERIPH_SRC)/TRNG \
-I$(PERIPH_SRC)/I2C \
-I$(PERIPH_SRC)/SPI

INC += -I$(CMSIS_ROOT)/Device/Maxim/$(MCU_VARIANT_UPPER)/Source/GCC

Expand Down Expand Up @@ -121,12 +126,19 @@ SRC_MAX32 += \
$(PERIPH_SRC)/UART/uart_revb.c \
$(PERIPH_SRC)/TRNG/trng_revb.c \
$(PERIPH_SRC)/TRNG/trng_$(DIE_TYPE).c
$(PERIPH_SRC)/I2C/i2c_$(DIE_TYPE).c \
$(PERIPH_SRC)/I2C/i2c_reva.c \
$(PERIPH_SRC)/SPI/spi_$(DIE_TYPE).c \
$(PERIPH_SRC)/SPI/spi_reva1.c

SRC_C += $(SRC_MAX32) \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
peripherals/$(MCU_VARIANT_LOWER)/pins.c \
peripherals/$(MCU_VARIANT_LOWER)/gpios.c
peripherals/$(MCU_VARIANT_LOWER)/gpios.c \
peripherals/$(MCU_VARIANT_LOWER)/max32_uart.c \
peripherals/$(MCU_VARIANT_LOWER)/max32_i2c.c \
peripherals/$(MCU_VARIANT_LOWER)/max32_spi.c

# *******************************************************************************
### Compiler & Linker Flags ###
Expand Down Expand Up @@ -267,11 +279,16 @@ flash-msdk:
-f interface/cmsis-dap.cfg -f target/$(MCU_VARIANT_LOWER).cfg \
-c "program $(BUILD)/firmware.elf verify; init; reset; exit"

flash-openocd-jlink:
$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
-f interface/jlink.cfg -f target/$(MCU_VARIANT_LOWER).cfg \
-c "program $(BUILD)/firmware.elf verify; init; reset; exit"

# flash target using JLink
JLINK_DEVICE = $(MCU_VARIANT_LOWER)

JLINKEXE ?= JLink.exe
JLINKEXE += -if SWD -device ${JLINK_DEVICE} -speed 10000
JLINKEXE += -if SWD -device ${JLINK_DEVICE} -speed 4000
COMMAND_FILE := tools/flash_max32.jlink

flash-jlink: $(BUILD)/firmware.bin
Expand Down
10 changes: 2 additions & 8 deletions ports/analog/background.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,13 @@ extern const mxc_gpio_cfg_t led_pin[];
extern const int num_leds;

/** NOTE: ALL "ticks" refer to a 1/1024 s period */
static int status_led_ticks = 0;
static int status_ticks = 0;

// This function is where port-specific background
// tasks should be performed
// Execute port specific actions during background tick. Only if ticks are enabled.
void port_background_tick(void) {
status_led_ticks++;

// Set an LED approx. 1/s
if (status_led_ticks > 1024) {
MXC_GPIO_OutToggle(led_pin[2].port, led_pin[2].mask);
status_led_ticks = 0;
}
status_ticks++;
}

// Execute port specific actions during background tasks. This is before the
Expand Down
Loading
Loading