void sys_driver_init() { //open screen gpio_setup(SCREES_DC, GPIO_OUTPUT); gpio_write(SCREES_DC, 0); //screen reset gpio_setup(SCREES_RES, GPIO_OUTPUT); gpio_write(SCREES_RES, 1); //rgb led uint8_t led_pin[] = {28, 29, 30}; light_setup(led_pin, 0); //init screen SSD1306_Init_Struct init_struct; init_struct.SCL = 9; init_struct.SDA = 8; ssd1306_config(&init_struct); OLED_Init(); OLED_Clear(); gfx_init_screen((uint8_t *)&screen, 128, 32, 1); gfx_clear(); OLED_Refresh_all(); //hall task gpio_change_point = NULL; gpio_watch(HALL, GPIO_FALLING); //button gpio_setup(BUTTON, GPIO_INPUT_PULLUP); }
/*** Request handler ***/ void handle_request() { char *p = NULL; unsigned long base = 10; unsigned long id; if((procfs_buffer[0] == 'P') || (procfs_buffer[0] == 'V')) base = 16; id = simple_strtoul(procfs_buffer+2, &p, base); switch(procfs_buffer[0]) { case 'r': printk(KERN_ERR "GPIOed: GPIO %lu is %s\n", id, gpio_get(id)?"high":"low "); break; case 's': gpio_watch(id); break; case 'h': gpio_set(id, 1); printk(KERN_ERR "GPIOed: GPIO %lu set high\n", id); break; case 'l': gpio_set(id, 0); printk(KERN_ERR "GPIOed: GPIO %lu set low\n", id); break; case 'd': printk(KERN_ERR "GPIOed: GPIO %lu is %s\n", id, GET_GPIO_REG(DR,id)?"output":"input"); break; case 'P': printk(KERN_ERR "GPIOed: P-V for 0x%x is 0x%x\n", id, (unsigned int)phys_to_virt(id)); break; case 'V': printk(KERN_ERR "GPIOed: V-P for 0x%x is 0x%x\n", id, (unsigned int)virt_to_phys(id)); break; case 'D': base = *((unsigned int*)id); printk(KERN_ERR "GPIOed: 0x%x = 0x%x\n", id, base); break; default: printk(KERN_ERR "GPIOed: Unknown request\n"); break; } }