Prof Greg Egan / Mbed 2 deprecated UAVXArm-GKE

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers outputs_y6.h Source File

outputs_y6.h

00001 // ===============================================================================================
00002 // =                              UAVXArm Quadrocopter Controller                                =
00003 // =                           Copyright (c) 2008 by Prof. Greg Egan                             =
00004 // =                 Original V3.15 Copyright (c) 2007 Ing. Wolfgang Mahringer                   =
00005 // =                           http://code.google.com/p/uavp-mods/                               =
00006 // ===============================================================================================
00007 
00008 //    This is part of UAVXArm.
00009 
00010 //    UAVXArm is free software: you can redistribute it and/or modify it under the terms of the GNU
00011 //    General Public License as published by the Free Software Foundation, either version 3 of the
00012 //    License, or (at your option) any later version.
00013 
00014 //    UAVXArm is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without
00015 //    even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 //    See the GNU General Public License for more details.
00017 
00018 //    You should have received a copy of the GNU General Public License along with this program.
00019 //    If not, see http://www.gnu.org/licenses/
00020 
00021 
00022 void OutSignals(void) {   // The PWM pulses are in two parts these being a 1mS preamble followed by a 0-1mS part.
00023     // Interrupts are enabled during the first part which uses TMR0.  TMR0 is monitored until
00024     // there is just sufficient time for one remaining interrupt latency before disabling
00025     // interrupts.  We do this because there appears to be no atomic method of detecting the
00026     // remaining time AND conditionally disabling the interupt.
00027     static int8 m;
00028     static uint8 r, s;
00029     static i16u SaveTimer0;
00030     static uint24 SaveClockmS;
00031 
00032     PWM[FrontTC] = TC(PWM[FrontTC]);
00033     PWM[LeftTC] = TC(PWM[LeftTC]);
00034     PWM[RightTC] = TC(PWM[RightTC]);
00035     PWM[FrontBC] = TC(PWM[FrontBC]);
00036     PWM[LeftBC] = TC(PWM[LeftBC]);
00037     PWM[RightBC] = TC(PWM[RightBC]);
00038 
00039 #if !( defined SIMULATE | defined TESTING )
00040 
00041     if ( !F.MotorsArmed )
00042         StopMotors();
00043     
00044     Out0.pulsewidth_us(1000 + (int16)( PWM[FrontTC] * PWMScale ) );
00045     Out1.pulsewidth_us(1000 + (int16)( PWM[RightTC] * PWMScale ) );
00046     Out2.pulsewidth_us(1000 + (int16)( PWM[LeftTC] * PWMScale ) );
00047     Out3.pulsewidth_us(1000 + (int16)( PWM[FrontBC] * PWMScale ) );
00048     
00049  xxx   #ifdef USING_PWM4AND5
00050     Out4.pulsewidth_us(1000 + (int16)( PWM[RightBC] * PWMScale ) );
00051     Out5.pulsewidth_us(1000 + (int16)( PWM[LeftBC] * PWMScale ) );
00052     #endif // USING_PWM4AND5
00053     
00054 #endif // !(SIMULATE | TESTING)
00055 
00056 } // OutSignals
00057 
00058 
00059 
00060