ARM-software / CMSIS_5

CMSIS Version 5 Development Repository
http://arm-software.github.io/CMSIS_5/index.html
Apache License 2.0
1.32k stars 1.08k forks source link

Question - use inner union as types (output of SvdConv) #1496

Open itay-yaakov-altair opened 2 years ago

itay-yaakov-altair commented 2 years ago

We currently generate .h using SVDConv.exe file.svd --generate=header --fields=struct --fields=macro. Is there a way to declare variable with the register's union/struct type on the stack? (I mean - without initialize the whole peripheral struct)

It can be useful for inner state tracking, without modify the real device register value. e.g. storing previous state of register

Maybe an option to create named union inside of the peripheral typedef?

typedef struct {                            

  union {
    __IOM uint32_t REGISTER;                  

    struct {
      __IM  uint32_t FIELD : 16;
            uint32_t       : 16;
    } REGISTER_b;
  } ;

  /*  other unions  */

} TEST;

TEST t; // valid

REGISTER_b previous_register_state; // goal (invalid code)

Thanks!

JonatanAntoni commented 2 years ago

Hi @itay-yaakov-altair,

No, unfortunately this is currently not possible. We already thought about it but due to the access qualifiers this does not work right away. E.g., having const qualifiers in the typedef.

Cheers, Jonatan