From b52b8861867d21e66bd2a7c0c835851e5e297dad Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 3 Nov 2017 20:33:10 +0100 Subject: [PATCH] [firmware] card_pres: Use 0/1 index number instead of 1/2 We have moved most (all?) other code to work with slots 0/1 rather than 1/2. --- firmware/libboard/qmod/source/card_pres.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/firmware/libboard/qmod/source/card_pres.c b/firmware/libboard/qmod/source/card_pres.c index 344ab09c..c1bbd01f 100644 --- a/firmware/libboard/qmod/source/card_pres.c +++ b/firmware/libboard/qmod/source/card_pres.c @@ -17,9 +17,9 @@ int is_card_present(int port) const Pin *pin; int present; - if (port < 1 || port > NUM_CARDPRES) + if (port < 0 || port >= NUM_CARDPRES) return -1; - pin = &pin_cardpres[port-1]; + pin = &pin_cardpres[port]; /* Card present signals are low-active, as we have a switch * against GND and an internal-pull-up in the SAM3 */ @@ -32,12 +32,12 @@ static void cardpres_tmr_cb(void *data) { unsigned int i; - for (i = 1; i <= ARRAY_SIZE(pin_cardpres); i++) { + for (i = 0; i < ARRAY_SIZE(pin_cardpres); i++) { int state = is_card_present(i); - if (state != last_state[i-1]) { + if (state != last_state[i]) { TRACE_INFO("Card Detect %d Status %d -> %d\r\n", i, last_state[i], state); /* FIXME: report to USB host */ - last_state[i-1] = state; + last_state[i] = state; } }