Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Refactor hw descriptors to be clearer #17
The current hardware descriptors are just a numeric index. This makes it non-obvious how they are mapped into actual hardware. This also goes against the general library philosophy of not trying to hide the fact the hardware has names.
Descriptors should be based on the actual hardware names instead. It needs to be efficient in how the reverse map works, however, since the reverse map will end up being called from ISRs frequently.
Suggested approach is:
For example, for usarts, the concept might be:
Then these are passed as arguments instead of numbers, so usart_conf becomes..
The ISR can then call the generic handler like this:
Because this will resolve to the correct entry in the array of port structs.
To protect the definitions on multiple different xmega chips, we only need to test for the presence of the hardware:
And we can do the same for ISRs. The chip support then only needs to define the usart_portname_t for each xmega case.