diff options
author | David Lamparter <equinox@diac24.net> | 2012-06-20 21:30:15 +0200 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2012-06-20 21:30:15 +0200 |
commit | cf365fa865d05b263d358f684abd54684005ca17 (patch) | |
tree | 5edb77e9a26ba6549597daaa8c5d2cd279e9156f | |
parent | 1b6e0ae14c74b7763e6e7d6320212985ec86c77b (diff) |
dali: better scan behaviour
-rw-r--r-- | dali2.c | 1 | ||||
-rw-r--r-- | dali_ctl.c | 16 |
2 files changed, 12 insertions, 5 deletions
@@ -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); } @@ -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(); |