着陸スロットル0追加

Dependencies:   HCSR04_2 MPU6050_2 mbed SDFileSystem3

Fork of Autoflight2018_21 by 航空研究会

Committer:
taknokolat
Date:
Mon Sep 17 10:33:13 2018 +0000
Revision:
18:f3dcb174b563
Parent:
0:17f575135219
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HARUKIDELTA 0:17f575135219 1 #ifndef MBED_SUBS_H
HARUKIDELTA 0:17f575135219 2 #define MBED_SUBS_H
HARUKIDELTA 0:17f575135219 3
HARUKIDELTA 0:17f575135219 4
HARUKIDELTA 0:17f575135219 5 #include "mbed.h"
HARUKIDELTA 0:17f575135219 6
HARUKIDELTA 0:17f575135219 7 #define SBUS_SIGNAL_OK 0x00
HARUKIDELTA 0:17f575135219 8 #define SBUS_SIGNAL_LOST 0x01
HARUKIDELTA 0:17f575135219 9 #define SBUS_SIGNAL_FAILSAFE 0x03
HARUKIDELTA 0:17f575135219 10
HARUKIDELTA 0:17f575135219 11 typedef void (*V_FUNC_V)(void);
HARUKIDELTA 0:17f575135219 12
HARUKIDELTA 0:17f575135219 13 class SBUS
HARUKIDELTA 0:17f575135219 14 {
HARUKIDELTA 0:17f575135219 15 public:
HARUKIDELTA 0:17f575135219 16 uint16_t manualpwm[8]; //pwmの数値 1000~2000で表記 main文ではこの変数を使う
HARUKIDELTA 0:17f575135219 17 uint8_t failsafe_status;
HARUKIDELTA 0:17f575135219 18 bool flg_ch_update;
HARUKIDELTA 0:17f575135219 19
HARUKIDELTA 0:17f575135219 20 //コンストラクタ
HARUKIDELTA 0:17f575135219 21 SBUS();
HARUKIDELTA 0:17f575135219 22 SBUS(PinName tx, PinName rx);
HARUKIDELTA 0:17f575135219 23 //デストラクタ
HARUKIDELTA 0:17f575135219 24 virtual ~SBUS(); //この場合virtualをつける必要はなさそうだが参考プログラムについてたため一応入れる
HARUKIDELTA 0:17f575135219 25
HARUKIDELTA 0:17f575135219 26 void initialize(void); //初期化
HARUKIDELTA 0:17f575135219 27 void startInterrupt(void); //シリアル割り込み開始
HARUKIDELTA 0:17f575135219 28 //void stopInterrupt(void);
HARUKIDELTA 0:17f575135219 29 void setLastfuncPoint(void (*func)(void)); //割り込み処理実行後に行う関数を設定 PWM出力用
HARUKIDELTA 0:17f575135219 30
HARUKIDELTA 0:17f575135219 31
HARUKIDELTA 0:17f575135219 32 private:
HARUKIDELTA 0:17f575135219 33 RawSerial *rawserial_p;
HARUKIDELTA 0:17f575135219 34 RawSerial &rawserial;
HARUKIDELTA 0:17f575135219 35
HARUKIDELTA 0:17f575135219 36 volatile uint8_t buf_sbus[25];
HARUKIDELTA 0:17f575135219 37 volatile int cnt_sbus;
HARUKIDELTA 0:17f575135219 38 uint8_t byte_in_sbus;
HARUKIDELTA 0:17f575135219 39 uint8_t bit_in_sbus;
HARUKIDELTA 0:17f575135219 40 uint8_t ch;
HARUKIDELTA 0:17f575135219 41 uint8_t bit_in_channel;
HARUKIDELTA 0:17f575135219 42 int16_t channels[18]; //元はstatic int16_t channels[18];
HARUKIDELTA 0:17f575135219 43 V_FUNC_V lastfunc;
HARUKIDELTA 0:17f575135219 44
HARUKIDELTA 0:17f575135219 45 void func_interrupt(void); //シリアル割り込みで実行する関数
HARUKIDELTA 0:17f575135219 46 int8_t catchSerial(void); //シリアルデータを取得
HARUKIDELTA 0:17f575135219 47 void unpackSerialdata(void); //シリアルデータから各チャンネルの情報を取得
HARUKIDELTA 0:17f575135219 48 void inputPwm(void); //manualpwm変数に値を入力
HARUKIDELTA 0:17f575135219 49 };
HARUKIDELTA 0:17f575135219 50
HARUKIDELTA 0:17f575135219 51
HARUKIDELTA 0:17f575135219 52 #endif