本帖最后由 人来人往 于 2020-6-20 11:18 编辑
请问我在学习“CH12_LED字符驱动程序,mp4”时,LED的Base Adress是0x41200000,请问这个值是从哪里找到的呢?UG585里面没有看到呢?(我只看到Vivado工程中,有一个AXI—GPIO地址是0x41200000,但是我驱动的编写并没有涉及到Vivado工程)。
//地址映射:把物理地址转换为虚拟地址
led_base = ioremap(0x41200000, 4);
printk("LED: Access address to device is:0x%x\n", (unsigned int)led_base);
另外,我在UG585上面看MIO基地址,以及MIO设置input/output、Dir、Enble等寄存器的移位地址,但是操作写1,不能点亮相应MIO的LED(如MIO7对应的LD9指示灯)。
//MIO基地址
#define GPIO_BASE_Address 0xe000a000
volatile unsigned int *mask_data_lsw; //屏蔽输出低16bit
#define MASK_DATA_0_LSW 0X00000000
volatile unsigned int *mask_data_msw; //屏蔽输出高16bit
#define MASK_DATA_0_MSW 0X00000004
volatile unsigned int *data; //输出数据
#define DATA_0 0X00000040
volatile unsigned int *dirm; //配置I/O口方向
#define DIRM_0 0X00000204
volatile unsigned int *oen; //输出使能
#define OEN_0 0X00000208
volatile unsigned int *clk; //时钟地址
#define CLK_ADDR 0XF800012C
volatile unsigned int *led_base;
static int board_demo_led_init (int which) /* 初始化LED, which-哪个LED */
{
mask_data_lsw = ioremap(GPIO_BASE_Address+MASK_DATA_0_LSW,4); //BANK0 低16bit
mask_data_msw = ioremap(GPIO_BASE_Address+MASK_DATA_0_MSW,4); //BANK0 高16bit
data = ioremap(GPIO_BASE_Address+DATA_0,4);
dirm = ioremap(GPIO_BASE_Address+DIRM_0,4);
oen = ioremap(GPIO_BASE_Address+OEN_0,4);
clk = ioremap(CLK_ADDR,4);//时钟默认打开,可以不用管啦
led_base = ioremap(0x41200000, 4);
iowrite32(0xffffff7f,mask_data_lsw); // 7f : 0111 1111 ==> MIO7
iowrite32(0xffffff7f,mask_data_msw);
iowrite32(0x00000080,dirm); // 0x80 : 1000 0000 ==> MIO7
iowrite32(0x00000080,oen);
printk("which = %d" , which);
printk("LED init");
return 0;
}
static int board_demo_led_ctl (int which, char status) /* 控制LED, which-哪个LED, status:1-亮,0-灭 */
{
if (which == 0)
{
if (status) /* on: output 0 */
{
iowrite32(1,led_base);
printk("LED ON!") ;
}
else
{
iowrite32(0,led_base);
printk("LED OFF!") ;
}
}
return 0;
}
希望有大佬可以解惑。万分感谢~~
|
|