s5pv210(tiny210)gpio地址表

    xiaoxiao2025-04-14  9

    画了一个下午点灯,谢天谢地总算点完了,关于s5pv210的地址表一直没找到,这里写下备忘。

    #ifndef _S5PV210_GPIO_H #define _S5PV210_GPIO_H #define S5PV210_GPIOBASE (0XE0200000) //基地址 struct s5pc210_gpio_bank { unsigned int con; unsigned int dat; unsigned int pud; unsigned int drv; unsigned int con_pdn; unsigned int pud_pdn; unsigned char res1[8]; }; struct s5pv210_gpio { struct s5pc210_gpio_bank gpio_a0; struct s5pc210_gpio_bank gpio_a1; struct s5pc210_gpio_bank gpio_b; struct s5pc210_gpio_bank gpio_c0; struct s5pc210_gpio_bank gpio_c1; struct s5pc210_gpio_bank gpio_d0; struct s5pc210_gpio_bank gpio_d1; struct s5pc210_gpio_bank gpio_e0; struct s5pc210_gpio_bank gpio_e1; struct s5pc210_gpio_bank gpio_f0; struct s5pc210_gpio_bank gpio_f1; struct s5pc210_gpio_bank gpio_f2; struct s5pc210_gpio_bank gpio_f3; struct s5pc210_gpio_bank gpio_g0; struct s5pc210_gpio_bank gpio_g1; struct s5pc210_gpio_bank gpio_g2; struct s5pc210_gpio_bank gpio_g3; struct s5pc210_gpio_bank gpio_i; struct s5pc210_gpio_bank gpio_j0; struct s5pc210_gpio_bank gpio_j1; struct s5pc210_gpio_bank gpio_j2; struct s5pc210_gpio_bank gpio_j3; struct s5pc210_gpio_bank gpio_j4; }; #endif

    几个常用的操作地址的宏

    #define _REG(adr) (*(volatile unsigned int *)(adr)) #define readb(adr) (*(volatile unsigned char *)(adr)) #define readw(adr) (*(volatile unsigned short *)(adr)) #define readl(adr) (*(volatile unsigned int *)(adr)) #define writeb(value,adr) ((*(volatile unsigned char *)(adr))=(value)) #define writew(value,adr) ((*(volatile unsigned short *)(adr))=(value)) #define writel(value,adr) ((*(volatile unsigned int*)(adr))=(value))

    使用方法 比如设置PA0 最低一位输出高电平

    volatile struct s5pv210_gpio *gpio_base = (volatile struct s5pv210_gpio *)S5PV210_GPIOBASE; unsigned int temp= _REG(&gpio_base->gpio_a0.con); temp&= ~0xf; temp|=0x1; writel(temp, &gpio_base->gpio_a0.con); temp=_REG(&gpio_base->gpio_j2.dat); temp |=0x01; writel(temp, &gpio_base->gpio_a0.dat);
    转载请注明原文地址: https://ju.6miu.com/read-1298062.html
    最新回复(0)