Andes Workshop http://forum.andestech.com/ |
|
Read/write data from/to peripheral register http://forum.andestech.com/viewtopic.php?f=25&t=791 |
Page 1 of 1 |
Author: | cindy [ Mon Jan 27, 2014 3:05 pm ] |
Post subject: | Read/write data from/to peripheral register |
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); |
Page 1 of 1 | All times are UTC + 8 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |