Skip to content

Commit

Permalink
update CH32X035
Browse files Browse the repository at this point in the history
  • Loading branch information
TianpeiLee committed Jun 14, 2023
1 parent 220426b commit 9871543
Show file tree
Hide file tree
Showing 110 changed files with 18,868 additions and 10 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ It will be a long-term support and maintenance project, unless we encounter forc

- [CH32V00x EVT Boards](#CH32V00x-EVT-Boards)
- [CH32V20x EVT Boards](#CH32V20x-EVT-Boards)
- [CH32X035 EVT Boards](#CH32X035-EVT-Boards)

### CH32V00x EVT Boards

Expand All @@ -41,7 +42,13 @@ It will be a long-term support and maintenance project, unless we encounter forc

| Status | Boards name | Peripherals | Release |
| :----: | ---- | ---- | :-----: |
| :heavy_check_mark: | CH32V203G8U | ADC,DAC,USART,GPIO,EXTI,SysTick | 1.0.0 |
| :heavy_check_mark: | CH32V203G8U | ADC,DAC,USART,GPIO,EXTI,SysTick | 1.0.0 |

### CH32X035 EVT Boards

| Status | Boards name | Peripherals | Release |
| :----: | ---- | ---- | :-----: |
| :heavy_check_mark: | CH32X035G8U | ADC,DAC,USART,GPIO,EXTI,SysTick | 1.0.1 |

## Submit bugs

Expand Down
86 changes: 86 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,92 @@ CH32V00x_EVT.menu.rtlib.full.build.flags.ldspecs=



#############################################################################
##CH32X035 EVT Board

CH32X035_EVT.name=CH32X035
CH32X035_EVT.build.core=arduino
CH32X035_EVT.build.board=CH32X035_EVT
CH32X035_EVT.upload.maximum_size=0
CH32X035_EVT.upload.maximum_data_size=0
CH32X035_EVT.build.variant_h=variant_{build.board}.h


#CH32X035 EVT Board
CH32X035_EVT.menu.pnum.CH32X035G8U=CH32X035G8U EVT
CH32X035_EVT.menu.pnum.CH32X035G8U.node=NODE_X035G8
CH32X035_EVT.menu.pnum.CH32X035G8U.upload.maximum_size=63488
CH32X035_EVT.menu.pnum.CH32X035G8U.upload.maximum_data_size=20480
CH32X035_EVT.menu.pnum.CH32X035G8U.build.mcu=QingKe-V4C
CH32X035_EVT.menu.pnum.CH32X035G8U.build.board=CH32X035G8U
CH32X035_EVT.menu.pnum.CH32X035G8U.build.series=CH32X035
CH32X035_EVT.menu.pnum.CH32X035G8U.build.variant=CH32X035/CH32X035G8U
CH32X035_EVT.menu.pnum.CH32X035G8U.build.chip=CH32X035G8U
CH32X035_EVT.menu.pnum.CH32X035G8U.build.march=rv32imacxw
CH32X035_EVT.menu.pnum.CH32X035G8U.build.mabi=ilp32
CH32X035_EVT.menu.pnum.CH32X035G8U.build.math_lib_gcc=-lm
CH32X035_EVT.menu.pnum.CH32X035G8U.build.IQ_math_RV32=
CH32X035_EVT.menu.pnum.CH32X035G8U.build.ch_extra_lib=-lprintf


# Upload menu
CH32X035_EVT.menu.upload_method.swdMethod=WCH-SWD
CH32X035_EVT.menu.upload_method.swdMethod.upload.protocol=
CH32X035_EVT.menu.upload_method.swdMethod.upload.options=
CH32X035_EVT.menu.upload_method.swdMethod.upload.tool=WCH_linkE



# Optimizations
CH32X035_EVT.menu.opt.osstd=Smallest (-Os default)
CH32X035_EVT.menu.opt.osstd.build.flags.optimize=-Os
CH32X035_EVT.menu.opt.oslto=Smallest (-Os) with LTO
CH32X035_EVT.menu.opt.oslto.build.flags.optimize=-Os -flto
CH32X035_EVT.menu.opt.o1std=Fast (-O1)
CH32X035_EVT.menu.opt.o1std.build.flags.optimize=-O1
CH32X035_EVT.menu.opt.o1lto=Fast (-O1) with LTO
CH32X035_EVT.menu.opt.o1lto.build.flags.optimize=-O1 -flto
CH32X035_EVT.menu.opt.o2std=Faster (-O2)
CH32X035_EVT.menu.opt.o2std.build.flags.optimize=-O2
CH32X035_EVT.menu.opt.o2lto=Faster (-O2) with LTO
CH32X035_EVT.menu.opt.o2lto.build.flags.optimize=-O2 -flto
CH32X035_EVT.menu.opt.o3std=Fastest (-O3)
CH32X035_EVT.menu.opt.o3std.build.flags.optimize=-O3
CH32X035_EVT.menu.opt.o3lto=Fastest (-O3) with LTO
CH32X035_EVT.menu.opt.o3lto.build.flags.optimize=-O3 -flto
CH32X035_EVT.menu.opt.ogstd=Debug (-Og)
CH32X035_EVT.menu.opt.ogstd.build.flags.optimize=-Og
CH32X035_EVT.menu.opt.o0std=No Optimization (-O0)
CH32X035_EVT.menu.opt.o0std.build.flags.optimize=-O0


# Debug information
CH32X035_EVT.menu.dbg.none=None
CH32X035_EVT.menu.dbg.none.build.flags.debug=
CH32X035_EVT.menu.dbg.enable_sym=Symbols Enabled (-g)
CH32X035_EVT.menu.dbg.enable_sym.build.flags.debug=-g -DNDEBUG
CH32X035_EVT.menu.dbg.enable_log=Core logs Enabled
CH32X035_EVT.menu.dbg.enable_log.build.flags.debug=
CH32X035_EVT.menu.dbg.enable_all=Core Logs and Symbols Enabled (-g)
CH32X035_EVT.menu.dbg.enable_all.build.flags.debug=-g


# C Runtime Library
CH32X035_EVT.menu.rtlib.nano=Newlib Nano (default)
CH32X035_EVT.menu.rtlib.nano.build.flags.ldflags=--specs=nano.specs --specs=nosys.specs
CH32X035_EVT.menu.rtlib.nanofp=Newlib Nano + Float Printf
CH32X035_EVT.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs --specs=nosys.specs -u _printf_float
CH32X035_EVT.menu.rtlib.nanofs=Newlib Nano + Float Scanf
CH32X035_EVT.menu.rtlib.nanofs.build.flags.ldspecs=--specs=nano.specs --specs=nosys.specs -u _scanf_float
CH32X035_EVT.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf
CH32X035_EVT.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs --specs=nosys.specs -u _printf_float -u _scanf_float
CH32X035_EVT.menu.rtlib.full=Newlib Standard
CH32X035_EVT.menu.rtlib.full.build.flags.ldspecs=





#############################################################################
##CH32V20x EVT Board

Expand Down
4 changes: 4 additions & 0 deletions cores/arduino/ch32/PinAF_ch32yyxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
#endif


#if defined(CH32X035)
#include "../../../variants/CH32X035/PinAF_CH32X035.h"
#endif

#endif /* _PINAF_CH32YYXX_H */
121 changes: 120 additions & 1 deletion cores/arduino/ch32/PinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
extern "C" {
#endif


// Alternative possibilities which use other HW peripheral instances
#define ALT0 0x000
#define ALT1 0x100
Expand All @@ -32,6 +33,8 @@ extern "C" {
// PinName mask
#define PNAME_MASK 0xFF

#if !defined(CH32X035)

typedef enum {
// Not connected
NC = 0xFFFFFFFF,
Expand All @@ -52,7 +55,7 @@ typedef enum {
PA_12 = (PortA << 4) + 0x0C,
PA_13 = (PortA << 4) + 0x0D,
PA_14 = (PortA << 4) + 0x0E,
PA_15 = (PortA << 4) + 0x0F,
PA_15 = (PortA << 4) + 0x0F,
#if defined GPIOB_BASE
PB_0 = (PortB << 4) + 0x00,
PB_1 = (PortB << 4) + 0x01,
Expand Down Expand Up @@ -205,6 +208,122 @@ typedef enum {
P_END = NC
} PinName;

#else

typedef enum {
// Not connected
NC = 0xFFFFFFFF,

// Pin name definition
PA_0 = (PortA << 5) + 0x00,
PA_1 = (PortA << 5) + 0x01,
PA_2 = (PortA << 5) + 0x02,
PA_3 = (PortA << 5) + 0x03,
PA_4 = (PortA << 5) + 0x04,
PA_5 = (PortA << 5) + 0x05,
PA_6 = (PortA << 5) + 0x06,
PA_7 = (PortA << 5) + 0x07,
PA_8 = (PortA << 5) + 0x08,
PA_9 = (PortA << 5) + 0x09,
PA_10 = (PortA << 5) + 0x0A,
PA_11 = (PortA << 5) + 0x0B,
PA_12 = (PortA << 5) + 0x0C,
PA_13 = (PortA << 5) + 0x0D,
PA_14 = (PortA << 5) + 0x0E,
PA_15 = (PortA << 5) + 0x0F,
PA_16 = (PortA << 5) + 0x10,
PA_17 = (PortA << 5) + 0x11,
PA_18 = (PortA << 5) + 0x12,
PA_19 = (PortA << 5) + 0x13,
PA_20 = (PortA << 5) + 0x14,
PA_21 = (PortA << 5) + 0x15,
PA_22 = (PortA << 5) + 0x16,
PA_23 = (PortA << 5) + 0x17,


#if defined GPIOB_BASE
PB_0 = (PortB << 5) + 0x00,
PB_1 = (PortB << 5) + 0x01,
PB_2 = (PortB << 5) + 0x02,
PB_3 = (PortB << 5) + 0x03,
PB_4 = (PortB << 5) + 0x04,
PB_5 = (PortB << 5) + 0x05,
PB_6 = (PortB << 5) + 0x06,
PB_7 = (PortB << 5) + 0x07,
PB_8 = (PortB << 5) + 0x08,
PB_9 = (PortB << 5) + 0x09,
PB_10 = (PortB << 5) + 0x0A,
PB_11 = (PortB << 5) + 0x0B,
PB_12 = (PortB << 5) + 0x0C,
PB_13 = (PortB << 5) + 0x0D,
PB_14 = (PortB << 5) + 0x0E,
PB_15 = (PortB << 5) + 0x0F,
PB_16 = (PortB << 5) + 0x10,
PB_17 = (PortB << 5) + 0x11,
PB_18 = (PortB << 5) + 0x12,
PB_19 = (PortB << 5) + 0x13,
PB_20 = (PortB << 5) + 0x14,
PB_21 = (PortB << 5) + 0x15,
PB_22 = (PortB << 5) + 0x16,
PB_23 = (PortB << 5) + 0x17,

#endif
#if defined GPIOC_BASE
PC_0 = (PortC << 5) + 0x00,
PC_1 = (PortC << 5) + 0x01,
PC_2 = (PortC << 5) + 0x02,
PC_3 = (PortC << 5) + 0x03,
PC_4 = (PortC << 5) + 0x04,
PC_5 = (PortC << 5) + 0x05,
PC_6 = (PortC << 5) + 0x06,
PC_7 = (PortC << 5) + 0x07,
PC_8 = (PortC << 5) + 0x08,
PC_9 = (PortC << 5) + 0x09,
PC_10 = (PortC << 5) + 0x0A,
PC_11 = (PortC << 5) + 0x0B,
PC_12 = (PortC << 5) + 0x0C,
PC_13 = (PortC << 5) + 0x0D,
PC_14 = (PortC << 5) + 0x0E,
PC_15 = (PortC << 5) + 0x0F,
PC_16 = (PortC << 5) + 0x10,
PC_17 = (PortC << 5) + 0x11,
PC_18 = (PortC << 5) + 0x12,
PC_19 = (PortC << 5) + 0x13,
PC_20 = (PortC << 5) + 0x14,
PC_21 = (PortC << 5) + 0x15,
PC_22 = (PortC << 5) + 0x16,
PC_23 = (PortC << 5) + 0x17,
#endif

// Specific pin name
PADC_BASE = PNAME_ANALOG_INTERNAL_BASE,
#if defined(ADC_Channel_TempSensor)
PADC_TEMP,
#endif
#ifdef ADC_Channel_Vrefint
PADC_VREF,
#endif
#ifdef ADC_Channel_Vbat
PADC_VBAT,
#endif
ANA_START,
#ifdef SYSCFG_PMCSETR_ANA0_SEL_Pos
ANA_0,
#endif
#ifdef SYSCFG_PMCSETR_ANA1_SEL_Pos
ANA_1,
#endif
// Specific pin name define in the variant
#if __has_include("PinNamesVar.h")
#include "PinNamesVar.h"
#endif
P_END = NC
} PinName;


#endif


#ifdef __cplusplus
}
#endif
Expand Down
20 changes: 19 additions & 1 deletion cores/arduino/ch32/PinNamesTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ typedef enum {
#define PULLUP (1)
#define PILLDOWN (2)


#if !defined(CH32X035)
// High nibble = port number (FirstPort <= PortName <= LastPort)
// Low nibble = pin number
#define CH_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
Expand All @@ -209,10 +211,26 @@ typedef enum {
// As FirstPort is equal to 0 and CH_PORT cast as an unsigned
// (CH_PORT(X) >= FirstPort) is always true
//#define CH_VALID_PINNAME(X) ((CH_PORT(X) >= FirstPort) && (CH_PORT(X) <= LastPort))
#define CH_VALID_PINNAME(X) (CH_PORT(X) <= LastPort)

#define CH_VALID_PINNAME(X) (CH_PORT(X) <= LastPort)
#define CH_GPIO_PIN(X) ((uint16_t)(1<<CH_PIN(X)))

#else

// High nibble = port number (FirstPort <= PortName <= LastPort)
// Low nibble = pin number
#define CH_PORT(X) (((uint32_t)(X) >> 5) & 0x7)
#define CH_PIN(X) ((uint32_t)(X) & 0x1F)

// Check PinName is valid: FirstPort <= PortName <= LastPort
// As FirstPort is equal to 0 and CH_PORT cast as an unsigned
// (CH_PORT(X) >= FirstPort) is always true
//#define CH_VALID_PINNAME(X) ((CH_PORT(X) >= FirstPort) && (CH_PORT(X) <= LastPort))
#define CH_VALID_PINNAME(X) (CH_PORT(X) <= LastPort)
#define CH_GPIO_PIN(X) ((uint32_t)(1<<CH_PIN(X)))

#endif

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion cores/arduino/ch32/PortNames.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

GPIO_TypeDef *GPIOPort[MAX_NB_PORT] = {
GPIOA
#if defined PGIOB_BASE
#if defined GPIOB_BASE
, GPIOB
#endif
#if defined GPIOC_BASE
Expand Down
Loading

0 comments on commit 9871543

Please sign in to comment.