diff options
Diffstat (limited to 'dali2.c')
-rw-r--r-- | dali2.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -22,7 +22,13 @@ static volatile bool dali_rx_avail; static volatile uint16_t dali_tx; static volatile bool dali_tx_rq; -static uint16_t dalistat_falsestart, dalistat_noise, dalistat_manchester, dalistat_rxok; +struct dalistat { + uint16_t + rxok, + falsestart, + noise, + manchester; +} dalistat; #undef DEBUG @@ -105,7 +111,7 @@ ISR(TIMER0_COMPA_vect) case DALI_RX_SBIT: if (!hist_majority_0()) { - dalistat_falsestart++; + dalistat.falsestart++; dali_state = rx_prevstate_errs; return; } @@ -118,7 +124,7 @@ ISR(TIMER0_COMPA_vect) case DALI_RX_DATA: if (!(hist_majority_1() || hist_majority_0())) { rx_prevstate_errs++; - dalistat_noise++; + dalistat.noise++; bit = 0; } else bit = hist_majority_1(); @@ -126,7 +132,7 @@ ISR(TIMER0_COMPA_vect) if (bitpos & 1) { if (bit == (rx_data & 1)) { rx_prevstate_errs++; - dalistat_manchester++; + dalistat.manchester++; } } else { rx_data <<= 1; @@ -139,7 +145,7 @@ ISR(TIMER0_COMPA_vect) if (!rx_prevstate_errs) { dali_rx = rx_data; dali_rx_avail = 1; - dalistat_rxok++; + dalistat.rxok++; } } break; @@ -257,7 +263,7 @@ static void dali_init(void) dali_tx_rq = 0; dali_rx_avail = 0; - dalistat_falsestart = dalistat_noise = dalistat_manchester = dalistat_rxok = 0; + dalistat.falsestart = dalistat.noise = dalistat.manchester = dalistat.rxok = 0; TIFR0 = (1 << OCF0A); TCNT0 = 0; |