hi3518/hi3516/等通用的gpio及寄存器读写驱动(理论上可以用于海思所有的芯片)
5 E币
成为会员,免费下载资料
文件大小:5.28 KB
上传者:cfgrpg
时间:2015-09-23 18:37:05
下载量:149
本帖最后由 cfgrpg 于 2017-2-28 15:37 编辑
封装出以下函数
[code]
#define GPIO_INPUT 0
#define GPIO_OUTPUT 1
extern int gpioClr(unsigned char gpioBank, unsigned char gpioBit);
extern int gpioGet(unsigned char gpioBank, unsigned char gpioBit);
extern int gpioSet(unsigned char gpioBank, unsigned char gpioBit);
extern int gpioSetMode(unsigned char gpioBank, unsigned char gpioBit
, unsigned char gpioDir, unsigned char gpioValue);
extern int reg_read(unsigned int arg, unsigned int *regvalue);
extern int reg_write(unsigned int arg, unsigned int regvalue);
[/code]
初始化
[code]
//0_3
reg_read(0x200F012C, ®value);
regvalue &= 0xFFFFFFFC;
reg_write(0x200F0020, regvalue);
gpioSetMode(0, 3, GPIO_OUTPUT, 0);
[/code]
读取设置gpio
[code]
int Get_Gpio_status(int gpio1,int gpio2)
{
return (gpioGet(gpio1, gpio2)) ^ 0x01;
}
int Set_Gpio_status(int gpio1,int gpio2,int status)
{
(status)? gpioSet(gpio1, gpio2):gpioClr(gpio1, gpio2);
return 0;
}
[/code]
把此文件夹放在sdk的mpp2/extdrv或者mpp/extdrv目录下面,
1、insmod gpio_driver.ko
结合项目里面的sdk,封装出了接口去设置寄存器的值及gpio读写。
不再使用himm 0x200A0030 0x0
封装出以下函数
[code]
#define GPIO_INPUT 0
#define GPIO_OUTPUT 1
extern int gpioClr(unsigned char gpioBank, unsigned char gpioBit);
extern int gpioGet(unsigned char gpioBank, unsigned char gpioBit);
extern int gpioSet(unsigned char gpioBank, unsigned char gpioBit);
extern int gpioSetMode(unsigned char gpioBank, unsigned char gpioBit
, unsigned char gpioDir, unsigned char gpioValue);
extern int reg_read(unsigned int arg, unsigned int *regvalue);
extern int reg_write(unsigned int arg, unsigned int regvalue);
[/code]
初始化
[code]
//0_3
reg_read(0x200F012C, ®value);
regvalue &= 0xFFFFFFFC;
reg_write(0x200F0020, regvalue);
gpioSetMode(0, 3, GPIO_OUTPUT, 0);
[/code]
读取设置gpio
[code]
int Get_Gpio_status(int gpio1,int gpio2)
{
return (gpioGet(gpio1, gpio2)) ^ 0x01;
}
int Set_Gpio_status(int gpio1,int gpio2,int status)
{
(status)? gpioSet(gpio1, gpio2):gpioClr(gpio1, gpio2);
return 0;
}
[/code]
把此文件夹放在sdk的mpp2/extdrv或者mpp/extdrv目录下面,
1、insmod gpio_driver.ko
结合项目里面的sdk,封装出了接口去设置寄存器的值及gpio读写。
不再使用himm 0x200A0030 0x0
展开》
折叠》