Add RCC register for STM32F4 and STM32L4

Register block based in STM32F427ZI and STM32L4R9.

Use bool for reset registers.

Define clock mapping for RNG peripherals. There are no 1 <-> 1 mapping
of RNG peripheral to clock in the Cubedb sources. The mapping will
pre-select the clock source for RNG for now.
This commit is contained in:
Ulf Lilleengen 2021-06-03 11:15:20 +02:00
parent 9cfdc5a647
commit 18a99a3a3b
5 changed files with 2049 additions and 15 deletions

1970
data/registers/rcc_f4.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -675,34 +675,42 @@ fieldset/CIER:
description: LSI ready interrupt flag description: LSI ready interrupt flag
bit_offset: 0 bit_offset: 0
bit_size: 1 bit_size: 1
enum: HSIRDYIE
- name: LSERDYIE - name: LSERDYIE
description: LSE ready interrupt flag description: LSE ready interrupt flag
bit_offset: 1 bit_offset: 1
bit_size: 1 bit_size: 1
enum: HSIRDYIE
- name: HSI16RDYIE - name: HSI16RDYIE
description: HSI16 ready interrupt flag description: HSI16 ready interrupt flag
bit_offset: 2 bit_offset: 2
bit_size: 1 bit_size: 1
enum: HSIRDYIE
- name: HSERDYIE - name: HSERDYIE
description: HSE ready interrupt flag description: HSE ready interrupt flag
bit_offset: 3 bit_offset: 3
bit_size: 1 bit_size: 1
enum: HSIRDYIE
- name: PLLRDYIE - name: PLLRDYIE
description: PLL ready interrupt flag description: PLL ready interrupt flag
bit_offset: 4 bit_offset: 4
bit_size: 1 bit_size: 1
enum: HSIRDYIE
- name: MSIRDYIE - name: MSIRDYIE
description: MSI ready interrupt flag description: MSI ready interrupt flag
bit_offset: 5 bit_offset: 5
bit_size: 1 bit_size: 1
enum: HSIRDYIE
- name: HSI48RDYIE - name: HSI48RDYIE
description: HSI48 ready interrupt flag description: HSI48 ready interrupt flag
bit_offset: 6 bit_offset: 6
bit_size: 1 bit_size: 1
enum: HSIRDYIE
- name: CSSLSE - name: CSSLSE
description: LSE CSS interrupt flag description: LSE CSS interrupt flag
bit_offset: 7 bit_offset: 7
bit_size: 1 bit_size: 1
enum: CSSLSE
fieldset/CIFR: fieldset/CIFR:
description: Clock interrupt flag register description: Clock interrupt flag register
fields: fields:
@ -758,10 +766,12 @@ fieldset/CR:
description: 16 MHz high-speed internal clock enable description: 16 MHz high-speed internal clock enable
bit_offset: 0 bit_offset: 0
bit_size: 1 bit_size: 1
enum: PLLON
- name: HSI16KERON - name: HSI16KERON
description: High-speed internal clock enable bit for some IP kernels description: High-speed internal clock enable bit for some IP kernels
bit_offset: 1 bit_offset: 1
bit_size: 1 bit_size: 1
enum: PLLON
- name: HSI16RDYF - name: HSI16RDYF
description: Internal high-speed clock ready flag description: Internal high-speed clock ready flag
bit_offset: 2 bit_offset: 2
@ -784,6 +794,7 @@ fieldset/CR:
description: MSI clock enable bit description: MSI clock enable bit
bit_offset: 8 bit_offset: 8
bit_size: 1 bit_size: 1
enum: PLLON
- name: MSIRDY - name: MSIRDY
description: MSI clock ready flag description: MSI clock ready flag
bit_offset: 9 bit_offset: 9
@ -793,6 +804,7 @@ fieldset/CR:
description: HSE clock enable bit description: HSE clock enable bit
bit_offset: 16 bit_offset: 16
bit_size: 1 bit_size: 1
enum: PLLON
- name: HSERDY - name: HSERDY
description: HSE clock ready flag description: HSE clock ready flag
bit_offset: 17 bit_offset: 17
@ -807,6 +819,7 @@ fieldset/CR:
description: Clock security system on HSE enable bit description: Clock security system on HSE enable bit
bit_offset: 19 bit_offset: 19
bit_size: 1 bit_size: 1
enum: PLLON
- name: RTCPRE - name: RTCPRE
description: TC/LCD prescaler description: TC/LCD prescaler
bit_offset: 20 bit_offset: 20
@ -816,6 +829,7 @@ fieldset/CR:
description: PLL enable bit description: PLL enable bit
bit_offset: 24 bit_offset: 24
bit_size: 1 bit_size: 1
enum: PLLON
- name: PLLRDY - name: PLLRDY
description: PLL clock ready flag description: PLL clock ready flag
bit_offset: 25 bit_offset: 25
@ -847,6 +861,7 @@ fieldset/CSR:
description: Internal low-speed oscillator enable description: Internal low-speed oscillator enable
bit_offset: 0 bit_offset: 0
bit_size: 1 bit_size: 1
enum: CSSLSEON
- name: LSIRDY - name: LSIRDY
description: Internal low-speed oscillator ready bit description: Internal low-speed oscillator ready bit
bit_offset: 1 bit_offset: 1
@ -856,6 +871,7 @@ fieldset/CSR:
description: External low-speed oscillator enable bit description: External low-speed oscillator enable bit
bit_offset: 8 bit_offset: 8
bit_size: 1 bit_size: 1
enum: CSSLSEON
- name: LSERDY - name: LSERDY
description: External low-speed oscillator ready bit description: External low-speed oscillator ready bit
bit_offset: 9 bit_offset: 9
@ -875,6 +891,7 @@ fieldset/CSR:
description: CSSLSEON description: CSSLSEON
bit_offset: 13 bit_offset: 13
bit_size: 1 bit_size: 1
enum: CSSLSEON
- name: CSSLSED - name: CSSLSED
description: CSS on LSE failure detection flag description: CSS on LSE failure detection flag
bit_offset: 14 bit_offset: 14
@ -992,32 +1009,26 @@ fieldset/IOPRSTR:
description: I/O port A reset description: I/O port A reset
bit_offset: 0 bit_offset: 0
bit_size: 1 bit_size: 1
enum: IOPHRST
- name: IOPBRST - name: IOPBRST
description: I/O port B reset description: I/O port B reset
bit_offset: 1 bit_offset: 1
bit_size: 1 bit_size: 1
enum: IOPHRST
- name: IOPCRST - name: IOPCRST
description: I/O port A reset description: I/O port A reset
bit_offset: 2 bit_offset: 2
bit_size: 1 bit_size: 1
enum: IOPHRST
- name: IOPDRST - name: IOPDRST
description: I/O port D reset description: I/O port D reset
bit_offset: 3 bit_offset: 3
bit_size: 1 bit_size: 1
enum: IOPHRST
- name: IOPERST - name: IOPERST
description: I/O port E reset description: I/O port E reset
bit_offset: 4 bit_offset: 4
bit_size: 1 bit_size: 1
enum: IOPHRST
- name: IOPHRST - name: IOPHRST
description: I/O port H reset description: I/O port H reset
bit_offset: 7 bit_offset: 7
bit_size: 1 bit_size: 1
enum: IOPHRST
fieldset/IOPSMEN: fieldset/IOPSMEN:
description: GPIO clock enable in sleep mode register description: GPIO clock enable in sleep mode register
fields: fields:
@ -1066,6 +1077,15 @@ enum/CSSHSEF:
- name: Clock - name: Clock
description: Clock security interrupt caused by HSE clock failure description: Clock security interrupt caused by HSE clock failure
value: 1 value: 1
enum/CSSLSE:
bit_size: 1
variants:
- name: Disabled
description: LSE CSS interrupt disabled
value: 0
- name: Enabled
description: LSE CSS interrupt enabled
value: 1
enum/CSSLSED: enum/CSSLSED:
bit_size: 1 bit_size: 1
variants: variants:
@ -1084,6 +1104,15 @@ enum/CSSLSEF:
- name: Failure - name: Failure
description: Failure detected on LSE clock failure description: Failure detected on LSE clock failure
value: 1 value: 1
enum/CSSLSEON:
bit_size: 1
variants:
- name: "Off"
description: Oscillator OFF
value: 0
- name: "On"
description: Oscillator ON
value: 1
enum/DBGRSTW: enum/DBGRSTW:
bit_size: 1 bit_size: 1
variants: variants:
@ -1165,6 +1194,15 @@ enum/HSIDIVFR:
- name: Div4 - name: Div4
description: 16 MHz HSI clock divided by 4 description: 16 MHz HSI clock divided by 4
value: 1 value: 1
enum/HSIRDYIE:
bit_size: 1
variants:
- name: Disabled
description: Ready interrupt disabled
value: 0
- name: Enabled
description: Ready interrupt enabled
value: 1
enum/ICSEL: enum/ICSEL:
bit_size: 2 bit_size: 2
variants: variants:
@ -1177,12 +1215,6 @@ enum/ICSEL:
- name: HSI16 - name: HSI16
description: HSI16 clock selected as peripheral clock description: HSI16 clock selected as peripheral clock
value: 2 value: 2
enum/IOPHRST:
bit_size: 1
variants:
- name: Reset
description: Reset I/O port
value: 1
enum/LPTIMRSTW: enum/LPTIMRSTW:
bit_size: 1 bit_size: 1
variants: variants:
@ -1375,6 +1407,15 @@ enum/PLLMUL:
- name: Mul48 - name: Mul48
description: PLL clock entry x 48 description: PLL clock entry x 48
value: 8 value: 8
enum/PLLON:
bit_size: 1
variants:
- name: Disabled
description: Clock disabled
value: 0
- name: Enabled
description: Clock enabled
value: 1
enum/PLLRDYR: enum/PLLRDYR:
bit_size: 1 bit_size: 1
variants: variants:

