X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=boards%2Ftriface%2Fhw%2Fhw_input.h;h=2a56b89fcb4391a11920e9403d55fab1b672f828;hb=2a58e0dd1a4ab0ded89edc417fd9342a9457564e;hp=f0ef721cf89fc1246c165d9643e64d23c52f8631;hpb=bf7b83a7ba537d9cc4ead0fa5e3c68648bff7597;p=bertos.git diff --git a/boards/triface/hw/hw_input.h b/boards/triface/hw/hw_input.h index f0ef721c..2a56b89f 100644 --- a/boards/triface/hw/hw_input.h +++ b/boards/triface/hw/hw_input.h @@ -26,7 +26,7 @@ * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. * - * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/) + * Copyright 2003, 2004, 2006, 2010 Develer S.r.l. (http://www.develer.com/) * Copyright 2000 Bernie Innocenti * * --> @@ -42,19 +42,17 @@ #include /* Set pins as input and enable pull-up */ -#define INPUT_INIT_D do \ -{ \ - (DDRD &= ~(BV(PD4) | BV(PD5) | BV(PD6) | BV(PD7))); \ - (PORTD |= (BV(PD4) | BV(PD5) | BV(PD6) | BV(PD7))); \ -} while(0) +#define INPUT_INIT_D \ + do{ \ + DDRD &= ~(BV(PD4) | BV(PD5) | BV(PD6) | BV(PD7)); \ + PORTD |= (BV(PD4) | BV(PD5) | BV(PD6) | BV(PD7)); \ + } while(0) -#define INPUT_INIT_E do \ -{ \ - (DDRE &= ~(BV(PE4) | BV(PE5) | BV(PE6) | BV(PE7))); \ - ATOMIC((PORTE |= (BV(PE4) | BV(PE5) | BV(PE6) | BV(PE7)))); \ -} while(0) - -#define INPUT_INIT do { INPUT_INIT_D; INPUT_INIT_E;} while(0) +#define INPUT_INIT_E \ + do{ \ + DDRE &= ~(BV(PE4) | BV(PE5) | BV(PE6) | BV(PE7)); \ + PORTE |= (BV(PE4) | BV(PE5) | BV(PE6) | BV(PE7)); \ + } while(0) INLINE uint8_t INPUT_GET(void) { @@ -62,10 +60,17 @@ INLINE uint8_t INPUT_GET(void) out_d = PIND; out_e = PINE; + /* Select our input (see scheme) */ out_d >>= 4; out_e = out_e & 0xF0; - return out_e | out_d; + return (out_e | out_d); } -#endif // HW_INPUT_H +#define INPUT_INIT() \ + do { \ + INPUT_INIT_D; \ + INPUT_INIT_E; \ + } while(0) + +#endif /* HW_INPUT_H */