Rev 1109 | Rev 1136 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1109 | Rev 1125 | ||
|---|---|---|---|
| Line 72... | Line 72... | ||
| 72 | 72 | ||
| 73 | /* Interrupted at a pin change on zero-cross pin |
73 | /* Interrupted at a pin change on zero-cross pin |
| 74 | The zero-cross pin will go high just before the real zero-cross and |
74 | The zero-cross pin will go high just before the real zero-cross and |
| 75 | low just after the real zero-cross. The time difference is measured |
75 | low just after the real zero-cross. The time difference is measured |
| 76 | and adjusted for. */ |
76 | and adjusted for. */ |
| 77 |
|
77 | void act_dimmer230_pcint_callback(uint8_t id) //ISR (act_dimmer230_ZC_PCINT_vect) |
| 78 | { |
78 | { |
| 79 | /* only execute if zerocross pin is low (after real zerocross). |
79 | /* only execute if zerocross pin is low (after real zerocross). |
| 80 | Calculate the diff from real zero-cross. |
80 | Calculate the diff from real zero-cross. |
| 81 | */ |
81 | */ |
| 82 | if (!gpio_get_state(act_dimmer230_ZC_IO)) |
82 | if (!gpio_get_state(act_dimmer230_ZC_IO)) |
| Line 251... | Line 251... | ||
| 251 | TCCR1A=0; |
251 | TCCR1A=0; |
| 252 | 252 | ||
| 253 | TCCR1B=(1<<CS11); /* enable timer, set to prescaler 8, must be changed if cpu freq is changed */ |
253 | TCCR1B=(1<<CS11); /* enable timer, set to prescaler 8, must be changed if cpu freq is changed */ |
| 254 | 254 | ||
| 255 | /* setup interrupt on zerocross, pcint */ |
255 | /* setup interrupt on zerocross, pcint */ |
| 256 |
|
256 | //act_dimmer230_ZC_PCMSK=(1<<(act_dimmer230_ZC_PCINT_BIT)); |
| 257 |
|
257 | //PCIFR=(1<<act_dimmer230_ZC_PCIF); /* clear any pending interrupt before enabling interrupts */ |
| 258 |
|
258 | //PCICR=(1<<act_dimmer230_ZC_PCIE); /* enable interrupt for PCINT */ |
| - | 259 | Pcint_SetCallbackPin(act_dimmer230_PCINT, act_dimmer230_ZC_IO, &act_dimmer230_pcint_callback); |
|
| 259 | 260 | ||
| 260 | /* Setup timeout for sending the net status packet */ |
261 | /* Setup timeout for sending the net status packet */ |
| 261 | Timer_SetTimeout(act_dimmer230_SEND_STATUS_TIMEOUT, act_dimmer230_SEND_STATUS_INTERVAL*1000, TimerTypeFreeRunning, &Send_Status_callback); |
262 | Timer_SetTimeout(act_dimmer230_SEND_STATUS_TIMEOUT, act_dimmer230_SEND_STATUS_INTERVAL*1000, TimerTypeFreeRunning, &Send_Status_callback); |
| 262 | } |
263 | } |
| 263 | 264 | ||