Skip to content

Commit 2fda55d

Browse files
BernardXionggitee-org
authored andcommitted
!233 [add]add gd32350r-eval bsp
Merge pull request !233 from Rice_Chen/gd32350r_bsp
2 parents c2d283e + f02ebb3 commit 2fda55d

File tree

103 files changed

+39814
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+39814
-0
lines changed

bsp/gd32350r-eval/.config

Lines changed: 555 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">
4+
5+
<component name="EventRecorderStub" version="1.0.0"/> <!--name and version of the component-->
6+
<events>
7+
</events>
8+
9+
</component_viewer>

bsp/gd32350r-eval/Kconfig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
config BSP_DIR
4+
string
5+
option env="BSP_ROOT"
6+
default "."
7+
8+
config RTT_DIR
9+
string
10+
option env="RTT_ROOT"
11+
default "../.."
12+
13+
# you can change the RTT_ROOT default: "rt-thread"
14+
# example : default "F:/git_repositories/rt-thread"
15+
16+
config PKGS_DIR
17+
string
18+
option env="PKGS_ROOT"
19+
default "packages"
20+
21+
source "$RTT_DIR/Kconfig"
22+
source "$PKGS_DIR/Kconfig"
23+
24+
config SOC_GD32350R
25+
bool
26+
select RT_USING_COMPONENTS_INIT
27+
select RT_USING_USER_MAIN
28+
default y
29+
30+
config BSP_USING_UART0
31+
bool "using uart0"
32+
select RT_USING_SERIAL
33+
default n
34+
config BSP_USING_UART1
35+
bool "using uart1"
36+
select RT_USING_SERIAL
37+
default n
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
/*!
2+
\file gd32f3x0.h
3+
\brief general definitions for gd32f3x0
4+
5+
\version 2017-06-06, V1.0.0, firmware for GD32F3x0
6+
\version 2019-06-01, V2.0.0, firmware for GD32F3x0
7+
*/
8+
9+
/*
10+
Copyright (c) 2019, GigaDevice Semiconductor Inc.
11+
12+
Redistribution and use in source and binary forms, with or without modification,
13+
are permitted provided that the following conditions are met:
14+
15+
1. Redistributions of source code must retain the above copyright notice, this
16+
list of conditions and the following disclaimer.
17+
2. Redistributions in binary form must reproduce the above copyright notice,
18+
this list of conditions and the following disclaimer in the documentation
19+
and/or other materials provided with the distribution.
20+
3. Neither the name of the copyright holder nor the names of its contributors
21+
may be used to endorse or promote products derived from this software without
22+
specific prior written permission.
23+
24+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+
WHETHER IN 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 POSSIBILITY
33+
OF SUCH DAMAGE.
34+
*/
35+
36+
#ifndef GD32F3X0_H
37+
#define GD32F3X0_H
38+
39+
#ifdef cplusplus
40+
extern "C" {
41+
#endif
42+
43+
/* define GD32F3x0 */
44+
#if !defined (GD32F3x0)
45+
#define GD32F3x0
46+
#endif /* define GD32F3x0 */
47+
#if !defined (GD32F3x0)
48+
#error "Please select the target GD32F3x0 device used in your application (in gd32f3x0.h file)"
49+
#endif /* undefine GD32F3x0 tip */
50+
51+
/* define GD32F3x0 device category */
52+
#if (!defined (GD32F330))&&(!defined (GD32F350))
53+
#error "Please select GD32F3x0 device category( GD32F330 or GD32F350 )"
54+
#endif /* undefine GD32F330 or GD32F350 tip */
55+
#if (defined (GD32F330))&&(defined (GD32F350))
56+
#error "Please select one GD32F3x0 device category( GD32F330 or GD32F350 )"
57+
#endif /* define GD32F330 and GD32F350 tip */
58+
59+
/* define value of high speed crystal oscillator (HXTAL) in Hz */
60+
#if !defined (HXTAL_VALUE)
61+
#define HXTAL_VALUE ((uint32_t)8000000)
62+
#endif /* high speed crystal oscillator value */
63+
64+
/* define startup timeout value of high speed crystal oscillator (HXTAL) */
65+
#if !defined (HXTAL_STARTUP_TIMEOUT)
66+
#define HXTAL_STARTUP_TIMEOUT ((uint16_t)0x0800)
67+
#endif /* high speed crystal oscillator startup timeout */
68+
69+
/* define value of internal 8MHz RC oscillator (IRC8M) in Hz */
70+
#if !defined (IRC8M_VALUE)
71+
#define IRC8M_VALUE ((uint32_t)8000000)
72+
#endif /* internal 8MHz RC oscillator value */
73+
74+
/* define startup timeout value of internal 8MHz RC oscillator (IRC8M) */
75+
#if !defined (IRC8M_STARTUP_TIMEOUT)
76+
#define IRC8M_STARTUP_TIMEOUT ((uint16_t)0x0500)
77+
#endif /* internal 8MHz RC oscillator startup timeout */
78+
79+
/* define value of internal RC oscillator for ADC in Hz */
80+
#if !defined (IRC28M_VALUE)
81+
#define IRC28M_VALUE ((uint32_t)28000000)
82+
#endif /* IRC28M_VALUE */
83+
84+
#if !defined (IRC48M_VALUE)
85+
#define IRC48M_VALUE ((uint32_t)48000000)
86+
#endif /* IRC48M_VALUE */
87+
88+
/* define value of internal 40KHz RC oscillator(IRC40K) in Hz */
89+
#if !defined (IRC40K_VALUE)
90+
#define IRC40K_VALUE ((uint32_t)40000)
91+
#endif /* internal 40KHz RC oscillator value */
92+
93+
/* define value of low speed crystal oscillator (LXTAL)in Hz */
94+
#if !defined (LXTAL_VALUE)
95+
#define LXTAL_VALUE ((uint32_t)32768)
96+
#endif /* low speed crystal oscillator value */
97+
98+
/* GD32F3x0 firmware library version number V1.0 */
99+
#define __GD32F3x0_STDPERIPH_VERSION_MAIN (0x01) /*!< [31:24] main version */
100+
#define __GD32F3x0_STDPERIPH_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
101+
#define __GD32F3x0_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
102+
#define __GD32F3x0_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
103+
#define __GD32F3x0_STDPERIPH_VERSION ((__GD32F3x0_STDPERIPH_VERSION_MAIN << 24)\
104+
|(__GD32F3x0_STDPERIPH_VERSION_SUB1 << 16)\
105+
|(__GD32F3x0_STDPERIPH_VERSION_SUB2 << 8)\
106+
|(__GD32F3x0_STDPERIPH_VERSION_RC))
107+
108+
/* configuration of the Cortex-M4 processor and core peripherals */
109+
#define __CM4_REV 0x0001 /*!< Core revision r0p1 */
110+
#define __MPU_PRESENT 0U /*!< GD32F3x0 do not provide MPU */
111+
#define __NVIC_PRIO_BITS 4U /*!< GD32F3x0 uses 4 bits for the priority levels */
112+
#define __Vendor_SysTickConfig 0U /*!< set to 1 if different sysTick config is used */
113+
#define __FPU_PRESENT 1U /*!< FPU present */
114+
115+
/* define interrupt number */
116+
typedef enum IRQn
117+
{
118+
/* Cortex-M4 processor exceptions numbers */
119+
NonMaskableInt_IRQn = -14, /*!< 2 non maskable interrupt */
120+
MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 memory management interrupt */
121+
BusFault_IRQn = -11, /*!< 5 Cortex-M4 bus fault interrupt */
122+
UsageFault_IRQn = -10, /*!< 6 Cortex-M4 usage fault interrupt */
123+
SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV call interrupt */
124+
DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 debug monitor interrupt */
125+
PendSV_IRQn = -2, /*!< 14 Cortex-M4 pend SV interrupt */
126+
SysTick_IRQn = -1, /*!< 15 Cortex-M4 system tick interrupt */
127+
/* interruput numbers */
128+
WWDGT_IRQn = 0, /*!< window watchdog timer interrupt */
129+
LVD_IRQn = 1, /*!< LVD through EXTI line detect interrupt */
130+
RCU_CTC_IRQn = 2, /*!< RTC and CTC interrupt */
131+
FMC_IRQn = 3, /*!< FMC interrupt */
132+
RCU_IRQn = 4, /*!< RCU interrupt */
133+
EXTI0_1_IRQn = 5, /*!< EXTI line 0 and 1 interrupts */
134+
EXTI2_3_IRQn = 6, /*!< EXTI line 2 and 3 interrupts */
135+
EXTI4_15_IRQn = 7, /*!< EXTI line 4 to 15 interrupts */
136+
TSI_IRQn = 8, /*!< TSI Interrupt */
137+
DMA_Channel0_IRQn = 9, /*!< DMA channel 0 interrupt */
138+
DMA_Channel1_2_IRQn = 10, /*!< DMA channel 1 and channel 2 interrupts */
139+
DMA_Channel3_4_IRQn = 11, /*!< DMA channel 3 and channel 4 interrupts */
140+
ADC_CMP_IRQn = 12, /*!< ADC, CMP0 and CMP1 interrupts */
141+
TIMER0_BRK_UP_TRG_COM_IRQn = 13, /*!< TIMER0 break, update, trigger and commutation interrupts */
142+
TIMER0_Channel_IRQn = 14, /*!< TIMER0 channel capture compare interrupts */
143+
TIMER1_IRQn = 15, /*!< TIMER1 interrupt */
144+
TIMER2_IRQn = 16, /*!< TIMER2 interrupt */
145+
#ifdef GD32F350
146+
TIMER5_DAC_IRQn = 17, /*!< TIMER5 and DAC interrupts */
147+
#endif /* GD32F350 */
148+
TIMER13_IRQn = 19, /*!< TIMER13 interrupt */
149+
TIMER14_IRQn = 20, /*!< TIMER14 interrupt */
150+
TIMER15_IRQn = 21, /*!< TIMER15 interrupt */
151+
TIMER16_IRQn = 22, /*!< TIMER16 interrupt */
152+
I2C0_EV_IRQn = 23, /*!< I2C0 event interrupt */
153+
I2C1_EV_IRQn = 24, /*!< I2C1 event interrupt */
154+
SPI0_IRQn = 25, /*!< SPI0 interrupt */
155+
SPI1_IRQn = 26, /*!< SPI1 interrupt */
156+
USART0_IRQn = 27, /*!< USART0 interrupt */
157+
USART1_IRQn = 28, /*!< USART1 interrupt */
158+
#ifdef GD32F350
159+
CEC_IRQn = 30, /*!< CEC interrupt */
160+
#endif /* GD32F350 */
161+
I2C0_ER_IRQn = 32, /*!< I2C0 error interrupt */
162+
I2C1_ER_IRQn = 34, /*!< I2C1 error interrupt */
163+
DMA_Channel5_6_IRQn = 48, /*!< DMA channel 5 and channel 6 interrupts */
164+
#ifdef GD32F350
165+
USBFS_WKUP_IRQn = 42, /*!< USBFS wakeup interrupt */
166+
USBFS_IRQn = 67, /*!< USBFS global interrupt */
167+
#endif /* GD32F350 */
168+
} IRQn_Type;
169+
170+
/* includes */
171+
#include "core_cm4.h"
172+
#include "system_gd32f3x0.h"
173+
#include <stdint.h>
174+
175+
/* enum definitions */
176+
typedef enum {DISABLE = 0, ENABLE = !DISABLE} EventStatus, ControlStatus;
177+
typedef enum {FALSE = 0, TRUE = !FALSE} bool;
178+
typedef enum {RESET = 0, SET = !RESET} FlagStatus;
179+
typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
180+
181+
/* bit operations */
182+
#define REG32(addr) (*(volatile uint32_t *)(uint32_t)(addr))
183+
#define REG16(addr) (*(volatile uint16_t *)(uint32_t)(addr))
184+
#define REG8(addr) (*(volatile uint8_t *)(uint32_t)(addr))
185+
#define BIT(x) ((uint32_t)((uint32_t)0x01U<<(x)))
186+
#define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
187+
#define GET_BITS(regval, start, end) (((regval) & BITS((start),(end))) >> (start))
188+
189+
/* main flash and SRAM memory map */
190+
#define FLASH_BASE ((uint32_t)0x08000000U) /*!< main FLASH base address */
191+
#define SRAM_BASE ((uint32_t)0x20000000U) /*!< SRAM base address */
192+
/* SRAM and peripheral base bit-band region */
193+
#define SRAM_BB_BASE ((uint32_t)0x22000000U) /*!< SRAM bit-band base address */
194+
#define PERIPH_BB_BASE ((uint32_t)0x42000000U) /*!< peripheral bit-band base address */
195+
/* peripheral memory map */
196+
#define APB1_BUS_BASE ((uint32_t)0x40000000U) /*!< apb1 base address */
197+
#define APB2_BUS_BASE ((uint32_t)0x40010000U) /*!< apb2 base address */
198+
#define AHB1_BUS_BASE ((uint32_t)0x40020000U) /*!< ahb1 base address */
199+
#define AHB2_BUS_BASE ((uint32_t)0x48000000U) /*!< ahb2 base address */
200+
/* advanced peripheral bus 1 memory map */
201+
#define TIMER_BASE (APB1_BUS_BASE + 0x00000000U) /*!< TIMER base address */
202+
#define RTC_BASE (APB1_BUS_BASE + 0x00002800U) /*!< RTC base address */
203+
#define WWDGT_BASE (APB1_BUS_BASE + 0x00002C00U) /*!< WWDGT base address */
204+
#define FWDGT_BASE (APB1_BUS_BASE + 0x00003000U) /*!< FWDGT base address */
205+
#define SPI_BASE (APB1_BUS_BASE + 0x00003800U) /*!< SPI base address */
206+
#define USART_BASE (APB1_BUS_BASE + 0x00004400U) /*!< USART base address */
207+
#define I2C_BASE (APB1_BUS_BASE + 0x00005400U) /*!< I2C base address */
208+
#define PMU_BASE (APB1_BUS_BASE + 0x00007000U) /*!< PMU base address */
209+
#define DAC_BASE (APB1_BUS_BASE + 0x00007400U) /*!< DAC base address */
210+
#define CEC_BASE (APB1_BUS_BASE + 0x00007800U) /*!< CEC base address */
211+
#define CTC_BASE (APB1_BUS_BASE + 0x0000C800U) /*!< CTC base address */
212+
/* advanced peripheral bus 2 memory map */
213+
#define SYSCFG_BASE (APB2_BUS_BASE + 0x00000000U) /*!< SYSCFG base address */
214+
#define CMP_BASE (APB2_BUS_BASE + 0x0000001CU) /*!< CMP base address */
215+
#define EXTI_BASE (APB2_BUS_BASE + 0x00000400U) /*!< EXTI base address */
216+
#define ADC_BASE (APB2_BUS_BASE + 0x00002400U) /*!< ADC base address */
217+
/* advanced high performance bus 1 memory map */
218+
#define DMA_BASE (AHB1_BUS_BASE + 0x00000000U) /*!< DMA base address */
219+
#define DMA_CHANNEL_BASE (DMA_BASE + 0x00000008U) /*!< DMA channel base address */
220+
#define RCU_BASE (AHB1_BUS_BASE + 0x00001000U) /*!< RCU base address */
221+
#define FMC_BASE (AHB1_BUS_BASE + 0x00002000U) /*!< FMC base address */
222+
#define CRC_BASE (AHB1_BUS_BASE + 0x00003000U) /*!< CRC base address */
223+
#define TSI_BASE (AHB1_BUS_BASE + 0x00004000U) /*!< TSI base address */
224+
#define USBFS_BASE (AHB1_BUS_BASE + 0x0FFE0000U) /*!< USBFS base address */
225+
/* advanced high performance bus 2 memory map */
226+
#define GPIO_BASE (AHB2_BUS_BASE + 0x00000000U) /*!< GPIO base address */
227+
/* option byte and debug memory map */
228+
#define OB_BASE ((uint32_t)0x1FFFF800U) /*!< OB base address */
229+
#define DBG_BASE ((uint32_t)0xE0042000U) /*!< DBG base address */
230+
231+
/* define marco USE_STDPERIPH_DRIVER */
232+
#if !defined USE_STDPERIPH_DRIVER
233+
#define USE_STDPERIPH_DRIVER
234+
#endif
235+
#ifdef USE_STDPERIPH_DRIVER
236+
#include "gd32f3x0_libopt.h"
237+
#endif /* USE_STDPERIPH_DRIVER */
238+
239+
#ifdef cplusplus
240+
}
241+
#endif
242+
#endif
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*!
2+
\file system_gd32f3x0.h
3+
\brief CMSIS Cortex-M4 Device Peripheral Access Layer Header File for
4+
GD32F3x0 Device Series
5+
*/
6+
7+
/* Copyright (c) 2012 ARM LIMITED
8+
9+
All rights reserved.
10+
Redistribution and use in source and binary forms, with or without
11+
modification, are permitted provided that the following conditions are met:
12+
- Redistributions of source code must retain the above copyright
13+
notice, this list of conditions and the following disclaimer.
14+
- Redistributions in binary form must reproduce the above copyright
15+
notice, this list of conditions and the following disclaimer in the
16+
documentation and/or other materials provided with the distribution.
17+
- Neither the name of ARM nor the names of its contributors may be used
18+
to endorse or promote products derived from this software without
19+
specific prior written permission.
20+
*
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
POSSIBILITY OF SUCH DAMAGE.
32+
---------------------------------------------------------------------------*/
33+
34+
/* This file refers the CMSIS standard, some adjustments are made according to GigaDevice chips */
35+
36+
#ifndef SYSTEM_GD32F3X0_H
37+
#define SYSTEM_GD32F3X0_H
38+
39+
#ifdef __cplusplus
40+
extern "C" {
41+
#endif
42+
43+
#include <stdint.h>
44+
45+
/* system clock frequency (core clock) */
46+
extern uint32_t SystemCoreClock;
47+
48+
/* function declarations */
49+
/* initialize the system and update the SystemCoreClock variable */
50+
extern void SystemInit (void);
51+
/* update the SystemCoreClock with current core clock retrieved from cpu registers */
52+
extern void SystemCoreClockUpdate (void);
53+
54+
#ifdef __cplusplus
55+
}
56+
#endif
57+
58+
#endif /* SYSTEM_GD32F3X0_H */

0 commit comments

Comments
 (0)