From 3b85868fe73ff86ae7aa79d492236aab22e8f6f9 Mon Sep 17 00:00:00 2001 From: skarg Date: Mon, 26 Nov 2012 02:12:37 +0000 Subject: [PATCH] Modified the BDK port for version 4 hardware layout --- bacnet-stack/ports/bdk-atxx4-mstp/input.c | 24 ++++++++++++++++++++++- bacnet-stack/ports/bdk-atxx4-mstp/input.h | 3 ++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/input.c b/bacnet-stack/ports/bdk-atxx4-mstp/input.c index 58932115..1fb920c2 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/input.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/input.c @@ -29,6 +29,10 @@ /* me */ #include "input.h" +#ifndef BDK_VERSION +#define BDK_VERSION 4 +#endif + static uint8_t Address_Switch; static uint8_t Buttons; static struct itimer Debounce_Timer; @@ -96,8 +100,14 @@ void input_task( Address_Switch = old_address; } old_address = value; +#if (BDK_VERSION==4) + /* pins used are PB3, PB2, PB1 */ + value = BITMASK_CHECK(PINB, 0x0E); + value >>= 1; +#else /* pins used are PB4, PB3, PB2, PB1, PB0 */ value = BITMASK_CHECK(PINB, 0x1F); +#endif if (value == old_buttons) { /* stable value */ Buttons = old_buttons; @@ -115,6 +125,12 @@ uint8_t input_address( return Address_Switch; } +uint8_t input_rotary_value( + uint8_t index) +{ + return Buttons; +} + bool input_button_value( uint8_t index) { @@ -163,10 +179,16 @@ void input_init( BIT_SET(PORTA, PORTA4); BIT_SET(PORTA, PORTA5); BIT_SET(PORTA, PORTA6); - /* configure the port pins for binary inputs */ + /* configure the port pins for rotary switch inputs */ +#if (BDK_VERSION==4) + BIT_CLEAR(DDRB, DDB1); + BIT_CLEAR(DDRB, DDB2); + BIT_CLEAR(DDRB, DDB3); +#else BIT_CLEAR(DDRB, DDB1); BIT_CLEAR(DDRB, DDB2); BIT_CLEAR(DDRB, DDB3); BIT_CLEAR(DDRB, DDB4); +#endif timer_interval_start(&Debounce_Timer, 30); } diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/input.h b/bacnet-stack/ports/bdk-atxx4-mstp/input.h index bb8ba7d5..19c30e5a 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/input.h +++ b/bacnet-stack/ports/bdk-atxx4-mstp/input.h @@ -38,7 +38,8 @@ extern "C" { void); bool input_button_value( uint8_t index); - + uint8_t input_rotary_value( + uint8_t index); #ifdef __cplusplus } #endif /* __cplusplus */