Skip to content

Commit e3ee532

Browse files
MyGh64605Michael Sherwood
authored andcommitted
soc: microchip: pic32cxsg Addition of pic32cxsg
Addition of pic32cxsg current family of devices Signed-off-by: Michael D Sherwood <[email protected]>
1 parent 08ac1ac commit e3ee532

28 files changed

+2380
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Makefile - Microchip PIC32CXSG MCU family
2+
#
3+
# Copyright (c) 2024 Microchip
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
zephyr_include_directories(${ZEPHYR_BASE}/drivers)
7+
8+
add_subdirectory(common)
9+
add_subdirectory(${SOC_SERIES})

soc/microchip/pic32cxsg/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Microchip PIC32CXSG MCU family configuration options
2+
# Copyright (c) 2024 Microchip
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
config SOC_FAMILY_MICROCHIP_PIC32CXSG
6+
select PIC32C
7+
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE
8+
9+
if SOC_FAMILY_MICROCHIP_PIC32CXSG
10+
11+
rsource "common/Kconfig.pic32cxsg"
12+
rsource "*/Kconfig"
13+
14+
endif # SOC_FAMILY_MICROCHIP_PIC32CXSG
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Microchip PIC32CXSG MCU family default configuration options
2+
3+
# Copyright (c) 2024 Microchip
4+
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
if SOC_FAMILY_MICROCHIP_PIC32CXSG
8+
9+
rsource "*/Kconfig.defconfig"
10+
11+
config GPIO
12+
default y
13+
14+
config HWINFO_PIC32CXSG
15+
default HWINFO
16+
config SYS_CLOCK_HW_CYCLES_PER_SEC
17+
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)
18+
19+
if USB_DEVICE_DRIVER
20+
21+
config HEAP_MEM_POOL_ADD_SIZE_SOC
22+
def_int 1024
23+
24+
endif # USB_DEVICE_DRIVER
25+
26+
endif # SOC_FAMILY_MICROCHIP_PIC32CXSG

soc/microchip/pic32cxsg/Kconfig.soc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2024 Microchip
2+
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
config SOC_FAMILY_MICROCHIP_PIC32CXSG
6+
bool
7+
8+
config SOC_FAMILY
9+
default "microchip_pic32cxsg" if SOC_FAMILY_MICROCHIP_PIC32CXSG
10+
11+
config SOC_SERIES_REVISION_N
12+
bool
13+
depends on SOC_FAMILY_MICROCHIP_PIC32CXSG
14+
15+
config SOC_SERIES_REVISION
16+
string
17+
default "n" if SOC_SERIES_REVISION_N
18+
default ""
19+
depends on SOC_FAMILY_MICROCHIP_PIC32CXSG
20+
21+
rsource "*/Kconfig.soc"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Makefile - Microchip PIC32CXSG MCU family
2+
#
3+
# Copyright (c) 2024 Microchip
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
zephyr_sources(soc_port.c)
7+
8+
zephyr_sources_ifdef(CONFIG_BOOTLOADER_BOSSA bossa.c)
9+
10+
zephyr_sources_ifdef(CONFIG_SOC_SERIES_PIC32CXSG41 soc_pic32cxsg.c)
11+
zephyr_sources_ifdef(CONFIG_SOC_SERIES_PIC32CXSG60 soc_pic32cxsg.c)
12+
zephyr_sources_ifdef(CONFIG_SOC_SERIES_PIC32CXSG61 soc_pic32cxsg.c)
13+
14+
zephyr_include_directories(.)
15+
16+
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright (c) 2024 Microchip
2+
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
if SOC_SERIES_PIC32CXSG41 || SOC_SERIES_PIC32CXSG60 || SOC_SERIES_PIC32CXSG61
6+
7+
config SOC_MICROCHIP_PIC32CXSG_XOSC32K
8+
bool "The external 32 kHz crystal oscillator"
9+
help
10+
Say y to enable the external 32 kHZ crystal oscillator at
11+
startup. This can then be selected as the main clock source
12+
for the SOC.
13+
14+
choice
15+
prompt "Main clock source"
16+
default SOC_MICROCHIP_PIC32CXSG_DEFAULT_AS_MAIN
17+
help
18+
Selects the clock that the main clocks, such as the CPU
19+
clock and AHB clock, will be derived from.
20+
21+
config SOC_MICROCHIP_PIC32CXSG_DEFAULT_AS_MAIN
22+
bool "DEFAULT"
23+
help
24+
This choice will leave all clocks to their current state.
25+
This can be the default reset state or a state set by a bootloader.
26+
27+
config SOC_MICROCHIP_PIC32CXSG_XOSC32K_AS_MAIN
28+
depends on SOC_MICROCHIP_PIC32CXSG_XOSC32K
29+
bool "XOSC32K"
30+
31+
config SOC_MICROCHIP_PIC32CXSG_OSCULP32K_AS_MAIN
32+
bool "OSCULP32K"
33+
34+
endchoice
35+
36+
endif
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2020 Google LLC.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <soc.h>
8+
#include <zephyr/drivers/uart/cdc_acm.h>
9+
#include <zephyr/drivers/usb/usb_dc.h>
10+
#include <zephyr/init.h>
11+
#include <zephyr/usb/class/usb_cdc.h>
12+
13+
/*
14+
* Magic value that causes the bootloader to stay in bootloader mode instead of
15+
* starting the application.
16+
*/
17+
#if CONFIG_BOOTLOADER_BOSSA_ADAFRUIT_UF2
18+
#define DOUBLE_TAP_MAGIC 0xf01669ef
19+
#elif CONFIG_BOOTLOADER_BOSSA_ARDUINO
20+
#define DOUBLE_TAP_MAGIC 0x07738135
21+
#else
22+
#error Unsupported BOSSA bootloader variant
23+
#endif
24+
25+
#if defined(CONFIG_BOOTLOADER_BOSSA_DEVICE_NAME)
26+
27+
static void bossa_reset(const struct device *dev, uint32_t rate)
28+
{
29+
uint32_t *top;
30+
31+
if (rate != 1200) {
32+
return;
33+
}
34+
35+
/* The programmer set the baud rate to 1200 baud. Reset into the
36+
* bootloader.
37+
*/
38+
usb_dc_detach();
39+
40+
top = (uint32_t *)(DT_REG_ADDR(DT_NODELABEL(sram0)) +
41+
DT_REG_SIZE(DT_NODELABEL(sram0)));
42+
top[-1] = DOUBLE_TAP_MAGIC;
43+
44+
NVIC_SystemReset();
45+
}
46+
47+
static int bossa_init(void)
48+
{
49+
const struct device *dev =
50+
device_get_binding(CONFIG_BOOTLOADER_BOSSA_DEVICE_NAME);
51+
52+
if (dev == NULL) {
53+
return -ENODEV;
54+
}
55+
56+
return cdc_acm_dte_rate_callback_set(dev, bossa_reset);
57+
}
58+
59+
SYS_INIT(bossa_init, APPLICATION, 0);
60+
61+
#endif /* CONFIG_BOOTLOADER_BOSSA_DEVICE_NAME */

0 commit comments

Comments
 (0)