Skip to content

Commit 24b53f5

Browse files
committed
Move configuration from board.c to supervisor/port.c (non-MCU specific) and peripherals/max32690 (mcu-specific)
1 parent 2a2ebb9 commit 24b53f5

File tree

6 files changed

+42
-58
lines changed

6 files changed

+42
-58
lines changed

ports/analog/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ SRC_MAX32 += \
121121
SRC_C += $(SRC_MAX32) \
122122
boards/$(BOARD)/board.c \
123123
boards/$(BOARD)/pins.c \
124-
peripherals/$(MCU_VARIANT_LOWER)/pins.c
124+
peripherals/$(MCU_VARIANT_LOWER)/pins.c \
125+
peripherals/$(MCU_VARIANT_LOWER)/gpios.c
125126

126127
# *******************************************************************************
127128
### Compiler & Linker Flags ###

ports/analog/boards/apard32690/board.c

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,18 @@
99
#include "mpconfigboard.h"
1010
#include "max32_port.h"
1111

12-
// Board-level setup for MAX32690
13-
mxc_gpio_regs_t *gpio_ports[NUM_GPIO_PORTS] =
14-
{MXC_GPIO0, MXC_GPIO1, MXC_GPIO2, MXC_GPIO3, MXC_GPIO4};
15-
16-
// clang-format off
17-
const mxc_gpio_cfg_t pb_pin[] = {
18-
{ MXC_GPIO1, MXC_GPIO_PIN_27, MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIOH, MXC_GPIO_DRVSTR_0},
19-
};
20-
const int num_pbs = (sizeof(pb_pin) / sizeof(mxc_gpio_cfg_t));
21-
22-
const mxc_gpio_cfg_t led_pin[] = {
23-
{ MXC_GPIO2, MXC_GPIO_PIN_1, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 },
24-
{ MXC_GPIO0, MXC_GPIO_PIN_11, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 },
25-
{ MXC_GPIO0, MXC_GPIO_PIN_12, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 },
26-
};
27-
const int num_leds = (sizeof(led_pin) / sizeof(mxc_gpio_cfg_t));
28-
// clang-format on
29-
12+
/***** OPTIONAL BOARD-SPECIFIC FUNCTIONS from supervisor/board.h *****/
3013
// DEFAULT: Using the weak-defined supervisor/shared/board.c functions
3114

32-
/***** OPTIONAL BOARD-SPECIFIC FUNCTIONS from supervisor/board.h *****/
15+
// Initializes board related state once on start up.
16+
void board_init(void) {
17+
}
18+
3319
// Returns true if the user initiates safe mode in a board specific way.
3420
// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific
3521
// way.
3622
// bool board_requests_safe_mode(void);
3723

38-
volatile uint32_t system_ticks = 0;
39-
40-
void SysTick_Handler(void) {
41-
system_ticks++;
42-
}
43-
44-
// Initializes board related state once on start up.
45-
void board_init(void) {
46-
}
47-
4824
// Reset the state of off MCU components such as neopixels.
4925
// void reset_board(void);
5026

ports/analog/boards/max32690evkit/board.c

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,18 @@
99
#include "mpconfigboard.h"
1010
#include "max32_port.h"
1111

12-
// Board-level setup for MAX32690
13-
mxc_gpio_regs_t *gpio_ports[NUM_GPIO_PORTS] =
14-
{MXC_GPIO0, MXC_GPIO1, MXC_GPIO2, MXC_GPIO3, MXC_GPIO4};
15-
16-
// clang-format off
17-
const mxc_gpio_cfg_t pb_pin[] = {
18-
{ MXC_GPIO4, MXC_GPIO_PIN_0, MXC_GPIO_FUNC_IN, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIOH, MXC_GPIO_DRVSTR_0},
19-
};
20-
const int num_pbs = (sizeof(pb_pin) / sizeof(mxc_gpio_cfg_t));
21-
22-
const mxc_gpio_cfg_t led_pin[] = {
23-
{ MXC_GPIO0, MXC_GPIO_PIN_14, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 },
24-
{ MXC_GPIO2, MXC_GPIO_PIN_12, MXC_GPIO_FUNC_OUT, MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO, MXC_GPIO_DRVSTR_0 },
25-
};
26-
const int num_leds = (sizeof(led_pin) / sizeof(mxc_gpio_cfg_t));
27-
// clang-format on
28-
12+
/***** OPTIONAL BOARD-SPECIFIC FUNCTIONS from supervisor/board.h *****/
2913
// DEFAULT: Using the weak-defined supervisor/shared/board.c functions
3014

31-
/***** OPTIONAL BOARD-SPECIFIC FUNCTIONS from supervisor/board.h *****/
15+
// Initializes board related state once on start up.
16+
void board_init(void) {
17+
}
18+
3219
// Returns true if the user initiates safe mode in a board specific way.
3320
// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific
3421
// way.
3522
// bool board_requests_safe_mode(void);
3623

37-
volatile uint32_t system_ticks = 0;
38-
39-
void SysTick_Handler(void) {
40-
system_ticks++;
41-
}
42-
43-
// Initializes board related state once on start up.
44-
void board_init(void) {
45-
}
46-
4724
// Reset the state of off MCU components such as neopixels.
4825
// void reset_board(void);
4926

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Brandon Hurst, Analog Devices, Inc.
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "gpios.h"
8+
9+
volatile mxc_gpio_regs_t *gpio_ports[NUM_GPIO_PORTS] =
10+
{MXC_GPIO0, MXC_GPIO1, MXC_GPIO2, MXC_GPIO3, MXC_GPIO4};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Brandon Hurst, Analog Devices, Inc.
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "py/obj.h"
8+
#include "py/mphal.h"
9+
10+
// MSDK HAL includes
11+
#include "gpio.h"
12+
#include "gpio_regs.h"
13+
#include "max32690.h"

ports/analog/supervisor/port.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ static uint32_t tick_flag = 0;
6565
// defined by cmsis core files
6666
extern void NVIC_SystemReset(void) NORETURN;
6767

68+
volatile uint32_t system_ticks = 0;
69+
70+
void SysTick_Handler(void) {
71+
system_ticks++;
72+
}
73+
74+
6875
safe_mode_t port_init(void) {
6976
int err = E_NO_ERROR;
7077

0 commit comments

Comments
 (0)