riscv-rust / k210-pac

Peripheral access API crate (PAC) for K210 SoC, generated by svd2rust
29 stars 23 forks source link

DMAC #24

Closed laanwj closed 5 years ago

laanwj commented 5 years ago

Source: src/drivers/include/dmac.h.

laanwj commented 5 years ago

I've moved the <size>64</size> down into all registers, which seems to work. I am confused by the generated structure though:

    #[doc = "0x100 - Channel configuration"]
    pub channel0: CHANNEL,
    _reserved2: [u8; 248usize],
    #[doc = "0x200 - Channel configuration"]
    pub channel1: CHANNEL,
    _reserved3: [u8; 248usize],
    #[doc = "0x300 - Channel configuration"]
    pub channel2: CHANNEL,
    _reserved4: [u8; 248usize],
    #[doc = "0x400 - Channel configuration"]
    pub channel3: CHANNEL,
    _reserved5: [u8; 248usize],
    #[doc = "0x500 - Channel configuration"]
    pub channel4: CHANNEL,
    _reserved6: [u8; 248usize],
    #[doc = "0x600 - Channel configuration"]
    pub channel5: CHANNEL,

How can this be correct? I've padded CHANNEL to 0x100 bytes, as far as I know! It should be generating an array channel[6].

burrbull commented 5 years ago

You can add _reserved to end of cluster like I did in i2s.

laanwj commented 5 years ago

I did, but even if that failed there would be no way there's 248 bytes left. THat'd mean the entire structure is only 8 bytes (did all the fields land on top of each other?).

burrbull commented 5 years ago

Looks like bug in svd2rust here: https://github.com/rust-embedded/svd2rust/blob/20d8bd4c7554c5b9ced6c1c6941a81747274e9e4/src/generate/peripheral.rs#L602

Disasm commented 5 years ago

Sorry, I forgot about this PR. Thanks for the corrections!