Skip to content

Commit 52ff62e

Browse files
committed
Add STM32C011D6 support.
1 parent c6bc5b2 commit 52ff62e

File tree

5 files changed

+318
-0
lines changed

5 files changed

+318
-0
lines changed

Diff for: boards.txt

+8
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,14 @@ GenC0.build.flash_offset=0x0
12071207
GenC0.upload.maximum_size=0
12081208
GenC0.upload.maximum_data_size=0
12091209

1210+
# Generic C011D6YX
1211+
GenC0.menu.pnum.GENERIC_C011D6YX=Generic C011D6Yx
1212+
GenC0.menu.pnum.GENERIC_C011D6YX.upload.maximum_size=32768
1213+
GenC0.menu.pnum.GENERIC_C011D6YX.upload.maximum_data_size=6144
1214+
GenC0.menu.pnum.GENERIC_C011D6YX.build.board=GENERIC_C011D6YX
1215+
GenC0.menu.pnum.GENERIC_C011D6YX.build.product_line=STM32C011xx
1216+
GenC0.menu.pnum.GENERIC_C011D6YX.build.variant=STM32C0xx/C011D6Y_C011F(4-6)(P-U)_C031F(4-6)P
1217+
12101218
# Generic C031C4Tx
12111219
GenC0.menu.pnum.GENERIC_C031C4TX=Generic C031C4Tx
12121220
GenC0.menu.pnum.GENERIC_C031C4TX.upload.maximum_size=16384

Diff for: cmake/boards_db.cmake

+86
Original file line numberDiff line numberDiff line change
@@ -6766,6 +6766,92 @@ target_compile_options(GENERIC_C031C6UX_serial_none INTERFACE
67666766
"SHELL:-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE"
67676767
)
67686768

