Subversion Repositories FlightCtrl

Rev

Rev 2118 | Rev 2122 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2118 Rev 2119
Line 45... Line 45...
45
 
45
 
Line 46... Line 46...
46
  // Timer/Counter1 Control Register A, B, C
46
  // Timer/Counter1 Control Register A, B, C
47
 
47
 
48
  // Normal Mode (bits: WGM13=0, WGM12=0, WGM11=0, WGM10=0)
48
  // Normal Mode (bits: WGM13=0, WGM12=0, WGM11=0, WGM10=0)
49
  // Compare output pin A & B is disabled (bits: COM1A1=0, COM1A0=0, COM1B1=0, COM1B0=0)
49
  // Compare output pin A & B is disabled (bits: COM1A1=0, COM1A0=0, COM1B1=0, COM1B0=0)
50
  // Set clock source to SYSCLK/64 (bit: CS12=0, CS11=1, CS10=1)
50
  // Set clock source to SYSCLK/8 (bit: CS12=0, CS11=1, CS10=0)
51
  // Enable input capture noise cancler (bit: ICNC1=1)
51
  // Enable input capture noise cancler (bit: ICNC1=1)
52
  // Trigger on positive edge of the input capture pin (bit: ICES1=1),
52
  // Trigger on positive edge of the input capture pin (bit: ICES1=1),
53
  // Therefore the counter incremets at a clock of 20 MHz/64 = 312.5 kHz or 3.2�s
53
  // Therefore the counter incremets at a clock of 20 MHz/64 = 312.5 kHz or 3.2�s
54
  // The longest period is 0xFFFF / 312.5 kHz = 0.209712 s.
54
  // The longest period is 0xFFFF / 312.5 kHz = 0.209712 s.
55
  TCCR1A &= ~((1 << COM1A1) | (1 << COM1A0) | (1 << COM1B1) | (1 << COM1B0) | (1 << WGM11) | (1 << WGM10));
55
  TCCR1A &= ~((1<<COM1A1)| (1<<COM1A0) | (1<<COM1B1) | (1<<COM1B0) | (1<<WGM11) | (1<<WGM10));
56
  TCCR1B &= ~((1 << WGM13) | (1 << WGM12) | (1 << CS12));
56
  TCCR1B &= ~((1<<WGM13) | (1<<WGM12)  | (1<<CS12));
-
 
57
  TCCR1B |= (1<<CS11)    | (1<<ICNC1);
-
 
58
  TCCR1C &= ~((1<<FOC1A) | (1<<FOC1B));
-
 
59
 
-
 
60
  if (channelMap.RCPolarity) {
-
 
61
    TCCR1B |= (1<<ICES1);
-
 
62
  } else {
Line 57... Line 63...
57
  TCCR1B |= (1 << CS11) | (1 << ICES1) | (1 << ICNC1);
63
    TCCR1B &= ~(1<<ICES1);
58
  TCCR1C &= ~((1 << FOC1A) | (1 << FOC1B));
64
  }
59
 
65
 
60
  // Timer/Counter1 Interrupt Mask Register
66
  // Timer/Counter1 Interrupt Mask Register
Line 230... Line 236...
230
 
236
 
231
void RC_calibrate(void) {
237
void RC_calibrate(void) {
232
  // Do nothing.
238
  // Do nothing.
Line 233... Line 239...
233
}
239
}
234
 
240
 
235
int16_t RC_getZeroThrottle() {
241
int16_t RC_getZeroThrottle(void) {