diff options
author | David Lamparter <equinox@diac24.net> | 2012-06-20 14:22:16 +0200 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2012-06-20 14:22:16 +0200 |
commit | 0c7bebea1bd05a95d2bb3e04ecb2e44792d6f174 (patch) | |
tree | 021c0ffc52f7d9cf710975b8da37d338dfa8c9c7 /lightctrl.c | |
parent | d58959c353f8e70b4b057ce8ba2907b52f6d28b7 (diff) |
light: CAN RX
Diffstat (limited to 'lightctrl.c')
-rw-r--r-- | lightctrl.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lightctrl.c b/lightctrl.c index 464a0ae..404ca33 100644 --- a/lightctrl.c +++ b/lightctrl.c @@ -27,6 +27,27 @@ const uint8_t __signature[3] __attribute__((section (".signature"), used)) = #include "dim.c" #include "can.c" +static void can_rx_exec(void) +{ + if (can_rx_addr.b[0] == 0xcc + && (can_rx_addr.b[1] & 0xfb) == 0x08 + && can_rx_addr.b[2] == 0x04 + && can_rx_addr.b[3] == 0x7f + && (can_rx_dlc & 0x4f) == 1) { + uart_puts("-- SET\n"); + + if (!can_rx_data[0]) { + dim_state = 0; + dali_send(DALI_ADDR | 0x100); + } else { + if (!dim_state && can_rx_data[0]) + dali_send(DALI_ADDR | 0x108); + dim_state = can_rx_data[0]; + dali_send(DALI_ADDR | dim_state); + } + } +} + int main(void) { DDRD |= (1 << D_LED1) | (1 << D_LED2 ) | (1 << D_TXD) | (1 << D_DALIO); @@ -51,6 +72,11 @@ int main(void) if (canint) { canint = false; can_int(); + + if (can_rx_addr.b[0]) { + can_rx_exec(); + can_rx_addr.u = 0; + } } _delay_ms(5); do_tick(); |