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:
- 7:4ad54efe2fdd
- Parent:
- 5:a7894e6982ea
- Child:
- 8:82727add54ce
--- a/scrp_slave.hpp Thu Nov 12 16:44:10 2020 +0000
+++ b/scrp_slave.hpp Sun Dec 06 08:09:01 2020 +0000
@@ -22,9 +22,17 @@
*このライブラリでは、シリアル送信、受信とも割り込みを利用しています。
*Nucleoはシリアル通信割り込みを同時に2ポートまでしか利用できません。
*このライブラリでシリアルポートを2ポート開いた場合、それ以外のシリアル通信で割り込みを利用できないので注意してください。
+ *
+ *シリアルポートに外部からアクセスして通信することもできるようになりました。
+ *このライブラリでは同時に2個シリアルポートを開いていますが、それぞれport1,port2としてアクセスできます。
+ *シリアルポートを1つだけ開くときは、port1とport2は同じモノ扱いになります。
+ *printfしたいときなどは、
+ *<obj>.port1.printf("");
+ *と書くことできます。
+ *シリアルのボーレートは基本的に変更しないでください。
*/
-//ScrpSlave slave(SERIAL_TX,SERIAL_RX, 3);
-//ScrpSlave slave(PC_12,PD_2 ,PH_1 ,SERIAL_TX,SERIAL_RX,0x0807f800);
+//ScrpSlave slave(SERIAL_TX,SERIAL_RX, 3); 3がそのままidとして使われる。
+//ScrpSlave slave(PC_12,PD_2 ,PH_1 ,SERIAL_TX,SERIAL_RX,0x0807f800); フラッシュメモリーの0x0807f800番地にidが保存される。
//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);
@@ -43,6 +51,8 @@
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();
+ Serial port1;
+ Serial port2;
void addCMD(uint8_t cmd, bool (*proc)(int rx_data,int& 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);
@@ -50,8 +60,8 @@
int16_t receiveData(uint8_t port);//0か1か sendのレスポンスは0、send2のレスポンスは1を指定。データがない時は-1を返す。
private:
DigitalOut *rede_;
+ FlashIAP *flash_;
Serial *serial_[2];
- FlashIAP *flash_;
uint8_t send_data_[2][8];
uint8_t mode_;
uint8_t my_id_;
@@ -66,10 +76,10 @@
bool (*procs_[256])(int rx_data, int& tx_data);
bool sending(int,uint8_t,uint8_t,int16_t);
void changeID(uint8_t);
- void init(PinName,PinName);
+ void init();
void check(int port);
- void port1();
- void port2();
+ void receive1();
+ void receive2();
void data_send1();
void data_send2();
void prime(int);