From 36e894b04ec6e9927740165a5875356b58b9b2ee Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 8 May 2012 00:53:51 +0200 Subject: digital/io-hub: optional pull-up for contacts --- digital/io-hub/src/common/contact.avr.c | 12 ++++++------ digital/io-hub/src/common/contact.host.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'digital/io-hub/src/common') diff --git a/digital/io-hub/src/common/contact.avr.c b/digital/io-hub/src/common/contact.avr.c index d6692566..f35f093a 100644 --- a/digital/io-hub/src/common/contact.avr.c +++ b/digital/io-hub/src/common/contact.avr.c @@ -45,9 +45,9 @@ void contact_init (void) { /* Pull-up. */ -#define CONTACT(io) IO_SET_ (io); - CONTACT (CONTACT_COLOR); - CONTACT (CONTACT_JACK); +#define CONTACT(io, pullup) if (pullup) IO_SET_ (io); + CONTACT (CONTACT_COLOR, 1); + CONTACT (CONTACT_JACK, 1); CONTACT_LIST #undef CONTACT /* Default to jack out. */ @@ -86,12 +86,12 @@ uint32_t contact_all (void) { uint32_t contacts = 0, bit = 1; -#define CONTACT(io) do { \ +#define CONTACT(io, pullup) do { \ contacts |= (IO_GET_ (io) ? bit : 0); \ bit <<= 1; \ } while (0); - CONTACT (CONTACT_COLOR); - CONTACT (CONTACT_JACK); + CONTACT (CONTACT_COLOR, 1); + CONTACT (CONTACT_JACK, 1); CONTACT_LIST #undef CONTACT return contacts; diff --git a/digital/io-hub/src/common/contact.host.c b/digital/io-hub/src/common/contact.host.c index cc302f46..1692ec65 100644 --- a/digital/io-hub/src/common/contact.host.c +++ b/digital/io-hub/src/common/contact.host.c @@ -52,7 +52,7 @@ contact_handle (void *user, mex_msg_t *msg) ctx.color_state = (contacts & 1) ? TEAM_COLOR_LEFT : TEAM_COLOR_RIGHT; ctx.jack_state = (contacts & 2) ? 1 : 0; contacts >>= 2; -#define CONTACT(io) do { \ +#define CONTACT(io, pullup) do { \ if (contacts & 1) \ IO_PIN_ (io) |= IO_BV_ (io); \ else \ -- cgit v1.2.3