内存映射的I / O寻址如何工作?
配置时钟:
#define BCM2708_PERI_BASE 0x20000000
#define CLOCK_BASE (BCM2708_PERI_BASE + 0x101000) /* Clocks */
它首先像这样映射代码...
clk_map = (unsigned char *)mmap(
(caddr_t)clk_mem,
MAP_BLOCK_SIZE,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED,
mem_fd,
CLOCK_BASE
);
然后它会做某事...
// Always use volatile pointer!
clk = (volatile unsigned *)clk_map;
当引用它时,会有0x26和0x27的这些奇怪的加法,那是什么意思?
printf("Disabling I2S clock\n");
*(clk+0x26) = 0x5A000000;
*(clk+0x27) = 0x5A000000;
usleep(10);
printf("Confiure I2S clock\n");
*(clk+0x26) = 0x5A000001;
*(clk+0x27) = 0x5A000000 | 3<<12 | 1<<9; // divider: 3.125==0b11.001
usleep(10);
printf("Enabling I2S clock\n");
*(clk+0x26) = 0x5A000011;
查看数据表,我可以看到它们在哪里有这些值,例如基址,但我正努力理解其他值。CLOCK_BASE
确定在哪里,这是怎么回事?