Modified the BDK port for version 4 hardware layout

This commit is contained in:
skarg
2012-11-26 02:12:37 +00:00
parent fce60832e6
commit 3b85868fe7
2 changed files with 25 additions and 2 deletions
+23 -1
View File
@@ -29,6 +29,10 @@
/* me */ /* me */
#include "input.h" #include "input.h"
#ifndef BDK_VERSION
#define BDK_VERSION 4
#endif
static uint8_t Address_Switch; static uint8_t Address_Switch;
static uint8_t Buttons; static uint8_t Buttons;
static struct itimer Debounce_Timer; static struct itimer Debounce_Timer;
@@ -96,8 +100,14 @@ void input_task(
Address_Switch = old_address; Address_Switch = old_address;
} }
old_address = value; 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 */ /* pins used are PB4, PB3, PB2, PB1, PB0 */
value = BITMASK_CHECK(PINB, 0x1F); value = BITMASK_CHECK(PINB, 0x1F);
#endif
if (value == old_buttons) { if (value == old_buttons) {
/* stable value */ /* stable value */
Buttons = old_buttons; Buttons = old_buttons;
@@ -115,6 +125,12 @@ uint8_t input_address(
return Address_Switch; return Address_Switch;
} }
uint8_t input_rotary_value(
uint8_t index)
{
return Buttons;
}
bool input_button_value( bool input_button_value(
uint8_t index) uint8_t index)
{ {
@@ -163,10 +179,16 @@ void input_init(
BIT_SET(PORTA, PORTA4); BIT_SET(PORTA, PORTA4);
BIT_SET(PORTA, PORTA5); BIT_SET(PORTA, PORTA5);
BIT_SET(PORTA, PORTA6); 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, DDB1);
BIT_CLEAR(DDRB, DDB2); BIT_CLEAR(DDRB, DDB2);
BIT_CLEAR(DDRB, DDB3); BIT_CLEAR(DDRB, DDB3);
BIT_CLEAR(DDRB, DDB4); BIT_CLEAR(DDRB, DDB4);
#endif
timer_interval_start(&Debounce_Timer, 30); timer_interval_start(&Debounce_Timer, 30);
} }
+2 -1
View File
@@ -38,7 +38,8 @@ extern "C" {
void); void);
bool input_button_value( bool input_button_value(
uint8_t index); uint8_t index);
uint8_t input_rotary_value(
uint8_t index);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */