Skip to content

Commit 25996a7

Browse files
authored
Merge pull request #10413 from Brandon-Hurst/ports/analog/add-busio
Add busio support for ADI MAX32xxx port
2 parents 134a77f + bb27b40 commit 25996a7

File tree

25 files changed

+1476
-32
lines changed

25 files changed

+1476
-32
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ update-frozen-libraries:
299299

300300
one-of-each: samd21 litex mimxrt10xx nordic stm
301301

302+
analog:
303+
$(MAKE) -C ports/analog/ BOARD=apard32690
304+
302305
samd21:
303306
$(MAKE) -C ports/atmel-samd BOARD=trinket_m0
304307

locale/circuitpython.pot

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ msgstr ""
130130
msgid "%q indices must be integers, not %s"
131131
msgstr ""
132132

133+
#: ports/analog/common-hal/busio/SPI.c ports/analog/common-hal/busio/UART.c
133134
#: shared-module/bitbangio/SPI.c
134135
msgid "%q init failed"
135136
msgstr ""
@@ -158,6 +159,10 @@ msgstr ""
158159
msgid "%q length must be >= %d"
159160
msgstr ""
160161

162+
#: py/runtime.c
163+
msgid "%q moved from %q to %q"
164+
msgstr ""
165+
161166
#: py/argcheck.c
162167
msgid "%q must be %d"
163168
msgstr ""
@@ -237,6 +242,7 @@ msgstr ""
237242
msgid "%q out of bounds"
238243
msgstr ""
239244

245+
#: ports/analog/common-hal/busio/SPI.c
240246
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
241247
#: ports/cxd56/common-hal/pulseio/PulseIn.c
242248
#: ports/nordic/common-hal/pulseio/PulseIn.c
@@ -498,7 +504,8 @@ msgstr ""
498504
msgid "All SPI peripherals are in use"
499505
msgstr ""
500506

501-
#: ports/espressif/common-hal/busio/UART.c ports/nordic/common-hal/busio/UART.c
507+
#: ports/analog/common-hal/busio/UART.c ports/espressif/common-hal/busio/UART.c
508+
#: ports/nordic/common-hal/busio/UART.c
502509
msgid "All UART peripherals are in use"
503510
msgstr ""
504511

@@ -649,6 +656,7 @@ msgstr ""
649656
msgid "Boot device must be first (interface #0)."
650657
msgstr ""
651658

659+
#: ports/analog/common-hal/busio/UART.c
652660
#: ports/mimxrt10xx/common-hal/busio/UART.c
653661
msgid "Both RX and TX required for flow control"
654662
msgstr ""
@@ -991,7 +999,7 @@ msgid ""
991999
"Failed to add service TXT record; non-string or bytes found in txt_records"
9921000
msgstr ""
9931001

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

@@ -1049,6 +1057,10 @@ msgstr ""
10491057
msgid "Failed to release mutex, err 0x%04x"
10501058
msgstr ""
10511059

1060+
#: ports/analog/common-hal/busio/SPI.c
1061+
msgid "Failed to set SPI Clock Mode"
1062+
msgstr ""
1063+
10521064
#: ports/zephyr-cp/common-hal/wifi/Radio.c
10531065
msgid "Failed to set hostname"
10541066
msgstr ""
@@ -1251,6 +1263,10 @@ msgstr ""
12511263
msgid "Interrupted by output function"
12521264
msgstr ""
12531265

1266+
#: ports/analog/common-hal/busio/UART.c
1267+
#: ports/analog/peripherals/max32690/max32_i2c.c
1268+
#: ports/analog/peripherals/max32690/max32_spi.c
1269+
#: ports/analog/peripherals/max32690/max32_uart.c
12541270
#: ports/espressif/common-hal/_bleio/Service.c
12551271
#: ports/espressif/common-hal/espulp/ULP.c
12561272
#: ports/espressif/common-hal/microcontroller/Processor.c
@@ -1343,6 +1359,7 @@ msgstr ""
13431359
msgid "Invalid socket for TLS"
13441360
msgstr ""
13451361

1362+
#: ports/analog/common-hal/busio/SPI.c
13461363
#: ports/espressif/common-hal/espidf/__init__.c
13471364
#: ports/nordic/common-hal/_bleio/__init__.c
13481365
msgid "Invalid state"
@@ -1902,6 +1919,7 @@ msgstr ""
19021919
msgid "ROS topic failed to initialize"
19031920
msgstr ""
19041921

1922+
#: ports/analog/common-hal/busio/UART.c
19051923
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
19061924
#: ports/nordic/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
19071925
msgid "RS485"
@@ -1994,6 +2012,10 @@ msgstr ""
19942012
msgid "SPI init error"
19952013
msgstr ""
19962014

2015+
#: ports/analog/common-hal/busio/SPI.c
2016+
msgid "SPI needs MOSI, MISO, and SCK"
2017+
msgstr ""
2018+
19972019
#: ports/raspberrypi/common-hal/busio/SPI.c
19982020
msgid "SPI peripheral in use"
19992021
msgstr ""
@@ -2125,6 +2147,10 @@ msgstr ""
21252147
msgid "Timeout is too long: Maximum timeout length is %d seconds"
21262148
msgstr ""
21272149

2150+
#: ports/analog/common-hal/busio/UART.c
2151+
msgid "Timeout must be < 100 seconds"
2152+
msgstr ""
2153+
21282154
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
21292155
msgid "Too many channels in sample"
21302156
msgstr ""
@@ -2168,6 +2194,10 @@ msgstr ""
21682194
msgid "UART init"
21692195
msgstr ""
21702196

2197+
#: ports/analog/common-hal/busio/UART.c
2198+
msgid "UART needs TX & RX"
2199+
msgstr ""
2200+
21712201
#: ports/raspberrypi/common-hal/busio/UART.c
21722202
msgid "UART peripheral in use"
21732203
msgstr ""
@@ -2176,6 +2206,14 @@ msgstr ""
21762206
msgid "UART re-init"
21772207
msgstr ""
21782208

2209+
#: ports/analog/common-hal/busio/UART.c
2210+
msgid "UART read error"
2211+
msgstr ""
2212+
2213+
#: ports/analog/common-hal/busio/UART.c
2214+
msgid "UART transaction timeout"
2215+
msgstr ""
2216+
21792217
#: ports/stm/common-hal/busio/UART.c
21802218
msgid "UART write"
21812219
msgstr ""

ports/analog/Makefile

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#
77
# SPDX-License-Identifier: MIT
88

9+
BOARD ?= apard32690
10+
CROSS_COMPILE = arm-none-eabi-
11+
912
# Includes mpconfigboard.mk & mpconfigport.mk,
1013
# along with numerous other shared environment makefiles.
1114
include ../../py/circuitpy_mkenv.mk
1215

13-
CROSS_COMPILE = arm-none-eabi-
14-
1516
# MCU_SERIES e.g. "max32"
1617
# MCU_VARIANT e.g. "max32690"
1718
# defined in mpconfigboard.mk
@@ -20,6 +21,7 @@ MCU_SERIES_UPPER := $(shell echo $(MCU_SERIES) | tr '[:lower:]' '[:upper:]')
2021
MCU_VARIANT_LOWER := $(shell echo $(MCU_VARIANT) | tr '[:upper:]' '[:lower:]')
2122
MCU_VARIANT_UPPER := $(shell echo $(MCU_VARIANT) | tr '[:lower:]' '[:upper:]')
2223

24+
2325
# *******************************************************************************
2426
#### MSDK INCLUDES ####
2527
# Necessary for msdk makefiles
@@ -59,6 +61,7 @@ DIE_TYPE=me18
5961
endif
6062

