Skip to content

Commit

Permalink
Merge pull request #53 from sparrowgrine/main
Browse files Browse the repository at this point in the history
Add GD32C1xx support
  • Loading branch information
qwandor authored Dec 14, 2023
2 parents 2c3e9cf + 9ea1e09 commit f7462e9
Show file tree
Hide file tree
Showing 16 changed files with 68,112 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
strategy:
matrix:
crate:
- gd32c1
- gd32e1
- gd32e2
- gd32e5
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## [unreleased]

- GD32C1x3
- Added support for GD32C103 and GD32C113 in new `gd32c1` crate.
- GD32E103
- Fixed range of `I2C*.CTL1.I2CCLK` and `I2C*.RT.RISETIME`.
- Fixed range of `DAC.DACC_R8DH.DAC*_DH`.
- Fixed range of `CAN*.BT.BAUDPSC`.
- GD32F1x0
- Fixed width of `I2C*.CTL1.I2CCLK` and `I2C*.RT.RISETIME` to be 7 bits rather than 6.
- Fixed range of `DAC.DACC_R8DH.DAC*_DH`.
- Fixed range of `CAN*.BT.BAUDPSC`.
- GD32F20x
- Fixed range of `I2C*.CTL1.I2CCLK` and `I2C*.RT.RISETIME`.
- Fixed range of `DAC.DACC_R8DH.DAC*_DH`.
- Fixed range of `CAN*.BT.BAUDPSC`.
- GD32F30x
- Fixed range of `DAC.DACC_R8DH.DAC*_DH`.
- Fixed range of `CAN*.BT.BAUDPSC`.

## [0.8.0]

- Updated to `critical-section` to 1.1.2.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ all: patch svd2rust

SHELL := /usr/bin/env bash

CRATES ?= gd32e1 gd32e2 gd32e5 gd32f1 gd32f2 gd32f3
CRATES ?= gd32e1 gd32c1 gd32e2 gd32e5 gd32f1 gd32f2 gd32f3

