Skip to content

Commit 926e8c1

Browse files
committed
Update GD32F30x CMSIS HAL to v3.0.3
Update CMSIS HAL files to firmware version 3.0.3 with enhanced stability during clock frequency switching. Key changes include: - Improved RCU_MODIFY macro for Vcore fluctuation prevention - Added software delay function to stabilize transitions - Converted direct register writes to read-modify-write pattern in clock functions - Added firmware version query support - Updated copyright year to 2026 - Removed deprecated GCC diagnostic pragmas - Added HardFault_IRQn to interrupt enumeration
1 parent e8cba32 commit 926e8c1

4 files changed

Lines changed: 365 additions & 85 deletions

File tree

lib-gd32/gd32f30x/CMSIS/GD/GD32F30x/Include/gd32f30x.h

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,42 @@
22
\file gd32f30x.h
33
\brief general definitions for GD32F30x
44
5-
\version 2017-02-10, V1.0.0, firmware for GD32F30x
6-
\version 2018-10-10, V1.1.0, firmware for GD32F30x
7-
\version 2018-12-25, V2.0.0, firmware for GD32F30x
8-
\version 2020-09-30, V2.1.0, firmware for GD32F30x
5+
\version 2026-2-6, V3.0.3, firmware for GD32F30x
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 GD32F30X_H
3939
#define GD32F30X_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-
4941
#ifdef __cplusplus
5042
extern "C" {
5143
#endif
@@ -100,10 +92,10 @@ OF SUCH DAMAGE.
10092
#define LXTAL_VALUE ((uint32_t)32768)
10193
#endif /* low speed crystal oscillator value */
10294

103-
/* GD32F30x firmware library version number V1.0 */
104-
#define __GD32F30x_STDPERIPH_VERSION_MAIN (0x01) /*!< [31:24] main version */
95+
/* GD32F30x firmware library version number V3.0.3 */
96+
#define __GD32F30x_STDPERIPH_VERSION_MAIN (0x03) /*!< [31:24] main version */
10597
#define __GD32F30x_STDPERIPH_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
106-
#define __GD32F30x_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
98+
#define __GD32F30x_STDPERIPH_VERSION_SUB2 (0x03) /*!< [15:8] sub2 version */
10799
#define __GD32F30x_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
108100
#define __GD32F30x_STDPERIPH_VERSION ((__GD32F30x_STDPERIPH_VERSION_MAIN << 24)\
109101
|(__GD32F30x_STDPERIPH_VERSION_SUB1 << 16)\
@@ -120,7 +112,8 @@ OF SUCH DAMAGE.
120112
typedef enum IRQn
121113
{
122114
/* Cortex-M4 processor exceptions numbers */
123-
NonMaskableInt_IRQn = -14, /*!< 2 non maskable interrupt */
115+
NonMaskableInt_IRQn = -14, /*!< non maskable interrupt */
116+
HardFault_IRQn = -13, /*!< hard-fault interrupt */
124117
MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 memory management interrupt */
125118
BusFault_IRQn = -11, /*!< 5 Cortex-M4 bus fault interrupt */
126119
UsageFault_IRQn = -10, /*!< 6 Cortex-M4 usage fault interrupt */

lib-gd32/gd32f30x/CMSIS/GD/GD32F30x/Include/system_gd32f30x.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
/* Copyright (c) 2012 ARM LIMITED
8+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
89
910
All rights reserved.
1011
Redistribution and use in source and binary forms, with or without
@@ -30,6 +31,7 @@
3031
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3132
POSSIBILITY OF SUCH DAMAGE.
3233
---------------------------------------------------------------------------*/
34+
3335
/* This file refers the CMSIS standard, some adjustments are made according to GigaDevice chips */
3436

3537
#ifndef SYSTEM_GD32F30X_H
@@ -43,12 +45,18 @@ extern "C" {
4345

4446
/* system clock frequency (core clock) */
4547
extern uint32_t SystemCoreClock;
48+
/* firmware version can be aquired by uncommenting the macro */
49+
#define __FIRMWARE_VERSION_DEFINE
4650

4751
/* function declarations */
4852
/* initialize the system and update the SystemCoreClock variable */
4953
extern void SystemInit (void);
5054
/* update the SystemCoreClock with current core clock retrieved from cpu registers */
5155
extern void SystemCoreClockUpdate (void);
56+
#ifdef __FIRMWARE_VERSION_DEFINE
57+
/* get firmware version */
58+
extern uint32_t gd32f30x_firmware_version_get(void);
59+
#endif /* __FIRMWARE_VERSION_DEFINE */
5260

5361
#ifdef __cplusplus
5462
}
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
/*!
2+
\file syscall.c
3+
\brief system calls file
4+
5+
\version 2026-2-6, V3.0.3, firmware for GD32F30x
6+
*/
7+
8+
/*
9+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
10+
11+
Redistribution and use in source and binary forms, with or without modification,
12+
are permitted provided that the following conditions are met:
13+
14+
1. Redistributions of source code must retain the above copyright notice, this
15+
list of conditions and the following disclaimer.
16+
2. Redistributions in binary form must reproduce the above copyright notice,
17+
this list of conditions and the following disclaimer in the documentation
18+
and/or other materials provided with the distribution.
19+
3. Neither the name of the copyright holder nor the names of its contributors
20+
may be used 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 IMPLIED
25+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32+
OF SUCH DAMAGE.
33+
*/
34+
35+
#include <_ansi.h>
36+
#include <sys/types.h>
37+
#include <sys/stat.h>
38+
#include <sys/fcntl.h>
39+
#include <stdio.h>
40+
#include <string.h>
41+
#include <time.h>
42+
#include <sys/time.h>
43+
#include <sys/times.h>
44+
#include <errno.h>
45+
#include <reent.h>
46+
#include <unistd.h>
47+
#include <sys/wait.h>
48+
49+
#undef errno
50+
extern int errno;
51+
52+
extern int __io_putchar(int ch) __attribute__((weak));
53+
extern int __io_getchar(void) __attribute__((weak));
54+
55+
caddr_t _sbrk(int incr)
56+
{
57+
extern char _end[];
58+
extern char _heap_end[];
59+
static char *curbrk = _end;
60+
61+
if((curbrk + incr < _end) || (curbrk + incr > _heap_end)) {
62+
return NULL - 1;
63+
}
64+
65+
curbrk += incr;
66+
return curbrk - incr;
67+
}
68+
69+
/* _gettimeofday primitive (Stub function) */
70+
int _gettimeofday(struct timeval *tp, struct timezone *tzp)
71+
{
72+
/* Return fixed data for the timezone. */
73+
if(tzp) {
74+
tzp->tz_minuteswest = 0;
75+
tzp->tz_dsttime = 0;
76+
}
77+
78+
return 0;
79+
}
80+
81+
void initialise_monitor_handles()
82+
{
83+
}
84+
85+
int _getpid(void)
86+
{
87+
return 1;
88+
}
89+
90+
int _kill(int pid, int sig)
91+
{
92+
errno = EINVAL;
93+
return -1;
94+
}
95+
96+
void _exit(int status)
97+
{
98+
_kill(status, -1);
99+
while(1) {
100+
}
101+
}
102+
103+
int _write(int file, char *ptr, int len)
104+
{
105+
int DataIdx;
106+
107+
for(DataIdx = 0; DataIdx < len; DataIdx++) {
108+
__io_putchar(*ptr++);
109+
}
110+
return len;
111+
}
112+
113+
int _close(int file)
114+
{
115+
return -1;
116+
}
117+
118+
int _fstat(int file, struct stat *st)
119+
{
120+
st->st_mode = S_IFCHR;
121+
return 0;
122+
}
123+
124+
int _isatty(int file)
125+
{
126+
return 1;
127+
}
128+
129+
int _lseek(int file, int ptr, int dir)
130+
{
131+
return 0;
132+
}
133+
134+
int _read(int file, char *ptr, int len)
135+
{
136+
int DataIdx;
137+
138+
for(DataIdx = 0; DataIdx < len; DataIdx++) {
139+
*ptr++ = __io_getchar();
140+
}
141+
142+
return len;
143+
}
144+
145+
int _open(char *path, int flags, ...)
146+
{
147+
/* Pretend like we always fail */
148+
return -1;
149+
}
150+
151+
int _wait(int *status)
152+
{
153+
errno = ECHILD;
154+
return -1;
155+
}
156+
157+
int _unlink(char *name)
158+
{
159+
errno = ENOENT;
160+
return -1;
161+
}
162+
163+
int _times(struct tms *buf)
164+
{
165+
return -1;
166+
}
167+
168+
int _stat(char *file, struct stat *st)
169+
{
170+
st->st_mode = S_IFCHR;
171+
return 0;
172+
}
173+
174+
int _link(char *old, char *new)
175+
{
176+
errno = EMLINK;
177+
return -1;
178+
}
179+
180+
int _fork(void)
181+
{
182+
errno = EAGAIN;
183+
return -1;
184+
}
185+
186+
int _execve(char *name, char **argv, char **env)
187+
{
188+
errno = ENOMEM;
189+
return -1;
190+
}

0 commit comments

Comments
 (0)