Skip to content

Commit 8c2341b

Browse files
committed
Update GD32F10x CMSIS v2.7 startup code
Refresh GD32F10x CMSIS headers and version metadata to v2.7.0, including updated standard-peripheral version macros and licensing blocks. Rework system clock switching to use staged AHB prescaler changes and added software delays to reduce Vcore instability during startup, and replace direct SCS bit writes with register-temporary updates across clock setup paths. Add an optional firmware version API (`gd32f10x_firmware_version_get`) behind `__FIRMWARE_VERSION_DEFINE`.
1 parent a86a8db commit 8c2341b

3 files changed

Lines changed: 166 additions & 94 deletions

File tree

lib-gd32/gd32f10x/CMSIS/GD/GD32F10x/Include/gd32f10x.h

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,43 @@
22
\file gd32f10x.h
33
\brief general definitions for GD32F10x
44
5-
\version 2014-12-26, V1.0.0, firmware for GD32F10x
6-
\version 2017-06-20, V2.0.0, firmware for GD32F10x
7-
\version 2018-07-31, V2.1.0, firmware for GD32F10x
8-
\version 2020-09-30, V2.2.0, firmware for GD32F10x
5+
\version 2026-02-12, V2.7.0, firmware for GD32F10x
96
*/
107

11-
/*
12-
Copyright (c) 2020, GigaDevice Semiconductor Inc.
13-
14-
Redistribution and use in source and binary forms, with or without modification,
15-
are permitted provided that the following conditions are met:
16-
17-
1. Redistributions of source code must retain the above copyright notice, this
18-
list of conditions and the following disclaimer.
19-
2. Redistributions in binary form must reproduce the above copyright notice,
20-
this list of conditions and the following disclaimer in the documentation
21-
and/or other materials provided with the distribution.
22-
3. Neither the name of the copyright holder nor the names of its contributors
23-
may be used to endorse or promote products derived from this software without
24-
specific prior written permission.
25-
26-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29-
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
30-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31-
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33-
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35-
OF SUCH DAMAGE.
36-
*/
8+
/* Copyright (c) 2012 ARM LIMITED
9+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
10+
11+
All rights reserved.
12+
Redistribution and use in source and binary forms, with or without
13+
modification, are permitted provided that the following conditions are met:
14+
- Redistributions of source code must retain the above copyright
15+
notice, this list of conditions and the following disclaimer.
16+
- Redistributions in binary form must reproduce the above copyright
17+
notice, this list of conditions and the following disclaimer in the
18+
documentation and/or other materials provided with the distribution.
19+
- Neither the name of ARM nor the names of its contributors may be used
20+
to endorse or promote products derived from this software without
21+
specific prior written permission.
22+
*
23+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
27+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33+
POSSIBILITY OF SUCH DAMAGE.
34+
---------------------------------------------------------------------------*/
35+
36+
/* This file refers the CMSIS standard, some adjustments are made according to GigaDevice chips */
3737

3838
#ifndef GD32F10X_H
3939
#define GD32F10X_H
4040

41-
/* AvV BEGIN */
42-
#pragma GCC diagnostic push
43-
#pragma GCC diagnostic ignored "-Wunused-function"
44-
#pragma GCC diagnostic ignored "-Wconversion"
45-
#pragma GCC diagnostic ignored "-Wsign-conversion"
46-
#pragma GCC diagnostic ignored "-Wduplicated-cond"
47-
/* AvV END */
48-
49-
#ifdef __cplusplus
41+
#ifdef cplusplus
5042
extern "C" {
5143
#endif
5244

@@ -96,15 +88,15 @@ OF SUCH DAMAGE.
9688
#define LXTAL_VALUE ((uint32_t)32768)
9789
#endif /* low speed crystal oscillator value */
9890

99-
/* GD32F10x firmware library version number V2.0 */
100-
#define __GD32F10x_STDPERIPH_VERSION_MAIN (0x01) /*!< [31:24] main version */
101-
#define __GD32F10x_STDPERIPH_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
102-
#define __GD32F10x_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
103-
#define __GD32F10x_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
104-
#define __GD32F10x_STDPERIPH_VERSION ((__GD32F10x_STDPERIPH_VERSION_MAIN << 24)\
105-
|(__GD32F10x_STDPERIPH_VERSION_SUB1 << 16)\
106-
|(__GD32F10x_STDPERIPH_VERSION_SUB2 << 8)\
107-
|(__GD32F10x_STDPERIPH_VERSION_RC))
91+
/* GD32F10x firmware library version number */
92+
#define __GD32F10X_STDPERIPH_VERSION_MAIN (0x02) /*!< [31:24] main version */
93+
#define __GD32F10X_STDPERIPH_VERSION_SUB1 (0x07) /*!< [23:16] sub1 version */
94+
#define __GD32F10X_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
95+
#define __GD32F10X_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
96+
#define __GD32F10X_STDPERIPH_VERSION ((__GD32F10X_STDPERIPH_VERSION_MAIN << 24)\
97+
|(__GD32F10X_STDPERIPH_VERSION_SUB1 << 16)\
98+
|(__GD32F10X_STDPERIPH_VERSION_SUB2 << 8)\
99+
|(__GD32F10X_STDPERIPH_VERSION_RC))
108100

109101
/* configuration of the Cortex-M3 processor and core peripherals */
110102
#define __MPU_PRESENT 0 /*!< GD32F10x do not provide MPU */
@@ -319,7 +311,7 @@ typedef enum IRQn
319311

320312
/* enum definitions */
321313
typedef enum {DISABLE = 0, ENABLE = !DISABLE} EventStatus, ControlStatus;
322-
//typedef enum {FALSE = 0, TRUE = !FALSE} bool; /* AvV BEGIN */
314+
// typedef enum {FALSE = 0, TRUE = !FALSE} bool; AvV
323315
typedef enum {RESET = 0, SET = !RESET} FlagStatus;
324316
typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
325317

@@ -382,7 +374,7 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
382374
#include "gd32f10x_libopt.h"
383375
#endif /* USE_STDPERIPH_DRIVER */
384376

385-
#ifdef __cplusplus
377+
#ifdef cplusplus
386378
}
387379
#endif
388380
#endif

lib-gd32/gd32f10x/CMSIS/GD/GD32F10x/Include/system_gd32f10x.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
GD32F10x Device Series
55
*/
66

7-
/*
8-
Copyright (c) 2012 ARM LIMITED
7+
/* Copyright (c) 2012 ARM LIMITED
8+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
99
1010
All rights reserved.
1111
@@ -44,6 +44,9 @@ extern "C" {
4444

4545
#include <stdint.h>
4646

47+
/* firmware version can be aquired by uncommenting the macro */
48+
#define __FIRMWARE_VERSION_DEFINE
49+
4750
/* system clock frequency (core clock) */
4851
extern uint32_t SystemCoreClock;
4952

@@ -52,6 +55,10 @@ extern uint32_t SystemCoreClock;
5255
extern void SystemInit(void);
5356
/* update the SystemCoreClock with current core clock retrieved from cpu registers */
5457
extern void SystemCoreClockUpdate(void);
58+
#ifdef __FIRMWARE_VERSION_DEFINE
59+
/* get firmware version */
60+
extern uint32_t gd32f10x_firmware_version_get(void);
61+
#endif /* __FIRMWARE_VERSION_DEFINE */
5562

5663
#ifdef __cplusplus
5764
}

0 commit comments

Comments
 (0)