# All yaml files in devices/ will be used to patch an SVD
YAMLS := $(foreach crate, $(CRATES), \
Expand Down
9 changes: 9 additions & 0 deletions devices/common_patches/gd32f1x0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ TIMER15:
name: "PECV"
TRS:
name: "TR"
CTL1:
_modify:
I2CCLK:
bitWidth: 7
RT:
_modify:
RISETIME:
bitWidth: 7

"SPI*":
STAT:
_modify:
Expand Down
4 changes: 4 additions & 0 deletions devices/common_patches/gd32f205_207.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
_modify:
DISSTRC:
name: SS
CTL1:
I2CCLK: [2,60]
RT:
RISETIME: [0,63]
SADDR0:
_merge: ["ADDRESS*"]
STAT1:
Expand Down
25 changes: 25 additions & 0 deletions devices/gd32c103.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 The gd32-rs authors.
#
# SPDX-License-Identifier: MIT OR Apache-2.0

_svd: ../svd/gd32c103.svd

_include:
- common_patches/gd32e1xx.yaml
- ../peripherals/adc/adc_e1.yaml
- ../peripherals/can/can_c1.yaml
- ../peripherals/crc/crc.yaml
- ../peripherals/dac/dac_e1.yaml
- ../peripherals/dbg/dbg_e1.yaml
- ../peripherals/dma/dma.yaml
- ../peripherals/exti/exti.yaml
- ../peripherals/flash/flash_e1.yaml
- ../peripherals/fwdgt/fwdgt_f2_f3.yaml
- ../peripherals/gpio/gpio_e1.yaml
- ../peripherals/i2c/i2c_e1.yaml
- ../peripherals/pmu/pmu.yaml
- ../peripherals/rcu/rcu_e1.yaml
- ../peripherals/spi/spi_e1.yaml
- ../peripherals/timer/timers_e1.yaml
- ../peripherals/usart/usart_f2_f3.yaml
- ../peripherals/wwdg/wwdg.yaml
25 changes: 25 additions & 0 deletions devices/gd32c113.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 The gd32-rs authors.
#
# SPDX-License-Identifier: MIT OR Apache-2.0

_svd: ../svd/gd32c113.svd

_include:
- common_patches/gd32e1xx.yaml
- ../peripherals/adc/adc_e1.yaml
- ../peripherals/can/can_c1.yaml
- ../peripherals/crc/crc.yaml
- ../peripherals/dac/dac_e1.yaml
- ../peripherals/dbg/dbg_e1.yaml
- ../peripherals/dma/dma.yaml
- ../peripherals/exti/exti.yaml
- ../peripherals/flash/flash_e1.yaml
- ../peripherals/fwdgt/fwdgt_f2_f3.yaml
- ../peripherals/gpio/gpio_e1.yaml
- ../peripherals/i2c/i2c_e1.yaml
- ../peripherals/pmu/pmu.yaml
- ../peripherals/rcu/rcu_e1.yaml
- ../peripherals/spi/spi_e1.yaml
- ../peripherals/timer/timers_e1.yaml
- ../peripherals/usart/usart_f2_f3.yaml
- ../peripherals/wwdg/wwdg.yaml
15 changes: 15 additions & 0 deletions gd32_part_table.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ gd32e1:
rm_url: https://www.gigadevice.com/manual/gd32e103xx-user-manual/
members:
- GD32E103
gd32c1:
gd32c103:
url: https://www.gigadevice.com/products/microcontrollers/gd32/arm-cortex-m4/value-line/gd32c103-series/
rm: GD32C103
rm_title: GD32C103
rm_url: https://gd32mcu.com/download/down/document_id/269/path_type/1
members:
- GD32C103
gd32c113:
url: https://www.gigadevice.com/products/microcontrollers/gd32/arm-cortex-m4/value-line/gd32c113-series/
rm: GD32C103
rm_title: GD32C113
rm_url: https://gd32mcu.com/download/down/document_id/382/path_type/1
members:
- GD32C113
gd32e2:
gd32e230:
url: https://www.gigadevice.com/products/microcontrollers/gd32/arm-cortex-m23/value-line/gd32e230-series/
Expand Down
17 changes: 17 additions & 0 deletions peripherals/can/can_c1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 The gd32-rs authors.
#
# SPDX-License-Identifier: MIT OR Apache-2.0

"CAN*":
BT:
_modify:
"BS1_0_3":
name: "BS1"
"BS1_4_6":
name: "BS1H"
"BS2_0_2":
name: "BS2"
"BS2_3_4":
name: "BS2H"
_include:
- can_common.yaml
2 changes: 1 addition & 1 deletion peripherals/can/can_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
Enabled: [1, "Loop Back Mode enabled"]
SJW: [0, 3]
"BS?": [0, 3]
BAUDPSC: [0, 0x400]
BAUDPSC: [0, 0x3FF]
"TMI?,RFIFOMI?":
SFID:
EFID:
Expand Down
2 changes: 1 addition & 1 deletion peripherals/dac/dac_2ch_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ DAC:
"DACC_L12DH":
"DAC?_DH": [0, 0xFFF]
"DACC_R8DH":
"DAC?_DH": [0, 0xFFF]
"DAC?_DH": [0, 0xFF]
"DAC[01]_DO":
"DAC?_DO": [0, 0xFFF]
4 changes: 4 additions & 0 deletions peripherals/i2c/i2c_e1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ _include:
FMPEN:
Disabled: [0, "Fast mode plus disabled"]
Enabled: [1, "Fast mode plus (1MHz max) enabled"]
CTL1:
I2CCLK: [2, 60]
RT:
RISETIME: [0, 0x3F]
2 changes: 2 additions & 0 deletions scripts/makecrates.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

CRATE_DOC_FEATURES = {
"gd32e1": ["rt", "gd32e103"],
"gd32c1": ["rt", "gd32c103", "gd32c113"],
"gd32e2": ["rt", "gd32e230", "gd32e231"],
"gd32e5": ["rt", "gd32e503", "gd32e508"],
"gd32f1": ["rt", "gd32f130", "gd32f190"],
Expand All @@ -30,6 +31,7 @@

CRATE_DOC_TARGETS = {
"gd32e1": "thumbv7m-none-eabi",
"gd32c1": "thumbv7m-none-eabi",
"gd32e2": "thumbv8m.base-none-eabi",
"gd32e5": "thumbv8m.base-none-eabi",
"gd32f1": "thumbv7m-none-eabi",
Expand Down
3 changes: 3 additions & 0 deletions svd/extract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# Copy GD32 SVD files and give them lower-case names.
cp vendor/GD32E10x.svd gd32e103.svd

cp vendor/GD32C10x.svd gd32c103.svd
cp vendor/GD32C11x.svd gd32c113.svd

cp vendor/GD32E230.svd gd32e230.svd
cp vendor/GD32E231.svd gd32e231.svd

Expand Down
Loading

0 comments on commit f7462e9

Please sign in to comment.