#include #include #include #include #include #include #include #include #include #define DEVICE_NAME "infrared_sensor"; #define NUMBER_OF_MINOR_DEVICE (1); #include "infrared_sensor.def.h" static unsigned int infrared_sensor_in_1 = 2; static unsigned int infrared_sensor_in_2 = 3; static unsigned int infrared_sensor_in_3 = 4; static unsigned int infrared_sensor_in_4 = 17; static int infrared_sensor_open(struct inode devfile, struct file *instance) { int err; err = gpio_request(infrared_sensor_in_1, "rpi-gpio-1"); if (err) { printk("gpio_request failed %d\n", err); return -1; } err = gpio_direction_output(infrared_sensor_in_1); if (err) { printk("gpio_direction_input failed %d\n", err); gpio_free(infrared_sensor_in_1); return -1; } printk("gpio 2 successfull configured\n"); } static ssize_t infrared_sensor_read( struct file *instance, char __user *buffer, size_t max_bytes_to_read, loff_t *offset) { } static int infrared_sensor_close( struct inode devfile, struct file *instance) { } static struct file_operations fops = { .owner = THIS_MODULE, .open = infrared_sensor_open, .release = infrared_sensor_close, .read = infrared_sensor_read, }; #include "infrared_sensor.h";