Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: scrp_slave.hpp
- Revision:
- 5:a7894e6982ea
- Parent:
- 4:39ef4d91dc34
- Child:
- 7:4ad54efe2fdd
diff -r 39ef4d91dc34 -r a7894e6982ea scrp_slave.hpp
--- a/scrp_slave.hpp Fri Jul 24 14:12:15 2020 +0000
+++ b/scrp_slave.hpp Thu Nov 12 16:38:23 2020 +0000
@@ -16,9 +16,15 @@
*<obj>.addCMD(int cmd, bool (*proc)(int rx_data, int& tx_data))
*でcmdで指定したコマンドを受信したときに呼び出される
*bool型で引数が(int rx_data, int& tx_data)の関数を指定する。
+ *addrで指定されたフラッシュメモリーのアドレスに通信で使う1バイトのアドレスが保存される。
+ *addrに0から254までの値を入れて、この値そのものをidとして通信で使うこともできる。
+ *
+ *このライブラリでは、シリアル送信、受信とも割り込みを利用しています。
+ *Nucleoはシリアル通信割り込みを同時に2ポートまでしか利用できません。
+ *このライブラリでシリアルポートを2ポート開いた場合、それ以外のシリアル通信で割り込みを利用できないので注意してください。
*/
-//ScrpSlave slave(SERIAL_TX,SERIAL_RX);
-//ScrpSlave slave(PC_12,PD_2 ,PH_1 ,SERIAL_TX,SERIAL_RX,0x0807ffff);
+//ScrpSlave slave(SERIAL_TX,SERIAL_RX, 3);
+//ScrpSlave slave(PC_12,PD_2 ,PH_1 ,SERIAL_TX,SERIAL_RX,0x0807f800);
//ScrpSlave slave(PA_9 ,PA_10,PA_12,SERIAL_TX,SERIAL_RX,0x0803e000);
//ScrpSlave slave(PD_5 ,PD_6,PD_7,SERIAL_TX,SERIAL_RX,0x081ee000);
@@ -37,10 +43,11 @@
ScrpSlave(PinName TX1,PinName RX1,PinName TX2,PinName RX2,uint32_t addr);//RedePinなし、2ポート
ScrpSlave(PinName TX1,PinName RX1,PinName REDE1,PinName TX2,PinName RX2,uint32_t addr);//RedePinあり、1ポート+RedePinなし、1ポート
~ScrpSlave();
- void setTimeout(int);
void addCMD(uint8_t cmd, bool (*proc)(int rx_data,int& tx_data));
- int16_t send(uint8_t id,uint8_t cmd,int16_t tx_data);
- int16_t send2(uint8_t id,uint8_t cmd,int16_t tx_data);
+ bool send(uint8_t id,uint8_t cmd,int16_t tx_data);//返り値 成功:true 失敗:false
+ bool send2(uint8_t id,uint8_t cmd,int16_t tx_data);
+ bool isWaiting(uint8_t port);//send,send2の通信のレスポンス待ち状況確認。
+ int16_t receiveData(uint8_t port);//0か1か sendのレスポンスは0、send2のレスポンスは1を指定。データがない時は-1を返す。
private:
DigitalOut *rede_;
Serial *serial_[2];
@@ -49,15 +56,15 @@
uint8_t mode_;
uint8_t my_id_;
uint32_t address_;
- int timeout_;
bool wait_data_[2];
+ bool get_responce_[2];
bool stx_flag_[2];
bool id_ok_[2];
uint8_t tmp_data_[2][5];
uint8_t data_count_[2];
int16_t rx_data_[2];
bool (*procs_[256])(int rx_data, int& tx_data);
- int16_t sending(int,uint8_t,uint8_t,int16_t);
+ bool sending(int,uint8_t,uint8_t,int16_t);
void changeID(uint8_t);
void init(PinName,PinName);
void check(int port);