sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
def.h
Go to the documentation of this file.
1 #ifndef DEF_H_
2 #define DEF_H_
3 
4 /**************************************************************************************/
5 /*************** test configurations ********************/
6 /**************************************************************************************/
7 #if COPTERTEST == 1
8  #define QUADP
9  #define WMP
10 #elif COPTERTEST == 2
11  #define FLYING_WING
12  #define WMP
13  #define BMA020
14  #define FAILSAFE
15  #define LCD_CONF
16  #define LCD_TEXTSTAR
17  #define VBAT
18  #define POWERMETER_SOFT
19 #elif COPTERTEST == 3
20  #define TRI
21  #define FREEIMUv035_MS
22  #define BUZZER
23  #define VBAT
24  #define POWERMETER_HARD
25  #define LCD_CONF
26  #define LCD_CONF_AUX
27  #define LCD_VT100
28  #define LCD_TELEMETRY
29  #define LCD_TELEMETRY_STEP "01245"
30  #define LOG_VALUES 1
31  #define SUPPRESS_BARO_ALTHOLD
32  #define VARIOMETER 12
33 #elif COPTERTEST == 4
34  #define QUADX
35  #define CRIUS_SE
36  #define SPEKTRUM 2048
37  #define LED_RING
38  #define GPS_SERIAL 2
39  #define NMEA
40  #define LOG_VALUES 2
41  #define LOG_PERMANENT
42  #define LOG_PERMANENT_SERVICE_LIFETIME 36000
43 #elif COPTERTEST == 5
44  #define HELI_120_CCPM
45  #define CRIUS_LITE
46  #undef DISABLE_POWER_PIN
47  #define RCAUXPIN8
48  #define OLED_I2C_128x64
49  #define LCD_TELEMETRY
50  #define LOG_VALUES 3
51  #define DEBUG
52  #undef SERVO_RFR_50HZ
53  #define SERVO_RFR_160HZ
54  #define VBAT
55  #define POWERMETER_SOFT
56  #define MMGYRO 10
57  #define MMGYROVECTORLENGTH 15
58  #define GYRO_SMOOTHING {45, 45, 50}
59  #define INFLIGHT_ACC_CALIBRATION
60  #define LOG_PERMANENT
61  #define LOG_PERMANENT_SHOW_AT_STARTUP
62  #define LOG_PERMANENT_SHOW_AT_L
63  #define LOG_PERMANENT_SERVICE_LIFETIME 36000
64  #define GOVERNOR_P 0
65  #define GOVERNOR_D 10
66  #define YAW_COLL_PRECOMP 15
67  #define YAW_COLL_PRECOMP_DEADBAND 130
68  #define VOLTAGEDROP_COMPENSATION
69 #elif COPTERTEST == 6
70  #define HEX6H
71  #define DIYFLYING_MAGE_V1
72  #define BUZZER
73  #define RCOPTIONSBEEP // ca. 80byte
74  #define ARMEDTIMEWARNING 480 // 8 min = 480seconds
75  #define VBAT
76  #define VOLTAGEDROP_COMPENSATION
77  #define MEGA_HW_PWM_SERVOS
78  #define SERVO_RFR_RATE 300 // In Hz, you can set it from 20 to 400Hz, used only in HW PWM mode
79  #define LOG_VALUES 1
80  #define DEBUG
81  #define MULTIPLE_CONFIGURATION_PROFILES
82  #define DISPLAY_FONT_DSIZE
83  #define OLED_DIGOLE
84  #define LCD_CONF
85 #elif COPTERTEST == 7
86  #define HELI_120_CCPM
87  #define YAW_COLL_PRECOMP 15
88  #define YAW_COLL_PRECOMP_DEADBAND 130
89  #define NANOWII
90  #define FORCE_ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = X; imu.accADC[PITCH] = Y; imu.accADC[YAW] = Z;}
91  #define FORCE_GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -Y; imu.gyroADC[PITCH] = X; imu.gyroADC[YAW] = -Z;}
92  #define A32U4_4_HW_PWM_SERVOS
93  #define SERVO_RFR_RATE 200 // 200 for graupner is ok
94  #define SERVO_PIN5_RFR_RATE 165 // In Hz, you can set it from 20 to 400Hz, used only in HW PWM mode for mega and 32u4
95  #define SPEKTRUM 1024
96  #define BUZZER
97  #define RCOPTIONSBEEP // ca. 80byte
98  #define VBAT
99  #define LOG_VALUES 1
100  #define DISPLAY_FONT_DSIZE
101  #define OLED_DIGOLE
102  #define LCD_CONF
103  #define LCD_TELEMETRY
104  #define LCD_TELEMETRY_AUTO "1"
105  #define LCD_TELEMETRY_STEP "F14$5R"
106  #define LOG_PERMANENT
107  #define LOG_PERMANENT_SHOW_AFTER_CONFIG
108  #define SUPPRESS_OTHER_SERIAL_COMMANDS
109  #define SUPPRESS_DEFAULTS_FROM_GUI
110  #define NO_FLASH_CHECK
111  #define DEBUG_FREE
112 #elif COPTERTEST == 8
113  #define BI
114  #define ITG3200
115  #define PID_CONTROLLER 2
116  #define ESC_CALIB_CANNOT_FLY
117 #elif COPTERTEST == 9
118  #define AIRPLANE
119  #define FREEIMUv035
120  #define POWERMETER_HARD
121  #define WATTS
122  #define VBAT
123  #define VBAT_CELLS
124  #define VBAT_CELLS_NUM 3
125  #define VBAT_CELLS_PINS {A0, A1, A2 }
126  #define VBAT_CELLS_OFFSETS {0, 50, 83 }
127  #define VBAT_CELLS_DIVS { 75, 122, 98 }
128 #elif COPTERTEST == 10
129  #define Y6
130  #define CRIUS_AIO_PRO
131  #define LCD_LCD03S
132  #define SERIAL0_COM_SPEED 9600
133  #define LCD_CONF
134 #elif defined(COPTERTEST)
135  #error "*** this test is not yet defined"
136 #endif
137 
138 
139 /**************************************************************************************/
140 /*************** Proc specific definitions ********************/
141 /**************************************************************************************/
142 // Proc auto detection
143 #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
144  #define PROMINI
145 #endif
146 #if defined(__AVR_ATmega32U4__) || defined(TEENSY20)
147  #define PROMICRO
148 #endif
149 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
150  #define MEGA
151 #endif
152 
153 
154 /**************************************************************************************/
155 /*************** motor and servo numbers ********************/
156 /**************************************************************************************/
157 #define SERVO_RATES {30,30,100,100,100,100,100,100}
158 
159 #if defined (AIRPLANE) || defined(FLYING_WING)
160  #define FIXEDWING
161 #endif
162 
163 #if defined(HELI_120_CCPM) || defined(HELI_90_DEG)
164  #define HELICOPTER
165 #endif
166 
167 #if defined(BI) || defined(TRI) || defined(FIXEDWING) || defined(HELICOPTER) || defined(SINGLECOPTER)|| defined(DUALCOPTER)
168  #define COPTER_WITH_SERVO
169 #endif
170 
171 #if defined(COPTER_WITH_SERVO) || defined(SERVO_TILT) || defined(GIMBAL) || defined(CAMTRIG) || defined(SERVO_MIX_TILT)
172  #define SERVO
173 #endif
174 
175 #if defined(DYNBALANCE)
176  #define DYNBAL 1
177 #else
178  #define DYNBAL 0
179 #endif
180 #if defined(FLAPS)
181  #define FLAP 1
182 #else
183  #define FLAP 0
184 #endif
185 
186 #if defined(MEGA) && defined(MEGA_HW_PWM_SERVOS)
187  #define TRI_SERVO 4
188 #else
189  #define TRI_SERVO 6
190 #endif
191 
192 #if defined(GIMBAL)
193  #define NUMBER_MOTOR 0
194  #define PRI_SERVO_FROM 1 // use servo from 1 to 2
195  #define PRI_SERVO_TO 2
196 #elif defined(FLYING_WING)
197  #define PRI_SERVO_FROM 4
198  #if defined (USE_THROTTLESERVO)
199  #define NUMBER_MOTOR 0
200  #define PRI_SERVO_TO 8 // use servo from 4,5 and 8
201  #else
202  #define NUMBER_MOTOR 1
203  #define PRI_SERVO_TO 5 // use servo from 4 to 5
204  #endif
205 #elif defined(SINGLECOPTER)
206  #define NUMBER_MOTOR 1
207  #define PRI_SERVO_FROM 4 // use servo from 4 to 7
208  #define PRI_SERVO_TO 7
209 #elif defined(DUALCOPTER)
210  #define NUMBER_MOTOR 2
211  #define PRI_SERVO_FROM 5 // use servo from 5 to 6
212  #define PRI_SERVO_TO 6
213 #elif defined(AIRPLANE)
214  #if defined (USE_THROTTLESERVO)
215  #define NUMBER_MOTOR 0
216  #define PRI_SERVO_TO 8
217  #else
218  #define NUMBER_MOTOR 1
219  #define PRI_SERVO_TO 7
220  #endif
221  #if defined(FLAPS)
222  #define PRI_SERVO_FROM 3 // use servo from 3 to 8
223  #undef CAMTRIG // Disable Camtrig on A2
224  #else
225  #define PRI_SERVO_FROM 4 // use servo from 4 to 8
226  #endif
227 #elif defined(BI)
228  #define NUMBER_MOTOR 2
229  #define PRI_SERVO_FROM 5 // use servo from 5 to 6
230  #define PRI_SERVO_TO 6
231 #elif defined(TRI)
232  #define NUMBER_MOTOR 3
233  #define PRI_SERVO_FROM TRI_SERVO // use only servo 6 (or 4 with Mega HW PWM)
234  #define PRI_SERVO_TO TRI_SERVO
235 #elif defined(QUADP) || defined(QUADX) || defined(Y4)|| defined(VTAIL4)
236  #define NUMBER_MOTOR 4
237 #elif defined(Y6) || defined(HEX6) || defined(HEX6X) || defined(HEX6H)
238  #define NUMBER_MOTOR 6
239 #elif defined(OCTOX8) || defined(OCTOFLATP) || defined(OCTOFLATX)
240  #define NUMBER_MOTOR 8
241 #elif defined(HELICOPTER)
242  #define PRI_SERVO_FROM 4
243  #ifdef HELI_USE_SERVO_FOR_THROTTLE
244  #define NUMBER_MOTOR 0 // use servo to drive throttle output
245  #define PRI_SERVO_TO 8 // use servo from 4 to 8
246  #else
247  #define NUMBER_MOTOR 1 // use motor1 for throttle, DO NOT SET TO 2, OR IT WILL BURN/DESTROY SERVO7 USED FOR SWASH
248  #define PRI_SERVO_TO 7 // use servo from 4 to 7
249  #endif
250 #endif
251 
252 #if (defined(SERVO_TILT)|| defined(SERVO_MIX_TILT))&& defined(CAMTRIG)
253  #define SEC_SERVO_FROM 1 // use servo from 1 to 3
254  #define SEC_SERVO_TO 3
255 #else
256  #if defined(SERVO_TILT)|| defined(SERVO_MIX_TILT)
257  // if A0 and A1 is taken by motors, we can use A2 and 12 for Servo tilt
258  #if defined(A0_A1_PIN_HEX) && (NUMBER_MOTOR == 6) && defined(PROMINI)
259  #define SEC_SERVO_FROM 3 // use servo from 3 to 4
260  #define SEC_SERVO_TO 4
261  #else
262  #define SEC_SERVO_FROM 1 // use servo from 1 to 2
263  #define SEC_SERVO_TO 2
264  #endif
265  #endif
266  #if defined(CAMTRIG)
267  #define SEC_SERVO_FROM 3 // use servo 3
268  #define SEC_SERVO_TO 3
269  #endif
270 #endif
271 
272 #if defined(SIRIUS_AIR) || defined(SIRIUS_AIR_GPS)
273  #define RCAUX2PIND17
274 #endif
275 
276 /************************** atmega328P (Promini) ************************************/
277 #if defined(PROMINI)
278  #if !defined(MONGOOSE1_0)
279  #define LEDPIN_PINMODE pinMode (13, OUTPUT);
280  #define LEDPIN_TOGGLE PINB |= 1<<5; //switch LEDPIN state (digital PIN 13)
281  #define LEDPIN_OFF PORTB &= ~(1<<5);
282  #define LEDPIN_ON PORTB |= (1<<5);
283  #endif
284  #if !defined(RCAUXPIN8)
285  #if !defined(MONGOOSE1_0)
286  #define BUZZERPIN_PINMODE pinMode (8, OUTPUT);
287  #if NUMBER_MOTOR >4
288  #undef PILOTLAMP
289  #endif
290  #if defined PILOTLAMP && NUMBER_MOTOR <5
291  #define PL_PIN_ON PORTB |= 1;
292  #define PL_PIN_OFF PORTB &= ~1;
293  #else
294  #define BUZZERPIN_ON PORTB |= 1;
295  #define BUZZERPIN_OFF PORTB &= ~1;
296  #endif
297  #endif
298  #else
299  #define BUZZERPIN_PINMODE ;
300  #define BUZZERPIN_ON ;
301  #define BUZZERPIN_OFF ;
302  #define RCAUXPIN
303  #endif
304  #if !defined(RCAUXPIN12) && !defined(DISABLE_POWER_PIN)
305  #define POWERPIN_PINMODE pinMode (12, OUTPUT);
306  #define POWERPIN_ON PORTB |= 1<<4;
307  #define POWERPIN_OFF PORTB &= ~(1<<4); //switch OFF WMP, digital PIN 12
308  #else
309  #define POWERPIN_PINMODE ;
310  #define POWERPIN_ON ;
311  #define POWERPIN_OFF ;
312  #endif
313  #if defined(RCAUXPIN12)
314  #define RCAUXPIN
315  #endif
316  #define I2C_PULLUPS_ENABLE PORTC |= 1<<4; PORTC |= 1<<5; // PIN A4&A5 (SDA&SCL)
317  #define I2C_PULLUPS_DISABLE PORTC &= ~(1<<4); PORTC &= ~(1<<5);
318  #if !defined(MONGOOSE1_0)
319  #define PINMODE_LCD pinMode(0, OUTPUT);
320  #define LCDPIN_OFF PORTD &= ~1; //switch OFF digital PIN 0
321  #define LCDPIN_ON PORTD |= 1;
322  #define STABLEPIN_PINMODE ;
323  #define STABLEPIN_ON ;
324  #define STABLEPIN_OFF ;
325  #endif
326  #define PPM_PIN_INTERRUPT attachInterrupt(0, rxInt, RISING); //PIN 0
327  #define RX_SERIAL_PORT 0
328  //RX PIN assignment inside the port //for PORTD
329  #define THROTTLEPIN 2
330  #define ROLLPIN 4
331  #define PITCHPIN 5
332  #define YAWPIN 6
333  #define AUX1PIN 7
334  #define AUX2PIN 0 // optional PIN 8 or PIN 12
335  #define AUX3PIN 1 // unused
336  #define AUX4PIN 3 // unused
337 
338  #define PCINT_PIN_COUNT 5
339  #define PCINT_RX_BITS (1<<2),(1<<4),(1<<5),(1<<6),(1<<7)
340  #define PCINT_RX_PORT PORTD
341  #define PCINT_RX_MASK PCMSK2
342  #define PCIR_PORT_BIT (1<<2)
343  #define RX_PC_INTERRUPT PCINT2_vect
344  #define RX_PCINT_PIN_PORT PIND
345  #define V_BATPIN A3 // Analog PIN 3
346  #define PSENSORPIN A2 // Analog PIN 2
347 
348  #if defined(A0_A1_PIN_HEX) || (NUMBER_MOTOR > 6)
349  #define SOFT_PWM_1_PIN_HIGH PORTC |= 1<<0;
350  #define SOFT_PWM_1_PIN_LOW PORTC &= ~(1<<0);
351  #define SOFT_PWM_2_PIN_HIGH PORTC |= 1<<1;
352  #define SOFT_PWM_2_PIN_LOW PORTC &= ~(1<<1);
353  #else
354  #define SOFT_PWM_1_PIN_HIGH PORTD |= 1<<5;
355  #define SOFT_PWM_1_PIN_LOW PORTD &= ~(1<<5);
356  #define SOFT_PWM_2_PIN_HIGH PORTD |= 1<<6;
357  #define SOFT_PWM_2_PIN_LOW PORTD &= ~(1<<6);
358  #endif
359  #define SOFT_PWM_3_PIN_HIGH PORTC |= 1<<2;
360  #define SOFT_PWM_3_PIN_LOW PORTC &= ~(1<<2);
361  #define SOFT_PWM_4_PIN_HIGH PORTB |= 1<<4;
362  #define SOFT_PWM_4_PIN_LOW PORTB &= ~(1<<4);
363 
364  #define SERVO_1_PINMODE pinMode(A0,OUTPUT); // TILT_PITCH - WING left
365  #define SERVO_1_PIN_HIGH PORTC |= 1<<0;
366  #define SERVO_1_PIN_LOW PORTC &= ~(1<<0);
367  #define SERVO_2_PINMODE pinMode(A1,OUTPUT); // TILT_ROLL - WING right
368  #define SERVO_2_PIN_HIGH PORTC |= 1<<1;
369  #define SERVO_2_PIN_LOW PORTC &= ~(1<<1);
370  #define SERVO_3_PINMODE pinMode(A2,OUTPUT); // CAM TRIG - alt TILT_PITCH
371  #define SERVO_3_PIN_HIGH PORTC |= 1<<2;
372  #define SERVO_3_PIN_LOW PORTC &= ~(1<<2);
373  #if !defined(MONGOOSE1_0)
374  #define SERVO_4_PINMODE pinMode(12,OUTPUT); // new - alt TILT_ROLL
375  #define SERVO_4_PIN_HIGH PORTB |= 1<<4;
376  #define SERVO_4_PIN_LOW PORTB &= ~(1<<4);
377  #endif
378  #define SERVO_5_PINMODE pinMode(11,OUTPUT); // BI LEFT
379  #define SERVO_5_PIN_HIGH PORTB |= 1<<3;
380  #define SERVO_5_PIN_LOW PORTB &= ~(1<<3);
381  #define SERVO_6_PINMODE pinMode(3,OUTPUT); // TRI REAR - BI RIGHT
382  #define SERVO_6_PIN_HIGH PORTD|= 1<<3;
383  #define SERVO_6_PIN_LOW PORTD &= ~(1<<3);
384  #define SERVO_7_PINMODE pinMode(10,OUTPUT); // new
385  #define SERVO_7_PIN_HIGH PORTB |= 1<<2;
386  #define SERVO_7_PIN_LOW PORTB &= ~(1<<2);
387  #define SERVO_8_PINMODE pinMode(9,OUTPUT); // new
388  #define SERVO_8_PIN_HIGH PORTB |= 1<<1;
389  #define SERVO_8_PIN_LOW PORTB &= ~(1<<1);
390 #endif
391 
392 /************************** atmega32u4 (Promicro) ***********************************/
393 #if defined(PROMICRO)
394  #if defined(MICROWII)
395  #define A32U4ALLPINS
396  #endif
397  #if !defined(TEENSY20)
398  #define LEDPIN_PINMODE //
399  #define LEDPIN_TOGGLE PIND |= 1<<5; //switch LEDPIN state (Port D5)
400  #if !defined(PROMICRO10)
401  #define LEDPIN_OFF PORTD |= (1<<5);
402  #define LEDPIN_ON PORTD &= ~(1<<5);
403  #else
404  #define LEDPIN_OFF PORTD &= ~(1<<5);
405  #define LEDPIN_ON PORTD |= (1<<5);
406  #endif
407  #else
408  #define LEDPIN_PINMODE DDRD |= (1<<6);
409  #define LEDPIN_OFF PORTD &= ~(1<<6);
410  #define LEDPIN_ON PORTD |= (1<<6);
411  #define LEDPIN_TOGGLE PIND |= 1<<6; //switch LEDPIN state (Port D6)
412  #endif
413  #if defined(D8BUZZER)
414  #define BUZZERPIN_PINMODE DDRB |= (1<<4);
415  #if defined PILOTLAMP
416  #define PL_PIN_ON PORTB |= 1<<4;
417  #define PL_PIN_OFF PORTB &= ~(1<<4);
418  #else
419  #define BUZZERPIN_ON PORTB |= 1<<4;
420  #define BUZZERPIN_OFF PORTB &= ~(1<<4);
421  #endif
422 
423  #elif defined(A32U4ALLPINS)
424  #define BUZZERPIN_PINMODE DDRD |= (1<<4);
425  #if defined PILOTLAMP
426  #define PL_PIN_ON PORTD |= 1<<4;
427  #define PL_PIN_OFF PORTD &= ~(1<<4);
428  #else
429  #define BUZZERPIN_ON PORTD |= 1<<4;
430  #define BUZZERPIN_OFF PORTD &= ~(1<<4);
431  #endif
432  #else
433  #define BUZZERPIN_PINMODE DDRD |= (1<<3);
434  #if defined PILOTLAMP
435  #define PL_PIN_ON PORTD |= 1<<3;
436  #define PL_PIN_OFF PORTD &= ~(1<<3);
437  #else
438  #define BUZZERPIN_ON PORTD |= 1<<3;
439  #define BUZZERPIN_OFF PORTD &= ~(1<<3);
440  #endif
441  #endif
442  #define POWERPIN_PINMODE //
443  #define POWERPIN_ON //
444  #define POWERPIN_OFF //
445  #define I2C_PULLUPS_ENABLE PORTD |= 1<<0; PORTD |= 1<<1; // PIN 2&3 (SDA&SCL)
446  #define I2C_PULLUPS_DISABLE PORTD &= ~(1<<0); PORTD &= ~(1<<1);
447  #define PINMODE_LCD DDRD |= (1<<2);
448  #define LCDPIN_OFF PORTD &= ~1;
449  #define LCDPIN_ON PORTD |= 1;
450  #define STABLEPIN_PINMODE ;
451  #define STABLEPIN_ON ;
452  #define STABLEPIN_OFF ;
453  #define PPM_PIN_INTERRUPT DDRE &= ~(1 << 6);PORTE |= (1 << 6); EICRB |= (1 << ISC61)|(1 << ISC60); EIMSK |= (1 << INT6);
454  #if !defined(RX_SERIAL_PORT)
455  #define RX_SERIAL_PORT 1
456  #endif
457  #define USB_CDC_TX 3
458  #define USB_CDC_RX 2
459 
460  //soft PWM Pins
461  #define SOFT_PWM_1_PIN_HIGH PORTD |= 1<<4;
462  #define SOFT_PWM_1_PIN_LOW PORTD &= ~(1<<4);
463  #define SOFT_PWM_2_PIN_HIGH PORTF |= 1<<5;
464  #define SOFT_PWM_2_PIN_LOW PORTF &= ~(1<<5);
465  #if !defined(A32U4ALLPINS)
466  #define SOFT_PWM_3_PIN_HIGH PORTF |= 1<<7;
467  #define SOFT_PWM_3_PIN_LOW PORTF &= ~(1<<7);
468  #define SOFT_PWM_4_PIN_HIGH PORTF |= 1<<6;
469  #define SOFT_PWM_4_PIN_LOW PORTF &= ~(1<<6);
470  #define SW_PWM_P3 A1
471  #define SW_PWM_P4 A0
472  #else
473  #define SOFT_PWM_3_PIN_HIGH PORTF |= 1<<4;
474  #define SOFT_PWM_3_PIN_LOW PORTF &= ~(1<<4);
475  #define SOFT_PWM_4_PIN_HIGH PORTF |= 1<<5;
476  #define SOFT_PWM_4_PIN_LOW PORTF &= ~(1<<5);
477  #define SW_PWM_P3 A2
478  #define SW_PWM_P4 A3
479  #endif
480 
481  // Servos
482  #define SERVO_1_PINMODE DDRF |= (1<<7); // A0
483  #define SERVO_1_PIN_HIGH PORTF|= 1<<7;
484  #define SERVO_1_PIN_LOW PORTF &= ~(1<<7);
485  #define SERVO_2_PINMODE DDRF |= (1<<6); // A1
486  #define SERVO_2_PIN_HIGH PORTF |= 1<<6;
487  #define SERVO_2_PIN_LOW PORTF &= ~(1<<6);
488  #define SERVO_3_PINMODE DDRF |= (1<<5); // A2
489  #define SERVO_3_PIN_HIGH PORTF |= 1<<5;
490  #define SERVO_3_PIN_LOW PORTF &= ~(1<<5);
491  #if !defined(A32U4ALLPINS)
492  #define SERVO_4_PINMODE DDRD |= (1<<4); // 4
493  #define SERVO_4_PIN_HIGH PORTD |= 1<<4;
494  #define SERVO_4_PIN_LOW PORTD &= ~(1<<4);
495  #else
496  #define SERVO_4_PINMODE DDRF |= (1<<4); // A3
497  #define SERVO_4_PIN_HIGH PORTF |= 1<<4;
498  #define SERVO_4_PIN_LOW PORTF &= ~(1<<4);
499  #endif
500  #define SERVO_5_PINMODE DDRC |= (1<<6); // 5
501  #define SERVO_5_PIN_HIGH PORTC|= 1<<6;
502  #define SERVO_5_PIN_LOW PORTC &= ~(1<<6);
503  #define SERVO_6_PINMODE DDRD |= (1<<7); // 6
504  #define SERVO_6_PIN_HIGH PORTD |= 1<<7;
505  #define SERVO_6_PIN_LOW PORTD &= ~(1<<7);
506  #define SERVO_7_PINMODE DDRB |= (1<<6); // 10
507  #define SERVO_7_PIN_HIGH PORTB |= 1<<6;
508  #define SERVO_7_PIN_LOW PORTB &= ~(1<<6);
509  #define SERVO_8_PINMODE DDRB |= (1<<5); // 9
510  #define SERVO_8_PIN_HIGH PORTB |= 1<<5;
511  #define SERVO_8_PIN_LOW PORTB &= ~(1<<5);
512 
513  //Standart RX
514  #define THROTTLEPIN 3
515  #if defined(A32U4ALLPINS)
516  #define ROLLPIN 6
517  #define PITCHPIN 2
518  #define YAWPIN 4
519  #define AUX1PIN 5
520  #else
521  #define ROLLPIN 4
522  #define PITCHPIN 5
523  #define YAWPIN 2
524  #define AUX1PIN 6
525  #endif
526  #define AUX2PIN 7
527  #define AUX3PIN 1 // unused
528  #define AUX4PIN 0 // unused
529  #if !defined(RCAUX2PIND17)
530  #define PCINT_PIN_COUNT 4
531  #define PCINT_RX_BITS (1<<1),(1<<2),(1<<3),(1<<4)
532  #else
533  #define PCINT_PIN_COUNT 5 // one more bit (PB0) is added in RX code
534  #define PCINT_RX_BITS (1<<1),(1<<2),(1<<3),(1<<4),(1<<0)
535  #endif
536  #define PCINT_RX_PORT PORTB
537  #define PCINT_RX_MASK PCMSK0
538  #define PCIR_PORT_BIT (1<<0)
539  #define RX_PC_INTERRUPT PCINT0_vect
540  #define RX_PCINT_PIN_PORT PINB
541 
542  #if !defined(A32U4ALLPINS) && !defined(TEENSY20)
543  #define V_BATPIN A3 // Analog PIN 3
544  #elif defined(A32U4ALLPINS)
545  #define V_BATPIN A4 // Analog PIN 4
546  #else
547  #define V_BATPIN A2 // Analog PIN 3
548  #endif
549  #if !defined(TEENSY20)
550  #define PSENSORPIN A2 // Analog PIN 2
551  #else
552  #define PSENSORPIN A2 // Analog PIN 2
553  #endif
554 #endif
555 
556 /************************** all the Mega types ***********************************/
557 #if defined(MEGA)
558  #define LEDPIN_PINMODE pinMode (13, OUTPUT);pinMode (30, OUTPUT);
559  #define LEDPIN_TOGGLE PINB |= (1<<7); PINC |= (1<<7);
560  #define LEDPIN_ON PORTB |= (1<<7); PORTC |= (1<<7);
561  #define LEDPIN_OFF PORTB &= ~(1<<7);PORTC &= ~(1<<7);
562  #define BUZZERPIN_PINMODE pinMode (32, OUTPUT);
563  #if defined PILOTLAMP
564  #define PL_PIN_ON PORTC |= 1<<5;
565  #define PL_PIN_OFF PORTC &= ~(1<<5);
566  #else
567  #define BUZZERPIN_ON PORTC |= 1<<5;
568  #define BUZZERPIN_OFF PORTC &= ~(1<<5);
569  #endif
570 
571  #if !defined(DISABLE_POWER_PIN)
572  #define POWERPIN_PINMODE pinMode (37, OUTPUT);
573  #define POWERPIN_ON PORTC |= 1<<0;
574  #define POWERPIN_OFF PORTC &= ~(1<<0);
575  #else
576  #define POWERPIN_PINMODE ;
577  #define POWERPIN_ON ;
578  #define POWERPIN_OFF ;
579  #endif
580  #define I2C_PULLUPS_ENABLE PORTD |= 1<<0; PORTD |= 1<<1; // PIN 20&21 (SDA&SCL)
581  #define I2C_PULLUPS_DISABLE PORTD &= ~(1<<0); PORTD &= ~(1<<1);
582  #define PINMODE_LCD pinMode(0, OUTPUT);
583  #define LCDPIN_OFF PORTE &= ~1; //switch OFF digital PIN 0
584  #define LCDPIN_ON PORTE |= 1;
585  #define STABLEPIN_PINMODE pinMode (31, OUTPUT);
586  #define STABLEPIN_ON PORTC |= 1<<6;
587  #define STABLEPIN_OFF PORTC &= ~(1<<6);
588  #if defined(PPM_ON_THROTTLE)
589  //configure THROTTLE PIN (A8 pin) as input witch pullup and enabled PCINT interrupt
590  #define PPM_PIN_INTERRUPT DDRK &= ~(1<<0); PORTK |= (1<<0); PCICR |= (1<<2); PCMSK2 |= (1<<0);
591  #else
592  #define PPM_PIN_INTERRUPT attachInterrupt(4, rxInt, RISING); //PIN 19, also used for Spektrum satellite option
593  #endif
594  #if !defined(RX_SERIAL_PORT)
595  #define RX_SERIAL_PORT 1
596  #endif
597  //RX PIN assignment inside the port //for PORTK
598  #define THROTTLEPIN 0 //PIN 62 = PIN A8
599  #define ROLLPIN 1 //PIN 63 = PIN A9
600  #define PITCHPIN 2 //PIN 64 = PIN A10
601  #define YAWPIN 3 //PIN 65 = PIN A11
602  #define AUX1PIN 4 //PIN 66 = PIN A12
603  #define AUX2PIN 5 //PIN 67 = PIN A13
604  #define AUX3PIN 6 //PIN 68 = PIN A14
605  #define AUX4PIN 7 //PIN 69 = PIN A15
606  #define V_BATPIN A0 // Analog PIN 0
607  #define PSENSORPIN A2 // Analog PIN 2
608  #define PCINT_PIN_COUNT 8
609  #define PCINT_RX_BITS (1<<2),(1<<4),(1<<5),(1<<6),(1<<7),(1<<0),(1<<1),(1<<3)
610  #define PCINT_RX_PORT PORTK
611  #define PCINT_RX_MASK PCMSK2
612  #define PCIR_PORT_BIT (1<<2)
613  #define RX_PC_INTERRUPT PCINT2_vect
614  #define RX_PCINT_PIN_PORT PINK
615 
616  #define SERVO_1_PINMODE pinMode(34,OUTPUT);pinMode(44,OUTPUT); // TILT_PITCH - WING left
617  #define SERVO_1_PIN_HIGH PORTC |= 1<<3;PORTL |= 1<<5;
618  #define SERVO_1_PIN_LOW PORTC &= ~(1<<3);PORTL &= ~(1<<5);
619  #define SERVO_2_PINMODE pinMode(35,OUTPUT);pinMode(45,OUTPUT); // TILT_ROLL - WING right
620  #define SERVO_2_PIN_HIGH PORTC |= 1<<2;PORTL |= 1<<4;
621  #define SERVO_2_PIN_LOW PORTC &= ~(1<<2);PORTL &= ~(1<<4);
622  #define SERVO_3_PINMODE pinMode(33,OUTPUT); pinMode(46,OUTPUT); // CAM TRIG - alt TILT_PITCH
623  #define SERVO_3_PIN_HIGH PORTC |= 1<<4;PORTL |= 1<<3;
624  #define SERVO_3_PIN_LOW PORTC &= ~(1<<4);PORTL &= ~(1<<3);
625  #define SERVO_4_PINMODE pinMode (37, OUTPUT);pinMode(7,OUTPUT); // new - alt TILT_ROLL
626  #define SERVO_4_PIN_HIGH PORTC |= 1<<0; PORTH |= 1<<4;
627  #define SERVO_4_PIN_LOW PORTC &= ~(1<<0);PORTH &= ~(1<<4);
628 
629  #define SERVO_5_PINMODE pinMode(6,OUTPUT); // BI LEFT
630  #define SERVO_5_PIN_HIGH PORTH |= 1<<3;
631  #define SERVO_5_PIN_LOW PORTH &= ~(1<<3);
632  #define SERVO_6_PINMODE pinMode(2,OUTPUT); // TRI REAR - BI RIGHT
633  #define SERVO_6_PIN_HIGH PORTE |= 1<<4;
634  #define SERVO_6_PIN_LOW PORTE &= ~(1<<4);
635  #define SERVO_7_PINMODE pinMode(5,OUTPUT); // new
636  #define SERVO_7_PIN_HIGH PORTE |= 1<<3;
637  #define SERVO_7_PIN_LOW PORTE &= ~(1<<3);
638  #define SERVO_8_PINMODE pinMode(3,OUTPUT); // new
639  #define SERVO_8_PIN_HIGH PORTE |= 1<<5;
640  #define SERVO_8_PIN_LOW PORTE &= ~(1<<5);
641 #endif
642 
643 
644 // special defines for the Mongose IMU board
645 // note: that may be moved to the IMU Orientations because this are board defines .. not Proc
646 
647 #if defined(MONGOOSE1_0) // basically it's a PROMINI without some PINS => same code as a PROMINI board except PIN definition
648  // note: to avoid too much dubble code there are now just the differencies
649  // http://www.multiwii.com/forum/viewtopic.php?f=6&t=627
650  #define LEDPIN_PINMODE pinMode (4, OUTPUT);
651  #define LEDPIN_TOGGLE PIND |= 1<<4; //switch LEDPIN state (digital PIN 13)
652  #define LEDPIN_OFF PORTD &= ~(1<<4);
653  #define LEDPIN_ON PORTD |= (1<<4);
654  #define SPEK_BAUD_SET UCSR0A = (1<<U2X0); UBRR0H = ((F_CPU / 4 / 115200 -1) / 2) >> 8; UBRR0L = ((F_CPU / 4 / 115200 -1) / 2);
655  #define RX_SERIAL_PORT 0
656 
657  /* Unavailable pins on MONGOOSE1_0 */
658  #define BUZZERPIN_PINMODE ; // D8
659  #define BUZZERPIN_ON ;
660  #define BUZZERPIN_OFF ;
661  #define POWERPIN_PINMODE ; // D12
662  #define POWERPIN_ON ;
663  #define POWERPIN_OFF ;
664  #define STABLEPIN_PINMODE ; //
665  #define STABLEPIN_ON ;
666  #define STABLEPIN_OFF ;
667  #define PINMODE_LCD ; //
668  #define LCDPIN_OFF ;
669  #define LCDPIN_ON ;
670 
671 
672  #define SERVO_4_PINMODE ; // Not available
673  #define SERVO_4_PIN_HIGH ;
674  #define SERVO_4_PIN_LOW ;
675 #endif
676 
677 
678 /********************** Sort the Servos for the most ideal SW PWM ************************/
679 // this define block sorts the above slected servos to be in a simple order from 1 - (count of total servos)
680 // its pretty fat but its the best way i found to get less compiled code and max speed in the ISR without loosing its flexibility
681 #if (PRI_SERVO_FROM == 1) || (SEC_SERVO_FROM == 1)
682  #define LAST_LOW SERVO_1_PIN_LOW
683  #define SERVO_1_HIGH SERVO_1_PIN_HIGH
684  #define SERVO_1_LOW SERVO_1_PIN_LOW
685  #define SERVO_1_ARR_POS 0
686 #endif
687 #if (PRI_SERVO_FROM <= 2 && PRI_SERVO_TO >= 2) || (SEC_SERVO_FROM <= 2 && SEC_SERVO_TO >= 2)
688  #undef LAST_LOW
689  #define LAST_LOW SERVO_2_PIN_LOW
690  #if !defined(SERVO_1_HIGH)
691  #define SERVO_1_HIGH SERVO_2_PIN_HIGH
692  #define SERVO_1_LOW SERVO_2_PIN_LOW
693  #define SERVO_1_ARR_POS 1
694  #else
695  #define SERVO_2_HIGH SERVO_2_PIN_HIGH
696  #define SERVO_2_LOW SERVO_2_PIN_LOW
697  #define SERVO_2_ARR_POS 1
698  #endif
699 #endif
700 #if (PRI_SERVO_FROM <= 3 && PRI_SERVO_TO >= 3) || (SEC_SERVO_FROM <= 3 && SEC_SERVO_TO >= 3)
701  #undef LAST_LOW
702  #define LAST_LOW SERVO_3_PIN_LOW
703  #if !defined(SERVO_1_HIGH)
704  #define SERVO_1_HIGH SERVO_3_PIN_HIGH
705  #define SERVO_1_LOW SERVO_3_PIN_LOW
706  #define SERVO_1_ARR_POS 2
707  #elif !defined(SERVO_2_HIGH)
708  #define SERVO_2_HIGH SERVO_3_PIN_HIGH
709  #define SERVO_2_LOW SERVO_3_PIN_LOW
710  #define SERVO_2_ARR_POS 2
711  #else
712  #define SERVO_3_HIGH SERVO_3_PIN_HIGH
713  #define SERVO_3_LOW SERVO_3_PIN_LOW
714  #define SERVO_3_ARR_POS 2
715  #endif
716 #endif
717 #if (PRI_SERVO_FROM <= 4 && PRI_SERVO_TO >= 4) || (SEC_SERVO_FROM <= 4 && SEC_SERVO_TO >= 4)
718  #undef LAST_LOW
719  #define LAST_LOW SERVO_4_PIN_LOW
720  #if !defined(SERVO_1_HIGH)
721  #define SERVO_1_HIGH SERVO_4_PIN_HIGH
722  #define SERVO_1_LOW SERVO_4_PIN_LOW
723  #define SERVO_1_ARR_POS 3
724  #elif !defined(SERVO_2_HIGH)
725  #define SERVO_2_HIGH SERVO_4_PIN_HIGH
726  #define SERVO_2_LOW SERVO_4_PIN_LOW
727  #define SERVO_2_ARR_POS 3
728  #elif !defined(SERVO_3_HIGH)
729  #define SERVO_3_HIGH SERVO_4_PIN_HIGH
730  #define SERVO_3_LOW SERVO_4_PIN_LOW
731  #define SERVO_3_ARR_POS 3
732  #else
733  #define SERVO_4_HIGH SERVO_4_PIN_HIGH
734  #define SERVO_4_LOW SERVO_4_PIN_LOW
735  #define SERVO_4_ARR_POS 3
736  #endif
737 #endif
738 #if (PRI_SERVO_FROM <= 5 && PRI_SERVO_TO >= 5) || (SEC_SERVO_FROM <= 5 && SEC_SERVO_TO >= 5)
739  #undef LAST_LOW
740  #define LAST_LOW SERVO_5_PIN_LOW
741  #if !defined(SERVO_1_HIGH)
742  #define SERVO_1_HIGH SERVO_5_PIN_HIGH
743  #define SERVO_1_LOW SERVO_5_PIN_LOW
744  #define SERVO_1_ARR_POS 4
745  #elif !defined(SERVO_2_HIGH)
746  #define SERVO_2_HIGH SERVO_5_PIN_HIGH
747  #define SERVO_2_LOW SERVO_5_PIN_LOW
748  #define SERVO_2_ARR_POS 4
749  #elif !defined(SERVO_3_HIGH)
750  #define SERVO_3_HIGH SERVO_5_PIN_HIGH
751  #define SERVO_3_LOW SERVO_5_PIN_LOW
752  #define SERVO_3_ARR_POS 4
753  #elif !defined(SERVO_4_HIGH)
754  #define SERVO_4_HIGH SERVO_5_PIN_HIGH
755  #define SERVO_4_LOW SERVO_5_PIN_LOW
756  #define SERVO_4_ARR_POS 4
757  #else
758  #define SERVO_5_HIGH SERVO_5_PIN_HIGH
759  #define SERVO_5_LOW SERVO_5_PIN_LOW
760  #define SERVO_5_ARR_POS 4
761  #endif
762 #endif
763 #if (PRI_SERVO_FROM <= 6 && PRI_SERVO_TO >= 6) || (SEC_SERVO_FROM <= 6 && SEC_SERVO_TO >= 6)
764  #undef LAST_LOW
765  #define LAST_LOW SERVO_6_PIN_LOW
766  #if !defined(SERVO_1_HIGH)
767  #define SERVO_1_HIGH SERVO_6_PIN_HIGH
768  #define SERVO_1_LOW SERVO_6_PIN_LOW
769  #define SERVO_1_ARR_POS 5
770  #elif !defined(SERVO_2_HIGH)
771  #define SERVO_2_HIGH SERVO_6_PIN_HIGH
772  #define SERVO_2_LOW SERVO_6_PIN_LOW
773  #define SERVO_2_ARR_POS 5
774  #elif !defined(SERVO_3_HIGH)
775  #define SERVO_3_HIGH SERVO_6_PIN_HIGH
776  #define SERVO_3_LOW SERVO_6_PIN_LOW
777  #define SERVO_3_ARR_POS 5
778  #elif !defined(SERVO_4_HIGH)
779  #define SERVO_4_HIGH SERVO_6_PIN_HIGH
780  #define SERVO_4_LOW SERVO_6_PIN_LOW
781  #define SERVO_4_ARR_POS 5
782  #elif !defined(SERVO_5_HIGH)
783  #define SERVO_5_HIGH SERVO_6_PIN_HIGH
784  #define SERVO_5_LOW SERVO_6_PIN_LOW
785  #define SERVO_5_ARR_POS 5
786  #else
787  #define SERVO_6_HIGH SERVO_6_PIN_HIGH
788  #define SERVO_6_LOW SERVO_6_PIN_LOW
789  #define SERVO_6_ARR_POS 5
790  #endif
791 #endif
792 #if (PRI_SERVO_FROM <= 7 && PRI_SERVO_TO >= 7) || (SEC_SERVO_FROM <= 7 && SEC_SERVO_TO >= 7)
793  #undef LAST_LOW
794  #define LAST_LOW SERVO_7_PIN_LOW
795  #if !defined(SERVO_1_HIGH)
796  #define SERVO_1_HIGH SERVO_7_PIN_HIGH
797  #define SERVO_1_LOW SERVO_7_PIN_LOW
798  #define SERVO_1_ARR_POS 6
799  #elif !defined(SERVO_2_HIGH)
800  #define SERVO_2_HIGH SERVO_7_PIN_HIGH
801  #define SERVO_2_LOW SERVO_7_PIN_LOW
802  #define SERVO_2_ARR_POS 6
803  #elif !defined(SERVO_3_HIGH)
804  #define SERVO_3_HIGH SERVO_7_PIN_HIGH
805  #define SERVO_3_LOW SERVO_7_PIN_LOW
806  #define SERVO_3_ARR_POS 6
807  #elif !defined(SERVO_4_HIGH)
808  #define SERVO_4_HIGH SERVO_7_PIN_HIGH
809  #define SERVO_4_LOW SERVO_7_PIN_LOW
810  #define SERVO_4_ARR_POS 6
811  #elif !defined(SERVO_5_HIGH)
812  #define SERVO_5_HIGH SERVO_7_PIN_HIGH
813  #define SERVO_5_LOW SERVO_7_PIN_LOW
814  #define SERVO_5_ARR_POS 6
815  #elif !defined(SERVO_6_HIGH)
816  #define SERVO_6_HIGH SERVO_7_PIN_HIGH
817  #define SERVO_6_LOW SERVO_7_PIN_LOW
818  #define SERVO_6_ARR_POS 6
819  #else
820  #define SERVO_7_HIGH SERVO_7_PIN_HIGH
821  #define SERVO_7_LOW SERVO_7_PIN_LOW
822  #define SERVO_7_ARR_POS 6
823  #endif
824 #endif
825 #if (PRI_SERVO_FROM <= 8 && PRI_SERVO_TO >= 8) || (SEC_SERVO_FROM <= 8 && SEC_SERVO_TO >= 8)
826  #undef LAST_LOW
827  #define LAST_LOW SERVO_8_PIN_LOW
828  #if !defined(SERVO_1_HIGH)
829  #define SERVO_1_HIGH SERVO_8_PIN_HIGH
830  #define SERVO_1_LOW SERVO_8_PIN_LOW
831  #define SERVO_1_ARR_POS 7
832  #elif !defined(SERVO_2_HIGH)
833  #define SERVO_2_HIGH SERVO_8_PIN_HIGH
834  #define SERVO_2_LOW SERVO_8_PIN_LOW
835  #define SERVO_2_ARR_POS 7
836  #elif !defined(SERVO_3_HIGH)
837  #define SERVO_3_HIGH SERVO_8_PIN_HIGH
838  #define SERVO_3_LOW SERVO_8_PIN_LOW
839  #define SERVO_3_ARR_POS 7
840  #elif !defined(SERVO_4_HIGH)
841  #define SERVO_4_HIGH SERVO_8_PIN_HIGH
842  #define SERVO_4_LOW SERVO_8_PIN_LOW
843  #define SERVO_4_ARR_POS 7
844  #elif !defined(SERVO_5_HIGH)
845  #define SERVO_5_HIGH SERVO_8_PIN_HIGH
846  #define SERVO_5_LOW SERVO_8_PIN_LOW
847  #define SERVO_5_ARR_POS 7
848  #elif !defined(SERVO_6_HIGH)
849  #define SERVO_6_HIGH SERVO_8_PIN_HIGH
850  #define SERVO_6_LOW SERVO_8_PIN_LOW
851  #define SERVO_6_ARR_POS 7
852  #elif !defined(SERVO_7_HIGH)
853  #define SERVO_7_HIGH SERVO_8_PIN_HIGH
854  #define SERVO_7_LOW SERVO_8_PIN_LOW
855  #define SERVO_7_ARR_POS 7
856  #else
857  #define SERVO_8_HIGH SERVO_8_PIN_HIGH
858  #define SERVO_8_LOW SERVO_8_PIN_LOW
859  #define SERVO_8_ARR_POS 7
860  #endif
861 #endif
862 
863 #if ( defined(MEGA) && defined(MEGA_HW_PWM_SERVOS) ) || (defined(PROMICRO) && defined(A32U4_4_HW_PWM_SERVOS))
864  #undef SERVO_1_HIGH // No software PWM's if we use hardware MEGA PWM or promicro hardware pwm
865  #define HW_PWM_SERVOS
866 #endif
867 
868 
869 /**************************************************************************************/
870 /*************** IMU Orientations and Sensor definitions ********************/
871 /**************************************************************************************/
872 
873 
874 //please submit any correction to this list.
875 #if defined(FFIMUv1)
876  #define ITG3200
877  #define BMA180
878  #define BMP085
879  #define HMC5843
880  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
881  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
882  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
883 #endif
884 
885 #if defined(FFIMUv2)
886  #define ITG3200
887  #define BMA180
888  #define BMP085
889  #define HMC5883
890  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
891  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
892  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = Y; imu.magADC[PITCH] = -X; imu.magADC[YAW] = -Z;}
893 #endif
894 
895 #if defined(FREEIMUv1)
896  #define ITG3200
897  #define ADXL345
898  #define HMC5843
899  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
900  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
901  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
902  #define ADXL345_ADDRESS 0x53
903  #undef INTERNAL_I2C_PULLUPS
904 #endif
905 
906 #if defined(FREEIMUv03)
907  #define ITG3200
908  #define ADXL345 // this is actually an ADXL346 but that's just the same as ADXL345
909  #define HMC5883
910  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
911  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
912  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
913  #define ADXL345_ADDRESS 0x53
914  #undef INTERNAL_I2C_PULLUPS
915 #endif
916 
917 #if defined(FREEIMUv035) || defined(FREEIMUv035_MS) || defined(FREEIMUv035_BMP)
918  #define ITG3200
919  #define BMA180
920  #define HMC5883
921  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
922  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
923  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
924  #undef INTERNAL_I2C_PULLUPS
925  #if defined(FREEIMUv035_MS)
926  #define MS561101BA
927  #elif defined(FREEIMUv035_BMP)
928  #define BMP085
929  #endif
930 #endif
931 
932 #if defined(FREEIMUv04)
933  #define FREEIMUv043
934 #endif
935 
936 #if defined(MultiWiiMega)
937  #define FREEIMUv043
938 #endif
939 
940 #if defined(FREEIMUv043) || defined(MICROWII)
941  #define MPU6050
942  #define HMC5883
943  #define MS561101BA
944  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
945  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
946  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
947  #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050
948  #undef INTERNAL_I2C_PULLUPS
949 #endif
950 
951 #if defined(NANOWII)
952  #define MPU6050
953  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -Y; imu.accADC[PITCH] = X; imu.accADC[YAW] = Z;}
954  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -X; imu.gyroADC[PITCH] = -Y; imu.gyroADC[YAW] = -Z;}
955  #undef INTERNAL_I2C_PULLUPS
956  // move motor 7 & 8 to pin 4 & A2
957  #undef SOFT_PWM_3_PIN_HIGH
958  #undef SOFT_PWM_3_PIN_LOW
959  #undef SOFT_PWM_4_PIN_HIGH
960  #undef SOFT_PWM_4_PIN_LOW
961  #undef SW_PWM_P3
962  #undef SW_PWM_P4
963  #define SOFT_PWM_3_PIN_HIGH PORTD |= 1<<4;
964  #define SOFT_PWM_3_PIN_LOW PORTD &= ~(1<<4);
965  #define SOFT_PWM_4_PIN_HIGH PORTF |= 1<<5;
966  #define SOFT_PWM_4_PIN_LOW PORTF &= ~(1<<5);
967  #define SW_PWM_P3 4
968  #define SW_PWM_P4 A2
969  #define HWPWM6
970  // move servo 3 & 4 to pin 13 & 11
971  #undef SERVO_3_PINMODE
972  #undef SERVO_3_PIN_HIGH
973  #undef SERVO_3_PIN_LOW
974  #undef SERVO_4_PINMODE
975  #undef SERVO_4_PIN_HIGH
976  #undef SERVO_4_PIN_LOW
977  #define SERVO_3_PINMODE DDRC |= (1<<7); // 13
978  #define SERVO_3_PIN_HIGH PORTC |= 1<<7;
979  #define SERVO_3_PIN_LOW PORTC &= ~(1<<7);
980  #define SERVO_4_PINMODE DDRB |= (1<<7); // 11
981  #define SERVO_4_PIN_HIGH PORTB |= 1<<7;
982  #define SERVO_4_PIN_LOW PORTB &= ~(1<<7);
983  // use pin 4 as status LED output if we have no octo
984  #if !defined(OCTOX8) && !defined(OCTOFLATP) && !defined(OCTOFLATX)
985  #undef LEDPIN_PINMODE
986  #undef LEDPIN_TOGGLE
987  #undef LEDPIN_OFF
988  #undef LEDPIN_ON
989  #define LEDPIN_PINMODE DDRD |= (1<<4); //D4 to output
990  #define LEDPIN_TOGGLE PIND |= (1<<5)|(1<<4); //switch LEDPIN state (Port D5) & pin D4
991  #define LEDPIN_OFF PORTD |= (1<<5); PORTD &= ~(1<<4);
992  #define LEDPIN_ON PORTD &= ~(1<<5); PORTD |= (1<<4);
993  #endif
994 #endif
995 
996 #if defined(PIPO)
997  #define L3G4200D
998  #define ADXL345
999  #define HMC5883
1000  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1001  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = Y; imu.gyroADC[YAW] = -Z;}
1002  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = Y; imu.magADC[PITCH] = -X; imu.magADC[YAW] = Z;}
1003  #define ADXL345_ADDRESS 0x53
1004 #endif
1005 
1006 #if defined(QUADRINO)
1007  #define ITG3200
1008  #define BMA180
1009  #define BMP085
1010  #define HMC5883
1011  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1012  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1013  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1014 #endif
1015 
1016 #if defined(QUADRINO_ZOOM)
1017  #define ITG3200
1018  #define BMA180
1019  #define BMP085
1020  #define HMC5883
1021  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1022  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1023  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1024  #define STABLEPIN_PINMODE pinMode (A2, OUTPUT);
1025  #define STABLEPIN_ON PORTC |= (1<<2);
1026  #define STABLEPIN_OFF PORTC &= ~(1<<2);
1027 #endif
1028 
1029 #if defined(QUADRINO_ZOOM_MS)
1030  #define ITG3200
1031  #define BMA180
1032  #define MS561101BA
1033  #define HMC5883
1034  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1035  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1036  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1037  #define STABLEPIN_PINMODE pinMode (A2, OUTPUT);
1038  #define STABLEPIN_ON PORTC |= (1<<2);
1039  #define STABLEPIN_OFF PORTC &= ~(1<<2);
1040 #endif
1041 
1042 #if defined(ALLINONE)
1043  #define ITG3200
1044  #define BMA180
1045  #define BMP085
1046  #define HMC5883
1047  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1048  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1049  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1050  #define BMA180_ADDRESS 0x41
1051 #endif
1052 
1053 #if defined(AEROQUADSHIELDv2) // to confirm
1054  #define ITG3200
1055  #define BMA180
1056  #define BMP085
1057  #define HMC5843
1058  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1059  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = Y; imu.gyroADC[YAW] = -Z;}
1060  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1061  #define GYRO_ADDRESS 0X69
1062 #endif
1063 
1064 #if defined(ATAVRSBIN1)
1065  #define ITG3200
1066  #define BMA020 //Actually it's a BMA150, but this is a drop in replacement for the discountinued BMA020
1067  #define AK8975
1068  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = Y; imu.accADC[PITCH] = -X; imu.accADC[YAW] = Z;}
1069  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = Y; imu.gyroADC[YAW] = -Z;}
1070  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = -Y; imu.magADC[PITCH] = -X; imu.magADC[YAW] = Z;}
1071 #endif
1072 
1073 #if defined(SIRIUS)
1074  #define ITG3200
1075  #define BMA180
1076  #define BMP085
1077  #define HMC5883
1078  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1079  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1080  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1081 #endif
1082 
1083 #if defined(SIRIUSGPS)
1084  #define ITG3200
1085  #define BMA180
1086  #define BMP085
1087  #define HMC5883
1088  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1089  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1090  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = -X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = Z;}
1091 #endif
1092 
1093 #if defined(SIRIUS600)
1094  #define WMP
1095  #define BMA180
1096  #define BMP085
1097  #define HMC5883
1098  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1099  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1100 #endif
1101 
1102 #if defined(SIRIUS_AIR)
1103  #define MPU6050
1104  #define BMP085
1105  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = X; imu.accADC[PITCH] = Y; imu.accADC[YAW] = Z;}
1106  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -Y; imu.gyroADC[PITCH] = X; imu.gyroADC[YAW] = -Z;}
1107  #undef INTERNAL_I2C_PULLUPS
1108  #define HWPWM6
1109 #endif
1110 
1111 #if defined(SIRIUS_AIR_GPS)
1112  #define MPU6050
1113  #define BMP085
1114  #define HMC5883
1115  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = X; imu.accADC[PITCH] = Y; imu.accADC[YAW] = Z;}
1116  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -Y; imu.gyroADC[PITCH] = X; imu.gyroADC[YAW] = -Z;}
1117  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = -X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = Z;} //normal Sirius MAG on top is X Y -Z
1118  #undef INTERNAL_I2C_PULLUPS
1119  #define HWPWM6
1120 #endif
1121 
1122 #if defined(SIRIUS_MEGAv5_OSD)
1123  #define ITG3050
1124  #define BMA280
1125  #define MS561101BA
1126  #define HMC5883
1127  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1128  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -X; imu.gyroADC[PITCH] = -Y; imu.gyroADC[YAW] = -Z;}
1129  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = Y; imu.magADC[PITCH] = -X; imu.magADC[YAW] = -Z;}
1130  #undef INTERNAL_I2C_PULLUPS
1131 #endif
1132 
1133 #if defined(MINIWII)
1134  #define ITG3200
1135  #define BMA180
1136  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1137  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1138 #endif
1139 
1140 #if defined(CITRUSv2_1)
1141  #define ITG3200
1142  #define ADXL345
1143  #define BMP085
1144  #define HMC5883
1145  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1146  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1147  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1148  #undef INTERNAL_I2C_PULLUPS
1149 #endif
1150 
1151 #if defined(CHERRY6DOFv1_0)
1152  #define MPU6050
1153  #define ACC_ORIENTATION(Y, X, Z) {imu.accADC[ROLL] = -Y; imu.accADC[PITCH] = -X; imu.accADC[YAW] = Z;}
1154  #define GYRO_ORIENTATION(Y, X, Z) {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = -Y; imu.gyroADC[YAW] = -Z;}
1155  #undef INTERNAL_I2C_PULLUPS
1156 #endif
1157 
1158 #if defined(DROTEK_10DOF) || defined(DROTEK_10DOF_MS)
1159  #define ITG3200
1160  #define BMA180
1161  #define HMC5883
1162  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1163  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1164  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1165  #define GYRO_ADDRESS 0X69
1166  #if defined(DROTEK_10DOF_MS)
1167  #define MS561101BA
1168  #elif defined(DROTEK_10DOF)
1169  #define BMP085
1170  #endif
1171 #endif
1172 
1173 #if defined(DROTEK_6DOFv2)
1174  #define ITG3200
1175  #define BMA180
1176  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -Y; imu.accADC[PITCH] = X; imu.accADC[YAW] = Z;}
1177  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -X; imu.gyroADC[PITCH] = -Y; imu.gyroADC[YAW] = -Z;}
1178  #define GYRO_ADDRESS 0X69
1179 #endif
1180 
1181 #if defined(DROTEK_6DOF_MPU)
1182  #define MPU6050
1183  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -Y; imu.accADC[PITCH] = X; imu.accADC[YAW] = Z;}
1184  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -X; imu.gyroADC[PITCH] = -Y; imu.gyroADC[YAW] = -Z;}
1185  #define MPU6050_ADDRESS 0x69
1186  #undef INTERNAL_I2C_PULLUPS
1187 #endif
1188 
1189 #if defined(DROTEK_10DOF_MPU)
1190  #define MPU6050
1191  #define HMC5883
1192  #define MS561101BA
1193  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = Y; imu.accADC[PITCH] = -X; imu.accADC[YAW] = Z;}
1194  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = Y; imu.gyroADC[YAW] = -Z;}
1195  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = -Y; imu.magADC[PITCH] = X; imu.magADC[YAW] = -Z;}
1196  #define MPU6050_ADDRESS 0X69
1197  #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050
1198  #undef INTERNAL_I2C_PULLUPS
1199 #endif
1200 
1201 #if defined(FLYDUINO_MPU)
1202  #define MPU6050
1203  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = X; imu.accADC[PITCH] = Y; imu.accADC[YAW] = Z;}
1204  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -Y; imu.gyroADC[PITCH] = X; imu.gyroADC[YAW] = -Z;}
1205 #endif
1206 
1207 #if defined(MONGOOSE1_0)
1208  #define ITG3200
1209  #define ADXL345
1210  #define BMP085
1211  #define HMC5883
1212  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = -Y; imu.gyroADC[PITCH] = X; imu.gyroADC[YAW] = -Z;}
1213  #define ACC_ORIENTATION(Y, X, Z) {imu.accADC[ROLL] = Y; imu.accADC[PITCH] = X; imu.accADC[YAW] = Z;}
1214  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = -X; imu.magADC[PITCH] = -Y; imu.magADC[YAW] = -Z;}
1215  #define ADXL345_ADDRESS 0x53
1216  #undef INTERNAL_I2C_PULLUPS
1217 #endif
1218 
1219 #if defined(CRIUS_LITE)
1220  #define ITG3200
1221  #define ADXL345
1222  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1223  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1224 #endif
1225 
1226 #if defined(CRIUS_SE)
1227  #define ITG3200
1228  #define BMA180
1229  #define HMC5883
1230  #define BMP085
1231  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1232  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1233  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1234 #endif
1235 
1236 #if defined(CRIUS_SE_v2_0)
1237  #define MPU6050
1238  #define HMC5883
1239  #define BMP085
1240  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1241  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1242  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1243 #endif
1244 
1245 #if defined(BOARD_PROTO_1)
1246  #define MPU6050
1247  #define HMC5883
1248  #define MS561101BA
1249  #define ACC_ORIENTATION(Y, X, Z) {imu.accADC[ROLL] = -Y; imu.accADC[PITCH] = -X; imu.accADC[YAW] = Z;}
1250  #define GYRO_ORIENTATION(Y, X, Z) {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = -Y; imu.gyroADC[YAW] = -Z;}
1251  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1252  #define MS561101BA_ADDRESS 0x76
1253  #define STABLEPIN_PINMODE pinMode (A2, OUTPUT);
1254  #define STABLEPIN_ON PORTC |= (1<<2);
1255  #define STABLEPIN_OFF PORTC &= ~(1<<2);
1256 #endif
1257 
1258 #if defined(BOARD_PROTO_2)
1259  #define MPU6050
1260  #define MAG3110
1261  #define MS561101BA
1262  #define ACC_ORIENTATION(Y, X, Z) {imu.accADC[ROLL] = -Y; imu.accADC[PITCH] = -X; imu.accADC[YAW] = Z;}
1263  #define GYRO_ORIENTATION(Y, X, Z) {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = -Y; imu.gyroADC[YAW] = -Z;}
1264  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = Z;}
1265  #define MPU6050_I2C_AUX_MASTER
1266  #define MS561101BA_ADDRESS 0x76
1267  #define STABLEPIN_PINMODE pinMode (A2, OUTPUT);
1268  #define STABLEPIN_ON PORTC |= (1<<2);
1269  #define STABLEPIN_OFF PORTC &= ~(1<<2);
1270 #endif
1271 
1272 #if defined(GY_80)
1273  #define L3G4200D
1274  #define ADXL345
1275  #define HMC5883
1276  #define BMP085
1277  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1278  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1279  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1280  #undef INTERNAL_I2C_PULLUPS
1281  #define ADXL345_ADDRESS 0x53
1282 #endif
1283 
1284 #if defined(GY_85)
1285  #define ITG3200
1286  #define ADXL345
1287  #define HMC5883
1288  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1289  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1290  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1291  #undef INTERNAL_I2C_PULLUPS
1292  #define ADXL345_ADDRESS 0x53
1293 #endif
1294 
1295 #if defined(GY_86)
1296  #define MPU6050
1297  #define HMC5883
1298  #define MS561101BA
1299  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1300  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1301  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1302  #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050
1303  #undef INTERNAL_I2C_PULLUPS
1304 #endif
1305 
1306 #if defined(GY_88)
1307  #define MPU6050
1308  #define HMC5883
1309  #define BMP085
1310  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1311  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1312  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1313  #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050
1314  #undef INTERNAL_I2C_PULLUPS
1315 #endif
1316 
1317 #if defined(GY_521)
1318  #define MPU6050
1319  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1320  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1321  #undef INTERNAL_I2C_PULLUPS
1322 #endif
1323 
1324 #if defined(INNOVWORKS_10DOF)
1325  #define ITG3200
1326  #define BMA180
1327  #define BMP085
1328  #define HMC5883
1329  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1330  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1331  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.imu.[YAW] = -Z;}
1332  #undef INTERNAL_I2C_PULLUPS
1333 #endif
1334 
1335 #if defined(INNOVWORKS_6DOF)
1336  #define ITG3200
1337  #define BMA180
1338  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1339  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1340  #undef INTERNAL_I2C_PULLUPS
1341 #endif
1342 
1343 #if defined(PROTO_DIY)
1344  #define ITG3200
1345  #define BMA180
1346  #define HMC5883
1347  #define MS561101BA
1348  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = X; imu.accADC[PITCH] = Y; imu.accADC[YAW] = Z;}
1349  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = X; imu.gyroADC[PITCH] = Y; imu.gyroADC[YAW] = -Z;}
1350  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1351  #undef INTERNAL_I2C_PULLUPS
1352  #define STABLEPIN_ON PORTC &= ~(1<<6);
1353  #define STABLEPIN_OFF PORTC |= 1<<6;
1354 #endif
1355 
1356 #if defined(IOI_MINI_MULTIWII)
1357  #define ITG3200
1358  #define BMA180
1359  #define HMC5883
1360  #define BMP085
1361  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1362  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1363  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = -Y; imu.magADC[PITCH] = X; imu.magADC[YAW] = -Z;}
1364 #endif
1365 
1366 #if defined(Bobs_6DOF_V1)
1367  #define ITG3200
1368  #define BMA180
1369  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1370  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1371  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = Y; imu.magADC[PITCH] = -X; imu.magADC[YAW] = -Z;}
1372  #undef INTERNAL_I2C_PULLUPS
1373 #endif
1374 
1375 #if defined(Bobs_9DOF_V1)
1376  #define ITG3200
1377  #define BMA180
1378  #define BMP085
1379  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1380  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1381  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = Y; imu.magADC[PITCH] = -X; imu.magADC[YAW] = -Z;}
1382  #undef INTERNAL_I2C_PULLUPS
1383 #endif
1384 
1385 #if defined(Bobs_10DOF_BMP_V1)
1386  #define ITG3200
1387  #define BMA180
1388  #define BMP085 // Bobs 10DOF uses the BMP180 - BMP085 and BMP180 are software compatible
1389  #define HMC5883
1390  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1391  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1392  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = Y; imu.magADC[PITCH] = -X; imu.magADC[YAW] = -Z;}
1393  #undef INTERNAL_IC2_PULLUPS
1394 #endif
1395 
1396 #if defined(HK_MultiWii_SE_V2 )
1397  #define MPU6050
1398  #define HMC5883
1399  #define BMP085
1400  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1401  #define GYRO_ORIENTATION(X, Y, Z){imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1402  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1403  #define MPU6050_EN_I2C_BYPASS // MAG connected to the AUX I2C bus of MPU6050
1404  #undef INTERNAL_I2C_PULLUPS
1405 #endif
1406 
1407 #if defined(HK_MultiWii_328P )
1408  #define ITG3200
1409  #define BMA180
1410  #define HMC5883
1411  #define BMP085
1412  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1413  #define GYRO_ORIENTATION(X, Y, Z){imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1414  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1415  #undef INTERNAL_I2C_PULLUPS
1416 #endif
1417 
1418 #if defined(CRIUS_AIO_PRO)
1419  #define MPU6050
1420  #define HMC5883
1421  #define MS561101BA
1422  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1423  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1424  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1425  #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050
1426  #undef INTERNAL_I2C_PULLUPS
1427  #define I2C_SPEED 400000L //400kHz fast mode
1428  //servo pins on AIO board is at pins 44,45,46, then release pins 33,34,35 for other usage
1429  //eg. pin 33 on AIO can be used for LEDFLASHER output
1430  #define SERVO_1_PINMODE pinMode(44,OUTPUT); // TILT_PITCH
1431  #define SERVO_1_PIN_HIGH PORTL |= 1<<5;
1432  #define SERVO_1_PIN_LOW PORTL &= ~(1<<5);
1433  #define SERVO_2_PINMODE pinMode(45,OUTPUT); // TILT_ROLL
1434  #define SERVO_2_PIN_HIGH PORTL |= 1<<4;
1435  #define SERVO_2_PIN_LOW PORTL &= ~(1<<4);
1436  #define SERVO_3_PINMODE pinMode(46,OUTPUT); // CAM TRIG
1437  #define SERVO_3_PIN_HIGH PORTL |= 1<<3;
1438  #define SERVO_3_PIN_LOW PORTL &= ~(1<<3);
1439 #endif
1440 
1441 #if defined(LADYBIRD)
1442  #define MPU6050
1443  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1444  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1445  #undef INTERNAL_I2C_PULLUPS
1446  #define MINTHROTTLE 1050
1447  #define MAXTHROTTLE 2000
1448  #define EXT_MOTOR_32KHZ
1449  #define VBAT
1450  #define VBATSCALE 54
1451  #define VBATLEVEL_WARN1 10
1452  #define VBATLEVEL_WARN2 10
1453  #define VBATLEVEL_CRIT 10
1454  #define NO_VBAT 10
1455  #define MOTOR_STOP
1456 #endif
1457 
1458 #if defined(MEGAWAP_V2_STD)
1459  #define ITG3200
1460  #define BMA180
1461  #define HMC5883
1462  #define BMP085
1463  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1464  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1465  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1466 #endif
1467 
1468 #if defined(MEGAWAP_V2_ADV)
1469  #define MPU6050
1470  #define HMC5883
1471  #define MS561101BA
1472  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1473  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1474  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1475  #define MPU6050_EN_I2C_BYPASS // MAG connected to the AUX I2C bus of MPU6050
1476  #undef INTERNAL_I2C_PULLUPS
1477 #endif
1478 
1479 #if defined(RCNet_FC_GPS)
1480  #define RCNet_FC
1481  #define HMC5883
1482  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = -X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = Z;}
1483  #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050
1484  #undef INTERNAL_I2C_PULLUPS
1485  #define GPS_SERIAL 2
1486  #define GPS_BAUD 115200
1487  #define UBLOX
1488 #endif
1489 
1490 #if defined(RCNet_FC)
1491  #define MPU6050
1492  #define MS561101BA
1493  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1494  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1495  #undef INTERNAL_I2C_PULLUPS
1496  //servo pins on RCNet FC board are at pins 38,39,40
1497  #define SERVO_1_PINMODE pinMode(40,OUTPUT); // TILT_PITCH
1498  #define SERVO_1_PIN_HIGH PORTL |= 1<<5;
1499  #define SERVO_1_PIN_LOW PORTL &= ~(1<<5);
1500  #define SERVO_2_PINMODE pinMode(39,OUTPUT); // TILT_ROLL
1501  #define SERVO_2_PIN_HIGH PORTL |= 1<<4;
1502  #define SERVO_2_PIN_LOW PORTL &= ~(1<<4);
1503  #define SERVO_3_PINMODE pinMode(38,OUTPUT); // CAM TRIG
1504  #define SERVO_3_PIN_HIGH PORTL |= 1<<3;
1505  #define SERVO_3_PIN_LOW PORTL &= ~(1<<3);
1506 #endif
1507 
1508 #if defined(FLYDU_ULTRA)
1509  #define ITG3200
1510  #define MMA8451Q
1511  #define MS561101BA
1512  #define MAG3110
1513 
1514  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = X; imu.accADC[PITCH] = Y; imu.accADC[YAW] = Z;}
1515  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1516  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = -Y; imu.magADC[PITCH] = X; imu.magADC[YAW] = Z;}
1517 
1518  #define GPS_SERIAL 2
1519  #define GPS_BAUD 57600
1520  #define MTK_BINARY19
1521  #define INIT_MTK_GPS
1522 #endif
1523 
1524 #if defined(MultiWii_32U4_SE)
1525  #define MPU6050
1526  #define HMC5883
1527  #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050
1528  #define MS561101BA
1529  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1530  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1531  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1532  #undef INTERNAL_I2C_PULLUPS
1533 #endif
1534 
1535 #if defined(MultiWii_32U4_SE_no_baro)
1536  #define MPU6050
1537  #define HMC5883
1538  #define MPU6050_I2C_AUX_MASTER // MAG connected to the AUX I2C bus of MPU6050
1539  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1540  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1541  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1542  #undef INTERNAL_I2C_PULLUPS
1543 #endif
1544 
1545 #if defined(Flyduino9DOF)
1546  #define MPU6050
1547  #define HMC5883
1548  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1549  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1550  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1551  #define MPU6050_EN_I2C_BYPASS // MAG connected to the AUX I2C bus of MPU6050
1552  #undef INTERNAL_I2C_PULLUPS
1553 #endif
1554 
1555 #if defined(Nano_Plane)
1556  #define LSM330
1557  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1558  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1559  #undef INTERNAL_I2C_PULLUPS
1560 #endif
1561 
1562 #if defined(OPENLRSv2MULTI)
1563  #define ITG3200
1564  #define ADXL345
1565  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1566  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1567  #define ADXL345_ADDRESS 0x53
1568 
1569  #define SDO_pin A0
1570  #define SDI_pin A1
1571  #define SCLK_pin A2
1572  #define IRQ_pin 2
1573  #define nSel_pin 4
1574  #define IRQ_interrupt 0
1575 
1576  #define nIRQ_1 (PIND & 0x04)==0x04 //D2
1577  #define nIRQ_0 (PIND & 0x04)==0x00 //D2
1578 
1579  #define nSEL_on PORTD |= 0x10 //D4
1580  #define nSEL_off PORTD &= 0xEF //D4
1581 
1582  #define SCK_on PORTC |= 0x04 //C2
1583  #define SCK_off PORTC &= 0xFB //C2
1584 
1585  #define SDI_on PORTC |= 0x02 //C1
1586  #define SDI_off PORTC &= 0xFD //C1
1587 
1588  #define SDO_1 (PINC & 0x01) == 0x01 //C0
1589  #define SDO_0 (PINC & 0x01) == 0x00 //C0
1590 
1591  //#### Other interface pinouts ###
1592  #define GREEN_LED_pin 13
1593  #define RED_LED_pin A3
1594 
1595  #define Red_LED_ON PORTC |= _BV(3);
1596  #define Red_LED_OFF PORTC &= ~_BV(3);
1597 
1598  #define Green_LED_ON PORTB |= _BV(5);
1599  #define Green_LED_OFF PORTB &= ~_BV(5);
1600 
1601  #define NOP() __asm__ __volatile__("nop")
1602 
1603  #define RF22B_PWRSTATE_READY 01
1604  #define RF22B_PWRSTATE_TX 0x09
1605  #define RF22B_PWRSTATE_RX 05
1606  #define RF22B_Rx_packet_received_interrupt 0x02
1607  #define RF22B_PACKET_SENT_INTERRUPT 04
1608  #define RF22B_PWRSTATE_POWERDOWN 00
1609 
1610 #endif
1611 
1612 #if defined(DESQUARED6DOFV2GO)
1613  #define ITG3200
1614  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1615  #undef INTERNAL_I2C_PULLUPS
1616 #endif
1617 
1618 #if defined(DESQUARED6DOFV4)
1619  #define MPU6050
1620  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1621  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1622  #undef INTERNAL_I2C_PULLUPS
1623 #endif
1624 
1625 #if defined(OSEPPGYRO)
1626  #define MPU3050
1627  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1628  #undef INTERNAL_I2C_PULLUPS
1629 #endif
1630 
1631 #if defined(DIYFLYING_MAGE_V1)
1632  #define MPU6050 // gyro+acc
1633  #define BMP085 // baro
1634  #define HMC5883 // mag
1635  #define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
1636  #define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
1637  #define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = X; imu.magADC[PITCH] = Y; imu.magADC[YAW] = -Z;}
1638  #undef INTERNAL_I2C_PULLUPS
1639 #endif
1640 
1641 /**************************************************************************************/
1642 /*************** Sensor Type definitions ********************/
1643 /**************************************************************************************/
1644 
1645 #if defined(ADXL345) || defined(BMA020) || defined(BMA180) || defined(BMA280) || defined(MMA7455) || defined(ADCACC) || defined(LIS3LV02) || defined(LSM303DLx_ACC) || defined(MPU6050) || defined(LSM330) || defined(LSM9DS0) || defined(MMA8451Q)
1646  #define ACC 1
1647 #else
1648  #define ACC 0
1649 #endif
1650 
1651 #if defined(HMC5883) || defined(HMC5843) || defined(AK8975) || defined(MAG3110) || defined(LSM9DS0)
1652  #define MAG 1
1653 #else
1654  #define MAG 0
1655 #endif
1656 
1657 #if defined(ITG3200) || defined(ITG3050) || defined(L3G4200D) || defined(MPU6050) || defined(LSM330) || defined(LSM9DS0) || defined(MPU3050) || defined(WMP)
1658  #define GYRO 1
1659 #else
1660  #define GYRO 0
1661 #endif
1662 
1663 #if defined(BMP085) || defined(BME280) || defined(MS561101BA)
1664  #define BARO 1
1665 #else
1666  #define BARO 0
1667 #endif
1668 
1669 #if defined(GPS_SERIAL) || defined(I2C_GPS)
1670  #define GPS 1
1671 #else
1672  #define GPS 0
1673 #endif
1674 
1675 #if defined(USE_MSP_WP)
1676  #define NAVCAP 1
1677 #else
1678  #define NAVCAP 0
1679 #endif
1680 
1681 #if defined(SRF02) || defined(SRF08) || defined(SRF10) || defined(SRC235) || defined(I2C_GPS_SONAR)
1682  #define SONAR 1
1683 #else
1684  #define SONAR 0
1685 #endif
1686 
1687 #if defined(EXTENDED_AUX_STATES)
1688  #define EXTAUX 1
1689 #else
1690  #define EXTAUX 0
1691 #endif
1692 
1693 #if defined(RX_RSSI_CHAN)
1694  #define RX_RSSI
1695 #endif
1696 
1697 /**************************************************************************************/
1698 /*************** Multitype decleration for the GUI's ********************/
1699 /**************************************************************************************/
1700 #if defined(TRI)
1701  #define MULTITYPE 1
1702 #elif defined(QUADP)
1703  #define MULTITYPE 2
1704 #elif defined(QUADX)
1705  #define MULTITYPE 3
1706 #elif defined(BI)
1707  #define MULTITYPE 4
1708  #define SERVO_RATES {30,30,100,100,0,1,100,100}
1709 #elif defined(GIMBAL)
1710  #define MULTITYPE 5
1711 #elif defined(Y6)
1712  #define MULTITYPE 6
1713 #elif defined(HEX6)
1714  #define MULTITYPE 7
1715 #elif defined(FLYING_WING)
1716  #define MULTITYPE 8
1717  #define SERVO_RATES {30,30,100,0,1,100,100,100}
1718 #elif defined(Y4)
1719  #define MULTITYPE 9
1720 #elif defined(HEX6X)
1721  #define MULTITYPE 10
1722 #elif defined(OCTOX8)
1723  #define MULTITYPE 11 //the JAVA GUI is the same for all 8 motor configs
1724 #elif defined(OCTOFLATP)
1725  #define MULTITYPE 12 //12 for MultiWinGui
1726 #elif defined(OCTOFLATX)
1727  #define MULTITYPE 13 //13 for MultiWinGui
1728 #elif defined(AIRPLANE)
1729  #define MULTITYPE 14
1730  #define SERVO_RATES {30,30,100,100,-100,100,100,100}
1731 #elif defined (HELI_120_CCPM)
1732  #define MULTITYPE 15
1733 #elif defined (HELI_90_DEG)
1734  #define MULTITYPE 16
1735  #define SERVO_RATES {30,30,100,-100,-100,100,100,100}
1736 #elif defined(VTAIL4)
1737  #define MULTITYPE 17
1738 #elif defined(HEX6H)
1739  #define MULTITYPE 18
1740 #elif defined(SINGLECOPTER)
1741  #define MULTITYPE 21
1742  #define SERVO_RATES {30,30,100,0,1,0,1,100}
1743 #elif defined(DUALCOPTER)
1744  #define MULTITYPE 20
1745 #endif
1746 
1747 /**************************************************************************************/
1748 /*************** Some unsorted "chain" defines ********************/
1749 /**************************************************************************************/
1750 
1751 #if defined (AIRPLANE) || defined(HELICOPTER)|| defined(SINGLECOPTER)|| defined(DUALCOPTER) && defined(PROMINI)
1752  #if defined(D12_POWER)
1753  #define SERVO_4_PINMODE ; // D12
1754  #define SERVO_4_PIN_HIGH ;
1755  #define SERVO_4_PIN_LOW ;
1756  #else
1757  #undef POWERPIN_PINMODE
1758  #undef POWERPIN_ON
1759  #undef POWERPIN_OFF
1760  #define POWERPIN_PINMODE ;
1761  #define POWERPIN_ON ;
1762  #define POWERPIN_OFF ;
1763  #endif
1764 #endif
1765 
1766 #if defined(POWERMETER_HARD) || defined(POWERMETER_SOFT)
1767  #define POWERMETER
1768  #define PLEVELSCALE 50 // step size you can use to set alarm
1769  #define PLEVELDIVSOFT 100000
1770  #define PLEVELDIV 36000
1771 #endif
1772 
1773 #if defined PILOTLAMP
1774  #define PL_CHANNEL OCR0B //use B since A can be used by camstab
1775  #define PL_ISR TIMER0_COMPB_vect
1776  #define PL_INIT TCCR0A=0;TIMSK0|=(1<<OCIE0B);PL_CHANNEL=PL_IDLE;PilotLamp(PL_GRN_OFF);PilotLamp(PL_BLU_OFF);PilotLamp(PL_RED_OFF);PilotLamp(PL_BZR_OFF);
1777  #define BUZZERPIN_ON PilotLamp(PL_BZR_ON);
1778  #define BUZZERPIN_OFF PilotLamp(PL_BZR_OFF);
1779  #define PL_GRN_ON 25 // 100us
1780  #define PL_GRN_OFF 50 // 200us
1781  #define PL_BLU_ON 75 // 300us
1782  #define PL_BLU_OFF 100 // 400us
1783  #define PL_RED_ON 125 // 500us
1784  #define PL_RED_OFF 150 // 600us
1785  #define PL_BZR_ON 175 // 700us
1786  #define PL_BZR_OFF 200 // 800us
1787  #define PL_IDLE 125 // 100us
1788 #endif
1789 
1790 #if defined(PILOTLAMP)
1791  #define BUZZER
1792 #endif
1793 
1794 //all new Special RX's must be added here
1795 //this is to avoid confusion :)
1796 #if !defined(SERIAL_SUM_PPM) && !defined(SPEKTRUM) && !defined(SBUS) && !defined(SUMD)
1797  #define STANDARD_RX
1798 #endif
1799 
1800 #if defined(SPEKTRUM) || defined(SBUS) || defined(SUMD)
1801  #define SERIAL_RX
1802 #endif
1803 
1804 // Spektrum Satellite
1805 #define BIND_CAPABLE 0 //Used for Spektrum today; can be used in the future for any RX type that needs a bind and has a MultiWii module.
1806 #if defined(SPEKTRUM) || defined(SPEK_BIND_NANO)
1807  #define SPEK_FRAME_SIZE 16
1808  #if (SPEKTRUM == 1024)
1809  #define SPEK_CHAN_SHIFT 2 // Assumes 10 bit frames, that is 1024 mode.
1810  #define SPEK_CHAN_MASK 0x03 // Assumes 10 bit frames, that is 1024 mode.
1811  #define SPEK_DATA_SHIFT // Assumes 10 bit frames, that is 1024 mode.
1812  #define SPEK_BIND_PULSES 3
1813  #endif
1814  #if (SPEKTRUM == 2048)
1815  #define SPEK_CHAN_SHIFT 3 // Assumes 11 bit frames, that is 2048 mode.
1816  #define SPEK_CHAN_MASK 0x07 // Assumes 11 bit frames, that is 2048 mode.
1817  #define SPEK_DATA_SHIFT >> 1 // Assumes 11 bit frames, that is 2048 mode.
1818  #define SPEK_BIND_PULSES 5
1819  #endif
1820  #if defined(SPEK_BIND)
1821  #define BIND_CAPABLE 1
1822  /*#if !defined(SPEK_BIND_GROUND)
1823  #define SPEK_BIND_GROUND 4
1824  #endif */
1825  #if !defined(SPEK_BIND_POWER)
1826  #define SPEK_BIND_POWER 5
1827  #endif
1828  #if !defined(SPEK_BIND_DATA)
1829  #define SPEK_BIND_DATA 6
1830  #endif
1831  #endif
1832 #endif
1833 
1834 #if defined(SBUS)
1835  #define RC_CHANS 18
1836 #elif defined(SPEKTRUM) || defined(SERIAL_SUM_PPM)
1837  #define RC_CHANS 12
1838 #else
1839  #define RC_CHANS 8
1840 #endif
1841 
1842 #if !(defined(DISPLAY_2LINES)) && !(defined(DISPLAY_MULTILINE))
1843  #if (defined(LCD_VT100)) || (defined(OLED_I2C_128x64) || defined(OLED_DIGOLE) )
1844  #define DISPLAY_MULTILINE
1845  #else
1846  #define DISPLAY_2LINES
1847  #endif
1848 #endif
1849 
1850 #if (defined(LCD_VT100))
1851  #if !(defined(MULTILINE_PRE))
1852  #define MULTILINE_PRE 6
1853  #endif
1854  #if !(defined(MULTILINE_POST))
1855  #define MULTILINE_POST 9
1856  #endif
1857  #if !(defined(DISPLAY_COLUMNS))
1858  #define DISPLAY_COLUMNS 40
1859  #endif
1860 #elif (defined(OLED_I2C_128x64) && defined(DISPLAY_FONT_DSIZE))
1861  #if !(defined(MULTILINE_PRE))
1862  #define MULTILINE_PRE 1
1863  #endif
1864  #if !(defined(MULTILINE_POST))
1865  #define MULTILINE_POST 3
1866  #endif
1867  #if !(defined(DISPLAY_COLUMNS))
1868  #define DISPLAY_COLUMNS 21
1869  #endif
1870 #elif (defined(OLED_I2C_128x64))
1871  #if !(defined(MULTILINE_PRE))
1872  #define MULTILINE_PRE 3
1873  #endif
1874  #if !(defined(MULTILINE_POST))
1875  #define MULTILINE_POST 5
1876  #endif
1877  #if !(defined(DISPLAY_COLUMNS))
1878  #define DISPLAY_COLUMNS 21
1879  #endif
1880 #elif (defined(OLED_DIGOLE) && defined(DISPLAY_FONT_DSIZE))
1881  #if !(defined(MULTILINE_PRE))
1882  #define MULTILINE_PRE 2
1883  #endif
1884  #if !(defined(MULTILINE_POST))
1885  #define MULTILINE_POST 3
1886  #endif
1887 #elif (defined(OLED_DIGOLE))
1888  #if !(defined(MULTILINE_PRE))
1889  #define MULTILINE_PRE 3
1890  #endif
1891  #if !(defined(MULTILINE_POST))
1892  #define MULTILINE_POST 4
1893  #endif
1894  #if !(defined(DISPLAY_COLUMNS))
1895  #define DISPLAY_COLUMNS 21
1896  #endif
1897 #endif
1898 
1899 #if !(defined(DISPLAY_COLUMNS))
1900  #define DISPLAY_COLUMNS 16
1901 #endif
1902 
1903 
1904 /**************************************************************************************/
1905 /*************** override defaults ********************/
1906 /**************************************************************************************/
1907 
1908  /*************** pin assignments ? ********************/
1909  #ifdef OVERRIDE_V_BATPIN
1910  #undef V_BATPIN
1911  #define V_BATPIN OVERRIDE_V_BATPIN
1912  #endif
1913  #ifdef OVERRIDE_PSENSORPIN
1914  #undef PSENSORPIN
1915  #define PSENSORPIN OVERRIDE_PSENSORPIN
1916  #endif
1917  #ifdef OVERRIDE_LEDPIN_PINMODE
1918  #undef LEDPIN_PINMODE
1919  #undef LEDPIN_TOGGLE
1920  #undef LEDPIN_OFF
1921  #undef LEDPIN_ON
1922  #define LEDPIN_PINMODE OVERRIDE_LEDPIN_PINMODE
1923  #define LEDPIN_TOGGLE OVERRIDE_LEDPIN_TOGGLE
1924  #define LEDPIN_OFF OVERRIDE_LEDPIN_OFF
1925  #define LEDPIN_ON OVERRIDE_LEDPIN_ON
1926  #endif
1927  #ifdef OVERRIDE_BUZZERPIN_PINMODE
1928  #undef BUZZERPIN_PINMODE
1929  #undef BUZZERPIN_ON
1930  #undef BUZZERPIN_OFF
1931  #define BUZZERPIN_PINMODE OVERRIDE_BUZZERPIN_PINMODE
1932  #define BUZZERPIN_ON OVERRIDE_BUZZERPIN_ON
1933  #define BUZZERPIN_OFF OVERRIDE_BUZZERPIN_OFF
1934  #endif
1935 
1936  /********* sensors orientation - possibly overriding board defaults *****/
1937  #ifdef FORCE_GYRO_ORIENTATION
1938  #undef GYRO_ORIENTATION
1939  #define GYRO_ORIENTATION FORCE_GYRO_ORIENTATION
1940  #endif
1941  #ifdef FORCE_ACC_ORIENTATION
1942  #undef ACC_ORIENTATION
1943  #define ACC_ORIENTATION FORCE_ACC_ORIENTATION
1944  #endif
1945  #ifdef FORCE_MAG_ORIENTATION
1946  #undef MAG_ORIENTATION
1947  #define MAG_ORIENTATION FORCE_MAG_ORIENTATION
1948  #endif
1949 
1950  /********* servo rates *****/
1951  #ifdef FORCE_SERVO_RATES
1952  #undef SERVO_RATES
1953  #define SERVO_RATES FORCE_SERVO_RATES
1954  #endif
1955 /**************************************************************************************/
1956 /*************** Error Checking Section ********************/
1957 /**************************************************************************************/
1958 
1959 #ifndef NUMBER_MOTOR
1960  #error "NUMBER_MOTOR is not set, most likely you have not defined any type of multicopter"
1961 #endif
1962 
1963 #if (defined(LCD_DUMMY) || defined(LCD_SERIAL3W) || defined(LCD_TEXTSTAR) || defined(LCD_VT100) || defined(LCD_TTY) || defined(LCD_ETPP) || defined(LCD_LCD03) || defined(LCD_LCD03S) || defined(OLED_I2C_128x64) ) || defined(OLED_DIGOLE)
1964  #define HAS_LCD
1965 #endif
1966 
1967 #if (defined(LCD_CONF) || defined(LCD_TELEMETRY)) && !(defined(HAS_LCD) )
1968  #error "LCD_CONF or LCD_TELEMETRY defined, and choice of LCD not defined. Uncomment one of LCD_SERIAL3W, LCD_TEXTSTAR, LCD_VT100, LCD_TTY or LCD_ETPP, LCD_LCD03, LCD_LCD03S, OLED_I2C_128x64, OLED_DIGOLE"
1969 #endif
1970 
1971 #if defined(POWERMETER_SOFT) && !(defined(VBAT))
1972  #error "to use powermeter, you must also define and configure VBAT"
1973 #endif
1974 
1975 #if defined(WATTS) && !(defined(POWERMETER_HARD)) && !(defined(VBAT))
1976  #error "to compute WATTS, you must also define and configure both POWERMETER_HARD and VBAT"
1977 #endif
1978 
1979 #if defined(LCD_TELEMETRY_AUTO) && !(defined(LCD_TELEMETRY))
1980  #error "to use automatic telemetry, you MUST also define and configure LCD_TELEMETRY"
1981 #endif
1982 
1983 #if defined(LCD_TELEMETRY_STEP) && !(defined(LCD_TELEMETRY))
1984  #error "to use single step telemetry, you MUST also define and configure LCD_TELEMETRY"
1985 #endif
1986 
1987 #if defined(A32U4_4_HW_PWM_SERVOS) && !(defined(HELI_120_CCPM))
1988  #error "for your protection: A32U4_4_HW_PWM_SERVOS was not tested with your coptertype"
1989 #endif
1990 
1991 #if GPS && !defined(NMEA) && !defined(UBLOX) && !defined(MTK_BINARY16) && !defined(MTK_BINARY19) && !defined(INIT_MTK_GPS) && !defined(I2C_GPS)
1992  #error "when using GPS you must specify the protocol NMEA, UBLOX..."
1993 #endif
1994 
1995 #if defined(NUNCHUK) || \
1996  defined( MPU6050_LPF_256HZ) || defined(MPU6050_LPF_188HZ) || defined( MPU6050_LPF_98HZ) || defined( MPU6050_LPF_42HZ) || \
1997  defined( MPU6050_LPF_20HZ) || defined( MPU6050_LPF_10HZ) || defined( MPU6050_LPF_5HZ) || \
1998  defined( ITG3200_LPF_256HZ) || defined( ITG3200_LPF_188HZ) || defined( ITG3200_LPF_98HZ) || defined( ITG3200_LPF_42HZ) || \
1999  defined( ITG3200_LPF_20HZ) || defined( ITG3200_LPF_10HZ)
2000  #error "you use one feature that is no longer supported or has undergone a name change"
2001 #endif
2002 
2003 #endif /* DEF_H_ */