Forum Discussion
Altera_Forum
Honored Contributor
12 years agoI agree about the struct access and you can extend it even further by taking the address of a pointer casted to the base address of the peripheral (plus 0x80000000) of the struct. This gives you a compile-time accessed non-cached access which IMO is much easier to read.
Example:
# define MY_PER_BASE 0x10000000UL
typedef struct {
alt_u32 control;
alt_u32 status;
} s_MyPeripheral;
# define MyPeripheral ((s_MyPeripheral *) (0x80000000UL | MY_PER_BASE))
void t(void)
{
alt_u32 stat = MyPeripheral->status;
MyPeripheral->control = 1;
}
Bill A