资源简介
s3c6410简单GPIO、LED、PWR驱动示例及使用说明。
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define DEVICE_NAME “buttons“
struct button_irq_desc {
int irq;
int number;
char *name;
};
static struct button_irq_desc button_irqs [] = {
{IRQ_EINT( 0) 0 “KEY0“}
{IRQ_EINT(18) 1 “KEY1“}
};
static volatile char key_values [] = {‘0‘ ‘0‘};
static DECLARE_WAIT_QUEUE_HEAD(button_waitq);
static volatile int ev_press = 0;
static irqreturn_t buttons_interrupt(int irq void *dev_id)
{
struct button_irq_desc *button_irqs = (struct button_irq_desc *)dev_id;
int down;
int number;
unsigned tmp;
udelay(0);
number = button_irqs->number;
switch(number) {
case 0:
tmp = readl(S3C64XX_GPNDAT);
down = !(tmp & (1< break;
case 1:
tmp = readl(S3C64XX_GPLDAT);
down = !(tmp & (1 << (number + 9)));
break;
default:
down = 0;
}
if (down != (key_values[number] & 1)) {
key_values[number] = ‘0‘ + down;
ev_press = 1;
wake_up_interruptible(&button_waitq);
}
return IRQ_RETVAL(IRQ_HANDLED);
}
static int s3c64xx_buttons_open(struct inode *inode struct file *file)
{
int i;
int err = 0;
for (i = 0; i < sizeof(button_irqs)/sizeof(button_irqs[0]); i++) {
if (button_irqs[i].irq < 0) {
continue;
}
err = request_irq(button_irqs[i].irq buttons_interrupt IRQ_TYPE_EDGE_BOTH
button_irqs[i].name (void *)&button_irqs[i]);
if (err)
break;
}
if (err) {
i--;
for (; i >= 0; i--) {
if (button_irqs[i].irq < 0) {
continue;
}
disable_irq(button_irqs[i].irq);
free_irq(button_irqs[i].irq (void *)&button_irqs[i]);
}
return -EBUSY;
}
ev_press = 1;
return 0;
}
static int s3c64xx_buttons_close(struct inode *inode struct file *file)
{
int i;
for (i = 0; i < sizeof(button_irqs)/sizeof(button_irqs[0]); i++) {
if (button_irqs[i].irq < 0) {
continue;
}
free_irq(button_irqs[i].irq (void *)&button_irqs[i]);
}
return 0;
}
static int s3c64xx_buttons_read(struct file *filp char __user *buff size_t count loff_t *offp)
{
unsigned long err;
if (!ev_press) {
if (filp->f_flags & O_NONBLOCK)
return -EAGAIN;
else
wait_event_interruptible(button_waitq ev_press);
}
ev_press = 0;
err = copy_to_user((void *)buff (const void *)(&key_values) min(sizeof(key_values) count));
return err ? -EFAULT : min(sizeof(key_values) count);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3925 2011-01-17 10:54 drivers\s3c6410_buttons.c
文件 3866 2011-01-17 10:55 drivers\s3c6410_leds.c
文件 3193 2011-01-17 10:53 drivers\s3c6410_pwm.c
I..D... 0 2011-01-17 10:56 drivers
文件 1242 2011-09-23 17:51 readme.txt
----------- --------- ---------- ----- ----
12226 5
相关资源
- LED PWM控制调光程序 c51
- STM32掌机驱动OLED屏幕
- 0.96OLED,z-stack驱动
- 16*64led点阵显示屏
- 太阳能LED路灯控制器设计
- STM32使用GPIO_F的0-7口的4*4矩阵按键
- tiny4412上实现QT控制LED
- 单片机驱动16*16点阵LED汉字显示c51程序
- 使用stm32控制彩色级联led WS2818B源程序
- LED数码管数据生成
- 学习Hyperledger Fabric 实战联盟链 地址
- 旋转LED模拟时钟程序源程序
- MBI5030 Application Note
- 基于52单片机LED点阵显示电子钟的设计
- SD1329驱动OLED芯片手册.pdf
- rc-g6 显示屏软件
- LED 字体 unity可用
- VHDL描述4*4标准矩阵键盘扫描读取并点
- 16*16点阵LED串口在线控制程序
- 区块链孔一学院视频+源码
- Hyperledger Fabric 超级账本视频教程
- SPI_OLED硬件与软件
- 最简单的hc06蓝牙模块控制led灯
- fatal: open /dev/null or dup failed: No such f
- 微机原理与接口技术课程设计-------
- 库函数驱动外设的应用:应用STM32的
-
WumpusWorld 使用 Knowledgeba
se的AI 实现 - 有源OLED全p_TFT屏上驱动电路设计
- Hyperledger Fabric kafka配置
- 迅为iTOP-4412开发板QtE-led例程,已验证
评论
共有 条评论