diff options
author | knolax <1339802534.kk@gmail.com> | 2017-12-07 22:27:00 -0500 |
---|---|---|
committer | knolax <1339802534.kk@gmail.com> | 2017-12-07 22:27:00 -0500 |
commit | 4d26093fd63934a5b3b8441bb9740675faff1d96 (patch) | |
tree | e8fed45c4a1f50326d2664d12ec5701ac8bc3510 | |
parent | e673f16c5d15640dd01d4af5effb08c9e298a1bd (diff) |
added functions to explicitly set pins as input or output do to kernel panics when trying to use gpio_set_value()
-rw-r--r-- | skey.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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 |