diff options
author | knolax <1339802534.kk@gmail.com> | 2017-12-20 00:36:29 -0500 |
---|---|---|
committer | knolax <1339802534.kk@gmail.com> | 2017-12-20 00:36:29 -0500 |
commit | fcba4be107df5b150251d4569a86dc8ff3e824c0 (patch) | |
tree | f73120c17f8d6ad6beb060f15bf5e4ba079beb38 | |
parent | 5b2857fba2fe5a364468ddfbeb20c056f4f2bbca (diff) |
reversed the roles of the row and column pins to account for an error in the prototype board.
-rw-r--r-- | skey.c | 37 |
1 files changed, 27 insertions, 10 deletions
@@ -13,6 +13,23 @@ */ #define USE_GPIO 1 /* + * On the prototype model, the diodes were soldered backwards, so that the + * negative ends were facing the cpins. + * as outputs they seem to opendrain(transistor to high, resistor to low) + * this means that the cpins can not pull the rlabels down. we can not + * work around this by using the pins as active_low + * we now have to use rpins as the output and cpins as the input because + * we can only use active_high, and the positive side of the diodes are + * facing the rpins. This means we don't have short-circuit since the diodes + * are still connected to the cpins. however, when shorting them in + * production it seems that the problem is not bad enough to cause the board + * to shut down. + */ + + + +/* + * GPIO pins * Unsigned ints containing the BCM pin numbers for the pins used, __initdata * helps with the loading and unloading of data in memory */ @@ -66,22 +83,22 @@ int skey_update_thread (void *data) { //reads the keyboard int row_index = 0; int column_index = 0; - while (column_index < 10) { + while (row_index < 3) { //sets the column pin high for reading - gpio_set_value(column_pins[column_index], 1); + gpio_set_value(row_pins[row_index], 1); //reads with all the rows - row_index = 0; - while (row_index < 3) { - if (gpio_get_value(row_pins[row_index])) { + column_index = 0; + while (column_index < 10) { + if (gpio_get_value(column_pins[column_index])) { printk(KERN_INFO "skey: key pressed at column %d, row %d\n", column_index, row_index); } else { printk(KERN_INFO "skey: key not pressed at column %d, row %d\n", column_index, row_index); } - row_index++; + column_index++; } //sets the row pin low - gpio_set_value(column_pins[column_index], 0); - column_index++; + gpio_set_value(row_pins[row_index], 0); + row_index++; } } //sleep 2000us= 2ms = 0.002 seconds @@ -111,7 +128,7 @@ static int __init skey_init (void) { return -EINVAL; } //requests access of the GPIO - if (gpio_request_one(column_pins[i], GPIOF_OUT_INIT_LOW ,clabels[i])) { + if (gpio_request_one(column_pins[i], GPIOF_IN ,clabels[i])) { printk(KERN_ALERT "skey: column_pins[%d], BCM %d request failed\n", i, column_pins[i]); return -EINVAL; } @@ -129,7 +146,7 @@ static int __init skey_init (void) { return -EINVAL; } //requests access of the GPIO - if (gpio_request_one(row_pins[j], GPIOF_DIR_IN ,rlabels[j])) { + if (gpio_request_one(row_pins[j], GPIOF_DIR_OUT_INIT_LOW ,rlabels[j])) { printk(KERN_ALERT "skey: row_pins[%d], BCM %d request failed\n", j, row_pins[j]); return -EINVAL; } |