6769+
# GENERIC_C011D6YX
6770+
# -----------------------------------------------------------------------------
6771+
6772+
set(GENERIC_C011D6YX_VARIANT_PATH "${CMAKE_CURRENT_LIST_DIR}/../variants/STM32C0xx/C011D6Y_C011F(4-6)(P-U)_C031F(4-6)P")
6773+
set(GENERIC_C011D6YX_MAXSIZE 32768)
6774+
set(GENERIC_C011D6YX_MAXDATASIZE 12288)
6775+
set(GENERIC_C011D6YX_MCU cortex-m0plus)
6776+
set(GENERIC_C011D6YX_FPCONF "-")
6777+
add_library(GENERIC_C011D6YX INTERFACE)
6778+
target_compile_options(GENERIC_C011D6YX INTERFACE
6779+
"SHELL:"
6780+
"SHELL:"
6781+
"SHELL:"
6782+
"SHELL: "
6783+
-mcpu=${GENERIC_C011D6YX_MCU}
6784+
)
6785+
target_compile_definitions(GENERIC_C011D6YX INTERFACE
6786+
"STM32C0xx"
6787+
"ARDUINO_GENERIC_C011D6YX"
6788+
"BOARD_NAME=\"GENERIC_C011D6YX\""
6789+
"BOARD_ID=GENERIC_C011D6YX"
6790+
"VARIANT_H=\"variant_generic.h\""
6791+
)
6792+
target_include_directories(GENERIC_C011D6YX INTERFACE
6793+
${CMAKE_CURRENT_LIST_DIR}/../system/STM32C0xx
6794+
${CMAKE_CURRENT_LIST_DIR}/../system/Drivers/STM32C0xx_HAL_Driver/Inc
6795+
${CMAKE_CURRENT_LIST_DIR}/../system/Drivers/STM32C0xx_HAL_Driver/Src
6796+
${CMAKE_CURRENT_LIST_DIR}/../system/Drivers/CMSIS/Device/ST/STM32C0xx/Include/
6797+
${CMAKE_CURRENT_LIST_DIR}/../system/Drivers/CMSIS/Device/ST/STM32C0xx/Source/Templates/gcc/
6798+
${GENERIC_C011D6YX_VARIANT_PATH}
6799+
)
6800+
6801+
target_link_options(GENERIC_C011D6YX INTERFACE
6802+
"LINKER:--default-script=${GENERIC_C011D6YX_VARIANT_PATH}/ldscript.ld"
6803+
"LINKER:--defsym=LD_FLASH_OFFSET=0"
6804+
"LINKER:--defsym=LD_MAX_SIZE=32768"
6805+
"LINKER:--defsym=LD_MAX_DATA_SIZE=12288"
6806+
"SHELL: "
6807+
-mcpu=${GENERIC_C011D6YX_MCU}
6808+
)
6809+
target_link_libraries(GENERIC_C011D6YX INTERFACE
6810+
arm_cortexM0l_math
6811+
)
6812+
6813+
add_library(GENERIC_C011D6YX_serial_disabled INTERFACE)
6814+
target_compile_options(GENERIC_C011D6YX_serial_disabled INTERFACE
6815+
"SHELL:"
6816+
)
6817+
add_library(GENERIC_C011D6YX_serial_generic INTERFACE)
6818+
target_compile_options(GENERIC_C011D6YX_serial_generic INTERFACE
6819+
"SHELL:-DHAL_UART_MODULE_ENABLED"
6820+
)
6821+
add_library(GENERIC_C011D6YX_serial_none INTERFACE)
6822+
target_compile_options(GENERIC_C011D6YX_serial_none INTERFACE
6823+
"SHELL:-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE"
6824+
)
6825+
# TODO: use following inspiration from other board?
6826+
# add_library(NUCLEO_C031C6_usb_CDC INTERFACE)
6827+
# target_compile_options(NUCLEO_C031C6_usb_CDC INTERFACE
6828+
# "SHELL:-DUSBCON -DUSBD_VID=0 -DUSBD_PID=0 -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC -DDISABLE_GENERIC_SERIALUSB"
6829+
# )
6830+
# add_library(NUCLEO_C031C6_usb_CDCgen INTERFACE)
6831+
# target_compile_options(NUCLEO_C031C6_usb_CDCgen INTERFACE
6832+
# "SHELL:-DUSBCON -DUSBD_VID=0 -DUSBD_PID=0 -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_CDC"
6833+
# )
6834+
# add_library(NUCLEO_C031C6_usb_HID INTERFACE)
6835+
# target_compile_options(NUCLEO_C031C6_usb_HID INTERFACE
6836+
# "SHELL:-DUSBCON -DUSBD_VID=0 -DUSBD_PID=0 -DHAL_PCD_MODULE_ENABLED -DUSBD_USE_HID_COMPOSITE"
6837+
# )
6838+
# add_library(NUCLEO_C031C6_usb_none INTERFACE)
6839+
# target_compile_options(NUCLEO_C031C6_usb_none INTERFACE
6840+
# "SHELL:"
6841+
# )
6842+
# add_library(NUCLEO_C031C6_xusb_FS INTERFACE)
6843+
# target_compile_options(NUCLEO_C031C6_xusb_FS INTERFACE
6844+
# "SHELL:"
6845+
# )
6846+
# add_library(NUCLEO_C031C6_xusb_HS INTERFACE)
6847+
# target_compile_options(NUCLEO_C031C6_xusb_HS INTERFACE
6848+
# "SHELL:-DUSE_USB_HS"
6849+
# )
6850+
# add_library(NUCLEO_C031C6_xusb_HSFS INTERFACE)
6851+
# target_compile_options(NUCLEO_C031C6_xusb_HSFS INTERFACE
6852+
# "SHELL:-DUSE_USB_HS -DUSE_USB_HS_IN_FS"
6853+
# )
6854+
67696855
# GENERIC_F030C6TX
67706856
# -----------------------------------------------------------------------------
67716857

Diff for: variants/STM32C0xx/C011D6Y_C011F(4-6)(P-U)_C031F(4-6)P/boards_entry.txt

+6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
# See: https://github.com/stm32duino/Arduino_Core_STM32/wiki/Add-a-new-variant-%28board%29
55

