summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--skey.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/skey.c b/skey.c
index 5038e36..70955f4 100644
--- a/skey.c
+++ b/skey.c
@@ -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;
}