Skip to content

Commit 4414beb

Browse files
ABOSTMfpistm
authored andcommitted
variant(C0): Add Nucleo C031C6 support
Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 1650f3a commit 4414beb

File tree

4 files changed

+313
-0
lines changed

4 files changed

+313
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
106106

107107
| Status | Device(s) | Name | Release | Notes |
108108
| :----: | :-------: | ---- | :-----: | :---- |
109+
| :yellow_heart: | STM32C031C6 | [Nucleo C031C6](https://www.st.com/en/evaluation-tools/nucleo-c031c6.html) | **2.5.0** | |
109110
| :green_heart: | STM32F030R8 | [Nucleo F030R8](http://www.st.com/en/evaluation-tools/nucleo-f030r8.html) | *0.2.0* | |
110111
| :green_heart: | STM32F070RB | [Nucleo F070RB](http://www.st.com/en/evaluation-tools/nucleo-f070rb.html) | *2.0.0* | |
111112
| :green_heart: | STM32F072RB | [Nucleo F072RB](http://www.st.com/en/evaluation-tools/nucleo-f072rb.html) | *1.9.0* | |

Diff for: boards.txt

+13
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,19 @@ Nucleo_64.build.st_extra_flags=-D{build.product_line} {build.enable_usb} {build.
282282
Nucleo_64.upload.maximum_size=0
283283
Nucleo_64.upload.maximum_data_size=0
284284

285+
# NUCLEO_C031C6 board
286+
Nucleo_64.menu.pnum.NUCLEO_C031C6=Nucleo C031C6
287+
Nucleo_64.menu.pnum.NUCLEO_C031C6.node="NOD_C031C6"
288+
Nucleo_64.menu.pnum.NUCLEO_C031C6.upload.maximum_size=32768
289+
Nucleo_64.menu.pnum.NUCLEO_C031C6.upload.maximum_data_size=12288
290+
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.mcu=cortex-m0plus
291+
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.board=NUCLEO_C031C6
292+
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.series=STM32C0xx
293+
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.product_line=STM32C031xx
294+
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.variant=STM32C0xx/C031C(4-6)(T-U)
295+
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.cmsis_lib_gcc=arm_cortexM0l_math
296+
Nucleo_64.menu.pnum.NUCLEO_C031C6.build.extra_flags=-D{build.product_line} {build.xSerial} -D__CORTEX_SC=0
297+
285298
# NUCLEO_F030R8 board
286299
Nucleo_64.menu.pnum.NUCLEO_F030R8=Nucleo F030R8
287300
Nucleo_64.menu.pnum.NUCLEO_F030R8.node="NODE_F030R8,NUCLEO"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
13+
#if defined(ARDUINO_NUCLEO_C031C6)
14+
#include "pins_arduino.h"
15+
#include "stm32yyxx_ll_utils.h"
16+
17+
// Digital PinName array
18+
const PinName digitalPin[] = {
19+
// CN9
20+
PB_7, // D0
21+
PB_6, // D1
22+
PA_10, // D2
23+
PB_3, // D3
24+
PB_10, // D4
25+
PB_4, // D5
26+
PB_5, // D6
27+
PA_15, // D7
28+
29+
// CN5
30+
PA_9, // D8
31+
PC_7, // D9
32+
PB_0, // D10
33+
PA_7, // D11
34+
PA_6, // D12
35+
PA_5, // D13 // LED
36+
PB_9, // D14
37+
PB_8, // D15
38+
39+
// CN7 Left Side
40+
PD_0, // D16
41+
PD_2, // D17
42+
PA_14, // D18
43+
PA_13, // D19
44+
PC_6, // D20
45+
PC_13, // D21 // Button
46+
PC_14, // D22 // OSCX_IN
47+
PF_0, // D23 // OSC_IN
48+
PF_1, // D24 // OSC_OUT
49+
PB_11, // D25
50+
PA_2, // D26 // VCP_TX
51+
52+
// CN7 Right Side
53+
PD_1, // D27
54+
55+
// CN10 Left Side
56+
PD_3, // D28
57+
PC_11, // D29
58+
59+
// CN8 Left Side
60+
PA_0, // D30
61+
PA_1, // D31
62+
PA_4, // D32
63+
PB_1, // D33
64+
PA_11, // D34
65+
PA_12, // D35
66+
67+
// CN10 Right Side
68+
PA_3, // D36 // VCP_RX
69+
PC_15, // D37 // OSCX_OUT
70+
PB_12, // D38
71+
PB_2, // D39
72+
PF_3, // D40
73+
PA_8, // D41
74+
PB_15, // D42
75+
PB_14, // D43
76+
PB_13, // D44
77+
78+
// Others
79+
PF_2 // D45 // NRST
80+
};
81+
82+
// Analog (Ax) pin number array
83+
const uint32_t analogInputPin[] = {
84+
30, // A0
85+
31, // A1
86+
32, // A2
87+
33, // A3
88+
34, // A4
89+
35, // A5
90+
26, // A6
91+
36, // A7
92+
13, // A8
93+
12, // A9
94+
11, // A10
95+
41, // A11
96+
19, // A12
97+
18, // A13
98+
10, // A14
99+
39, // A15
100+
4, // A16
101+
25, // A17
102+
38 // A18
103+
};
104+
105+
// ----------------------------------------------------------------------------
106+
#ifdef __cplusplus
107+
extern "C" {
108+
#endif
109+
110+
/**
111+
* @brief System Clock Configuration
112+
* @param None
113+
* @retval None
114+
*/
115+
WEAK void SystemClock_Config(void)
116+
{
117+
LL_FLASH_SetLatency(LL_FLASH_LATENCY_1);
118+
119+
/* HSE configuration and activation */
120+
LL_RCC_HSE_Enable();
121+
while (LL_RCC_HSE_IsReady() != 1) {
122+
}
123+
124+
/* Set AHB prescaler*/
125+
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
126+
127+
/* Sysclk activation on the HSE */
128+
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSE);
129+
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSE) {
130+
}
131+
132+
/* Set APB1 prescaler*/
133+
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
134+
/* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */
135+
LL_SetSystemCoreClock(48000000);
136+
137+
/* Update the time base */
138+
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) {
139+
Error_Handler();
140+
}
141+
}
142+
143+
#ifdef __cplusplus
144+
}
145+
#endif
146+
#endif /* ARDUINO_NUCLEO_C031C6 */
+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2022, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
13+
#pragma once
14+
15+
/*----------------------------------------------------------------------------
16+
* STM32 pins number
17+
*----------------------------------------------------------------------------*/
18+
19+
// CN9
20+
#define PB7 0
21+
#define PB6 1
22+
#define PA10 2
23+
#define PB3 3
24+
#define PB10 PIN_A16
25+
#define PB4 5
26+
#define PB5 6
27+
#define PA15 7
28+
29+
// CN5
30+
#define PA9 8
31+
#define PC7 9
32+
#define PB0 PIN_A14
33+
#define PA7 PIN_A10
34+
#define PA6 PIN_A9
35+
#define PA5 PIN_A8 // LED
36+
#define PB9 14
37+
#define PB8 15
38+
39+
// CN7 Left Side
40+
#define PD0 16
41+
#define PD2 17
42+
#define PA14 PIN_A13
43+
#define PA13 PIN_A12
44+
#define PC6 20
45+
#define PC13 21 // Button
46+
#define PC14 22 // OSCX_IN
47+
#define PF0 23 // OSC_IN
48+
#define PF1 24 // OSC_OUT
49+
#define PB11 PIN_A17
50+
#define PA2 PIN_A6 // VCP_TX
51+
52+
// CN7 Right Side
53+
#define PD1 27
54+
55+
// CN10 Left Side
56+
#define PD3 28
57+
#define PC11 29
58+
59+
// CN8 Left Side
60+
#define PA0 PIN_A0
61+
#define PA1 PIN_A1
62+
#define PA4 PIN_A2
63+
#define PB1 PIN_A3
64+
#define PA11 PIN_A4
65+
#define PA12 PIN_A5
66+
67+
// CN10 Right side
68+
#define PA3 PIN_A7 // VCP_RX
69+
#define PC15 37 // OSCX_OUT
70+
#define PB12 PIN_A18
71+
#define PB2 PIN_A15
72+
#define PF3 40
73+
#define PA8 PIN_A11
74+
#define PB15 42
75+
#define PB14 43
76+
#define PB13 44
77+
78+
// Others
79+
#define PF2 45 // NRST
80+
81+
82+
#define NUM_DIGITAL_PINS 46
83+
#define NUM_ANALOG_INPUTS 19
84+
85+
// On-board LED pin number
86+
#define LED_GREEN PA5
87+
#ifndef LED_BUILTIN
88+
#define LED_BUILTIN LED_GREEN
89+
#endif
90+
91+
// On-board user button
92+
#ifndef USER_BTN
93+
#define USER_BTN PC13
94+
#endif
95+
96+
// I2C Definitions
97+
#ifndef PIN_WIRE_SDA
98+
#define PIN_WIRE_SDA PB9
99+
#endif
100+
#ifndef PIN_WIRE_SCL
101+
#define PIN_WIRE_SCL PB8
102+
#endif
103+
104+
// Timer Definitions
105+
#ifndef TIMER_TONE
106+
#define TIMER_TONE TIM16
107+
#endif
108+
#ifndef TIMER_SERVO
109+
#define TIMER_SERVO TIM17
110+
#endif
111+
112+
// UART Definitions
113+
#ifndef SERIAL_UART_INSTANCE
114+
#define SERIAL_UART_INSTANCE 2
115+
#endif
116+
117+
// Default pin used for generic 'Serial' instance
118+
// Mandatory for Firmata
119+
#ifndef PIN_SERIAL_RX
120+
#define PIN_SERIAL_RX PA3
121+
#endif
122+
#ifndef PIN_SERIAL_TX
123+
#define PIN_SERIAL_TX PA2
124+
#endif
125+
126+
127+
/*----------------------------------------------------------------------------
128+
* Arduino objects - C++ only
129+
*----------------------------------------------------------------------------*/
130+
131+
#ifdef __cplusplus
132+
// These serial port names are intended to allow libraries and architecture-neutral
133+
// sketches to automatically default to the correct port name for a particular type
134+
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
135+
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
136+
//
137+
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
138+
//
139+
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
140+
//
141+
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
142+
//
143+
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
144+
//
145+
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
146+
// pins are NOT connected to anything by default.
147+
#ifndef SERIAL_PORT_MONITOR
148+
#define SERIAL_PORT_MONITOR Serial
149+
#endif
150+
#ifndef SERIAL_PORT_HARDWARE
151+
#define SERIAL_PORT_HARDWARE Serial
152+
#endif
153+
#endif

0 commit comments

Comments
 (0)