Andes Workshop

It is currently Thu Mar 28, 2024 11:37 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Read/write data from/to peripheral register
PostPosted: Mon Jan 27, 2014 3:05 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
Read/write data from/to peripheral register

word access example:

#define inw(reg) (*((volatile unsigned int *) (reg)))
#define outw(reg, data) ((*((volatile unsigned int *)(reg)))=(unsigned int)(data))
#define UART_BASE 0x99600000

outw(UART_BASE + 0x00, 0x36);
temp=inw(UART_BASE + 0x08);
-----------------------------------------------------------------------------------------------
half-word access example:

#define inh(reg) (*((volatile unsigned short *) (reg)))
#define outh(reg, data) ((*((volatile unsigned short *)(reg)))=(unsigned short)(data))
#define UART_BASE 0x99600000

outh(UART_BASE + 0x00, 0x36);
temp=inh(UART_BASE + 0x08);
-----------------------------------------------------------------------------------------------
byte access example:

#define inb(reg) (*((volatile unsigned char *) (reg)))
#define outb(reg, data) ((*((volatile unsigned char *)(reg)))=(unsigned char)(data))
#define UART_BASE 0x99600000

outb(UART_BASE + 0x00, 0x36);
temp=inb(UART_BASE + 0x08);


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group