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 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5052177
Setup files for busio
Brandon-Hurst Dec 26, 2024
0220236
Add default build for analog ports for apard32690 board.
Brandon-Hurst Jan 14, 2025
3ce7bdd
Add preliminary busio.UART support
Brandon-Hurst Jan 14, 2025
3608b8c
Add tools files for debugging
Brandon-Hurst Jan 14, 2025
8848d43
Fixed most UART write issues.
Brandon-Hurst Jan 24, 2025
872e81c
Fix issues with UART reads and unreliable UART writes.
Brandon-Hurst Jan 25, 2025
d47b882
Add pre-commit changes to UART
Brandon-Hurst Jan 27, 2025
68d8daa
Resolve UART ISR naming issues
Brandon-Hurst Feb 1, 2025
edf069d
Add BUSIO.I2C and MAX32690 I2C structure
Brandon-Hurst Mar 7, 2025
6967949
Add hardware mapping for BUSIO.SPI for MAX32690
Brandon-Hurst Mar 7, 2025
a81ea5e
Add complete BUSIO driver structure for SPI & I2C.
Brandon-Hurst Mar 7, 2025
ddd4cf6
Add call to MXC_DelayHandler in SysTick ISR
Brandon-Hurst Mar 7, 2025
32c6b3e
Corrected I2C & SPI. Tested with example scripts; works with real per…
Brandon-Hurst Mar 7, 2025
88099be
Add extra I2C options for MAX32690 non-TQFN packages
Brandon-Hurst Mar 18, 2025
5cf0305
Clean up MAX32 BUSIO drivers
Brandon-Hurst May 2, 2025
deda980
Cleanup copy-paste comments in MAX32 busio files
Brandon-Hurst May 2, 2025
0f9ea29
Correct ringbuffer code for ports/analog BUSIO
Brandon-Hurst May 5, 2025
a305ece
Update jlink script for ports/analog
Brandon-Hurst May 5, 2025
cbbf34d
Refactor ports/analog/common-hal/busio i2c probe function.
Brandon-Hurst May 6, 2025
c3ea182
Expand command in ports/analog/tools/flash_max32.jlink for clarity.
Brandon-Hurst May 6, 2025
db95dd0
Fix i2c scan bug with ports/analog/ BUSIO.
Brandon-Hurst May 6, 2025
9b8e08f
Add translations for ports/analog/busio
Brandon-Hurst May 6, 2025
363e310
Merge branch 'main' into ports/analog/add-busio
dhalbert Jun 12, 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 @@ -304,6 +304,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
114 changes: 114 additions & 0 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ msgid ""
"Code stopped by auto-reload. Reloading soon.\n"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
#, c-format
msgid ""
"\n"
"ERR: Error starting transaction: %d\n"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid ""
"\n"
"ERR: Requested bus is busy\n"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid ""
"\n"
"ERR: Uart transaction timed out.\n"
msgstr ""

#: supervisor/shared/safe_mode.c
msgid ""
"\n"
Expand Down Expand Up @@ -632,6 +651,10 @@ msgid ""
"disable.\n"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "Baudrate invalid. Must be a standard UART baudrate.\n"
msgstr ""

#: ports/espressif/common-hal/canio/CAN.c
msgid "Baudrate not supported by peripheral"
msgstr ""
Expand Down Expand Up @@ -721,6 +744,10 @@ msgstr ""
msgid "CIRCUITPY drive could not be found or created."
msgstr ""

#: ports/analog/common-hal/busio/SPI.c
msgid "CPOL / CPHA must both be either 0 or 1\n"
msgstr ""

#: ports/espressif/common-hal/espidf/__init__.c
msgid "CRC or checksum was invalid"
msgstr ""
Expand Down Expand Up @@ -943,6 +970,38 @@ msgstr ""
msgid "ECB only operates on 16 bytes at a time"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "ERR: Could not init ringbuffer\n"
msgstr ""

#: ports/analog/peripherals/max32690/max32_uart.c
#, c-format
msgid ""
"ERR: Unable to find a uart matching pins...\n"
"TX: port %d mask %d\n"
"RX: port %d mask %d\n"
msgstr ""

#: ports/analog/peripherals/max32690/max32_i2c.c
#, c-format
msgid ""
"ERR: Unable to find an I2C matching pins...\n"
"SCL: port %d mask %d\n"
"SDA: port %d mask %d\n"
msgstr ""

