Rev 1963 | Rev 1969 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1963 | Rev 1964 | ||
---|---|---|---|
Line 89... | Line 89... | ||
89 | // disable watchdog |
89 | // disable watchdog |
90 | MCUSR &= ~(1 << WDRF); |
90 | MCUSR &= ~(1 << WDRF); |
91 | WDTCSR |= (1 << WDCE) | (1 << WDE); |
91 | WDTCSR |= (1 << WDCE) | (1 << WDE); |
92 | WDTCSR = 0; |
92 | WDTCSR = 0; |
Line 93... | Line -... | ||
93 | - | ||
94 | // PPM_in[CH_THROTTLE] = 0; |
- | |
95 | // Why??? They are already initialized to 0. |
- | |
96 | // stickPitch = stickRoll = stickYaw = 0; |
- | |
97 | - | ||
98 | RED_OFF; |
- | |
99 | 93 | ||
100 | // initalize modules |
94 | // initalize modules |
101 | output_init(); |
95 | output_init(); |
102 | timer0_init(); |
96 | timer0_init(); |
103 | timer2_init(); |
97 | timer2_init(); |
Line 117... | Line 111... | ||
117 | sei(); |
111 | sei(); |
Line 118... | Line 112... | ||
118 | 112 | ||
119 | printf("\n\r==================================="); |
113 | printf("\n\r==================================="); |
120 | printf("\n\rFlightControl"); |
114 | printf("\n\rFlightControl"); |
121 | printf("\n\rHardware: Custom"); |
115 | printf("\n\rHardware: Custom"); |
122 | printf("\r\n CPU: Atmega644"); |
116 | printf("\n\r CPU: Atmega644"); |
123 | if (CPUType == ATMEGA644P) |
117 | if (CPUType == ATMEGA644P) |
124 | printf("p"); |
118 | printf("p"); |
125 | printf("\n\rSoftware: V%d.%d%c",VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH + 'a'); |
119 | printf("\n\rSoftware: V%d.%d%c",VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH + 'a'); |
Line 126... | Line 120... | ||
126 | printf("\n\r==================================="); |
120 | printf("\n\r==================================="); |
127 | 121 | ||
- | 122 | // Parameter Set handling |
|
128 | // Parameter Set handling |
123 | channelMap_readOrDefault(); |
Line 129... | Line 124... | ||
129 | channelMap_readOrDefault(); |
124 | mixerMatrix_readOrDefault(); |
130 | paramSet_readOrDefault(); |
125 | paramSet_readOrDefault(); |
131 | 126 | ||
Line 132... | Line 127... | ||
132 | // Wait for a short time (otherwise the RC channel check won't work below) |
127 | // Wait for a short time (otherwise the RC channel check won't work below) |
133 | // timer = SetDelay(500); |
128 | // timer = SetDelay(500); |
134 | // while(!CheckDelay(timer)); |
129 | // while(!CheckDelay(timer)); |
135 | 130 | ||
136 | // Instead, while away the time by flashing the 2 outputs: |
131 | // Instead, while away the time by flashing the 2 outputs: |
137 | // First J16, then J17. Makes it easier to see which is which. |
132 | // First J16, then J17. Makes it easier to see which is which. |
138 | timer = setDelay(200); |
133 | timer = setDelay(200); |
139 | OUTPUT_SET(0,1); |
134 | outputSet(0,1); |
Line 140... | Line 135... | ||
140 | GRN_OFF; |
135 | GRN_OFF; |
141 | RED_ON; |
136 | RED_ON; |
142 | while (!checkDelay(timer)) |
137 | while (!checkDelay(timer)) |
143 | ; |
138 | ; |
144 | 139 | ||
145 | timer = setDelay(200); |
140 | timer = setDelay(200); |
146 | OUTPUT_SET(0,0); |
141 | outputSet(0,0); |
Line 147... | Line 142... | ||
147 | OUTPUT_SET(1,1); |
142 | outputSet(1,1); |
148 | RED_OFF; |
143 | RED_OFF; |
149 | GRN_ON; |
144 | GRN_ON; |
150 | while (!checkDelay(timer)) |
145 | while (!checkDelay(timer)) |
- | 146 | ; |
|
Line 151... | Line 147... | ||
151 | ; |
147 | |
Line 152... | Line 148... | ||
152 | 148 | timer = setDelay(200); |
|
Line 186... | Line 182... | ||
186 | Servo_On(); |
182 | Servo_On(); |
Line 187... | Line 183... | ||
187 | 183 | ||
188 | // Init flight parameters |
184 | // Init flight parameters |
Line 189... | Line -... | ||
189 | flight_setNeutral(); |
- | |
190 | - | ||
191 | // RED_OFF; |
185 | flight_setNeutral(); |
Line 192... | Line 186... | ||
192 | 186 | ||
193 | beep(2000); |
187 | beep(2000); |
194 | 188 | ||
Line 214... | Line 208... | ||
214 | J4HIGH; |
208 | J4HIGH; |
215 | flight_control(); |
209 | flight_control(); |
216 | J4LOW; |
210 | J4LOW; |
Line 217... | Line 211... | ||
217 | 211 | ||
218 | if (!--I2CTimeout || missingMotor) { // try to reset the i2c if motor is missing or timeout |
- | |
219 | RED_ON; |
212 | if (!--I2CTimeout || missingMotor) { // try to reset the i2c if motor is missing or timeout |
220 | if (!I2CTimeout) { |
213 | if (!I2CTimeout) { |
221 | I2C_Reset(); |
214 | I2C_Reset(); |
222 | I2CTimeout = 5; |
215 | I2CTimeout = 5; |
223 | } |
- | |
224 | } else { |
- | |
225 | RED_OFF; |
216 | } |
226 | } |
217 | } |
227 | 218 | ||
228 | // Allow Serial Data Transmit if motors must not updated or motors are not running |
219 | // Allow Serial Data Transmit if motors must not updated or motors are not running |
229 | if (!runFlightControl || !(MKFlags & MKFLAG_MOTOR_RUN)) { |
220 | if (!runFlightControl || !(MKFlags & MKFLAG_MOTOR_RUN)) { |
230 | usart0_TransmitTxData(); |
221 | usart0_TransmitTxData(); |