连续寄存器寻址
#include <stdio.h>
#define __arch_getb(a) (*(volatile unsigned char *)(a))
struct lpuart_serial_platdata {
void *reg;
};
#define u8 unsigned char
struct lpuart_fsl {
int ubdh;
u8 ubdl;
u8 uc1;
u8 uc2;
u8 us1;
u8 us2;
u8 uc3;
u8 ud;
u8 uma1;
u8 uma2;
u8 uc4;
u8 uc5;
u8 ued;
u8 umodem;
u8 uir;
u8 reserved;
u8 upfifo;
u8 ucfifo;
u8 usfifo;
u8 utwfifo;
u8 utcfifo;
u8 urwfifo;
u8 urcfifo;
u8 rsvd[28];
};
int main()
{
struct lpuart_serial_platdata data1;
data1.reg = (void *)0x123456;
struct lpuart_fsl *base = data1.reg;
printf("reg=%x\n",data1.reg);
printf("base=%x\n",base);
printf("&base=%x\n",&base);
/*printf("reg1=%x\n",base->urcfifo);*/
printf("urcfifo=%x\n",&base->ubdh);
printf("urcfifo=%x\n",&base->ubdl);
打印结果:
reg=123456
base=123456
&base=3c16aa60
urcfifo=123456
urcfifo=12345a