Skip to content

Commit

Permalink
Move configuration from board.c to supervisor/port.c (non-MCU specifi…
Browse files Browse the repository at this point in the history
…c) and peripherals/max32690 (mcu-specific)
  • Loading branch information
Brandon-Hurst committed Nov 27, 2024
1 parent 2a2ebb9 commit 24b53f5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 58 deletions.
3 changes: 2 additions & 1 deletion ports/analog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down
34 changes: 5 additions & 29 deletions ports/analog/boards/apard32690/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
33 changes: 5 additions & 28 deletions ports/analog/boards/max32690evkit/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 10 additions & 0 deletions ports/analog/peripherals/max32690/gpios.c
Original file line number Diff line number Diff line change
@@ -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};
13 changes: 13 additions & 0 deletions ports/analog/peripherals/max32690/gpios.h
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 7 additions & 0 deletions ports/analog/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 24b53f5

Please sign in to comment.