66
# Generic C011D6Yx
7+
78
GenC0.menu.pnum.GENERIC_C011D6YX=Generic C011D6Yx
9+
GenC0.menu.pnum.GENERIC_C011D6YX.node="No_mass_storage_for_this_board_Use_STLink_upload_method"
810
GenC0.menu.pnum.GENERIC_C011D6YX.upload.maximum_size=32768
911
GenC0.menu.pnum.GENERIC_C011D6YX.upload.maximum_data_size=6144
12+
GenC0.menu.pnum.GENERIC_C011D6YX.build.mcu=cortex-m0plus
1013
GenC0.menu.pnum.GENERIC_C011D6YX.build.board=GENERIC_C011D6YX
14+
GenC0.menu.pnum.GENERIC_C011D6YX.build.series=STM32C0xx
1115
GenC0.menu.pnum.GENERIC_C011D6YX.build.product_line=STM32C011xx
1216
GenC0.menu.pnum.GENERIC_C011D6YX.build.variant=STM32C0xx/C011D6Y_C011F(4-6)(P-U)_C031F(4-6)P
17+
GenC0.menu.pnum.GENERIC_C011D6YX.build.cmsis_lib_gcc=arm_cortexM0l_math
18+
GenC0.menu.pnum.GENERIC_C011D6YX.build.extra_flags=-D{build.product_line} {build.xSerial} -D__CORTEX_SC=0
1319

1420
# Generic C011F4Px
1521
GenC0.menu.pnum.GENERIC_C011F4PX=Generic C011F4Px
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/**
2+
******************************************************************************
3+
* @file LinkerScript.ld
4+
* @author Modified from auto-generated file
5+
* Abstract : Linker script for STM32C011D6Yx Device from stm32c0 series
6+
* 32Kbytes FLASH
7+
* 6Kbytes RAM
8+
*
9+
* Set heap size, stack size and stack location according
10+
* to application requirements.
11+
*
12+
* Set memory bank area and size if external memory is used
13+
******************************************************************************
14+
* @attention
15+
*
16+
* This software is licensed under terms that can be found in the LICENSE file
17+
* in the root directory of this software component.
18+
* If no LICENSE file comes with this software, it is provided AS-IS.
19+
*
20+
******************************************************************************
21+
*/
22+
23+
/* Entry Point */
24+
ENTRY(Reset_Handler)
25+
26+
/* Highest address of the user mode stack */
27+
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
28+
29+
_Min_Heap_Size = 0x200; /* required amount of heap */
30+
_Min_Stack_Size = 0x400; /* required amount of stack */
31+
32+
/* Memories definition */
33+
MEMORY
34+
{
35+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
36+
FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
37+
}
38+
39+
/* Sections */
40+
SECTIONS
41+
{
42+
/* The startup code into "FLASH" Rom type memory */
43+
.isr_vector :
44+
{
45+
. = ALIGN(4);
46+
KEEP(*(.isr_vector)) /* Startup code */
47+
. = ALIGN(4);
48+
} >FLASH
49+
50+
/* The program code and other data into "FLASH" Rom type memory */
51+
.text :
52+
{
53+
. = ALIGN(4);
54+
*(.text) /* .text sections (code) */
55+
*(.text*) /* .text* sections (code) */
56+
*(.glue_7) /* glue arm to thumb code */
57+
*(.glue_7t) /* glue thumb to arm code */
58+
*(.eh_frame)
59+
60+
KEEP (*(.init))
61+
KEEP (*(.fini))
62+
63+
. = ALIGN(4);
64+
_etext = .; /* define a global symbols at end of code */
65+
} >FLASH
66+
67+
/* Constant data into "FLASH" Rom type memory */
68+
.rodata :
69+
{
70+
. = ALIGN(4);
71+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
72+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
73+
. = ALIGN(4);
74+
} >FLASH
75+
76+
.ARM.extab : {
77+
. = ALIGN(4);
78+
*(.ARM.extab* .gnu.linkonce.armextab.*)
79+
. = ALIGN(4);
80+
} >FLASH
81+
82+
.ARM : {
83+
. = ALIGN(4);
84+
__exidx_start = .;
85+
*(.ARM.exidx*)
86+
__exidx_end = .;
87+
. = ALIGN(4);
88+
} >FLASH
89+
90+
.preinit_array :
91+
{
92+
. = ALIGN(4);
93+
PROVIDE_HIDDEN (__preinit_array_start = .);
94+
KEEP (*(.preinit_array*))
95+
PROVIDE_HIDDEN (__preinit_array_end = .);
96+
. = ALIGN(4);
97+
} >FLASH
98+
99+
.init_array :
100+
{
101+
. = ALIGN(4);
102+
PROVIDE_HIDDEN (__init_array_start = .);
103+
KEEP (*(SORT(.init_array.*)))
104+
KEEP (*(.init_array*))
105+
PROVIDE_HIDDEN (__init_array_end = .);
106+
. = ALIGN(4);
107+
} >FLASH
108+
109+
.fini_array :
110+
{
111+
. = ALIGN(4);
112+
PROVIDE_HIDDEN (__fini_array_start = .);
113+
KEEP (*(SORT(.fini_array.*)))
114+
KEEP (*(.fini_array*))
115+
PROVIDE_HIDDEN (__fini_array_end = .);
116+
. = ALIGN(4);
117+
} >FLASH
118+
119+
/* Used by the startup to initialize data */
120+
_sidata = LOADADDR(.data);
121+
122+
/* Initialized data sections into "RAM" Ram type memory */
123+
.data :
124+
{
125+
. = ALIGN(4);
126+
_sdata = .; /* create a global symbol at data start */
127+
*(.data) /* .data sections */
128+
*(.data*) /* .data* sections */
129+
*(.RamFunc) /* .RamFunc sections */
130+
*(.RamFunc*) /* .RamFunc* sections */
131+
132+
. = ALIGN(4);
133+
_edata = .; /* define a global symbol at data end */
134+
135+
} >RAM AT> FLASH
136+
137+
/* Uninitialized data section into "RAM" Ram type memory */
138+
. = ALIGN(4);
139+
.bss :
140+
{
141+
/* This is used by the startup in order to initialize the .bss section */
142+
_sbss = .; /* define a global symbol at bss start */
143+
__bss_start__ = _sbss;
144+
*(.bss)
145+
*(.bss*)
146+
*(COMMON)
147+
148+
. = ALIGN(4);
149+
_ebss = .; /* define a global symbol at bss end */
150+
__bss_end__ = _ebss;
151+
} >RAM
152+
153+
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
154+
._user_heap_stack :
155+
{
156+
. = ALIGN(8);
157+
PROVIDE ( end = . );
158+
PROVIDE ( _end = . );
159+
. = . + _Min_Heap_Size;
160+
. = . + _Min_Stack_Size;
161+
. = ALIGN(8);
162+
} >RAM
163+
164+
/* Remove information from the compiler libraries */
165+
/DISCARD/ :
166+
{
167+
libc.a ( * )
168+
libm.a ( * )
169+
libgcc.a ( * )
170+
}
171+
172+
.ARM.attributes 0 : { *(.ARM.attributes) }
173+
}

