From 32182fe8b0e7af37f0cab0b5233e40414f7b629e Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 19 Sep 2012 19:38:36 +0200 Subject: dali: pretty up bus scan --- dali_ctl.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/dali_ctl.c b/dali_ctl.c index 797f58f..ed23ce1 100644 --- a/dali_ctl.c +++ b/dali_ctl.c @@ -80,7 +80,12 @@ static void dali_search_single(void) static void dali_search(void) { dali_twice(DALI_C_INITIALISE); - // dali_twice(DALI_C_RANDOMISE); + + /* _some_ EVGs keep the long address in nonvolatile memory, + * among them the OSRAM one we have lying around. however, + * this doesn't seem to work with Tridonic EVGs. + */ + dali_twice(DALI_C_RANDOMISE); dali_assign = eeprom_read_byte(&dali_nextaddr); @@ -98,24 +103,28 @@ static void dali_search(void) if ((dali_rx & 0x81) == 0x01) { addr = dali_rx >> 1; - uart_puts(" short: "); + uart_puts(" current: "); uart_puthex(addr); - uart_puts("\n"); - } else { - uart_puts(" noshort "); + } + + if (addr == 0x00 || (dali_map[addr >> 3] & (1 << (addr & 0x07)))) { + uart_puts(" reprog"); + addr = 0xff; + } + if (addr == 0xff) { dali_send(DALI_C_PROGSHORT | (dali_assign << 1)); dali_send(DALI_C_VRFYSHORT | (dali_assign << 1)); if (dali_rx_avail) { uart_puts("prog "); uart_puthex(dali_assign); - uart_puts("\n"); } else - uart_puts("progfail\n"); + uart_puts("progfail"); addr = dali_assign; dali_assign++; } + uart_puts("\n"); if (addr < 64) dali_map[addr >> 3] |= 1 << (addr & 0x7); -- cgit v1.2.1