Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a complete makeover of the processor's C-language low-level hardware access. Instead of the current single-pointer approach a
struct
-based approach is used (https://blog.feabhas.com/2019/01/peripheral-register-access-using-c-structs-part-1/). The new approach is more intuitive and also more efficient as accesses to registers within the same unit can be computed from the module's base address and a simple offset (done by the compiler; it does not need to reload/reconstruct the whole 32-bit address).This PR is used to gather all the modifications (for easy referencing changes). Once everything is converted, tested and documented, this PR will be merged 😉
Old Version (Current State)
In the current state memory-mapped registers are defined as single pointers and are accessed via pre-defined
#define
s:C-example program:
New Version
The reworked version uses pre-defined
struct
s to provide easier access to all memory-mapped interface registers of peripheral modules. Each module has it's ownstruct
where the unit's interface registers are defined as members of this struct:C-example program:
This also allows to do nice things like determining a module's address space size via
sizeof(NEORV32_SPI)
.Compatibility
A new file
neorv32_legacy.h
is added to thesw/lib/include
folder that provides the "old"#define
-based register names (mapping to the new structs) to provide backward compatibility for existing software.Misc
This PR also renames the pre-defined control register names and bits:
*CT*
->*CTRL*
Furthermore, the
neorv32_cpu_delay_ms
function is reworked to use MTIME by default for busy wait. If MTIME is not available (not implemented) the old ASM-based delay loop is used as fall-back.