#: ports/analog/peripherals/max32690/max32_spi.c
#, c-format
msgid ""
"ERR: Unable to find an SPI matching pins... \n"
"MOSI: port %d mask %d\n"
"MISO: port %d mask %d\n"
msgstr ""

#: ports/analog/common-hal/busio/I2C.c
msgid "ERROR during I2C Transaction\n"
msgstr ""

#: ports/espressif/common-hal/busio/SPI.c
#: ports/espressif/common-hal/canio/CAN.c
msgid "ESP-IDF memory allocation failed"
Expand Down Expand Up @@ -1036,6 +1095,19 @@ msgstr ""
msgid "Failed to enable continuous"
msgstr ""

#: ports/analog/common-hal/busio/I2C.c
#, c-format
msgid "Failed to init I2C. ERR: %d\n"
msgstr ""

#: ports/analog/common-hal/busio/SPI.c
msgid "Failed to init SPI.\n"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "Failed to initialize UART.\n"
msgstr ""

#: shared-module/audiomp3/MP3Decoder.c
msgid "Failed to parse MP3 file"
msgstr ""
Expand All @@ -1049,6 +1121,23 @@ msgstr ""
msgid "Failed to release mutex, err 0x%04x"
msgstr ""

#: ports/analog/common-hal/busio/I2C.c
#, c-format
msgid "Failed to set I2C frequency. ERR: %d\n"
msgstr ""

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

#: ports/analog/common-hal/busio/SPI.c
msgid "Failed to set SPI Frame Size\n"
msgstr ""

#: ports/analog/common-hal/busio/SPI.c
msgid "Failed to set SPI Frequency\n"
msgstr ""

#: ports/zephyr-cp/common-hal/wifi/Radio.c
msgid "Failed to set hostname"
msgstr ""
Expand Down Expand Up @@ -1089,6 +1178,10 @@ msgstr ""
msgid "Firmware is too big"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "Flow Ctrl needs both CTS & RTS"
msgstr ""

#: shared-bindings/bitmaptools/__init__.c
msgid "For L8 colorspace, input bitmap must have 8 bits per pixel"
msgstr ""
Expand Down Expand Up @@ -1148,6 +1241,10 @@ msgstr ""
msgid "I2C init error"
msgstr ""

#: ports/analog/common-hal/busio/I2C.c
msgid "I2C needs SDA & SCL"
msgstr ""

#: ports/raspberrypi/common-hal/busio/I2C.c
#: ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c
msgid "I2C peripheral in use"
Expand Down Expand Up @@ -1761,6 +1858,10 @@ msgstr ""
msgid "Parameter error"
msgstr ""

#: ports/analog/common-hal/busio/UART.c
msgid "Parity must be ODD, EVEN, or NONE\n"
msgstr ""

#: ports/espressif/common-hal/audiobusio/__init__.c
msgid "Peripheral in use"
msgstr ""
Expand Down Expand Up @@ -1898,6 +1999,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 @@ -1990,6 +2092,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 @@ -2121,6 +2227,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 @@ -2164,6 +2274,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 Down
31 changes: 24 additions & 7 deletions ports/analog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,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 @@ -19,6 +20,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 @@ -58,6 +60,7 @@ DIE_TYPE=me18
endif

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

INC += -I.
INC += -I../..
Expand All @@ -74,7 +77,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 @@ -83,7 +86,9 @@ INC += \
-I$(PERIPH_SRC)/ICC \
-I$(PERIPH_SRC)/TMR \
-I$(PERIPH_SRC)/RTC \
-I$(PERIPH_SRC)/UART
-I$(PERIPH_SRC)/UART \
-I$(PERIPH_SRC)/I2C \
-I$(PERIPH_SRC)/SPI

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

Expand Down Expand Up @@ -116,13 +121,20 @@ SRC_MAX32 += \
$(PERIPH_SRC)/TMR/tmr_$(DIE_TYPE).c \
$(PERIPH_SRC)/UART/uart_common.c \
$(PERIPH_SRC)/UART/uart_$(DIE_TYPE).c \
$(PERIPH_SRC)/UART/uart_revb.c
$(PERIPH_SRC)/UART/uart_revb.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 @@ -263,11 +275,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