Diff for: variants/STM32C0xx/C011D6Y_C011F(4-6)(P-U)_C031F(4-6)P/variant_generic.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
defined(ARDUINO_GENERIC_C011F6UX) || defined(ARDUINO_GENERIC_C031F4PX) ||\
1616
defined(ARDUINO_GENERIC_C031F6PX)
1717
#include "pins_arduino.h"
18+
#include "stm32yyxx_ll_utils.h"
1819

1920
// Digital PinName array
2021
const PinName digitalPin[] = {
@@ -57,4 +58,48 @@ const uint32_t analogInputPin[] = {
5758
12 // A12, PA14
5859
};
5960

61+
// ----------------------------------------------------------------------------
62+
#ifdef __cplusplus
63+
extern "C" {
64+
#endif
65+
66+
/**
67+
* @brief System Clock Configuration
68+
* @param None
69+
* @retval None
70+
*/
71+
// Removed the "WEAK" symbol as some of the following settings were overwritten
72+
void SystemClock_Config(void)
73+
{
74+
LL_FLASH_SetLatency(LL_FLASH_LATENCY_1);
75+
76+
/* HSI configuration and activation */
77+
LL_RCC_HSI_Enable();
78+
while (LL_RCC_HSI_IsReady() != 1) {
79+
}
80+
81+
LL_RCC_HSI_SetCalibTrimming(64);
82+
LL_RCC_SetHSIDiv(LL_RCC_HSI_DIV_1);
83+
/* Set AHB prescaler*/
84+
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
85+
86+
/* Sysclk activation on the HSI */
87+
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
88+
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) {
89+
}
90+
91+
/* Set APB1 prescaler*/
92+
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
93+
/* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */
94+
LL_SetSystemCoreClock(48000000);
95+
96+
/* Update the time base */
97+
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) {
98+
Error_Handler();
99+
}
100+
}
101+
102+
#ifdef __cplusplus
103+
}
104+
#endif
60105
#endif /* ARDUINO_GENERIC_* */

0 commit comments

Comments
 (0)