From bff713d8d8c628edc5da9c530a546e4d9d8f6307 Mon Sep 17 00:00:00 2001 From: "gruvin@gmail.com" Date: Sun, 11 Nov 2012 04:04:54 +0000 Subject: [PATCH] [avr boards] Just code comments plus one fix ... -#if defined(PCBGRUVIN9X) +#if defined(PCBGRUVIN9X) && defined(DSM2_PPM) DSM2=SERIAL mode continuous WDT reset problem still present. Still can't figure out why. Still working on it. :-/ Gruvin. --- src/pulses_avr.cpp | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/pulses_avr.cpp b/src/pulses_avr.cpp index b57f83baf..c3419e6eb 100644 --- a/src/pulses_avr.cpp +++ b/src/pulses_avr.cpp @@ -398,6 +398,7 @@ normal: */ +// DSM2=SERIAL mode FORCEINLINE void setupPulsesDsm2() { uint16_t *ptr = (uint16_t *)pulses2MHz; @@ -439,11 +440,13 @@ FORCEINLINE void setupPulsesDsm2() pulses2MHzRPtr = pulses2MHz; } +// DSM2=SERIAL mode void DSM2_Done() { UCSR0B &= ~((1 << TXEN0) | (1 << UDRIE0)); // disable UART TX and interrupt } +// DSM2=SERIAL mode void DSM2_Init(void) { #ifndef SIMU @@ -471,7 +474,17 @@ void DSM2_Init(void) #endif // SIMU } -#endif +#endif // ifdef DSM2_SERIAL + +/****** END DSM2=SERIAL ********/ + + + +///////////////////////////////////////////////////////////// + + + +/******* BEGIN DSM2=PPM ********/ #if defined(DSM2_PPM) inline void _send_1(uint8_t v) @@ -511,6 +524,7 @@ void sendByteDsm2(uint8_t b) //max 10changes 0 10 10 10 10 1 #endif } +// DSM2=PPM mode void setupPulsesDsm2() { static uint8_t dsmDat[2+6*2] = {0xFF,0x00, 0x00,0xAA, 0x05,0xFF, 0x09,0xFF, 0x0D,0xFF, 0x13,0x54, 0x14,0xAA}; @@ -568,6 +582,11 @@ void setupPulsesDsm2() } #endif +/****** END DSM2=PPM ********/ + + + + #if defined(IRPROTOS) static void _send_u8(uint8_t u8) { @@ -748,7 +767,7 @@ void setupPulses() switch (required_protocol) { -#if defined(DSM2_PPM) +#if defined(DSM2_PPM) // Nothing done here for DSM2=SERIAL. See second switch() {...}, below case PROTO_DSM2: set_timer3_capture(); TCCR1B = 0; // Stop counter @@ -758,9 +777,9 @@ void setupPulses() #if defined(PCBGRUVIN9X) TIMSK1 &= ~0x2F; // All Timer1 interrupts off TIFR1 = 0x2F; - TIMSK1 |= 0x28; // Enable COMPC and CAPT interrupts + TIMSK1 |= 0x28; // Enable Timer1 COMPC and CAPT interrupts TCCR1A = (0 << WGM10); // Set output waveform mode to normal, for now. Note that - // WGM will be set to toggle OCR1B pin on compare capture, + // WGM will be changed to toggle OCR1B pin on compare capture, // in next switch(required_protocol) {...}, below #else TIMSK &= ~0x3C; // All Timer1 interrupts off @@ -772,7 +791,7 @@ void setupPulses() #endif TCCR1B = (3 << WGM12) | (2 << CS10); // CTC ICR, 16MHz / 8 break; -#endif +#endif // defined(DSM2_PPM) #if defined(PXX) case PROTO_PXX: @@ -879,16 +898,17 @@ void setupPulses() #ifdef DSM2 case PROTO_DSM2: #if defined(PCBGRUVIN9X) + // schedule next Mixer interrupt OCR5A = (uint16_t)0x7d * (44-lastMixerDuration-2/*1ms*/); TCNT5 = 0; #endif sei(); setupPulsesDsm2(); -#if defined(PCBGRUVIN9X) +#if defined(PCBGRUVIN9X) && defined(DSM2_PPM) // Ensure each DSM packet starts out with the correct bit polarity - TCCR1A = (0 << WGM10) | (3<