Skip to content

Commit

Permalink
Add GD32C1xx support, clean up errors that svd2rust was complaining a…
Browse files Browse the repository at this point in the history
…bout.
  • Loading branch information
sparrowgrine committed Dec 10, 2023
1 parent 2c3e9cf commit 19f8910
Show file tree
Hide file tree
Showing 14 changed files with 68,323 additions and 3 deletions.
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 2022 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 2022 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
249 changes: 249 additions & 0 deletions peripherals/can/can_c1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
# Copyright 2021 The gd32-rs authors.
#
# SPDX-License-Identifier: MIT OR Apache-2.0

"CAN*":
CTL:
DFZ:
Continue: [0, "Continue running CAN during debug"]
Stop: [1, "Stop CAN reception and transmission during debug hold"]
SWRST:
_read:
NotResetting: [0, "Finished resetting"]
Resetting: [1, "Reset in progress"]
_write:
Reset: [1, "Reset CAN"]
TTC:
Disabled: [0, "Disable time-triggered communication"]
Enabled: [1, "Enable time-triggered communication"]
ABOR:
Manual: [0, "Bus off state is set by software"]
Automatic: [1, "Bus off state is set automatically by hardware"]
AWU:
Manual: [0, "Sleep state is set by software"]
Automatic: [1, "Sleep state is set automatically by hardware"]
ARD:
Enabled: [0, "Enable automatic retransmission"]
Disabled: [1, "Disable automatic retransmission"]
RFOD:
Overwrite: [0, "Overwrite full receive FIFO with incoming frame"]
Discard: [1, "Discard incoming frame when receive FIFO is full"]
TFO:
Identifier: [0, "Order by identifier of the frame"]
FIFO: [1, "First in first out order"]
SLPWMOD:
Active: [0, "Disable sleep mode, bus activity detected"]
Sleep: [1, "Enable sleep mode"]
IWMOD:
Disabled: [0, "Disable initial working mode"]
Enabled: [1, "Enable initial working mode"]
STAT:
RXL:
LASTRX:
RS:
NotWorking: [0, "CAN is not working in receiving state"]
Working: [1, "CAN is working in receiving state"]
TS:
NotWorking: [0, "CAN is not working in transmitting state"]
Working: [1, "CAN is working in transmitting state"]
SLPIF:
_read:
Awake: [0, "CAN is not entering sleep working mode"]
Sleeping: [1, "CAN is entering sleep working mode"]
_write:
Clear: [1, "Clears flag"]
WUIF:
_read:
NoWakeup: [0, "No wakeup event"]
Wakeup: [1, "Wakeup event"]
_write:
Clear: [1, "Clears flag"]
ERRIF:
_read:
NoError: [0, "There was no error"]
Error: [1, "An error was detected"]
_write:
Clear: [1, "Clears flag"]
SLPWS:
Normal: [0, "CAN is not in sleep working mode"]
Sleeping: [1, "CAN is in sleep working mode"]
IWS:
Normal: [0, "CAN is not in initial working mode"]
Initial: [1, "CAN is in initial working mode"]
TSTAT:
"TMLS?":
NotLast: [0, "The mailbox doesn't have the last sending order"]
Last:
[
1,
"The mailbox has the last sending order with at least two frames pending",
]
"TME?":
NotEmpty: [0, "Transmit mailbox not empty"]
Empty: [1, "Transmit mailbox is empty"]
NUM: [0, 2]
"MST?":
_read:
NotStop: [0, "Mailbox is not stopped, or is empty"]
Stop: [1, "Stop mailbox transmitting"]
_write:
Stop: [1, "Stop mailbox transmitting"]
"MTE?":
_read:
NoError: [0, "There was no error"]
Error: [1, "An error was detected"]
_write:
Clear: [1, "Clears error flag"]
"MAL?":
_read:
NoArbitrationLost: [0, "Arbitration was not lost"]
ArbitrationLost: [1, "Arbitration lost"]
_write:
Clear: [1, "Clears flag"]
"MTFNERR?":
_read:
FinishedWithError: [0, "Mailbox transmission finished with an error"]
FinishedNoError: [1, "Mailbox transmission finished with no error"]
_write:
Clear: [1, "Clears flag"]
"MTF?":
_read:
InProgress: [0, "Mailbox transmission still in progress"]
Finished: [1, "Mailbox transmission finished"]
_write:
Clear: [1, "Clears flag"]
"RFIFO?":
"RFD?":
_read:
Finished: [0, "Dequeuing done"]
InProgress: [1, "Dequeuing in progress"]
_write:
Start: [1, "Start dequeuing"]
"RFO?":
_read:
NotOverfull: [0, "Receive FIFO is not overfull"]
Overfull: [1, "Receive FIFO is overfull"]
_write:
Clear: [1, "Clears flag"]
"RFF?":
_read:
NotFull: [0, "Receive FIFO is not full"]
Full: [1, "Receive FIFO is full"]
_write:
Clear: [1, "Clears flag"]
"RFL?": [0, 3]
INTEN:
SLPWIE:
Disabled: [0, "Sleep working interrupt is disabled"]
Enabled: [1, "Sleep working interrupt is enabled"]
WIE:
Disabled: [0, "Wakeup interrupt is disabled"]
Enabled: [1, "Wakeup interrupt is enabled"]
ERRIE:
Disabled: [0, "Error interrupt is disabled"]
Enabled: [1, "Error interrupt is enabled"]
ERRNIE:
Disabled: [0, "Error number interrupt is disabled"]
Enabled: [1, "Error number interrupt is enabled"]
BOIE:
Disabled: [0, "Bus-off interrupt is disabled"]
Enabled: [1, "Bus-off interrupt is enabled"]
PERRIE:
Disabled: [0, "Passive error interrupt is disabled"]
Enabled: [1, "Passive error interrupt is enabled"]
WERRIE:
Disabled: [0, "Warning error interrupt is disabled"]
Enabled: [1, "Warning error interrupt is enabled"]
"RFOIE?":
Disabled: [0, "Receive FIFO overfull interrupt is disabled"]
Enabled: [1, "Receive FIFO overfull interrupt is enabled"]
"RFFIE?":
Disabled: [0, "Receive FIFO full interrupt is disabled"]
Enabled: [1, "Receive FIFO full interrupt is enabled"]
"RFNEIE?":
Disabled: [0, "Receive FIFO not empty interrupt is disabled"]
Enabled: [1, "Receive FIFO not empty interrupt is enabled"]
TMEIE:
Disabled: [0, "Transmit mailbox empty interrupt is disabled"]
Enabled: [1, "Transmit mailbox empty interrupt is enabled"]
ERR:
RECNT: [0, 0xFF]
TECNT: [0, 0xFF]
ERRN:
NoError: [0, "No Error"]
Stuff: [1, "Stuff Error"]
Form: [2, "Form Error"]
Ack: [3, "Acknowledgment Error"]
BitRecessive: [4, "Bit recessive Error"]
BitDominant: [5, "Bit dominant Error"]
Crc: [6, "CRC Error"]
Custom: [7, "Set by software"]
BOERR:
NoError: [0, "No bus-off error"]
Error: [1, "Bus-off error"]
PERR:
NoError: [0, "No passive error"]
Error: [1, "Passive error"]
WERR:
NoError: [0, "No warning error"]
Error: [1, "Warning error"]
BT:
SCMOD:
Normal: [0, "Normal operation"]
Silent: [1, "Silent Mode"]
LCMOD:
Disabled: [0, "Loop Back Mode disabled"]
Enabled: [1, "Loop Back Mode enabled"]
SJW: [0, 3]
"BS?_0_?": [0, 3]
BAUDPSC: [0, 0x3FF]
"TMI?,RFIFOMI?":
SFID:
EFID:
FF:
Standard: [0, "Standard format frame"]
Extended: [1, "Extended format frame"]
FT:
Data: [0, "Data frame"]
Remote: [1, "Remote frame"]
"TMI?":
TEN:
Disabled: [0, "Transmit disabled"]
Enabled: [1, "Transmit enabled"]
"TMP?":
TS: [0, 0xFFFF]
TSEN:
Disabled: [0, "Timestamp disabled"]
Enabled: [1, "Timestamp enabled"]
DLENC: [0, 0xF]
"TMDATA*":
"DB?": [0, 0xFF]
"RFIFOMP?":
TS: [0, 0xFFFF]
FI: [0, 0xFF]
DLENC: [0, 0xF]
"RFIFOMDATA*":
"DB?": [0, 0xFF]
FCTL:
HBC1F: [0, 28]
FLD:
Disabled: [0, "Filter lock disabled"]
Enabled: [1, "Filter lock enabled"]
FMCFG:
"FMOD*":
Mask: [0, "Mask mode"]
List: [1, "List mode"]
FSCFG:
"FS*":
Scale16: [0, "Filter with 16-bit scale"]
Scale32: [1, "Filter with 32-bit scale"]
FAFIFO:
"FAF*":
FIFO0: [0, "Filter associated with FIFO0"]
FIFO1: [1, "Filter associated with FIFO1"]
FW:
"FW*":
Disabled: [0, "Filter working disabled"]
Enabled: [1, "Filter working enabled"]
"F*DATA?":
"FD*": # Meaning is different in mask mode or list mode
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]
Loading

0 comments on commit 19f8910

Please sign in to comment.