为什么我这样点灯点不起来?()

林鼎鼎 2017-08-23 11:32:43
芯片手册RK3328
原理图

#include <linux/init.h>
#include <linux/module.h>
#include <asm/io.h>
#include <linux/ioport.h>

#define GPIO2_BASE 0xFF230000
#define GPIO2_MEM_SIZE 0x00010000
#define GPIO2_DIR (volatile unsigned long *)ioremap(GPIO2_BASE + 4, 4)
#define GPIO2_OUT (volatile unsigned long *)ioremap(GPIO2_BASE + 0, 4)
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
unsigned int res;
unsigned int set;

printk(KERN_INFO "Hello, world\n");
//request_mem_region(GPIO2_BASE, GPIO2_MEM_SIZE, "GPIO2_LED");

res = __raw_readl(GPIO2_DIR);
printk(KERN_INFO "Before set GPIO2_DIR value :%d\n", res);
res = __raw_readl(GPIO2_OUT);
printk(KERN_INFO "Before set GPIO2_OUT value :%d\n", res);

//GPIO2_B7 output
set = __raw_readl(GPIO2_DIR);
set |= ~(1 << 23);
set = 0; //全out
__raw_writel(set, GPIO2_DIR);

//GPIO2_B7 = 1
set = __raw_readl(GPIO2_OUT);
set |= (1 << 23);
set = 0xffffffff; //全高电平
__raw_writel(set, GPIO2_OUT);

res = __raw_readl(GPIO2_DIR);
printk(KERN_INFO "After set GPIO2_DIR value :%d\n", res);
res = __raw_readl(GPIO2_OUT);
printk(KERN_INFO "After set GPIO2_OUT value :%d\n", res);

//ERR:
return 0;
}
static void hello_exit(void)
{
printk(KERN_INFO "Goodbye, cruel world\n");
//release_mem_region(GPIO2_BASE, GPIO2_MEM_SIZE);
}
module_init(hello_init);
module_exit(hello_exit);

这样写有问题吗?(实际上灯没被点亮)
...全文
79 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,319

社区成员

发帖
与我相关
我的任务
社区描述
主要是开发驱动技术
社区管理员
  • 驱动程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