FEP interrupt, response, ring buffer
Dependents: 087_myFEP_TX 087_myFEP_RX
Diff: FEP.h
- Revision:
- 2:aa9a344a42a8
- Parent:
- 1:a4103af46277
- Child:
- 3:12dcc46fb9dc
diff -r a4103af46277 -r aa9a344a42a8 FEP.h --- a/FEP.h Sat Oct 09 11:54:44 2021 +0000 +++ b/FEP.h Sat Oct 09 13:35:40 2021 +0000 @@ -1,78 +1,87 @@ +/** @FEP.h + * @brief FEP + */ #ifndef FEP_H #define FEP_H #include "mbed.h" +/** + * @class myFEP Class for communicating using FEP-01, FEP-02 + * @brief Class for communicating using FEP-01, FEP-02 + * @note Not compatible with mbed-os 6 + */ class myFEP{ public : - /** コンストラクタ - * @param tx FEPtxに繋いでるピン - * @param rx FEPrxに繋いでるピン - * @param addr 通信相手のアドレス - * @param baud 通信速度 + /** constructor + * @param tx SerialTX mbed pin to connect to FEP + * @param rx SerialRX mbed pin to connect to FEP + * @param addr Destination address + * @param baud baudrate */ myFEP(PinName tx, PinName rx, uint8_t addr_, int baud=115200); - /** 受信開始用関数 + /** Receive start function */ void StartReceive(); - /** 受信割り込み用関数 + /** Receive interrupt function */ void ReceiveBytes(); - /** メッセージ読み取り用関数 + /** Message reading function */ void CheckData(); - /** 受信メッセージ引き渡し用関数 - * @param data 格納先のデータアドレス + /** Received message substitution function + * @param data Data address of storage destination */ void GetData(uint8_t *data); - /** 通信相手FEPにデータ送信 - * @brief 引数の中のデータ全部送信 - * @param data 送信する配列 - * @return 0 送信成功 - * @return 1 データ量過多 - * @return 2 コマンドエラー - * @return 3 相手からの応答なし - * @return 4 相手が受信失敗 - * @return -1 可否不明 + /** Send data to the other party FEP + * Send all data in the @brief argument + * @param data Array to send + * @return 0 Successful transmission + * @return 1 Excessive amount of data + * @return 2 command error + * @return 3 No response from the other party + * @return 4 The other party failed to receive + * @return -1 Not sure */ uint8_t SendData(uint8_t *data); - /** 長さ指定ver - * @brief dataの配列をlength分送る - * @param data 送信する配列 - * @param length 送信する長さ - * @return 0 送信成功 - * @return 1 データ量過多 - * @return 2 コマンドエラー - * @return 3 相手からの応答なし - * @return 4 相手が受信失敗 - * @return -1 可否不明 + /** Send by specifying the length + * @brief Send 'data' of 'length' length + * @param data address of array to send + * @param length length to send + * + * @return 0 Successful transmission + * @return 1 Excessive amount of data + * @return 2 command error + * @return 3 No response from the other party + * @return 4 The other party failed to receive + * @return -1 Not sure */ uint8_t SendData(uint8_t *data, uint8_t length); - /** レスポンス取得用関数 - * @return 0 送信成功 - * @return 1 データ量過多 - * @return 2 コマンドエラー - * @return 3 相手からの応答なし - * @return 4 相手が受信失敗 - * @return -1 可否不明 + /** Response acquisition function + * @return 0 Successful transmission + * @return 1 Excessive amount of data + * @return 2 command error + * @return 3 No response from the other party + * @return 4 The other party failed to receive + * @return -1 Not sure */ uint8_t GetResponse(); private : uint8_t ctoi(char c); - uint8_t addr; //! 通信相手のアドレス - uint8_t buffer[256]; //! 受信データ格納用配列 - uint8_t retdata[256]; //! 引き渡し用データ格納用配列 - uint16_t bufindex; //! bufferの添え字用変数 - uint16_t retindex; //! retdataの添え字用変数 + uint8_t addr; //! Destination address + uint8_t buffer[256]; //! Array for storing received data + uint8_t retdata[256]; //! Data storage array for Substitution + uint16_t bufindex; //! index of buffer + uint16_t retindex; //! index of retdata } #endif \ No newline at end of file