From 4d26093fd63934a5b3b8441bb9740675faff1d96 Mon Sep 17 00:00:00 2001 From: knolax <1339802534.kk@gmail.com> Date: Thu, 7 Dec 2017 22:27:00 -0500 Subject: added functions to explicitly set pins as input or output do to kernel panics when trying to use gpio_set_value() --- skey.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/skey.c b/skey.c index d9bdef9..2d5b4aa 100644 --- a/skey.c +++ b/skey.c @@ -28,7 +28,7 @@ static void skey_update (unsigned long unused) { int column_index = 0; while (column_index < 10) { //sets the column pin high for reading - gpio_set_value(column_pins[column_index],1); + gpio_set_value(column_pins[column_index], 1); //reads with all the rows row_index = 0; while (row_index < 3) { @@ -38,7 +38,7 @@ static void skey_update (unsigned long unused) { row_index++; } //sets the row pin low - gpio_set_value(column_pins[column_index],0); + gpio_set_value(column_pins[column_index], 0); column_index++; } //updates the timer @@ -63,6 +63,9 @@ static int __init skey_init (void) { printk(KERN_ALERT "skey: column_pins[%d], BCM %d request failed\n", i, column_pins[i]); return -EINVAL; } + if (gpio_direction_output(column_pins[i], 0)) { + printk(KERN_ALERT "skey: column_pins[%d], BCM %d, set output failed\n",i, column_pins[i]); + } i++; } //ditto for row pins @@ -78,6 +81,9 @@ static int __init skey_init (void) { printk(KERN_ALERT "skey: row_pins[%d], BCM %d request failed\n", j, row_pins[j]); return -EINVAL; } + if (gpio_direction_input(row_pins[j])) { + printk(KERN_ALERT "skey: row_pins[%d], BCM %d, set output failed\n",j, row_pins[j]); + } j++; } //sets up timer for keyboard read function -- cgit v1.1