led can now glow
This commit is contained in:
parent
1a70ce9c0c
commit
ac91c5cb2b
6
src/io.c
6
src/io.c
|
@ -2,6 +2,7 @@
|
|||
#define LCD_IO_H_
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/gpio.h>
|
||||
#include "lcd.h"
|
||||
|
||||
loff_t lcd_llseek(struct file* filp, loff_t where, int whence)
|
||||
|
@ -30,12 +31,17 @@ int lcd_open(struct inode* inode, struct file* filp)
|
|||
dev = container_of(inode->i_cdev, struct lcd_dev, dev);
|
||||
filp->private_data = (void*)dev;
|
||||
|
||||
gpio_set_value(dev->gpio, 1);
|
||||
|
||||
printk(KERN_INFO "%s: Opened device\n", THIS_MODULE->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lcd_release(struct inode* inode, struct file* filp)
|
||||
{
|
||||
struct lcd_dev* dev;
|
||||
dev = (struct lcd_dev*)filp->private_data;
|
||||
gpio_set_value(dev->gpio, 0);
|
||||
printk(KERN_INFO "%s: Released device\n", THIS_MODULE->name);
|
||||
return 0;
|
||||
}
|
||||
|
|
21
src/lcd.c
21
src/lcd.c
|
@ -2,6 +2,7 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
|
@ -17,6 +18,9 @@ static struct lcd_dev lcddev = { 0 };
|
|||
static int __init lcd_init_cdev(void);
|
||||
static void __exit lcd_exit_cdev(void);
|
||||
|
||||
static int __init lcd_init_gpio(void);
|
||||
static void __exit lcd_exit_gpio(void);
|
||||
|
||||
extern loff_t lcd_llseek (struct file*, loff_t, int);
|
||||
extern ssize_t lcd_read (struct file*, char __user*, size_t, loff_t*);
|
||||
extern ssize_t lcd_write (struct file*, const char __user*, size_t, loff_t*);
|
||||
|
@ -60,12 +64,17 @@ static int __init lcd_init_module(void)
|
|||
if(result < 0)
|
||||
return result;
|
||||
|
||||
result = lcd_init_gpio();
|
||||
if(result < 0)
|
||||
return result;
|
||||
|
||||
printk(KERN_INFO "%s: Module loaded!\n", THIS_MODULE->name);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void __exit lcd_exit_module(void)
|
||||
{
|
||||
lcd_exit_gpio();
|
||||
lcd_exit_cdev();
|
||||
unregister_chrdev_region(lcddev.devno, 1);
|
||||
|
||||
|
@ -94,3 +103,15 @@ static void __exit lcd_exit_cdev(void)
|
|||
{
|
||||
cdev_del(&lcddev.dev);
|
||||
}
|
||||
|
||||
static int __init lcd_init_gpio(void)
|
||||
{
|
||||
lcddev.gpio = 18;
|
||||
gpio_direction_output(lcddev.gpio, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit lcd_exit_gpio(void)
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in a new issue