diff --git a/course/12-Linux_device_drivers.pdf b/course/12-Linux_device_drivers.pdf index 64ebb9bf2ab2476f40313a6979860e35bbd5d4b1..8517478a6ef84cdb7d180a152286f7e31da16269 100644 Binary files a/course/12-Linux_device_drivers.pdf and b/course/12-Linux_device_drivers.pdf differ diff --git a/labs/lab06-gpio_driver.pdf b/labs/lab06-gpio_driver.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ed199b27729fb1c87e384cc93c2ae5e103a2d427 Binary files /dev/null and b/labs/lab06-gpio_driver.pdf differ diff --git a/labs/lab06-resources/template.c b/labs/lab06-resources/template.c new file mode 100644 index 0000000000000000000000000000000000000000..7b59397f3cfe0bb27ef77833035bd0397414e63a --- /dev/null +++ b/labs/lab06-resources/template.c @@ -0,0 +1,70 @@ +#include <linux/module.h> +#include <linux/device.h> +#include <linux/fs.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/interrupt.h> +#include <linux/gpio.h> + +// Operation prototypes +static int dev_open(struct inode *, struct file *); + +// The driver's file operations +static const struct file_operations fops = { + .owner = THIS_MODULE, + .open = dev_open +}; + +/** + * Driver initialization code. + */ +static int __init xxx_dev_init(void) { + + // TODO + // 1) Register the device by dynamically obtaining a major number + // 2) Create the class + // 3) Create the device in /dev + // 6) Request the necessary GPIOs + // 7) Register an IRQ handler per GPIO + pr_info("xxx: driver initialized\n"); + return 0; +} + +/** + * This function is called when the module is unloaded. + */ +static void __exit xxx_dev_exit(void) { + // TODO + // 1) Destroy the device + // 2) Destroy the class + // 4) Unregister the device + // 5) Free the IRQs + // 6) Free the GPIOs + pr_info("xxx: driver destroyed\n"); +} + +/** + * Open operation + */ +static int dev_open(struct inode *inod, struct file *f) { + pr_info("xxx: device opened\n"); + return 0; +} + +/** + * Joystick left IRQ handler + */ +static irqreturn_t mylab_left_irq_handler(int irq, void *dev_id) { + // TODO + // - Operations to be done when the left position of the joystick is triggered + // - At minimum, the joystick state must be updated + return (irqreturn_t) IRQ_HANDLED; // Announce that the IRQ has been handled correctly +} + +module_init(xxx_dev_init); +module_exit(xxx_dev_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Jaime Coder <jaime.coder@hesge.ch>"); +MODULE_DESCRIPTION("template module"); +MODULE_VERSION("0.1");