summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2012-06-20 21:30:15 +0200
committerDavid Lamparter <equinox@diac24.net>2012-06-20 21:30:15 +0200
commitcf365fa865d05b263d358f684abd54684005ca17 (patch)
tree5edb77e9a26ba6549597daaa8c5d2cd279e9156f
parent1b6e0ae14c74b7763e6e7d6320212985ec86c77b (diff)
dali: better scan behaviour
-rw-r--r--dali2.c1
-rw-r--r--dali_ctl.c16
2 files changed, 12 insertions, 5 deletions
diff --git a/dali2.c b/dali2.c
index 7cee997..1823c97 100644
--- a/dali2.c
+++ b/dali2.c
@@ -253,6 +253,7 @@ static void dali_send(uint16_t word)
static void dali_twice(uint16_t word)
{
dali_send(word);
+ _delay_ms(25);
dali_send(word);
}
diff --git a/dali_ctl.c b/dali_ctl.c
index b1502d4..98e7cef 100644
--- a/dali_ctl.c
+++ b/dali_ctl.c
@@ -18,9 +18,15 @@ static bool dali_s_notfound;
static bool dali_compare(void)
{
+ uint16_t manchester = dalistat.manchester, falsestart = dalistat.falsestart, noise = dalistat.noise;
+
dali_send(DALI_C_COMPARE);
asm volatile ("" ::: "memory");
- return dali_rx_avail && dali_rx == 0xff;
+
+ return dali_rx_avail
+ || (manchester != dalistat.manchester)
+ || (falsestart != dalistat.falsestart)
+ || (noise != dalistat.noise);
}
static void dali_search_byte(uint16_t cmd)
@@ -31,9 +37,9 @@ static void dali_search_byte(uint16_t cmd)
while (bit) {
dali_twice(cmd | (dali_s_byte & ~bit));
if (dali_compare()) {
- dali_s_byte &= ~bit;
- } else if (dali_compare()) {
- dali_s_byte &= ~bit;
+ _delay_ms(1);
+ if (dali_compare())
+ dali_s_byte &= ~bit;
}
bit >>= 1;
}
@@ -68,7 +74,7 @@ static void dali_search_single(void)
static void dali_search(void)
{
dali_twice(DALI_C_INITIALISE);
- dali_twice(DALI_C_RANDOMISE);
+ // dali_twice(DALI_C_RANDOMISE);
do {
dali_search_single();