Closed farcaller closed 10 years ago
The memory addresses are needed in the macro to handle bitband access for single bit registers. I can feed them to the linker script with a rake script to parse the AST. You might want to have either #[cfg(...)]
support or something to handle sub-architectures.
This one is much more verbose though. Well, I see reasoning behind that one given we want to have bit-band access.
Can you provide a bit more details on clear()
and set()
? I'm not sure why do we care about those in a special way.
One more thing is that I'm not sure it needs to be that much rust-y. It currently looks like a reasonably usual rust code but it's not, as you would process this with a custom parser rather than rust parser. One might think that it's a valid rust code and add something (like arithmetic operation) that's not supported by custom parser. I think it would be better to keep the syntax simple.
Clear and set is for the write-only registers on some things that clear or set the relevant bits in the aliased register. I've seen some peripherals have them and figured it would be better to sugar them a little instead of duplication.
CR0::reg1();
CR0::set_reg1(x);
CR0::set_reg1();
CR0::clear_reg1();
CR0::toggle_reg1(); // some things also have a toggling alias register
The GPIO peripheral on the K20 is one example of these special aliases.
I feel that a custom syntax leaves more room for errors that the compiler will accept (whereas using arithmetic would cause a compiler error). Given that this is the most unsafe part of our code, I think it should be the most verbose and hardest to make a mistake.
Just remembered that I wanted to include enum support too, to sugar the writes to multi-bit variables.
Should we close this as the discussion is now in #90?
Makes sense.
I started having at look at this last night. Ended up with something along the lines of this (trying to be very Rust).
A little 'nicer' than.