Skip to content

Commit 5555460

Browse files
ABOSTMfpistm
authored andcommitted
variant(C0): Add support of Disco board STM32C0316-DK
Note: SystemClock_Config() is based on LL API to spare Flash memory Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 4414beb commit 5555460

File tree

4 files changed

+224
-0
lines changed

4 files changed

+224
-0
lines changed

Diff for: README.md

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

153153
| Status | Device(s) | Name | Release | Notes |
154154
| :----: | :-------: | ---- | :-----: | :---- |
155+
| :yellow_heart: | STM32C031C6 | [STM32C0316-DK](https://www.st.com/en/evaluation-tools/stm32c0316-dk.html) | **2.5.0** | |
155156
| :green_heart: | STM32F030R8 | [32F0308DISCOVERY](http://www.st.com/en/evaluation-tools/32f0308discovery.html) | *1.3.0* | |
156157
| :green_heart: | STM32F072RB | [32F072BDISCOVERY](https://www.st.com/en/evaluation-tools/32f072bdiscovery.html) | *1.5.0* | |
157158
| :green_heart: | STM32F100RB | [STM32VLDISCOVERY](https://www.st.com/en/evaluation-tools/stm32vldiscovery.html) | 0.2.1 | |

Diff for: boards.txt

+13
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,19 @@ Disco.menu.pnum.B_U585I_IOT02A.build.variant=STM32U5xx/U575A(G-I)IxQ_U585AIIxQ
883883
Disco.menu.pnum.B_U585I_IOT02A.build.peripheral_pins=-DCUSTOM_PERIPHERAL_PINS
884884
Disco.menu.pnum.B_U585I_IOT02A.build.cmsis_lib_gcc=arm_ARMv8MMLlfsp_math
885885

886+
# STM32C0316-DK board
887+
Disco.menu.pnum.STM32C0316_DK=STM32C0316-DK
888+
Disco.menu.pnum.STM32C0316_DK.node="No_mass_storage_for_this_board_Use_STLink_upload_method"
889+
Disco.menu.pnum.STM32C0316_DK.upload.maximum_size=32768
890+
Disco.menu.pnum.STM32C0316_DK.upload.maximum_data_size=12288
891+
Disco.menu.pnum.STM32C0316_DK.build.mcu=cortex-m0plus
892+
Disco.menu.pnum.STM32C0316_DK.build.board=STM32C0316_DK
893+
Disco.menu.pnum.STM32C0316_DK.build.series=STM32C0xx
894+
Disco.menu.pnum.STM32C0316_DK.build.product_line=STM32C031xx
895+
Disco.menu.pnum.STM32C0316_DK.build.variant=STM32C0xx/C031C(4-6)(T-U)
896+
Disco.menu.pnum.STM32C0316_DK.build.cmsis_lib_gcc=arm_cortexM0l_math
897+
Disco.menu.pnum.STM32C0316_DK.build.extra_flags=-D{build.product_line} {build.xSerial} -D__CORTEX_SC=0
898+
886899
# DISCO_F030R8 board
887900
Disco.menu.pnum.DISCO_F030R8=STM32F030R8-DISCVL
888901
Disco.menu.pnum.DISCO_F030R8.node="No_mass_storage_for_this_board_Use_STLink_upload_method"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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_STM32C0316_DK)
14+
#include "pins_arduino.h"
15+
#include "stm32yyxx_ll_utils.h"
16+
17+
// Digital PinName array
18+
const PinName digitalPin[] = {
19+
20+
PA_3, // D0
21+
PA_2, // D1
22+
PC_6, // D2
23+
PC_7, // D3
24+
PA_0, // D4
25+
PD_0, // D5
26+
PD_1, // D6
27+
PD_2, // D7
28+
PD_3, // D8
29+
PA_8, // D9
30+
PB_0, // D10
31+
PA_7, // D11
32+
PA_6, // D12
33+
PA_1, // D13
34+
PA_4, // D14
35+
PA_5, // D15
36+
PA_10, // D16
37+
PA_9, // D17
38+
PB_11, // D18
39+
PB_10, // D19
40+
PB_6, // D20
41+
PB_7 // D21
42+
};
43+
44+
// Analog (Ax) pin number array
45+
const uint32_t analogInputPin[] = {
46+
14, // A4,
47+
15, // A5,
48+
16, // A0,
49+
17, // A1,
50+
18, // A2,
51+
19 // A3,
52+
};
53+
54+
// ----------------------------------------------------------------------------
55+
#ifdef __cplusplus
56+
extern "C" {
57+
#endif
58+
59+
/**
60+
* @brief System Clock Configuration
61+
* @param None
62+
* @retval None
63+
*/
64+
WEAK void SystemClock_Config(void)
65+
{
66+
LL_FLASH_SetLatency(LL_FLASH_LATENCY_1);
67+
68+
/* HSI configuration and activation */
69+
LL_RCC_HSI_Enable();
70+
while (LL_RCC_HSI_IsReady() != 1) {
71+
}
72+
73+
LL_RCC_HSI_SetCalibTrimming(64);
74+
LL_RCC_SetHSIDiv(LL_RCC_HSI_DIV_1);
75+
/* Set AHB prescaler*/
76+
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
77+
78+
/* Sysclk activation on the HSI */
79+
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
80+
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) {
81+
}
82+
83+
/* Set APB1 prescaler*/
84+
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
85+
/* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */
86+
LL_SetSystemCoreClock(48000000);
87+
88+
/* Update the time base */
89+
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) {
90+
Error_Handler();
91+
}
92+
}
93+
94+
#ifdef __cplusplus
95+
}
96+
#endif
97+
#endif /* ARDUINO_STM32C0316_DK */
+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+
#define PA3 0
19+
#define PA2 1
20+
#define PC6 2
21+
#define PC7 3
22+
#define PA0 4
23+
#define PD0 5
24+
#define PD1 6
25+
#define PD2 7
26+
#define PD3 8
27+
#define PA8 9
28+
#define PB0 10
29+
#define PA7 11
30+
#define PA6 12
31+
#define PA1 13
32+
#define PB10 A5
33+
#define PB11 A4
34+
#define PA4 A0 // Joystick
35+
#define PA5 A1 // LED BLUE
36+
#define PA10 A2 // SDA // No ADC capability, despite analog "A2" Silk mark on board
37+
#define PA9 A3 // SCL // No ADC capability, despite analog "A3" Silk mark on board
38+
#define PB6 20 // STM32_TX1
39+
#define PB7 21 // STM32_RX1
40+
41+
42+
#define NUM_DIGITAL_PINS 22
43+
#define NUM_ANALOG_INPUTS 6
44+
45+
// On-board LED pin number
46+
#define LED_GREEN PA5
47+
#ifndef LED_BUILTIN
48+
#define LED_BUILTIN LED_GREEN
49+
#endif
50+
51+
// On-board user button
52+
#ifndef USER_BTN
53+
#define USER_BTN PA4
54+
#endif
55+
56+
// I2C Definitions
57+
#ifndef PIN_WIRE_SDA
58+
#define PIN_WIRE_SDA PA10
59+
#endif
60+
#ifndef PIN_WIRE_SCL
61+
#define PIN_WIRE_SCL PA9
62+
#endif
63+
64+
// Timer Definitions
65+
#ifndef TIMER_TONE
66+
#define TIMER_TONE TIM16
67+
#endif
68+
#ifndef TIMER_SERVO
69+
#define TIMER_SERVO TIM17
70+
#endif
71+
72+
// UART Definitions
73+
#ifndef SERIAL_UART_INSTANCE
74+
#define SERIAL_UART_INSTANCE 1
75+
#endif
76+
77+
// Default pin used for generic 'Serial' instance
78+
// Mandatory for Firmata
79+
#ifndef PIN_SERIAL_RX
80+
#define PIN_SERIAL_RX PB7
81+
#endif
82+
#ifndef PIN_SERIAL_TX
83+
#define PIN_SERIAL_TX PB6
84+
#endif
85+
86+
87+
/*----------------------------------------------------------------------------
88+
* Arduino objects - C++ only
89+
*----------------------------------------------------------------------------*/
90+
91+
#ifdef __cplusplus
92+
// These serial port names are intended to allow libraries and architecture-neutral
93+
// sketches to automatically default to the correct port name for a particular type
94+
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
95+
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
96+
//
97+
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
98+
//
99+
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
100+
//
101+
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
102+
//
103+
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
104+
//
105+
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
106+
// pins are NOT connected to anything by default.
107+
#ifndef SERIAL_PORT_MONITOR
108+
#define SERIAL_PORT_MONITOR Serial
109+
#endif
110+
#ifndef SERIAL_PORT_HARDWARE
111+
#define SERIAL_PORT_HARDWARE Serial
112+
#endif
113+
#endif

0 commit comments

Comments
 (0)