diff --git a/cntr/fw/cntr/cntr.c b/cntr/fw/cntr/cntr.c index 9f0bf54..b7815ec 100644 --- a/cntr/fw/cntr/cntr.c +++ b/cntr/fw/cntr/cntr.c @@ -22,7 +22,7 @@ uint8_t cntr[4]; -enum hw_type hw_type = HW_TYPE_V1; +enum hw_type hw_type; static void delay(unsigned ms) @@ -37,17 +37,22 @@ static void delay(unsigned ms) static void init_io(void) { - if (VERSION_ID) { - /* flash LED a second time */ + int i; + + /* SDCC bug - needs parentheses here */ + hw_type = VERSION_ID1 ? + (VERSION_ID2 ? HW_TYPE_V2 : HW_TYPE_V3) : + HW_TYPE_V1; + + for (i = HW_TYPE_V1; i != hw_type; i++) { + /* flash LED a second or third time */ LEDv2 = 0; delay(250); LEDv2 = 1; delay(250); - - PROBE_TERM_MODE |= 1 << PROBE_TERM_BIT; - - hw_type = HW_TYPE_V2; } + if (hw_type == HW_TYPE_V2) + PROBE_TERM_MODE |= 1 << PROBE_TERM_BIT; /* * Signal Mode Value @@ -70,7 +75,7 @@ static void init_io(void) P2 = 0; P3 = 0; - if (hw_type == HW_TYPE_V2) + if (hw_type == HW_TYPE_V2 || hw_type == HW_TYPE_V3) PROBE_TERM = 1; /* diff --git a/cntr/fw/cntr/cntr.h b/cntr/fw/cntr/cntr.h index db248c8..b70340b 100644 --- a/cntr/fw/cntr/cntr.h +++ b/cntr/fw/cntr/cntr.h @@ -25,6 +25,7 @@ extern uint8_t cntr[4]; extern enum hw_type { HW_TYPE_V1 = 0, HW_TYPE_V2 = 1, + HW_TYPE_V3 = 2, } hw_type; #endif /* !CNTR_H */ diff --git a/cntr/fw/common/io.h b/cntr/fw/common/io.h index 6b798dd..52409c4 100644 --- a/cntr/fw/common/io.h +++ b/cntr/fw/common/io.h @@ -30,6 +30,7 @@ * * - v1: 100 kOhm termination (not very useful) * - v2: pull-up for input amplifier + * - v3: 330 Ohm termination */ #define PROBE_TERM P1_2 @@ -40,8 +41,20 @@ * In version 1, P2_1 is used to provide ground to the input side. In version * 2, we use a ground place for this and P2_1 is unconnected. We can therefore * use it to identify the hardware version. + * + * In version 3, P2_0 is connected to ground. In all other versions, it is + * unconnected. + * + * Board VERSION_ID1 + * | VERSION_ID2 + * | | + * v1 0 Z + * v2 Z Z + * v3 Z 0 + * */ -#define VERSION_ID P2_1 +#define VERSION_ID1 P2_1 +#define VERSION_ID2 P2_0 #endif /* !IO_H */