6163
PERIPH_SRC = $(ADI_PERIPH)/Source
64+
PERIPH_INC = $(ADI_PERIPH)/Include/$(MCU_VARIANT_UPPER)
6265

6366
INC += -I.
6467
INC += -I../..
@@ -75,7 +78,7 @@ INC += \
7578
-I$(TOP)/lib/cmsis/inc \
7679
-I$(CMSIS_ROOT)/Include \
7780
-I$(CMSIS_ROOT)/Device/Maxim/$(MCU_VARIANT_UPPER)/Include \
78-
-I$(ADI_PERIPH)/Include/$(MCU_VARIANT_UPPER) \
81+
-I$(PERIPH_INC) \
7982
-I$(PERIPH_SRC)/SYS \
8083
-I$(PERIPH_SRC)/CTB \
8184
-I$(PERIPH_SRC)/DMA \
@@ -85,7 +88,9 @@ INC += \
8588
-I$(PERIPH_SRC)/TMR \
8689
-I$(PERIPH_SRC)/RTC \
8790
-I$(PERIPH_SRC)/UART \
88-
-I$(PERIPH_SRC)/TRNG
91+
-I$(PERIPH_SRC)/TRNG \
92+
-I$(PERIPH_SRC)/I2C \
93+
-I$(PERIPH_SRC)/SPI
8994

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

@@ -120,13 +125,20 @@ SRC_MAX32 += \
120125
$(PERIPH_SRC)/UART/uart_$(DIE_TYPE).c \
121126
$(PERIPH_SRC)/UART/uart_revb.c \
122127
$(PERIPH_SRC)/TRNG/trng_revb.c \
123-
$(PERIPH_SRC)/TRNG/trng_$(DIE_TYPE).c
128+
$(PERIPH_SRC)/TRNG/trng_$(DIE_TYPE).c \
129+
$(PERIPH_SRC)/I2C/i2c_$(DIE_TYPE).c \
130+
$(PERIPH_SRC)/I2C/i2c_reva.c \
131+
$(PERIPH_SRC)/SPI/spi_$(DIE_TYPE).c \
132+
$(PERIPH_SRC)/SPI/spi_reva1.c
124133

125134
SRC_C += $(SRC_MAX32) \
126135
boards/$(BOARD)/board.c \
127136
boards/$(BOARD)/pins.c \
128137
peripherals/$(MCU_VARIANT_LOWER)/pins.c \
129-
peripherals/$(MCU_VARIANT_LOWER)/gpios.c
138+
peripherals/$(MCU_VARIANT_LOWER)/gpios.c \
139+
peripherals/$(MCU_VARIANT_LOWER)/max32_uart.c \
140+
peripherals/$(MCU_VARIANT_LOWER)/max32_i2c.c \
141+
peripherals/$(MCU_VARIANT_LOWER)/max32_spi.c
130142

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

282+
flash-openocd-jlink:
283+
$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
284+
-f interface/jlink.cfg -f target/$(MCU_VARIANT_LOWER).cfg \
285+
-c "program $(BUILD)/firmware.elf verify; init; reset; exit"
286+
270287
# flash target using JLink
271288
JLINK_DEVICE = $(MCU_VARIANT_LOWER)
272289

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

277294
flash-jlink: $(BUILD)/firmware.bin

ports/analog/background.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,13 @@ extern const mxc_gpio_cfg_t led_pin[];
1919
extern const int num_leds;
2020

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

2424
// This function is where port-specific background
2525
// tasks should be performed
2626
// Execute port specific actions during background tick. Only if ticks are enabled.
2727
void port_background_tick(void) {
28-
status_led_ticks++;
29-
30-
// Set an LED approx. 1/s
31-
if (status_led_ticks > 1024) {
32-
MXC_GPIO_OutToggle(led_pin[2].port, led_pin[2].mask);
33-
status_led_ticks = 0;
34-
}
28+
status_ticks++;
3529
}
3630

3731
// Execute port specific actions during background tasks. This is before the

0 commit comments

Comments
 (0)