- 论坛徽章:
- 0
|
芯片:at91rm920
代码:
#define AT91C_BASE_PIOB 0xFFFFF600 /* (PIOB) Base Address */
static AT91PS_PIO s_piob;
INT32 pio_map(VOID)
{
INT32 i32Fd;
off_t addr;
static VOID *base;
if ((i32Fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1)
{
printf("Cannot open /dev/mem.\n");
return 0;
}
#ifdef _DEBUG
printf("/dev/mem opened.\n");
#endif
addr = AT91C_BASE_PIOB; //map PIO controller B
base = mmap(0,MAP_SIZE,PROT_READ|PROT_WRITE,MAP_SHARED,i32Fd, addr & ~MAP_MASK);
if (base == (VOID *)-1)
{
printf("Cannot mmap.\n");
close(i32Fd);
return 0;
}
#ifdef _DEBUG
printf("PIOB memory mapped at address %p.\n", base);
#endif
s_piob = base + (addr & MAP_MASK);
close(i32Fd);
return 1;
}
请教:
/dev/mem中的地址信息是怎么样的啊,我想要映射PIOB到用户空间来使用,
MAP_SIZE和MAP_MASK这两个参数应该是多少才对?请做过类似的达人来给我指点一下。 |
|