Ian Hua / Quadcopter-mbedRTOS
Committer:
pHysiX
Date:
Thu May 08 10:33:43 2014 +0000
Revision:
22:ef8aa9728013
Parent:
21:b642c18eccd1
Child:
27:18b6580eb0b1
Commented and tidied entire code for release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pHysiX 22:ef8aa9728013 1 /* File: setup.h
pHysiX 22:ef8aa9728013 2 * Author: Trung Tin Ian HUA
pHysiX 22:ef8aa9728013 3 * Date: May 2014
pHysiX 22:ef8aa9728013 4 * Purpose: Setup code to initialise all devices.
pHysiX 22:ef8aa9728013 5 */
pHysiX 22:ef8aa9728013 6
pHysiX 1:43f8ac7ca6d7 7 #include "mbed.h"
pHysiX 1:43f8ac7ca6d7 8 #include "MPU6050_6Axis_MotionApps20.h"
pHysiX 3:605fbcb54e75 9 #include "PID.h"
pHysiX 12:953d25061417 10 #include "MPL3115A2.h"
pHysiX 12:953d25061417 11
pHysiX 12:953d25061417 12 #ifdef ENABLE_COMPASS
pHysiX 12:953d25061417 13 #include "HMC5883L.h"
pHysiX 12:953d25061417 14 #endif
pHysiX 1:43f8ac7ca6d7 15
pHysiX 1:43f8ac7ca6d7 16 #ifndef _SETUP_H_
pHysiX 1:43f8ac7ca6d7 17 #define _SETUP_H_
pHysiX 1:43f8ac7ca6d7 18
pHysiX 22:ef8aa9728013 19 /* PID Gains: */
pHysiX 22:ef8aa9728013 20 extern float KP_PITCH_STABLE;
pHysiX 22:ef8aa9728013 21 extern float KP_ROLL_STABLE;
pHysiX 20:b193a50a2ba3 22 extern float KP_YAW_RATE;
pHysiX 20:b193a50a2ba3 23 extern float KP_PITCH_RATE;
pHysiX 20:b193a50a2ba3 24 extern float KP_ROLL_RATE;
pHysiX 21:b642c18eccd1 25 extern float PID_TI_RATE;
pHysiX 21:b642c18eccd1 26 extern float PID_TI_STABLE;
pHysiX 21:b642c18eccd1 27
pHysiX 14:267368c83b6a 28 #define ESC_FREQUENCY 200
pHysiX 2:ab967d7b4346 29 #define ESC_PERIOD_US 1000000/ESC_FREQUENCY
pHysiX 2:ab967d7b4346 30
pHysiX 22:ef8aa9728013 31 /* Sensors and devices: */
pHysiX 1:43f8ac7ca6d7 32 extern Serial BT;
pHysiX 1:43f8ac7ca6d7 33 extern DigitalOut BT_CMD;
pHysiX 1:43f8ac7ca6d7 34 extern MPU6050 imu;
pHysiX 1:43f8ac7ca6d7 35 extern uint16_t packetSize;
pHysiX 22:ef8aa9728013 36 extern MPL3115A2 altimeter;
pHysiX 22:ef8aa9728013 37 extern PwmOut ESC[4];
pHysiX 12:953d25061417 38
pHysiX 22:ef8aa9728013 39 /* PID Devices: */
pHysiX 21:b642c18eccd1 40 extern PID pitchPIDstable;
pHysiX 21:b642c18eccd1 41 extern PID rollPIDstable;
pHysiX 3:605fbcb54e75 42 extern PID yawPIDrate;
pHysiX 3:605fbcb54e75 43 extern PID pitchPIDrate;
pHysiX 3:605fbcb54e75 44 extern PID rollPIDrate;
pHysiX 1:43f8ac7ca6d7 45
pHysiX 22:ef8aa9728013 46 /* Setup routines: */
pHysiX 3:605fbcb54e75 47 bool setupALLdevices(void);
pHysiX 2:ab967d7b4346 48 bool setup_ESC(void);
pHysiX 1:43f8ac7ca6d7 49 bool setup_bt(void);
pHysiX 3:605fbcb54e75 50 bool setup_PID(void);
pHysiX 1:43f8ac7ca6d7 51 bool setup_mpu6050(void);
pHysiX 22:ef8aa9728013 52 bool setup_altimeter(void);
pHysiX 22:ef8aa9728013 53
pHysiX 12:953d25061417 54 #ifdef ENABLE_COMPASS
pHysiX 22:ef8aa9728013 55 extern HMC5883L compass;
pHysiX 12:953d25061417 56 bool setup_compass(void);
pHysiX 12:953d25061417 57 #endif
pHysiX 1:43f8ac7ca6d7 58
pHysiX 1:43f8ac7ca6d7 59 #endif