Skip to content

Commit fcda884

Browse files
committed
Add target support for XDOT_MAX32670
1 parent 1a036c2 commit fcda884

File tree

5 files changed

+376
-0
lines changed

5 files changed

+376
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
add_library(mbed-xdot-max32670 INTERFACE)
2+
3+
target_include_directories(mbed-xdot-max32670
4+
INTERFACE
5+
.
6+
)
7+
8+
target_link_libraries(mbed-xdot-max32670
9+
INTERFACE
10+
mbed-max32670
11+
)
12+
13+
target_sources(mbed-xdot-max32670
14+
INTERFACE
15+
SystemInit.c
16+
)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*******************************************************************************
2+
* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
18+
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*
22+
* Except as contained in this notice, the name of Maxim Integrated
23+
* Products, Inc. shall not be used except as stated in the Maxim Integrated
24+
* Products, Inc. Branding Policy.
25+
*
26+
* The mere transfer of this software does not imply any licenses
27+
* of trade secrets, proprietary technology, copyrights, patents,
28+
* trademarks, maskwork rights, or any other form of intellectual
29+
* property whatsoever. Maxim Integrated Products, Inc. retains all
30+
* ownership rights.
31+
*******************************************************************************
32+
*/
33+
34+
#ifndef MBED_PERIPHERALNAMES_H
35+
#define MBED_PERIPHERALNAMES_H
36+
37+
#include "cmsis.h"
38+
39+
#ifdef __cplusplus
40+
extern "C" {
41+
#endif
42+
43+
typedef enum {
44+
UART_0 = MXC_BASE_UART0,
45+
UART_1 = MXC_BASE_UART1,
46+
UART_2 = MXC_BASE_UART2,
47+
UART_3 = MXC_BASE_UART3,
48+
#if defined(MBED_CONF_TARGET_STDIO_UART)
49+
STDIO_UART = MBED_CONF_TARGET_STDIO_UART,
50+
#else
51+
STDIO_UART = UART_0,
52+
#endif
53+
} UARTName;
54+
55+
typedef enum {
56+
I2C_0 = MXC_BASE_I2C0,
57+
I2C_1 = MXC_BASE_I2C1,
58+
I2C_2 = MXC_BASE_I2C2,
59+
} I2CName;
60+
61+
typedef enum {
62+
SPI_0 = MXC_BASE_SPI0,
63+
SPI_1 = MXC_BASE_SPI1,
64+
SPI_2 = MXC_BASE_SPI2,
65+
} SPIName;
66+
67+
68+
#ifdef __cplusplus
69+
}
70+
#endif
71+
72+
#endif
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/*******************************************************************************
2+
* Copyright (C) 2022 Maxim Integrated Products, Inc., All Rights Reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
18+
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*
22+
* Except as contained in this notice, the name of Maxim Integrated
23+
* Products, Inc. shall not be used except as stated in the Maxim Integrated
24+
* Products, Inc. Branding Policy.
25+
*
26+
* The mere transfer of this software does not imply any licenses
27+
* of trade secrets, proprietary technology, copyrights, patents,
28+
* trademarks, maskwork rights, or any other form of intellectual
29+
* property whatsoever. Maxim Integrated Products, Inc. retains all
30+
* ownership rights.
31+
*******************************************************************************
32+
*/
33+
34+
/* MBED TARGET LIST: MAX32670EVKIT */
35+
36+
#ifndef MBED_PINNAMES_H
37+
#define MBED_PINNAMES_H
38+
39+
#include "cmsis.h"
40+
#include "gpio_regs.h"
41+
42+
#ifdef __cplusplus
43+
extern "C" {
44+
#endif
45+
46+
typedef enum {
47+
PIN_INPUT = 0,
48+
PIN_OUTPUT = 1
49+
} PinDirection;
50+
51+
#define PORT_SHIFT 12
52+
53+
#define PINNAME_TO_PORT(name) ((unsigned int)(name) >> PORT_SHIFT)
54+
#define PINNAME_TO_PIN(name) ((unsigned int)(name) & ~(0xFFFFFFFF << PORT_SHIFT))
55+
#define NOT_CONNECTED (int)0xFFFFFFFF
56+
57+
typedef enum {
58+
// Port 0
59+
P0_0 = (0 << PORT_SHIFT),
60+
P0_1, P0_2, P0_3, P0_4, P0_5, P0_6, P0_7, P0_8, P0_9, P0_10, P0_11, P0_12, P0_13, P0_14, P0_15,
61+
P0_16, P0_17, P0_18, P0_19, P0_20, P0_21, P0_22, P0_23,P0_24, P0_25, P0_26, P0_27, P0_28, P0_29, P0_30, P0_31,
62+
63+
// Port 1
64+
P1_0 = (1 << PORT_SHIFT),
65+
P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7, P1_8, P1_9, P1_10, P1_11, P1_12, P1_13, P1_14, P1_15,
66+
P1_16, P1_17, P1_18, P1_19, P1_20, P1_21, P1_22, P1_23,P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31,
67+
68+
// USB bridge connected UART pins
69+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
70+
CONSOLE_TX = MBED_CONF_TARGET_STDIO_UART_TX,
71+
#else
72+
CONSOLE_TX = P0_29,
73+
#endif // MBED_CONF_TARGET_STDIO_UART_TX
74+
75+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
76+
CONSOLE_RX = MBED_CONF_TARGET_STDIO_UART_RX,
77+
#else
78+
CONSOLE_RX = P0_28,
79+
#endif // MBED_CONF_TARGET_STDIO_UART_RX
80+
81+
STDIO_UART_TX = CONSOLE_TX,
82+
STDIO_UART_RX = CONSOLE_RX,
83+
84+
// ----- Start of xDot external pin definitions -----
85+
WAKE = P0_19,
86+
LED1 = P0_30,
87+
GPIO0 = P0_30,
88+
GPIO1 = P0_27,
89+
GPIO2 = P0_26,
90+
GPIO3 = P0_25,
91+
92+
// AT command port UART
93+
UART_RX = P0_8,
94+
UART_TX = P0_9,
95+
UART_CTS = P0_10,
96+
UART_RTS = P0_11,
97+
98+
UART0_RX = UART_RX,
99+
UART0_TX = UART_TX,
100+
UART0_CTS = UART_CTS,
101+
UART0_RTS = UART_RTS,
102+
103+
// debug UART
104+
UART1_RX = P0_28,
105+
UART1_TX = P0_29,
106+
107+
// SwD
108+
SWDIO = P0_0,
109+
SWCLK = P0_1,
110+
111+
// I2C
112+
I2C1_SCL = P0_12,
113+
I2C1_SDA = P0_13,
114+
I2C_SCL = I2C1_SCL,
115+
I2C_SDA = I2C1_SDA,
116+
117+
// SPI
118+
SPI0_SCK = P0_4,
119+
SPI0_MOSI = P0_3,
120+
SPI0_MISO = P0_2,
121+
SPI0_SS = P0_5,
122+
SPI_MISO = SPI0_MISO,
123+
SPI_MOSI = SPI0_MOSI,
124+
SPI_SCK = SPI0_SCK,
125+
SPI_NSS = SPI0_SS,
126+
// ----- End of xDot external pin definitions -----
127+
128+
// ----- Start of xDot dedicated internal pins. -----
129+
MEM_PWR_EN = P0_24, // Power to EEPROM, Flash & Secure element
130+
FLASH_CS = P0_23,
131+
132+
// EEPROM and SE I2C
133+
I2C0_SCL = P0_6,
134+
I2C0_SDA = P0_7,
135+
SE_SDA = I2C0_SDA,
136+
SE_SCL = I2C0_SCL,
137+
138+
// SX1262
139+
SPI1_SCK = P0_16,
140+
SPI1_MOSI = P0_15,
141+
SPI1_MISO = P0_14,
142+
SPI1_SS = P0_17,
143+
LORA_MISO = SPI1_MISO,
144+
LORA_MOSI = SPI1_MOSI,
145+
LORA_SCK = SPI1_SCK,
146+
LORA_NSS = SPI1_SS,
147+
148+
LORA_RESET = P0_20,
149+
LORA_BUSY = P0_21,
150+
LORA_DIO1 = P0_22,
151+
152+
RF_SW_CTRL = P0_18, // RF switch, active high
153+
// ----- End of xDot dedicated internal pins. -----
154+
155+
// ----- Start of aliases for MAX32670 serial_api.c -----
156+
// The xDot does not use these serial UARTs or the serial_api
157+
// code. These pins are used on the xDot as detailed above.
158+
UART0B_RX = P0_24,
159+
UART0B_TX = P0_25,
160+
161+
UART1B_RX = P0_2,
162+
UART1B_TX = P0_3,
163+
164+
UART2B_RX = P0_14,
165+
UART2B_TX = P0_15,
166+
// ----- end of aliases for MAX32670 serial_api.c -----
167+
168+
// Not connected
169+
NC = NOT_CONNECTED
170+
} PinName;
171+
172+
typedef enum {
173+
PullNone = 0,
174+
PullUp = 1,
175+
PullDown = 2,
176+
PullDefault = PullUp
177+
} PinMode;
178+
179+
typedef enum {
180+
LED_ON = 0,
181+
LED_OFF = 1
182+
} LedStates;
183+
184+
#ifdef __cplusplus
185+
}
186+
#endif
187+
188+
#endif
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#include <string.h>
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include "max32670.h"
5+
#include "gcr_regs.h"
6+
#include "mxc_sys.h"
7+
#include "pwrseq_regs.h"
8+
9+
#define XDOT_ERFO_FREQ 24000000 // Change to 24000000 for xDot 1.5 Rev A
10+
11+
void SystemCoreClockUpdateXdot(void)
12+
{
13+
uint32_t base_freq, div, clk_src;
14+
15+
// Get the clock source and frequency
16+
clk_src = (MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_SYSCLK_SEL);
17+
switch (clk_src)
18+
{
19+
case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_EXTCLK:
20+
base_freq = EXTCLK_FREQ;
21+
break;
22+
case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_ERFO:
23+
base_freq = XDOT_ERFO_FREQ;
24+
break;
25+
case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_INRO:
26+
base_freq = INRO_FREQ;
27+
break;
28+
case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_IPO:
29+
base_freq = IPO_FREQ;
30+
break;
31+
case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_IBRO:
32+
base_freq = IBRO_FREQ;
33+
break;
34+
case MXC_S_GCR_CLKCTRL_SYSCLK_SEL_ERTCO:
35+
base_freq = ERTCO_FREQ;
36+
break;
37+
default:
38+
// Codes 001 and 111 are reserved.
39+
// This code should never execute, however, initialize to safe value.
40+
base_freq = HIRC_FREQ;
41+
break;
42+
}
43+
// Get the clock divider
44+
if (clk_src == MXC_S_GCR_CLKCTRL_SYSCLK_SEL_IPO)
45+
{
46+
base_freq = base_freq >> ((MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_IPO_DIV)>> MXC_F_GCR_CLKCTRL_IPO_DIV_POS);
47+
}
48+
div = (MXC_GCR->clkctrl & MXC_F_GCR_CLKCTRL_SYSCLK_DIV) >> MXC_F_GCR_CLKCTRL_SYSCLK_DIV_POS;
49+
50+
SystemCoreClock = base_freq >> div;
51+
52+
// base_freq1 = base_freq;
53+
// div1 = div;
54+
// sys_core_clk1 = SystemCoreClock;
55+
// tries = 25;
56+
57+
}
58+
59+
int PreInit(void)
60+
{
61+
return 0;
62+
}
63+
64+
void SystemInit(void)
65+
{
66+
/* Make sure interrupts are enabled. */
67+
__enable_irq();
68+
69+
#if (__FPU_PRESENT == 1)
70+
/* Enable FPU on Cortex-M4, which occupies coprocessor slots 10 & 11 */
71+
/* Grant full access, per "Table B3-24 CPACR bit assignments". */
72+
/* DDI0403D "ARMv7-M Architecture Reference Manual" */
73+
SCB->CPACR |= SCB_CPACR_CP10_Msk | SCB_CPACR_CP11_Msk;
74+
__DSB();
75+
__ISB();
76+
#endif
77+
78+
MXC_PWRSEQ->lpcn &= ~(1 << 31); // Ensure ERTCO is on
79+
80+
MXC_SYS_Clock_Select(MXC_SYS_CLOCK_IPO);
81+
SystemCoreClockUpdateXdot();
82+
83+
// Increase drive strength of I2C_SE bus and Mem Pwr En.
84+
// Note: Mem Pwr En doesn't help, higher drive strength on se i2c pins seems to though
85+
MXC_GPIO0->ds0 |= (1 << 6) | (1 << 7) | (1 << 24);
86+
MXC_GPIO0->ds1 |= (1 << 6) | (1 << 7) | (1 << 24);
87+
88+
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO0);
89+
MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO1);
90+
}

targets/targets.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4022,6 +4022,16 @@
40224022
"0350"
40234023
]
40244024
},
4025+
"XDOT_MAX32670": {
4026+
"inherits": [
4027+
"MAX32670"
4028+
],
4029+
"device_name": "MAX32670",
4030+
"bootloader_supported": true,
4031+
"detect_code": [
4032+
"0351"
4033+
]
4034+
},
40254035
"FF1705_L151CC": {
40264036
"inherits": [
40274037
"XDOT_L151CC"

0 commit comments

Comments
 (0)