diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/src/GPIO.c b/org.fortiss.af3.platform.raspberry/trunk/lib/src/GPIO.c index 2f10a17e4b69ea6ff69f2f28ee4a433c7541770c..c129d2d93f2907a8e5e0e9150bfd4bae95c15ba3 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/src/GPIO.c +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/src/GPIO.c @@ -1,12 +1,22 @@ #include "inc/GPIO.h" // init, term +GEN_TYPE_boolean gpio_initialized = false; +GEN_TYPE_boolean gpio_terminated = false; + void gpio_init(GPIO_PIN_T pin) { + // important, since all pins are accessing the same method + if(gpio_initialized) return; + gpio_initialized = true; + // TODO initialize... } -void gpio_term(GPIO_PIN_T pin) { +void gp_term() { + // important, since all pins are accessing the same method + if(gpio_terminated) return; + gpio_terminated = false; } // noval @@ -15,7 +25,7 @@ GEN_TYPE_boolean gpio_is_noval(GPIO_PIN_T pin) { } void gpio_set_noval(GPIO_PIN_T pin) { - + // do nothing } // readers diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c b/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c index af773b6ff20cf3ca55574d92e691e4f2c1a5ddd0..8583b0fbc8ea2a43f3e416db6638d669ad08afe5 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c @@ -30,12 +30,15 @@ GEN_TYPE_int lrf_read() { // looks like a blocking call and actually is but is always very fast // since it only has to read the queue while (1) { - n_read = uart_receive(bytes, 5, 0); + n_read = uart_receive(&bytes, 5, 0); for (i = 0; i < n_read; i++) { if (bytes[i] != 0xd && bytes[i] != 0xa) { value[n++] = bytes[i]; } else if (atoi(value) != 0) { + for (i = n; i < 3; i++) { + value[i] = 0; + } return atoi(value); } }