#include #include #include #include int major; char *name = "led"; int count = 0; ssize_t led_write(struct file* filp, const char *buf, size_t size, loff_t *offp) { volatile unsigned short *m; if (size < 2) return -EMSGSIZE; if (!buf) return -EFAULT; if(buf[0] == '0') m = pFIO_FLAG_C; else m = pFIO_FLAG_S; *m |= (1 << 2); // définir ou inhiber PF2 return size; } struct file_operations fops = {write:led_write}; int init_module(void) { // Définir PF2 en tant que sortie *pFIO_DIR = (1 << 2); major = register_chrdev(0, name, &fops);// espérons que cela réussisse ! printk("registered, major = %dn", major); return 0; } void cleanup_module(void) { unregister_chrdev(major, name); }