diff --git a/ports/analog/Makefile b/ports/analog/Makefile index 5d923cbaf6b6..c31bb6dea191 100644 --- a/ports/analog/Makefile +++ b/ports/analog/Makefile @@ -121,7 +121,8 @@ SRC_MAX32 += \ SRC_C += $(SRC_MAX32) \ boards/$(BOARD)/board.c \ boards/$(BOARD)/pins.c \ - peripherals/$(MCU_VARIANT_LOWER)/pins.c + peripherals/$(MCU_VARIANT_LOWER)/pins.c \ + peripherals/$(MCU_VARIANT_LOWER)/gpios.c # ******************************************************************************* ### Compiler & Linker Flags ### diff --git a/ports/analog/boards/apard32690/board.c b/ports/analog/boards/apard32690/board.c index 44c5a47faa6e..76c3e7f5591f 100644 --- a/ports/analog/boards/apard32690/board.c +++ b/ports/analog/boards/apard32690/board.c @@ -9,42 +9,18 @@ #include "mpconfigboard.h" #include "max32_port.h" -// Board-level setup for MAX32690 -mxc_gpio_regs_t *gpio_ports[NUM_GPIO_PORTS] = -{MXC_GPIO0, MXC_GPIO1, MXC_GPIO2, MXC_GPIO3, MXC_GPIO4}; - -// clang-format off -const mxc_gpio_cfg_t pb_pin[] = { - { MXC_GPIO1, MXC_GPIO_PIN_27, MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIOH, MXC_GPIO_DRVSTR_0}, -}; -const int num_pbs = (sizeof(pb_pin) / sizeof(mxc_gpio_cfg_t)); - -const mxc_gpio_cfg_t led_pin[] = { - { MXC_GPIO2, MXC_GPIO_PIN_1, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 }, - { MXC_GPIO0, MXC_GPIO_PIN_11, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 }, - { MXC_GPIO0, MXC_GPIO_PIN_12, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 }, -}; -const int num_leds = (sizeof(led_pin) / sizeof(mxc_gpio_cfg_t)); -// clang-format on - +/***** OPTIONAL BOARD-SPECIFIC FUNCTIONS from supervisor/board.h *****/ // DEFAULT: Using the weak-defined supervisor/shared/board.c functions -/***** OPTIONAL BOARD-SPECIFIC FUNCTIONS from supervisor/board.h *****/ +// Initializes board related state once on start up. +void board_init(void) { +} + // Returns true if the user initiates safe mode in a board specific way. // Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific // way. // bool board_requests_safe_mode(void); -volatile uint32_t system_ticks = 0; - -void SysTick_Handler(void) { - system_ticks++; -} - -// Initializes board related state once on start up. -void board_init(void) { -} - // Reset the state of off MCU components such as neopixels. // void reset_board(void); diff --git a/ports/analog/boards/max32690evkit/board.c b/ports/analog/boards/max32690evkit/board.c index 57d5cf74e7be..76c3e7f5591f 100644 --- a/ports/analog/boards/max32690evkit/board.c +++ b/ports/analog/boards/max32690evkit/board.c @@ -9,41 +9,18 @@ #include "mpconfigboard.h" #include "max32_port.h" -// Board-level setup for MAX32690 -mxc_gpio_regs_t *gpio_ports[NUM_GPIO_PORTS] = -{MXC_GPIO0, MXC_GPIO1, MXC_GPIO2, MXC_GPIO3, MXC_GPIO4}; - -// clang-format off -const mxc_gpio_cfg_t pb_pin[] = { - { MXC_GPIO4, MXC_GPIO_PIN_0, MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIOH, MXC_GPIO_DRVSTR_0}, -}; -const int num_pbs = (sizeof(pb_pin) / sizeof(mxc_gpio_cfg_t)); - -const mxc_gpio_cfg_t led_pin[] = { - { MXC_GPIO0, MXC_GPIO_PIN_14, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 }, - { MXC_GPIO2, MXC_GPIO_PIN_12, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 }, -}; -const int num_leds = (sizeof(led_pin) / sizeof(mxc_gpio_cfg_t)); -// clang-format on - +/***** OPTIONAL BOARD-SPECIFIC FUNCTIONS from supervisor/board.h *****/ // DEFAULT: Using the weak-defined supervisor/shared/board.c functions -/***** OPTIONAL BOARD-SPECIFIC FUNCTIONS from supervisor/board.h *****/ +// Initializes board related state once on start up. +void board_init(void) { +} + // Returns true if the user initiates safe mode in a board specific way. // Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific // way. // bool board_requests_safe_mode(void); -volatile uint32_t system_ticks = 0; - -void SysTick_Handler(void) { - system_ticks++; -} - -// Initializes board related state once on start up. -void board_init(void) { -} - // Reset the state of off MCU components such as neopixels. // void reset_board(void); diff --git a/ports/analog/peripherals/max32690/gpios.c b/ports/analog/peripherals/max32690/gpios.c new file mode 100644 index 000000000000..d0dd3ad0fc19 --- /dev/null +++ b/ports/analog/peripherals/max32690/gpios.c @@ -0,0 +1,10 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2024 Brandon Hurst, Analog Devices, Inc. +// +// SPDX-License-Identifier: MIT + +#include "gpios.h" + +volatile mxc_gpio_regs_t *gpio_ports[NUM_GPIO_PORTS] = +{MXC_GPIO0, MXC_GPIO1, MXC_GPIO2, MXC_GPIO3, MXC_GPIO4}; diff --git a/ports/analog/peripherals/max32690/gpios.h b/ports/analog/peripherals/max32690/gpios.h new file mode 100644 index 000000000000..4677bf8f33db --- /dev/null +++ b/ports/analog/peripherals/max32690/gpios.h @@ -0,0 +1,13 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2024 Brandon Hurst, Analog Devices, Inc. +// +// SPDX-License-Identifier: MIT + +#include "py/obj.h" +#include "py/mphal.h" + +// MSDK HAL includes +#include "gpio.h" +#include "gpio_regs.h" +#include "max32690.h" diff --git a/ports/analog/supervisor/port.c b/ports/analog/supervisor/port.c index da668d1f31a7..ad003c12ed9e 100644 --- a/ports/analog/supervisor/port.c +++ b/ports/analog/supervisor/port.c @@ -65,6 +65,13 @@ static uint32_t tick_flag = 0; // defined by cmsis core files extern void NVIC_SystemReset(void) NORETURN; +volatile uint32_t system_ticks = 0; + +void SysTick_Handler(void) { + system_ticks++; +} + + safe_mode_t port_init(void) { int err = E_NO_ERROR;