Ian Hua / Quadcopter-mbedRTOS

RTOS-Threads/inc/Task3.h

Committer:
pHysiX
Date:
2014-05-12
Revision:
33:f88a6ee18103
Parent:
32:7a9be7761c46
Child:
36:d95e3d6f2fc4

File content as of revision 33:f88a6ee18103:

/* File:        Task3.h
 * Author:      Trung Tin Ian HUA
 * Date:        May 2014
 * Purpose:     Thread3: RC & BT Command, and Telemetry
 * Settings:    50Hz
 */ 
#include "mbed.h"
#include "rtos.h"
#include "tasks.h"

#ifndef _TASK3_H_
#define _TASKS3_H_

// ms timing: Refer to tasks.h to change frequency of Task3.
#define TASK3_PERIOD 1000/TASK3_FREQUENCY

/* Scale:
Vin = ADC * Vread * scale
Vin = (2^n-1)/3.3 * k*Vin * scale * ADJUST
*/
#define VOLTAGE_SCALE 49.60248447

//typedef enum {
enum FLIGHT_MODE {
    RATE,
    ATTITUDE
};

extern float ypr_offset[3];

extern bool box_demo;
extern bool rc_out;
extern bool gyro_out;
extern bool command_check;
extern bool adjust_check;

extern int RCCommand[5];
extern int inputYPR[3];

extern FLIGHT_MODE mode;

/* Thread3: RC & BT Command, and Telemetry */
void Task3(void const *argument);

// ========================
// === Helper functions ===
// ========================
int constrainRCCommand(int input);
int deadbandInputYPR(int input);
void uartDecoder(char input);

#endif