a

Dependencies:   HCSR04_2 MPU6050_2 mbed SDFileSystem3

Fork of AutoFlight2018_Control by 航空研究会

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sbus.h Source File

sbus.h

00001 #ifndef MBED_SUBS_H
00002 #define MBED_SUBS_H
00003 
00004 
00005 #include "mbed.h"
00006 
00007 #define SBUS_SIGNAL_OK          0x00
00008 #define SBUS_SIGNAL_LOST        0x01
00009 #define SBUS_SIGNAL_FAILSAFE    0x03
00010 
00011 typedef void (*V_FUNC_V)(void);
00012 
00013 class SBUS
00014 {
00015 public:
00016     uint16_t manualpwm[8];  //pwmの数値 1000~2000で表記 main文ではこの変数を使う
00017     uint8_t  failsafe_status; 
00018     bool flg_ch_update;
00019 
00020     //コンストラクタ
00021     SBUS();
00022     SBUS(PinName tx, PinName rx);
00023     //デストラクタ
00024     virtual ~SBUS();    //この場合virtualをつける必要はなさそうだが参考プログラムについてたため一応入れる
00025 
00026     void initialize(void);  //初期化
00027     void startInterrupt(void);  //シリアル割り込み開始
00028     //void stopInterrupt(void);
00029     void setLastfuncPoint(void (*func)(void));  //割り込み処理実行後に行う関数を設定 PWM出力用
00030 
00031 
00032 private:
00033     RawSerial   *rawserial_p;
00034     RawSerial &rawserial;
00035 
00036     volatile    uint8_t buf_sbus[25];
00037     volatile    int cnt_sbus;
00038     uint8_t byte_in_sbus;
00039     uint8_t bit_in_sbus;
00040     uint8_t ch;
00041     uint8_t bit_in_channel;
00042     int16_t channels[18];       //元はstatic int16_t channels[18];
00043     V_FUNC_V lastfunc;
00044 
00045     void func_interrupt(void);  //シリアル割り込みで実行する関数 
00046     int8_t catchSerial(void);   //シリアルデータを取得
00047     void unpackSerialdata(void);   //シリアルデータから各チャンネルの情報を取得
00048     void inputPwm(void);    //manualpwm変数に値を入力
00049 };
00050 
00051 
00052 #endif