├── cortex_m
├── .gitignore
├── peripherals
│ ├── bak
│ │ ├── syst.yaml
│ │ ├── tpiu.yaml
│ │ ├── dcb.yaml
│ │ ├── fpu.yaml
│ │ ├── nvic_v6.yaml
│ │ ├── cpuid_v6.yaml
│ │ ├── scb.yaml
│ │ ├── mpu.yaml
│ │ ├── cpb.yaml
│ │ ├── fpb.yaml
│ │ └── cpuid_v7.yaml
│ ├── syst.yaml
│ ├── dcb.yaml
│ ├── scb_v7.yaml
│ ├── fpu.yaml
│ ├── nvic_v6.yaml
│ ├── tpiu.yaml
│ ├── cpuid_v6.yaml
│ ├── scb.yaml
│ ├── mpu.yaml
│ ├── cpb.yaml
│ ├── fpb.yaml
│ └── cpuid_v7.yaml
├── armv8m.yaml
├── Makefile
├── armv6m.yaml
├── README.md
├── armv7m.yaml
├── armv7em.yaml
├── armv6m.svd
├── armv7em.svd
├── armv7m.svd
└── armv8m.svd
├── devices
├── common_patches
│ ├── timer_ccr_reg_array.yaml
│ ├── adc_rw.yaml
│ ├── flash_f040_rename.yaml
│ ├── f002b_dbg.yaml
│ ├── spi_f002b.yaml
│ ├── usart_f040_rename.yaml
│ ├── syscfg_f002b.yaml
│ ├── dma_cluster.yaml
│ ├── usart_dr8.yaml
│ ├── spi_dr8.yaml
│ ├── rtc_040_renames.yaml
│ ├── syscfg_f002a.yaml
│ ├── isr_array.yaml
│ └── pwr_f002a.yaml
├── py32f002a.yaml
├── py32f002b.yaml
├── py32f003.yaml
├── py32f030.yaml
└── py32f040.yaml
├── peripherals
├── crc
│ └── crc_f0.yaml
├── dbg
│ ├── dbg_f002b.yaml
│ ├── dbg_f002a.yaml
│ └── dbg_f0.yaml
├── iwdg
│ ├── iwdg_f002b.yaml
│ └── iwdg_f0.yaml
├── wwdg
│ └── wwdg_f0.yaml
├── syscfg
│ ├── syscfg_f002a.yaml
│ ├── syscfg_f002b.yaml
│ ├── syscfg_f0.yaml
│ └── syscfg_f040.yaml
├── pwr
│ ├── pwr_f002b.yaml
│ ├── pwr_f002a.yaml
│ ├── pwr_f040.yaml
│ └── pwr_f0.yaml
├── lptim
│ └── lptim_f0.yaml
├── exti
│ └── exti_f0.yaml
├── comp
│ ├── comp_f002b.yaml
│ ├── comp_f040.yaml
│ └── comp_f0.yaml
├── led
│ └── led_f0.yaml
├── gpio
│ └── gpio_f0.yaml
├── rtc
│ └── rtc_f0.yaml
├── dma
│ └── dma_f0.yaml
├── lcd
│ └── lcd_f0.yaml
├── flash
│ ├── flash_f040.yaml
│ ├── flash_f002a.yaml
│ ├── flash_f002b.yaml
│ └── flash_f0.yaml
├── spi
│ ├── spi_f002b.yaml
│ ├── spi_f002a.yaml
│ ├── spi_f040.yaml
│ └── spi_f0.yaml
├── i2c
│ ├── i2c_f002a.yaml
│ ├── i2c_f002b.yaml
│ └── i2c_f0.yaml
├── usart
│ ├── usart_f002b.yaml
│ ├── usart_f002a.yaml
│ └── usart_f0.yaml
└── rcc
│ ├── rcc_f002a.yaml
│ └── rcc_f002b.yaml
├── .gitignore
├── svd
└── extract.sh
├── Makefile.toml
├── .github
└── workflows
│ ├── changelog.yaml
│ ├── gh-pages.yaml
│ ├── ci.yaml
│ └── cargo-make.yaml
├── scripts
├── comparesvd.py
├── htmlcomparesvdall.sh
├── interrupts.py
├── tool_install.sh
├── makehtml.index.template.html
├── timer_hierarchy.py
├── viewgroups.html
├── README.md
├── periphtemplate.py
├── matchperipherals.py
└── makejson.py
├── LICENSE-MIT
├── CHANGELOG.md
├── py32_part_table.yaml
└── Makefile
/cortex_m/.gitignore:
--------------------------------------------------------------------------------
1 | *.patched
2 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/bak/syst.yaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/bak/tpiu.yaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/cortex_m/armv8m.yaml:
--------------------------------------------------------------------------------
1 | _svd: armv8m.svd
2 |
3 | # No files included yet.
4 |
--------------------------------------------------------------------------------
/devices/common_patches/timer_ccr_reg_array.yaml:
--------------------------------------------------------------------------------
1 | _array:
2 | CCR*: {}
3 |
--------------------------------------------------------------------------------
/devices/common_patches/adc_rw.yaml:
--------------------------------------------------------------------------------
1 | SR:
2 | _modify:
3 | OVER:
4 | access: read-write
5 |
--------------------------------------------------------------------------------
/devices/common_patches/flash_f040_rename.yaml:
--------------------------------------------------------------------------------
1 | OPTR:
2 | _modify:
3 | NBOOT1:
4 | name: nBOOT1
5 |
--------------------------------------------------------------------------------
/devices/common_patches/f002b_dbg.yaml:
--------------------------------------------------------------------------------
1 | APB_FZ2:
2 | _modify:
3 | DBG_TIM14_STOP:
4 | name: DBG_TIMER14_STOP
5 |
--------------------------------------------------------------------------------
/devices/common_patches/spi_f002b.yaml:
--------------------------------------------------------------------------------
1 | # Rename DDF field in CR1 to DFF to match datasheet
2 | CR1:
3 | _modify:
4 | DDF:
5 | name: DFF
6 | description: desc DFF
7 |
--------------------------------------------------------------------------------
/devices/common_patches/usart_f040_rename.yaml:
--------------------------------------------------------------------------------
1 | BRR:
2 | _modify:
3 | DIV_FRACTION:
4 | name: DIV_Fraction
5 | DIV_MANTISSA:
6 | name: DIV_Mantissa
7 | CR3:
8 | _modify:
9 | ABRMODE:
10 | name: ABRMOD
11 |
--------------------------------------------------------------------------------
/peripherals/crc/crc_f0.yaml:
--------------------------------------------------------------------------------
1 | CRC:
2 | DR:
3 | DR: [0, 4294967295]
4 | IDR:
5 | IDR: [0, 255]
6 | CR:
7 | RESET:
8 | _write:
9 | Reset: [1, "Resets the CRC calculation unit and sets the data register to 0xFFFF FFFF"]
10 |
--------------------------------------------------------------------------------
/cortex_m/Makefile:
--------------------------------------------------------------------------------
1 | all: patch
2 |
3 | YAMLS := $(wildcard *.yaml)
4 | PATCHED_SVDS := $(patsubst %.yaml, %.svd.patched, $(YAMLS))
5 |
6 | %.svd.patched: %.yaml %.svd
7 | svd patch $<
8 |
9 | patch: $(PATCHED_SVDS)
10 |
11 | clean:
12 | rm -f $(PATCHED_SVDS)
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | **/__pycache__/
2 | **/target/
3 | **/*.rs.bk
4 | **/Cargo.lock
5 | .deps/
6 | */src/py32*/
7 | */src/generic.rs
8 | html/
9 | mmaps/
10 | /venv
11 | .devcontainer
12 | svd/*.svd*
13 | svd/.extracted
14 |
15 | # automatically generated crates
16 | /py32*/
17 |
--------------------------------------------------------------------------------
/svd/extract.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Copy svd files and rename to remove trailing 'x'
4 | cp vendor/PY32F002Axx.svd py32f002a.svd
5 | cp vendor/PY32F002Bxx.svd py32f002b.svd
6 | cp vendor/PY32F003xx.svd py32f003.svd
7 | cp vendor/PY32F030xx.svd py32f030.svd
8 | cp vendor/py32f040xx.svd py32f040.svd
9 |
--------------------------------------------------------------------------------
/devices/common_patches/syscfg_f002b.yaml:
--------------------------------------------------------------------------------
1 | SYSCFG:
2 | CFGR2:
3 | _add:
4 | COMP1_BRK_TIM1:
5 | description: "COMP1 output connect to TIM1 Break input"
6 | bitOffset: 3
7 | bitWidth: 1
8 | COMP2_BRK_TIM1:
9 | description: "COMP2 output connect to TIM1 Break input"
10 | bitOffset: 4
11 | bitWidth: 1
--------------------------------------------------------------------------------
/devices/common_patches/dma_cluster.yaml:
--------------------------------------------------------------------------------
1 | _cluster:
2 | "CH%s":
3 | description: "Channel cluster: CCR?, CNDTR?, CPAR?, and CMAR? registers"
4 | "CCR?":
5 | name: CR
6 | "CNDTR?":
7 | name: NDTR
8 | "CPAR?":
9 | name: PAR
10 | "CMAR?":
11 | name: MAR
12 |
13 | _include:
14 | - isr_array.yaml
15 |
--------------------------------------------------------------------------------
/devices/common_patches/usart_dr8.yaml:
--------------------------------------------------------------------------------
1 | _add:
2 | DR8:
3 | description: Direct 8-bit access to data register
4 | access: read-write
5 | addressOffset: 0x4
6 | alternateRegister: DR
7 | size: 0x8
8 | fields:
9 | DR:
10 | bitOffset: 0
11 | bitWidth: 8
12 | description: Data register
13 |
14 | DR8:
15 | DR: [0, 0xFF]
16 |
--------------------------------------------------------------------------------
/devices/common_patches/spi_dr8.yaml:
--------------------------------------------------------------------------------
1 | _add:
2 | DR8:
3 | description: Direct 8-bit access to data register
4 | access: read-write
5 | addressOffset: 0xC
6 | alternateRegister: DR
7 | size: 0x8
8 | fields:
9 | DR:
10 | bitOffset: 0
11 | bitWidth: 8
12 | description: Data register
13 |
14 | DR8:
15 | DR: [0, 0xFF]
16 |
17 |
--------------------------------------------------------------------------------
/Makefile.toml:
--------------------------------------------------------------------------------
1 | [tasks.crates]
2 | command = "make"
3 | args = ["crates"]
4 |
5 | [tasks.install]
6 | command = "make"
7 | args = ["install"]
8 |
9 | [tasks.patch]
10 | command = "make"
11 | args = ["patch"]
12 |
13 | [tasks.svd2rust]
14 | command = "make"
15 | args = ["svd2rust"]
16 |
17 | [tasks.form]
18 | command = "make"
19 | args = ["form"]
20 |
21 | [tasks.check]
22 | command = "make"
23 | args = ["check"]
24 |
25 | [tasks.clean]
26 | command = "make"
27 | args = ["clean"]
28 |
--------------------------------------------------------------------------------
/cortex_m/armv6m.yaml:
--------------------------------------------------------------------------------
1 | _svd: armv6m.svd
2 |
3 | _include:
4 | - peripherals/cpuid_v6.yaml
5 | - peripherals/dcb.yaml
6 | - peripherals/dwt.yaml
7 | # These three peripherals are included in the ST SVD files, so don't
8 | # include them in the generic ARMv6-M SVD as well.
9 | # Uncomment them here if you want to include them for some other reason.
10 | #- peripherals/mpu.yaml
11 | #- peripherals/nvic.yaml
12 | #- peripherals/nvic_v6.yaml
13 | #- peripherals/scb.yaml
14 | - peripherals/syst.yaml
15 |
--------------------------------------------------------------------------------
/cortex_m/README.md:
--------------------------------------------------------------------------------
1 | # Cortex-M SVD files
2 |
3 | We can use the existing SVD patching framework to build SVD files which define
4 | the peripherals common to all Cortex-M devices.
5 |
6 | The base SVD files are `armv6m.svd`, `armv7m.svd`, and `armv7em.svd`, which do
7 | not contain any peripherals. They are patched to create `armv6m.svd.patched`
8 | and `armv7m.patched` using `svd patch` and the `armv6m.yaml` and
9 | `armv7m.yaml` device files. The peripheral definitions all come from
10 | the `peripherals/` directory.
11 |
--------------------------------------------------------------------------------
/devices/common_patches/rtc_040_renames.yaml:
--------------------------------------------------------------------------------
1 | PRLH:
2 | _modify:
3 | PRL:
4 | name: PRLH
5 | PRLL:
6 | _modify:
7 | PRL:
8 | name: PRLL
9 | DIVH:
10 | _modify:
11 | DIV:
12 | name: DIVH
13 | DIVL:
14 | _modify:
15 | DIV:
16 | name: DIVL
17 | CNTH:
18 | _modify:
19 | RTC_CNT:
20 | name: CNTH
21 | CNTL:
22 | _modify:
23 | RTC_CNT:
24 | name: CNTL
25 | ALRH:
26 | _modify:
27 | RTC_ALR:
28 | name: ALRH
29 | ALRL:
30 | _modify:
31 | RTC_ALR:
32 | name: ALRL
33 | _modify:
34 | BKP_RTCCR:
35 | name: RTCCR
36 |
--------------------------------------------------------------------------------
/devices/common_patches/syscfg_f002a.yaml:
--------------------------------------------------------------------------------
1 | SYSCFG:
2 | CFGR2:
3 | _add:
4 | COMP1_BRK_TIM1:
5 | description: "COMP1 output connect to TIM1 Break input"
6 | bitOffset: 3
7 | bitWidth: 1
8 | COMP2_BRK_TIM1:
9 | description: "COMP2 output connect to TIM1 Break input"
10 | bitOffset: 4
11 | bitWidth: 1
12 | COMP1_BRK_TIM16:
13 | description: "COMP1 output connect to TIM16 Break input"
14 | bitOffset: 5
15 | bitWidth: 1
16 | COMP2_BRK_TIM16:
17 | description: "COMP2 output connect to TIM16 Break input"
18 | bitOffset: 6
19 | bitWidth: 1
--------------------------------------------------------------------------------
/cortex_m/armv7m.yaml:
--------------------------------------------------------------------------------
1 | _svd: armv7m.svd
2 |
3 | _include:
4 | - peripherals/cpb.yaml
5 | - peripherals/cpuid_v7.yaml
6 | - peripherals/dcb.yaml
7 | - peripherals/dwt.yaml
8 | - peripherals/fpb.yaml
9 | - peripherals/itm.yaml
10 | # These three peripherals are included in the ST SVD files, so don't
11 | # include them in the generic ARMv7-M SVD as well.
12 | # Uncomment them here if you want to include them for some other reason.
13 | #- peripherals/mpu.yaml
14 | #- peripherals/nvic.yaml
15 | #- peripherals/nvic_v7.yaml
16 | #- peripherals/scb.yaml
17 | #- peripherals/scb_v7.yaml
18 | - peripherals/syst.yaml
19 | - peripherals/tpiu.yaml
20 |
--------------------------------------------------------------------------------
/devices/common_patches/isr_array.yaml:
--------------------------------------------------------------------------------
1 | ISR:
2 | _array:
3 | "TEIF*":
4 | description: Channel %s Transfer Error flag
5 | "HTIF*":
6 | description: Channel %s Half Transfer Complete flag
7 | "TCIF*":
8 | description: Channel %s Transfer Complete flag
9 | "GIF*":
10 | description: Channel %s Global interrupt flag
11 |
12 | IFCR:
13 | _array:
14 | "CTEIF*":
15 | description: Channel %s Transfer Error clear
16 | "CHTIF*":
17 | description: Channel %s Half Transfer clear
18 | "CTCIF*":
19 | description: Channel %s Transfer Complete clear
20 | "CGIF*":
21 | description: Channel %s Global interrupt clear
22 |
--------------------------------------------------------------------------------
/cortex_m/armv7em.yaml:
--------------------------------------------------------------------------------
1 | _svd: armv7em.svd
2 |
3 | _include:
4 | - peripherals/cpb.yaml
5 | - peripherals/cpuid_v7.yaml
6 | - peripherals/dcb.yaml
7 | - peripherals/dwt.yaml
8 | - peripherals/fpb.yaml
9 | # These five peripherals are included in the ST SVD files, so don't
10 | # include them in the generic ARMv7E-M SVD as well.
11 | # Uncomment them here if you want to include them for some other reason.
12 | #- peripherals/fpu.yaml
13 | #- peripherals/mpu.yaml
14 | #- peripherals/nvic.yaml
15 | #- peripherals/nvic_v7.yaml
16 | #- peripherals/scb.yaml
17 | #- peripherals/scb_v7.yaml
18 | - peripherals/itm.yaml
19 | - peripherals/syst.yaml
20 | - peripherals/tpiu.yaml
21 |
--------------------------------------------------------------------------------
/.github/workflows/changelog.yaml:
--------------------------------------------------------------------------------
1 | on:
2 | pull_request:
3 | # Run on labeled/unlabeled in addition to defaults to detect
4 | # adding/removing skip-changelog labels.
5 | types: [ opened, reopened, labeled, unlabeled, synchronize ]
6 | merge_group:
7 |
8 | name: Changelog
9 |
10 | jobs:
11 | changelog:
12 | name: Require Changelog
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout sources
16 | uses: actions/checkout@v3
17 |
18 | - name: Check changelog update
19 | uses: dangoslen/changelog-enforcer@v3
20 | with:
21 | skipLabels: skip-changelog
22 | missingUpdateErrorMessage: 'Please add a changelog entry to the appropriate section of the CHANGELOG.md file.'
23 |
--------------------------------------------------------------------------------
/peripherals/dbg/dbg_f002b.yaml:
--------------------------------------------------------------------------------
1 | _modify:
2 | DBGMCU:
3 | name: DBG
4 |
5 | DBG:
6 | IDCODE:
7 | _add:
8 | CODE:
9 | description: DBG ID code register
10 | bitOffset: 0
11 | bitWidth: 32
12 | CR:
13 | DBG_STOP:
14 | Disabled: [0, "Debug Stop Mode Disabled"]
15 | Enabled: [1, "Debug Stop Mode Enabled"]
16 | APB_FZ1:
17 | DBG_LPTIM_STOP:
18 | Continue: [ 0, "LPTIMx counter clock is fed even if the core is halted" ]
19 | Stop: [ 1, "LPTIMx counter clock is stopped when the core is halted" ]
20 | APB_FZ2:
21 | "DBG_TIM*_STOP":
22 | Continue: [0, "The counter clock of TIMx is fed even if the core is halted"]
23 | Stop: [1, "The counter clock of TIMx is stopped when the core is halted"]
24 |
25 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/syst.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv7-M Architecture Reference Manual issue E.b
2 |
3 | _add:
4 | SYST:
5 | description: System Timer
6 | baseAddress: 0xE000E010
7 | addressBlock:
8 | offset: 0x0
9 | size: 0xF0
10 | registers:
11 | CSR:
12 | description: SysTick Control and Status Register
13 | addressOffset: 0x0
14 | access: read-write
15 | RVR:
16 | description: SysTick Reload Value Register
17 | addressOffset: 0x4
18 | access: read-write
19 | CVR:
20 | description: SysTick Current Value Register
21 | addressOffset: 0x8
22 | access: read-write
23 | CALIB:
24 | description: SysTick Calibration Value Register
25 | addressOffset: 0x1C
26 | access: read-only
27 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/dcb.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv7-M Architecture Reference Manual issue E.b
2 |
3 | _add:
4 | DCB:
5 | description: Debug Control Block
6 | baseAddress: 0xE000EDF0
7 | addressBlock:
8 | offset: 0x0
9 | size: 0x110
10 | registers:
11 | DHCSR:
12 | description: Debug Halting Control and Status Register
13 | addressOffset: 0x0
14 | access: read-write
15 | DCRSR:
16 | description: Debug Core Register Selector Register
17 | addressOffset: 0x4
18 | access: write-only
19 | DCRDR:
20 | description: Debug Core Register Data Register
21 | addressOffset: 0x8
22 | access: read-write
23 | DEMCR:
24 | description: Debug Exception and Monitor Control Register
25 | addressOffset: 0xC
26 | access: read-write
27 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/bak/dcb.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv7-M Architecture Reference Manual issue E.b
2 |
3 | _add:
4 | DCB:
5 | description: Debug Control Block
6 | baseAddress: 0xE000EDF0
7 | addressBlock:
8 | offset: 0x0
9 | size: 0x110
10 | registers:
11 | DHCSR:
12 | description: Debug Halting Control and Status Register
13 | addressOffset: 0x0
14 | access: read-write
15 | DCRSR:
16 | description: Debug Core Register Selector Register
17 | addressOffset: 0x4
18 | access: write-only
19 | DCRDR:
20 | description: Debug Core Register Data Register
21 | addressOffset: 0x8
22 | access: read-write
23 | DEMCR:
24 | description: Debug Exception and Monitor Control Register
25 | addressOffset: 0xC
26 | access: read-write
27 |
--------------------------------------------------------------------------------
/peripherals/iwdg/iwdg_f002b.yaml:
--------------------------------------------------------------------------------
1 | "IWDG,IWDG?":
2 | KR:
3 | KEY:
4 | Enable: [21845, "Enable access to PR, RLR and WINR registers (0x5555)"]
5 | Reset: [43690, "Reset the watchdog value (0xAAAA)"]
6 | Start: [52428, "Start the watchdog (0xCCCC)"]
7 | PR:
8 | PR:
9 | DivideBy4: [0, "Divider /4"]
10 | DivideBy8: [1, "Divider /8"]
11 | DivideBy16: [2, "Divider /16"]
12 | DivideBy32: [3, "Divider /32"]
13 | DivideBy64: [4, "Divider /64"]
14 | DivideBy128: [5, "Divider /128"]
15 | DivideBy256: [6, "Divider /256"]
16 | DivideBy256bis: [7, "Divider /256"]
17 | RLR:
18 | RL: [0, 4095]
19 | SR:
20 | RVU:
21 | Idle: [0, "No update on-going"]
22 | Busy: [1, "Update on-going"]
23 | PVU:
24 | Idle: [0, "No update on-going"]
25 | Busy: [1, "Update on-going"]
26 |
--------------------------------------------------------------------------------
/cortex_m/armv6m.svd:
--------------------------------------------------------------------------------
1 |
2 |
5 | ARMv6-M
6 | 1.0
7 | ARMv6-M Common Peripherals
8 |
9 | CM3
10 | r1p0
11 | little
12 | false
13 | false
14 | 3
15 | false
16 |
17 | 8
18 | 32
19 | 0x20
20 | 0x0
21 | 0xFFFFFFFF
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/cortex_m/armv7em.svd:
--------------------------------------------------------------------------------
1 |
2 |
5 | ARMv7E-M
6 | 1.0
7 | ARMv7E-M Common Peripherals
8 |
9 | CM4
10 | r1p0
11 | little
12 | true
13 | true
14 | 3
15 | false
16 |
17 | 8
18 | 32
19 | 0x20
20 | 0x0
21 | 0xFFFFFFFF
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/cortex_m/armv7m.svd:
--------------------------------------------------------------------------------
1 |
2 |
5 | ARMv7-M
6 | 1.0
7 | ARMv7-M Common Peripherals
8 |
9 | CM4
10 | r1p0
11 | little
12 | true
13 | false
14 | 3
15 | false
16 |
17 | 8
18 | 32
19 | 0x20
20 | 0x0
21 | 0xFFFFFFFF
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/cortex_m/armv8m.svd:
--------------------------------------------------------------------------------
1 |
2 |
5 | ARMv8-M
6 | 1.0
7 | ARMv8-M Common Peripherals
8 |
9 | CM33
10 | r1p0
11 | little
12 | true
13 | false
14 | 3
15 | false
16 |
17 | 8
18 | 32
19 | 0x20
20 | 0x0
21 | 0xFFFFFFFF
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/peripherals/wwdg/wwdg_f0.yaml:
--------------------------------------------------------------------------------
1 | "WWDG,WWDG?":
2 | CR:
3 | WDGA:
4 | Disabled: [0, "Watchdog disabled"]
5 | Enabled: [1, "Watchdog enabled"]
6 | T: [0, 127]
7 | CFR:
8 | _merge:
9 | - "WDGTB*"
10 | WDGTB:
11 | Div1: [0, "Counter clock (PCLK1 div 4096) div 1"]
12 | Div2: [1, "Counter clock (PCLK1 div 4096) div 2"]
13 | Div4: [2, "Counter clock (PCLK1 div 4096) div 4"]
14 | Div8: [3, "Counter clock (PCLK1 div 4096) div 8"]
15 | W: [0, 127]
16 | EWI:
17 | _write:
18 | Enable: [1, "interrupt occurs whenever the counter reaches the value 0x40"]
19 | SR:
20 | EWIF:
21 | _read:
22 | Pending: [1, "The EWI Interrupt Service Routine has been triggered"]
23 | Finished: [0, "The EWI Interrupt Service Routine has been serviced"]
24 | _W0C:
25 | Finished: [0, "The EWI Interrupt Service Routine has been serviced"]
26 |
--------------------------------------------------------------------------------
/scripts/comparesvd.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import xml.etree.ElementTree as ET
3 |
4 | s1 = ET.parse(sys.argv[1])
5 | s2 = ET.parse(sys.argv[2])
6 |
7 |
8 | def getregs(s):
9 | regs = {}
10 | for peripheral in s.iter('peripheral'):
11 | pname = peripheral.find('name').text
12 | base = int(peripheral.find('baseAddress').text, 0)
13 | for register in peripheral.iter('register'):
14 | rname = register.find('name').text
15 | name = pname + "_" + rname
16 | offset = int(register.find('addressOffset').text, 0)
17 | regs[name] = hex(base+offset)
18 | return regs
19 |
20 | r1 = getregs(s1)
21 | r2 = getregs(s2)
22 |
23 | for reg in r1:
24 | if reg not in r2:
25 | print("+A", reg, r1[reg])
26 | else:
27 | if r1[reg] != r2[reg]:
28 | print("X ", reg, r1[reg], r2[reg])
29 | for reg in r2:
30 | if reg not in r1:
31 | print("+B", reg, r2[reg])
32 |
--------------------------------------------------------------------------------
/peripherals/iwdg/iwdg_f0.yaml:
--------------------------------------------------------------------------------
1 | "IWDG,IWDG?":
2 | KR:
3 | KEY:
4 | Enable: [21845, "Enable access to PR, RLR and WINR registers (0x5555)"]
5 | Reset: [43690, "Reset the watchdog value (0xAAAA)"]
6 | Start: [52428, "Start the watchdog (0xCCCC)"]
7 | PR:
8 | PR:
9 | DivideBy4: [0, "Divider /4"]
10 | DivideBy8: [1, "Divider /8"]
11 | DivideBy16: [2, "Divider /16"]
12 | DivideBy32: [3, "Divider /32"]
13 | DivideBy64: [4, "Divider /64"]
14 | DivideBy128: [5, "Divider /128"]
15 | DivideBy256: [6, "Divider /256"]
16 | DivideBy256bis: [7, "Divider /256"]
17 | RLR:
18 | RL: [0, 4095]
19 | SR:
20 | ?~WVU:
21 | Idle: [0, "No update on-going"]
22 | Busy: [1, "Update on-going"]
23 | RVU:
24 | Idle: [0, "No update on-going"]
25 | Busy: [1, "Update on-going"]
26 | PVU:
27 | Idle: [0, "No update on-going"]
28 | Busy: [1, "Update on-going"]
29 | ?~WINR:
30 | WIN: [0, 4095]
31 |
--------------------------------------------------------------------------------
/peripherals/dbg/dbg_f002a.yaml:
--------------------------------------------------------------------------------
1 | _modify:
2 | DBGMCU:
3 | name: DBG
4 |
5 | DBG:
6 | IDCODE:
7 | _add:
8 | CODE:
9 | description: DBG ID code register
10 | bitOffset: 0
11 | bitWidth: 32
12 | CR:
13 | DBG_STOP:
14 | Disabled: [0, "Debug Stop Mode Disabled"]
15 | Enabled: [1, "Debug Stop Mode Enabled"]
16 | APB_FZ1:
17 | DBG_IWDG_STOP:
18 | Continue: [0, "The independent watchdog counter clock continues even if the core is halted"]
19 | Stop: [1, "The independent watchdog counter clock is stopped when the core is halted"]
20 | DBG_LPTIM_STOP:
21 | Continue: [ 0, "LPTIMx counter clock is fed even if the core is halted" ]
22 | Stop: [ 1, "LPTIMx counter clock is stopped when the core is halted" ]
23 | APB_FZ2:
24 | "DBG_TIM*_STOP":
25 | Continue: [0, "The counter clock of TIMx is fed even if the core is halted"]
26 | Stop: [1, "The counter clock of TIMx is stopped when the core is halted"]
27 |
28 |
--------------------------------------------------------------------------------
/devices/py32f002a.yaml:
--------------------------------------------------------------------------------
1 | _svd: ../svd/py32f002a.svd
2 |
3 | "SPI*":
4 | _include:
5 | - common_patches/spi_dr8.yaml
6 |
7 | "USART*":
8 | _include:
9 | - common_patches/usart_dr8.yaml
10 |
11 | TIM1:
12 | _include:
13 | - common_patches/timer_ccr_reg_array.yaml
14 |
15 | _include:
16 | - ./common_patches/pwr_f002a.yaml
17 | - ./common_patches/syscfg_f002a.yaml
18 | - ../peripherals/flash/flash_f002a.yaml
19 | - ../peripherals/pwr/pwr_f002a.yaml
20 | - ../peripherals/rcc/rcc_f002a.yaml
21 | - ../peripherals/gpio/gpio_f0.yaml
22 | - ../peripherals/syscfg/syscfg_f002a.yaml
23 | - ../peripherals/exti/exti_f0.yaml
24 | - ../peripherals/crc/crc_f0.yaml
25 | - ../peripherals/adc/adc_f002a.yaml
26 | - ../peripherals/comp/comp_f0.yaml
27 | - ../peripherals/tim/tim_f002a.yaml
28 | - ../peripherals/lptim/lptim_f0.yaml
29 | - ../peripherals/iwdg/iwdg_f0.yaml
30 | - ../peripherals/i2c/i2c_f002a.yaml
31 | - ../peripherals/usart/usart_f002a.yaml
32 | - ../peripherals/spi/spi_f002a.yaml
33 | - ../peripherals/dbg/dbg_f002a.yaml
34 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/scb_v7.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv7-M Architecture Reference Manual issue E.b
2 |
3 | SCB:
4 | _add:
5 | _registers:
6 | SHPR1:
7 | description: System Handler Priority Register 1
8 | addressOffset: 0x18
9 | access: read-write
10 | CFSR:
11 | description: Configurable Fault Status Register
12 | addressOffset: 0x28
13 | access: read-write
14 | HFSR:
15 | description: HardFault Status Register
16 | addressOffset: 0x2C
17 | access: read-write
18 | MMFAR:
19 | description: MemManage Fault Address Register
20 | addressOffset: 0x34
21 | access: read-write
22 | BFAR:
23 | description: BusFault Address Register
24 | addressOffset: 0x38
25 | access: read-write
26 | AFSR:
27 | description: Auxiliary Fault Status Register
28 | addressOffset: 0x3C
29 | access: read-write
30 | CPACR:
31 | description: Coprocessor Access Control Register
32 | addressOffset: 0x88
33 | access: read-write
34 |
--------------------------------------------------------------------------------
/peripherals/syscfg/syscfg_f002a.yaml:
--------------------------------------------------------------------------------
1 | SYSCFG:
2 | CFGR1:
3 | MEM_MODE:
4 | MainFlash: [0, "Main Flash memory mapped at 0x0000_0000"]
5 | SystemFlash: [1, "System Flash memory mapped at 0x0000_0000"]
6 | MainFlash2: [2, "Main Flash memory mapped at 0x0000_0000"]
7 | SRAM: [3, "Embedded SRAM mapped at 0x0000_0000"]
8 | "I2C_P?*_ANF":
9 | Standard: [0, "Pin operate in standard mode"]
10 | AnalogFilter: [1, "I2C Analog filter enabled on pin"]
11 | CFGR2:
12 | ETR_SRC_TIM1:
13 | GPIO: [0, "TIM1_ETR is connected to GPIO"]
14 | COMP1: [1, "TIM1_ETR is connected to COMP1"]
15 | COMP2: [2, "TIM1_ETR is connected to COMP2"]
16 | ADC: [3, "TIM1_ETR is connected to ADC"]
17 | "COMP?_BRK_TIM*":
18 | Disconnected: [0, "COMP? output not connect to TIM? Break input"]
19 | Connected: [1, "COMP? output connected to TIM? Break input"]
20 | LOCKUP_LOCK:
21 | Disconnected: [0, "Cortex-M0+ LOCKUP output disconnected from TIM1/16/17 Break input"]
22 | Connected: [1, "Cortex-M0+ LOCKUP output connected to TIM1/16/17 Break input"]
--------------------------------------------------------------------------------
/peripherals/pwr/pwr_f002b.yaml:
--------------------------------------------------------------------------------
1 | PWR:
2 | CR1:
3 | HSION_CTRL:
4 | WaiteMR: [0, "Enable HSI after MR is stable"]
5 | WakeOnVR: [1, "Enable HSI when VR is on (enable HSI immediately when wakeup)"]
6 | SRAM_RETV:
7 | V0_9: [3, "Supply voltage 0.9 V for SRAM"]
8 | V1_x: [4, "Supply voltage 1.0 or 1.2 V (depends on VOS) for SRAM"]
9 | _modify:
10 | LPR:
11 | name: LPRUN
12 | LPRUN:
13 | MainMode: [0, "Voltage regulator in Main mode in Low-power run mode"]
14 | LowPowerMode: [1, "Voltage regulator in low-power mode in Low-power run mode"]
15 | FLS_SLPTIME:
16 | FiveMicroSec: [0, "Flash wait 5 us after wakeup from stop mode"]
17 | TwoMicroSec: [1, "Flash wait 2 us after wakeup from stop mode"]
18 | ThreeMicroSec: [2, "Flash wait 3 us after wakeup from stop mode"]
19 | ExcuteFromSRAM: [3, "Excute program from SRAM after wakeup from stop mode"]
20 | BIAS_CR_SEL:
21 | FactoryConfig: [0, "Bias config from factory config bytes"]
22 | BiasCR: [1, "Bias config from BIAS_CR register"]
23 | BIAS_CR:
24 | [0, 15]
--------------------------------------------------------------------------------
/cortex_m/peripherals/fpu.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv7-M Architecture Reference Manual issue E.b
2 |
3 | _add:
4 | FPU:
5 | description: Floating Point Unit
6 | baseAddress: 0xE000EF30
7 | addressBlock:
8 | offset: 0x0
9 | size: 0x1C
10 | registers:
11 | FPCCR:
12 | description: Floating Point Context Control Register
13 | addressOffset: 0x4
14 | access: read-write
15 | FPCAR:
16 | description: Floating Point Context Address Register
17 | addressOffset: 0x8
18 | access: read-write
19 | FPDSCR:
20 | description: Floating Point Default Status Control Register
21 | addressOffset: 0xC
22 | access: read-write
23 | MVFR0:
24 | description: Media and FP Feature Register 0
25 | addressOffset: 0x10
26 | access: read-only
27 | MVFR1:
28 | description: Media and FP Feature Register 1
29 | addressOffset: 0x14
30 | access: read-only
31 | MVFR2:
32 | description: Media and FP Feature Register 2
33 | addressOffset: 0x18
34 | access: read-only
35 |
--------------------------------------------------------------------------------
/devices/py32f002b.yaml:
--------------------------------------------------------------------------------
1 | _svd: ../svd/py32f002b.svd
2 |
3 | "SPI*":
4 | _include:
5 | - common_patches/spi_dr8.yaml
6 | - common_patches/spi_f002b.yaml
7 |
8 | "USART*":
9 | _include:
10 | - common_patches/usart_dr8.yaml
11 |
12 | "DBG":
13 | _include:
14 | - common_patches/f002b_dbg.yaml
15 |
16 | "TIM*":
17 | _include:
18 | - common_patches/timer_ccr_reg_array.yaml
19 |
20 | _include:
21 | - ./common_patches/syscfg_f002b.yaml
22 | - ../peripherals/flash/flash_f002b.yaml
23 | - ../peripherals/pwr/pwr_f002b.yaml
24 | - ../peripherals/rcc/rcc_f002b.yaml
25 | - ../peripherals/gpio/gpio_f0.yaml
26 | - ../peripherals/syscfg/syscfg_f002b.yaml
27 | - ../peripherals/exti/exti_f0.yaml
28 | - ../peripherals/crc/crc_f0.yaml
29 | - ../peripherals/adc/adc_f002b.yaml
30 | - ../peripherals/comp/comp_f002b.yaml
31 | - ../peripherals/tim/tim_f002b.yaml
32 | - ../peripherals/lptim/lptim_f0.yaml
33 | - ../peripherals/iwdg/iwdg_f002b.yaml
34 | - ../peripherals/i2c/i2c_f002b.yaml
35 | - ../peripherals/usart/usart_f002b.yaml
36 | - ../peripherals/spi/spi_f002b.yaml
37 | - ../peripherals/dbg/dbg_f002b.yaml
38 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/bak/fpu.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv7-M Architecture Reference Manual issue E.b
2 |
3 | _add:
4 | FPU:
5 | description: Floating Point Unit
6 | baseAddress: 0xE000EF30
7 | addressBlock:
8 | offset: 0x0
9 | size: 0x1C
10 | registers:
11 | FPCCR:
12 | description: Floating Point Context Control register
13 | addressOffset: 0x4
14 | access: read-write
15 | FPCAR:
16 | description: Floating Point Context Address register
17 | addressOffset: 0x8
18 | access: read-write
19 | FPDSCR:
20 | description: Floating Point Default Status Control register
21 | addressOffset: 0xC
22 | access: read-write
23 | MVFR0:
24 | description: Media and FP Feature Register 0
25 | addressOffset: 0x10
26 | access: read-only
27 | MVFR1:
28 | description: Media and FP Feature Register 1
29 | addressOffset: 0x14
30 | access: read-only
31 | MVFR2:
32 | description: Media and FP Feature Register 2
33 | addressOffset: 0x18
34 | access: read-only
35 |
--------------------------------------------------------------------------------
/devices/py32f003.yaml:
--------------------------------------------------------------------------------
1 | _svd: ../svd/py32f003.svd
2 |
3 | "SPI*":
4 | _include:
5 | - common_patches/spi_dr8.yaml
6 |
7 | "USART*":
8 | _include:
9 | - common_patches/usart_dr8.yaml
10 |
11 | "DMA, DMA[12]":
12 | _include:
13 | - common_patches/dma_cluster.yaml
14 |
15 | "TIM*":
16 | _include:
17 | - common_patches/timer_ccr_reg_array.yaml
18 |
19 | _include:
20 | - ../peripherals/flash/flash_f0.yaml
21 | - ../peripherals/pwr/pwr_f0.yaml
22 | - ../peripherals/rcc/rcc_f003.yaml
23 | - ../peripherals/gpio/gpio_f0.yaml
24 | - ../peripherals/syscfg/syscfg_f0.yaml
25 | - ../peripherals/dma/dma_f0.yaml
26 | - ../peripherals/exti/exti_f0.yaml
27 | - ../peripherals/crc/crc_f0.yaml
28 | - ../peripherals/adc/adc_f0.yaml
29 | - ../peripherals/comp/comp_f0.yaml
30 | - ../peripherals/tim/tim_f0.yaml
31 | - ../peripherals/lptim/lptim_f0.yaml
32 | - ../peripherals/iwdg/iwdg_f0.yaml
33 | - ../peripherals/wwdg/wwdg_f0.yaml
34 | - ../peripherals/rtc/rtc_f0.yaml
35 | - ../peripherals/i2c/i2c_f0.yaml
36 | - ../peripherals/usart/usart_f0.yaml
37 | - ../peripherals/spi/spi_f0.yaml
38 | - ../peripherals/dbg/dbg_f0.yaml
39 |
--------------------------------------------------------------------------------
/.github/workflows/gh-pages.yaml:
--------------------------------------------------------------------------------
1 | name: build gh-pages
2 | on:
3 | push:
4 | branches:
5 | - master
6 |
7 | jobs:
8 | build_html:
9 | name: Build HTML
10 | runs-on: ubuntu-latest
11 | env:
12 | SVDTOOLS: svdtools
13 | steps:
14 | - name: Checkout master
15 | uses: actions/checkout@v3
16 | with:
17 | persist-credentials: false
18 | - name: Install tools
19 | run: |
20 | ./scripts/tool_install.sh svdtools
21 | ./scripts/tool_install.sh svd2html
22 | - name: Build HTML
23 | run: make -j2 html
24 | - name: Upload artifact
25 | uses: actions/upload-pages-artifact@v1
26 | with:
27 | path: html
28 |
29 | deploy_pages:
30 | name: Deploy GH Pages
31 | runs-on: ubuntu-latest
32 | needs: build_html
33 | permissions:
34 | pages: write
35 | id-token: write
36 | environment:
37 | name: github-pages
38 | url: ${{ steps.deployment.outputs.page_url }}
39 | steps:
40 | - name: Deploy to Github Pages
41 | id: deployment
42 | uses: actions/deploy-pages@v1
43 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/nvic_v6.yaml:
--------------------------------------------------------------------------------
1 | NVIC:
2 | _add:
3 | _registers:
4 | IPR0:
5 | description: Interrupt Priority Register 0
6 | addressOffset: 0x300
7 | access: read-write
8 | IPR1:
9 | description: Interrupt Priority Register 1
10 | addressOffset: 0x304
11 | access: read-write
12 | IPR2:
13 | description: Interrupt Priority Register 2
14 | addressOffset: 0x308
15 | access: read-write
16 | IPR3:
17 | description: Interrupt Priority Register 3
18 | addressOffset: 0x30c
19 | access: read-write
20 | IPR4:
21 | description: Interrupt Priority Register 4
22 | addressOffset: 0x310
23 | access: read-write
24 | IPR5:
25 | description: Interrupt Priority Register 5
26 | addressOffset: 0x314
27 | access: read-write
28 | IPR6:
29 | description: Interrupt Priority Register 6
30 | addressOffset: 0x318
31 | access: read-write
32 | IPR7:
33 | description: Interrupt Priority Register 7
34 | addressOffset: 0x31c
35 | access: read-write
36 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/bak/nvic_v6.yaml:
--------------------------------------------------------------------------------
1 | NVIC:
2 | _add:
3 | _registers:
4 | IPR0:
5 | description: Interrupt Priority register 0
6 | addressOffset: 0x300
7 | access: read-write
8 | IPR1:
9 | description: Interrupt Priority register 1
10 | addressOffset: 0x304
11 | access: read-write
12 | IPR2:
13 | description: Interrupt Priority register 2
14 | addressOffset: 0x308
15 | access: read-write
16 | IPR3:
17 | description: Interrupt Priority register 3
18 | addressOffset: 0x30c
19 | access: read-write
20 | IPR4:
21 | description: Interrupt Priority register 4
22 | addressOffset: 0x310
23 | access: read-write
24 | IPR5:
25 | description: Interrupt Priority register 5
26 | addressOffset: 0x314
27 | access: read-write
28 | IPR6:
29 | description: Interrupt Priority register 6
30 | addressOffset: 0x318
31 | access: read-write
32 | IPR7:
33 | description: Interrupt Priority register 7
34 | addressOffset: 0x31c
35 | access: read-write
36 |
--------------------------------------------------------------------------------
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 The py32-rs authors.
2 |
3 | Permission is hereby granted, free of charge, to any
4 | person obtaining a copy of this software and associated
5 | documentation files (the "Software"), to deal in the
6 | Software without restriction, including without
7 | limitation the rights to use, copy, modify, merge,
8 | publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software
10 | is furnished to do so, subject to the following
11 | conditions:
12 |
13 | The above copyright notice and this permission notice
14 | shall be included in all copies or substantial portions
15 | of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 | DEALINGS IN THE SOFTWARE.
26 |
--------------------------------------------------------------------------------
/devices/py32f030.yaml:
--------------------------------------------------------------------------------
1 | _svd: ../svd/py32f030.svd
2 |
3 | "SPI*":
4 | _include:
5 | - common_patches/spi_dr8.yaml
6 |
7 | "USART*":
8 | _include:
9 | - common_patches/usart_dr8.yaml
10 |
11 | "DMA, DMA[12]":
12 | _include:
13 | - common_patches/dma_cluster.yaml
14 |
15 | "TIM*":
16 | _include:
17 | - common_patches/timer_ccr_reg_array.yaml
18 |
19 | _include:
20 | - ../peripherals/flash/flash_f0.yaml
21 | - ../peripherals/pwr/pwr_f0.yaml
22 | - ../peripherals/rcc/rcc_f0.yaml
23 | - ../peripherals/gpio/gpio_f0.yaml
24 | - ../peripherals/syscfg/syscfg_f0.yaml
25 | - ../peripherals/dma/dma_f0.yaml
26 | - ../peripherals/exti/exti_f0.yaml
27 | - ../peripherals/crc/crc_f0.yaml
28 | - ../peripherals/adc/adc_f0.yaml
29 | - ../peripherals/comp/comp_f0.yaml
30 | - ../peripherals/led/led_f0.yaml
31 | - ../peripherals/tim/tim_f0.yaml
32 | - ../peripherals/lptim/lptim_f0.yaml
33 | - ../peripherals/iwdg/iwdg_f0.yaml
34 | - ../peripherals/wwdg/wwdg_f0.yaml
35 | - ../peripherals/rtc/rtc_f0.yaml
36 | - ../peripherals/i2c/i2c_f0.yaml
37 | - ../peripherals/usart/usart_f0.yaml
38 | - ../peripherals/spi/spi_f0.yaml
39 | - ../peripherals/dbg/dbg_f0.yaml
40 |
--------------------------------------------------------------------------------
/peripherals/syscfg/syscfg_f002b.yaml:
--------------------------------------------------------------------------------
1 | SYSCFG:
2 | CFGR1:
3 | MEM_MODE:
4 | MainFlash: [0, "Main Flash memory mapped at 0x0000_0000"]
5 | SystemFlash: [1, "System Flash memory mapped at 0x0000_0000"]
6 | MainFlash2: [2, "Main Flash memory mapped at 0x0000_0000"]
7 | SRAM: [3, "Embedded SRAM mapped at 0x0000_0000"]
8 | "I2C_P?*_FMP":
9 | Standard: [0, "Pin operate in standard mode"]
10 | AnalogFilter: [1, "I2C FM+ mode enabled on pin"]
11 | CFGR2:
12 | ETR_SRC_TIM1:
13 | GPIO: [0, "TIM1_ETR is connected to GPIO"]
14 | COMP1: [1, "TIM1_ETR is connected to COMP1"]
15 | COMP2: [2, "TIM1_ETR is connected to COMP2"]
16 | ADC: [3, "TIM1_ETR is connected to ADC"]
17 | "COMP?_BRK_TIM*":
18 | Disconnected: [0, "COMP? output not connect to TIM? Break input"]
19 | Connected: [1, "COMP? output connected to TIM? Break input"]
20 | LOCKUP_LOCK:
21 | Disconnected: [0, "Cortex-M0+ LOCKUP output disconnected from TIM1/16/17 Break input"]
22 | Connected: [1, "Cortex-M0+ LOCKUP output connected to TIM1/16/17 Break input"]
23 | GPIO_ENS:
24 | PA_ENS: [0, 63]
25 | PB_ENS: [0, 63]
26 | PC_ENS: [0, 3]
27 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/tpiu.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv7-M Architecture Reference Manual issue E.b
2 |
3 | _add:
4 | TPIU:
5 | description: Trace Port Interface Unit
6 | baseAddress: 0xE0040000
7 | addressBlock:
8 | offset: 0x0
9 | size: 0x1000
10 | registers:
11 | SSPSR:
12 | description: Supported Parallel Port Sizes Register
13 | addressOffset: 0x0
14 | access: read-only
15 | CSPSR:
16 | description: Current Parallel Port Size Register
17 | addressOffset: 0x4
18 | access: read-write
19 | ACPR:
20 | description: Asynchronous Clock Prescaler Register
21 | addressOffset: 0x10
22 | access: read-write
23 | SPPR:
24 | description: Selected Pin Protocol Register
25 | addressOffset: 0xF0
26 | access: read-write
27 | TYPE:
28 | description: TPIU Type Register
29 | addressOffset: 0xFC8
30 | access: read-only
31 | LSR:
32 | description: Lock Status Register
33 | addressOffset: 0xFB4
34 | access: read-only
35 | LAR:
36 | description: Lock Access Register
37 | addressOffset: 0xFB0
38 | access: write-only
39 |
--------------------------------------------------------------------------------
/peripherals/lptim/lptim_f0.yaml:
--------------------------------------------------------------------------------
1 | LPTIM,LPTIM?:
2 | ISR:
3 | ARRM:
4 | _read:
5 | Set: [1, "Autoreload match"]
6 | ICR:
7 | ARRMCF:
8 | _write:
9 | Clear: [1, "Autoreload match Clear Flag"]
10 | IER:
11 | ARRMIE:
12 | Disabled: [0, "ARRM interrupt disabled"]
13 | Enabled: [1, "ARRM interrupt enabled"]
14 | CFGR:
15 | PRELOAD:
16 | Immediate: [0, "Registers are updated after each APB bus write access"]
17 | EndOfPeriod: [1, "Registers are updated at the end of the current LPTIM period"]
18 | PRESC:
19 | Div1: [0, "/1"]
20 | Div2: [1, "/2"]
21 | Div4: [2, "/4"]
22 | Div8: [3, "/8"]
23 | Div16: [4, "/16"]
24 | Div32: [5, "/32"]
25 | Div64: [6, "/64"]
26 | Div128: [7, "/128"]
27 | CR:
28 | RSTARE:
29 | Disabled: [0, "CNT Register reads do not trigger reset"]
30 | Enabled: [1, "CNT Register reads trigger reset of LPTIM"]
31 | SNGSTRT:
32 | _write:
33 | Start: [1, "LPTIM start in Single mode"]
34 | ENABLE:
35 | Disabled: [0, "LPTIM is disabled"]
36 | Enabled: [1, "LPTIM is enabled"]
37 | ARR:
38 | ARR: [0, 0xFFFF]
39 | CNT:
40 | CNT: [0, 0xFFFF]
41 |
--------------------------------------------------------------------------------
/peripherals/exti/exti_f0.yaml:
--------------------------------------------------------------------------------
1 | EXTI:
2 | RTSR:
3 | "RT*":
4 | Disabled: [0, "Rising edge trigger is disabled"]
5 | Enabled: [1, "Rising edge trigger is enabled"]
6 | FTSR:
7 | "FT*":
8 | Disabled: [0, "Falling edge trigger is disabled"]
9 | Enabled: [1, "Falling edge trigger is enabled"]
10 | SWIER,SWIER?:
11 | "SWI*":
12 | _write:
13 | Pend: [1, "Generates an interrupt request"]
14 | PR:
15 | "PR*":
16 | _W1C:
17 | Clear: [1, "Clears pending bit"]
18 | _read:
19 | NotPending: [0, "No trigger request occurred"]
20 | Pending: [1, "Selected trigger request occurred"]
21 | "EXTICR[12]":
22 | "EXTI[0-4]":
23 | PA: [0, "GPIO port A selected"]
24 | PB: [1, "GPIO port B selected"]
25 | PF: [2, "GPIO port F selected"]
26 | "EXTICR[23]":
27 | "EXTI[5-8]":
28 | PA: [0, "GPIO port A selected"]
29 | PB: [1, "GPIO port B selected"]
30 | IMR:
31 | "IM*":
32 | Masked: [0, "Interrupt request line is masked"]
33 | Unmasked: [1, "Interrupt request line is unmasked"]
34 | EMR:
35 | "EM*":
36 | Masked: [0, "Interrupt request line is masked"]
37 | Unmasked: [1, "Interrupt request line is unmasked"]
38 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yaml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | merge_group:
9 |
10 | jobs:
11 | check:
12 | name: Check
13 | runs-on: ubuntu-latest
14 | strategy:
15 | matrix:
16 | crate:
17 | - py32f0
18 |
19 | env:
20 | CRATES: ${{ matrix.crate }}
21 | CARGO_INCREMENTAL: 0
22 | SVDTOOLS: svdtools
23 |
24 | steps:
25 | - name: Checkout code
26 | uses: actions/checkout@v3
27 |
28 | - name: Install Rust
29 | uses: dtolnay/rust-toolchain@stable
30 | with:
31 | components: rustfmt
32 |
33 | - name: Install xmllint
34 | run: |
35 | sudo apt-get update
36 | sudo apt-get install libxml2-utils
37 |
38 | - name: Create working crate
39 | run: make crates
40 |
41 | - name: Install tools
42 | run: |
43 | ./scripts/tool_install.sh svdtools
44 | ./scripts/tool_install.sh svd2rust
45 |
46 | - name: Patch SVDs
47 | run: make -j2 patch
48 |
49 | - name: Check SVDs
50 | run: make lint
51 |
52 | - name: Build PACs
53 | run: make -j2 svd2rust
54 |
55 | - name: Check PACs
56 | run: make -j2 check
57 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/cpuid_v6.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv6-M Architecture Reference Manual issue C
2 |
3 | _add:
4 | CPUID:
5 | description: CPUID
6 | baseAddress: 0xE000ED00
7 | addressBlock:
8 | offset: 0x0
9 | size: 4
10 | registers:
11 | Base:
12 | description: Provides identification information for the processor
13 | addressOffset: 0x0
14 | access: read-only
15 | fields:
16 | IMPLEMENTER:
17 | description: This field defines the implementer
18 | bitOffset: 24
19 | bitWidth: 7
20 | VARIANT:
21 | description: Implementation defined
22 | bitOffset: 20
23 | bitWidth: 4
24 | ARCHITECTURE:
25 | description: This field defines the architecture
26 | bitOffset: 16
27 | bitWidth: 4
28 | PARTNO:
29 | description: Implementation defined.
30 | bitOffset: 4
31 | bitWidth: 12
32 | REVISION:
33 | description: Implementation defined.
34 | bitOffset: 0
35 | bitWidth: 4
36 |
37 | CPUID:
38 | Base:
39 | IMPLEMENTER:
40 | ARM: [0x41, "ARM Limited"]
41 | ARCHITECTURE:
42 | ARMv6M: [0xC, "ARMv6-M"]
43 |
--------------------------------------------------------------------------------
/cortex_m/peripherals/bak/cpuid_v6.yaml:
--------------------------------------------------------------------------------
1 | # Reference: ARMv6-M Architecture Reference Manual issue C
2 |
3 | _add:
4 | CPUID:
5 | description: CPUID
6 | baseAddress: 0xE000ED00
7 | addressBlock:
8 | offset: 0x0
9 | size: 4
10 | registers:
11 | Base:
12 | description: Provides identification information for the processor
13 | addressOffset: 0x0
14 | access: read-only
15 | fields:
16 | IMPLEMENTER:
17 | description: This field defines the implementer
18 | bitOffset: 24
19 | bitWidth: 7
20 | VARIANT:
21 | description: Implementation defined
22 | bitOffset: 20
23 | bitWidth: 4
24 | ARCHITECTURE:
25 | description: This field defines the architecture
26 | bitOffset: 16
27 | bitWidth: 4
28 | PARTNO:
29 | description: Implementation defined.
30 | bitOffset: 4
31 | bitWidth: 12
32 | REVISION:
33 | description: Implementation defined.
34 | bitOffset: 0
35 | bitWidth: 4
36 |
37 | CPUID:
38 | Base:
39 | IMPLEMENTER:
40 | ARM: [0x41, "ARM Limited"]
41 | ARCHITECTURE:
42 | ARMv6M: [0xC, "ARMv6-M"]
43 |
--------------------------------------------------------------------------------
/.github/workflows/cargo-make.yaml:
--------------------------------------------------------------------------------
1 | name: Cargo Make
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | merge_group:
9 |
10 | jobs:
11 | cargo_make:
12 | name: Cargo Make
13 | runs-on: ubuntu-latest
14 |
15 | env:
16 | CRATES: py32f0
17 | CARGO_INCREMENTAL: 0
18 | SVDTOOLS: svdtools
19 |
20 | steps:
21 | - name: Checkout code
22 | uses: actions/checkout@v3
23 |
24 | - name: Install Rust
25 | uses: dtolnay/rust-toolchain@stable
26 | with:
27 | components: rustfmt
28 |
29 | - name: Install cargo-make
30 | run: |
31 | wget https://github.com/sagiegurari/cargo-make/releases/download/0.36.8/cargo-make-v0.36.8-x86_64-unknown-linux-gnu.zip
32 | unzip cargo-make-*.zip
33 | mv cargo-make*/cargo-make $HOME/.cargo/bin
34 |
35 | - name: Create working crate
36 | run: cargo make crates
37 |
38 | - name: Install tools
39 | run: cargo make install
40 |
41 | - name: Patch SVDs
42 | run: cargo make patch
43 |
44 | - name: Build PACs
45 | run: cargo make svd2rust
46 |
47 | - name: Format PACs
48 | run: cargo make form
49 |
50 | - name: Check PACs
51 | run: cargo make check
52 |
53 | - name: Clean up
54 | run: cargo make clean
55 |
--------------------------------------------------------------------------------
/peripherals/comp/comp_f002b.yaml:
--------------------------------------------------------------------------------
1 | COMP?:
2 | CSR:
3 | _modify:
4 | COMP_EN:
5 | name: EN
6 | COMP_OUT:
7 | name: VALUE
8 | EN:
9 | Disabled: [0, "Comparator 1 disabled"]
10 | Enabled: [1, "Comparator 1 enabled"]
11 | POLARITY:
12 | NotInverted: [0, "Output is not inverted"]
13 | Inverted: [1, "Output is inverted"]
14 | VALUE:
15 | _read:
16 | Low: [0, "Comparator output is low"]
17 | High: [1, "Comparator output is high"]
18 | FR:
19 | _modify:
20 | FLTEN:
21 | name: FLTEN*
22 | Disabled: [0, "Comparator digital filter disabled"]
23 | Enabled: [1, "Comparator digital filter enabled"]
24 | FLTCNT:
25 | name: FLTCNT*
26 | value: [0, 0xFFFF]
27 |
28 | COMP1:
29 | CSR:
30 | INNSEL:
31 | PB0: [0, "PB0 connected to inverting input"]
32 | PB1: [1, "PB1 connected to inverting input"]
33 | WINMODE:
34 | Disabled: [0, "COMP1 non-inverting input is connected to COMP1_INP"]
35 | Enabled: [1, "COMP1 non-inverting input is connected to COMP2_INP"]
36 |
37 | COMP2:
38 | CSR:
39 | INMSEL:
40 | PA4: [0, "PA4 connected to inverting input"]
41 | PA3: [1, "PA3 connected to inverting input"]
42 | INPSEL:
43 | PA3: [0, "PA3 connected to non-inverting input"]
44 | VRefCmp: [1, "VRef comp"]
45 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | ## v0.2.1 2025-01-28
6 |
7 | ### Added
8 |
9 | - Added array access to timer CCR registers
10 | - Added py32f040 device
11 | - `scripts/README.md` to show usage of scripts
12 | - modified scripts to handle `bitRange` vs `bitOffset` and `bitWidth` usage in svd files
13 |
14 | ### Changed
15 |
16 | - Renamed field `DBG_TIM14_STOP` to `DBG_TIMER14_STOP` in `DBG` peripheral for py32f002b to make it consistent with other devices
17 |
18 | ### Removed
19 |
20 | - Removed renaming of timer CCR registers
21 |
22 | ## v0.2.0 2024-12-28
23 |
24 | ### Added
25 |
26 | - Clustered DMA registers into channels
27 | - Added arrays to DMA registers
28 | - Add direct 8-bit access to USART data register
29 |
30 | ### Changed
31 |
32 | - Updated Repository url in `README.md` and `scripts/makecrates.py`
33 | - Renamed `DDF` field in spi CR1 register to `DFF` to match datasheet for device py32f002b
34 | - Updated form version from 0.10.0 to 0.12.1
35 | - Updated svdtools version from 0.3.0 to 0.3.14
36 |
37 | ## v0.1.1 2024-10-10
38 |
39 | ## V0.1.0 2024-09-27
40 |
41 | ## v0.0.1 2023-06-10
42 |
43 | - Original Release
44 |
45 | The format is based on [Keep a Changelog](http://keepachangelog.com/)
46 | and this project adheres to [Semantic Versioning](http://semver.org/).
47 |
--------------------------------------------------------------------------------
/devices/py32f040.yaml:
--------------------------------------------------------------------------------
1 | _svd: ../svd/py32f040.svd
2 |
3 | "SPI*":
4 | _include:
5 | - common_patches/spi_dr8.yaml
6 |
7 | "USART*":
8 | _include:
9 | - common_patches/usart_dr8.yaml
10 | - common_patches/usart_f040_rename.yaml
11 |
12 | "DMA, DMA[12]":
13 | _include:
14 | - common_patches/dma_cluster.yaml
15 |
16 | "FLASH":
17 | _include:
18 | - common_patches/flash_f040_rename.yaml
19 |
20 | "ADC":
21 | _include:
22 | - common_patches/adc_rw.yaml
23 |
24 | "RTC":
25 | _include:
26 | - common_patches/rtc_040_renames.yaml
27 |
28 | _include:
29 | - ../peripherals/flash/flash_f040.yaml
30 | - ../peripherals/pwr/pwr_f040.yaml
31 | - ../peripherals/rcc/rcc_f040.yaml
32 | - ../peripherals/gpio/gpio_f0.yaml
33 | - ../peripherals/syscfg/syscfg_f040.yaml
34 | - ../peripherals/dma/dma_f0.yaml
35 | - ../peripherals/exti/exti_f0.yaml
36 | - ../peripherals/crc/crc_f0.yaml
37 | - ../peripherals/adc/adc_f040.yaml
38 | - ../peripherals/comp/comp_f040.yaml
39 | - ../peripherals/lcd/lcd_f0.yaml
40 | - ../peripherals/tim/tim_f040.yaml
41 | - ../peripherals/lptim/lptim_f0.yaml
42 | - ../peripherals/iwdg/iwdg_f0.yaml
43 | - ../peripherals/wwdg/wwdg_f0.yaml
44 | - ../peripherals/rtc/rtc_f0.yaml
45 | - ../peripherals/i2c/i2c_f040.yaml
46 | - ../peripherals/usart/usart_f0.yaml
47 | - ../peripherals/spi/spi_f040.yaml
48 | - ../peripherals/dbg/dbg_f0.yaml
49 |
--------------------------------------------------------------------------------
/scripts/htmlcomparesvdall.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -euxo pipefail
3 |
4 | mkdir -p html/py32f/py32f0
5 | python3 scripts/htmlcomparesvd.py html/py32f/py32f0 svd/py32f0*.svd.patched
6 |
7 |
8 | cat > html/comparisons.html <
10 |
11 |
12 |
13 | py32-rs Peripheral Comparisons
14 |
15 |
16 |
17 |
18 |
19 |
31 |
32 | Device families
33 |
36 |
37 |