初次接触嵌入式开发,请教一个问题,希望大侠们指教
-
- 帖子: 5
- 注册时间: 2008-10-26 11:57
初次接触嵌入式开发,请教一个问题,希望大侠们指教
问一个问题,在开发基于at91rm9200的驱动时在访问I/O端口时,在linux系统下我如何来访问这个I/O端口,可以直接通过物理地址 就行访问么?我如果这样写#define PIOA_PER (*(volatile unsigned *)0xfffff400)定义了该端口,然后通过这样PIOA_PER |=0x00000001对其进行赋值是否可行,还是通过ioremap函数将其定位到内核的虚拟地址然后进行访问?希望大侠们帮我指点一下,不胜感激!
-
- 帖子: 5
- 注册时间: 2008-11-04 18:29
Re: 初次接触嵌入式开发,请教一个问题,希望大侠们指教
在 LDD 中的 Communication with Hardware 中的 Platform Dependencies 中是这样描述的:
- ARM
Ports are memory-mapped, and all functions are supported; string functions are
implemented in C. Ports are of type unsigned int.
- To read from I/O memory, use one of the following:
unsigned int ioread8(void *addr);
unsigned int ioread16(void *addr);
unsigned int ioread32(void *addr);
Here, addr should be an address obtained from ioremap (perhaps with an integer offset);
the return value is what was read from the given I/O memory.
There is a similar set of functions for writing to I/O memory:
void iowrite8(u8 value, void *addr);
void iowrite16(u16 value, void *addr);
void iowrite32(u32 value, void *addr);