View File

@ -6,7 +6,7 @@ board=$1
peri=$2 peri=$2
mkdir -p regs/$peri mkdir -p regs/$peri
cargo build --release --manifest-path ../../../svd2rust/Cargo.toml cargo build --release --manifest-path ../../svd2rust/Cargo.toml
transform="transform.yaml" transform="transform.yaml"
@ -28,7 +28,7 @@ for f in `ls $query`; do
f=${f#"stm32"} f=${f#"stm32"}
f=${f%".svd"} f=${f%".svd"}
echo -n processing $f ... echo -n processing $f ...
RUST_LOG=info ../../../svd2rust/target/release/svd4rust extract-peripheral --svd sources/svd/stm32$f.svd --transform $transform --peripheral $peri > regs/$peri/$f.yaml 2> regs/$peri/$f.yaml.out RUST_LOG=info ../../svd2rust/target/release/svd4rust extract-peripheral --svd sources/svd/stm32$f.svd --transform $transform --peripheral $peri > regs/$peri/$f.yaml 2> regs/$peri/$f.yaml.out
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
mv regs/$peri/$f.yaml.out regs/$peri/$f.err mv regs/$peri/$f.yaml.out regs/$peri/$f.err
rm regs/$peri/$f.yaml rm regs/$peri/$f.yaml

View File

@ -242,6 +242,8 @@ perimap = [
('STM32L0.*:SYS:.*', 'syscfg_l0/SYSCFG'), ('STM32L0.*:SYS:.*', 'syscfg_l0/SYSCFG'),
('STM32H7.*:SYS:.*', 'syscfg_h7/SYSCFG'), ('STM32H7.*:SYS:.*', 'syscfg_h7/SYSCFG'),
('STM32L0.*:RCC:.*', 'rcc_l0/RCC'), ('STM32L0.*:RCC:.*', 'rcc_l0/RCC'),
('STM32L4.*:RCC:.*', 'rcc_l4/RCC'),
('STM32F4.*:RCC:.*', 'rcc_f4/RCC'),
('.*:STM32L0_dbgmcu_v1_0', 'dbg_l0/DBG'), ('.*:STM32L0_dbgmcu_v1_0', 'dbg_l0/DBG'),
('.*:STM32L0_crs_v1_0', 'crs_l0/CRS'), ('.*:STM32L0_crs_v1_0', 'crs_l0/CRS'),
('.*SDMMC:sdmmc2_v1_0', 'sdmmc_v2/SDMMC'), ('.*SDMMC:sdmmc2_v1_0', 'sdmmc_v2/SDMMC'),
@ -252,6 +254,13 @@ perimap = [
('.*TIM\d.*:gptimer.*', 'timer_v1/TIM_GP16'), ('.*TIM\d.*:gptimer.*', 'timer_v1/TIM_GP16'),
] ]
rng_clock_map = [
('STM32L0.*:RNG:.*', 'AHB'),
('STM32L4.*:RNG:.*', 'AHB2'),
('STM32F4.*:RNG:.*', 'AHB2'),
('STM32H7.*:RNG:.*', 'AHB2'),
]
def match_peri(peri): def match_peri(peri):
for r, block in perimap: for r, block in perimap:
@ -266,6 +275,11 @@ def find_af(gpio_af, peri_name, pin_name, signal_name):
return af[gpio_af][pin_name][peri_name + '_' + signal_name] return af[gpio_af][pin_name][peri_name + '_' + signal_name]
return None return None
def match_rng_clock(rcc):
for r, clock in rng_clock_map:
if re.match(r, rcc):
return clock
return None
def parse_headers(): def parse_headers():
os.makedirs('sources/headers_parsed', exist_ok=True) os.makedirs('sources/headers_parsed', exist_ok=True)
@ -458,6 +472,11 @@ def parse_chips():
if len(chip['pins'][pname]) > 0: if len(chip['pins'][pname]) > 0:
p['pins'] = chip['pins'][pname] p['pins'] = chip['pins'][pname]
# RNG Clock definitions are not easily determined, so lookup in mapping
if block is not None and block.startswith("rng_"):
if (clock := match_rng_clock(chip_name+':'+pname+':'+pkind)) != None:
p['clock'] = clock
peris[pname] = p peris[pname] = p
@ -599,6 +618,7 @@ def parse_clocks():
peripherals = peripherals.split(",") peripherals = peripherals.split(",")
for p in peripherals: for p in peripherals:
chip_clocks[p] = name chip_clocks[p] = name
clocks[ff] = chip_clocks clocks[ff] = chip_clocks

View File

@ -41,5 +41,8 @@ transforms:
from: '[HL](IFCR|ISR)' from: '[HL](IFCR|ISR)'
to: $1 to: $1
- DeleteEnums: - DeleteEnums:
from: '.*[EN]' from: '.*EN'
bit_size: 1
- DeleteEnums:
from: '.*RST'
bit_size: 1 bit_size: 1