mise interrupt

This commit is contained in:
tipouic 2016-12-01 22:36:46 +01:00
parent ddd2150d8e
commit aa6058b0dd
5 changed files with 19 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -248,6 +248,11 @@ void setup()
// Timer1 config
TCCR1A = 0;
TCCR1B = (1 << CS11); //prescaler8, set timer1 to increment every 0.5us(16Mhz) and start timer
#ifdef ENABLE_NUNCHUCK
TCCR2A = 0; //default
TCCR2B = 0b00000010; // clk/8
TIMSK2 = 0b00000001; // TOIE2
#endif
// Random
random_init();
@ -1159,6 +1164,20 @@ static uint32_t random_id(uint16_t adress, uint8_t create_new)
/**************************/
/**************************/
//NUNCHUCK
#ifdef ENABLE_NUNCHUCK
ISR (TIMER2_OVF_vect) {
static uint16_t Prev_TCNT2=0;
// le flag OVF est mis à zéro par la fonction ISR
TCNT2 = 62;
// 256-200 --> 200X50ns = 100 us
if (Prev_TCNT2++ > 10000) {
Prev_TCNT2 = 0;
nunchuck_update();
}
}
#endif
//PPM
#ifdef ENABLE_PPM
#ifdef ORANGE_TX

View File

@ -22,9 +22,6 @@
#if not defined(ARDUINO_AVR_PRO) && not defined(ARDUINO_AVR_MINI) && not defined(ARDUINO_AVR_NANO)
#error You must select one of these boards: "Multi 4-in-1", "Arduino Pro or Pro Mini" or "Arduino Mini"
#endif
#if F_CPU != 16000000L || not defined(__AVR_ATmega328P__)
#error You must select the processor type "ATmega328(5V, 16MHz)"
#endif
#undef ENABLE_SERIAL
#undef ENABLE_PPM

Binary file not shown.