Saya Matsuura / Mbed 2 deprecated drum

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
TanakaRobo
Date:
Fri Jul 24 14:12:15 2020 +0000
Parent:
3:28c77df7c0b6
Child:
5:68617f409aaf
Child:
6:a7894e6982ea
Commit message:
update serial interrupt

Changed in this revision

gy521.cpp Show annotated file Show diff for this revision Revisions of this file
gy521.hpp Show annotated file Show diff for this revision Revisions of this file
scrp_slave.cpp Show annotated file Show diff for this revision Revisions of this file
scrp_slave.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/gy521.cpp	Mon Jan 06 11:06:26 2020 +0000
+++ b/gy521.cpp	Fri Jul 24 14:12:15 2020 +0000
@@ -2,20 +2,6 @@
 
 const double GY521_LSB_MAP[4] = {131, 65.5, 32.8, 16.4};
 const unsigned int dev_id = 0x68 <<  1;
-enum GY521RegisterMap {
-  WHO_AM_I = 0x75,
-  PWR_MGMT_1 = 0x6B,
-  LPF = 0x1A,
-  FS_SEL = 0x1B,
-  AFS_SEL = 0x1C,
-  ACCEL_XOUT_H = 0x3B,
-  ACCEL_YOUT_H = 0x3D,
-  ACCEL_ZOUT_H = 0x3F,
-  //TEMPERATURE  = 0x41,
-  //GYRO_XOUT_H = 0x43,
-  //GYRO_YOUT_H = 0x45,
-  GYRO_ZOUT_H = 0x47
-};
 
 GY521::GY521(I2C &i2c,int bit,int calibration,double user_reg):i2c_(i2c),bit_(bit),calibration_(calibration){
     char check;
--- a/gy521.hpp	Mon Jan 06 11:06:26 2020 +0000
+++ b/gy521.hpp	Fri Jul 24 14:12:15 2020 +0000
@@ -15,6 +15,21 @@
 //I2C i2c(SDA,SCL);
 //GY521 gyro(i2c);
 
+enum GY521RegisterMap {
+  WHO_AM_I = 0x75,
+  PWR_MGMT_1 = 0x6B,
+  LPF = 0x1A,
+  FS_SEL = 0x1B,
+  AFS_SEL = 0x1C,
+  ACCEL_XOUT_H = 0x3B,
+  ACCEL_YOUT_H = 0x3D,
+  ACCEL_ZOUT_H = 0x3F,
+  //TEMPERATURE  = 0x41,
+  //GYRO_XOUT_H = 0x43,
+  //GYRO_YOUT_H = 0x45,
+  GYRO_ZOUT_H = 0x47
+};
+
 class GY521{
 public:
     GY521(I2C &i2c,int bit = 2,int calibration = 1000,double user_reg = 1.0);
--- a/scrp_slave.cpp	Mon Jan 06 11:06:26 2020 +0000
+++ b/scrp_slave.cpp	Fri Jul 24 14:12:15 2020 +0000
@@ -80,8 +80,7 @@
 }
 
 int16_t ScrpSlave::send2(uint8_t id,uint8_t cmd,int16_t tx_data){
-    if(mode_ < 2)return -1;
-    return sending(1,id,cmd,tx_data);
+    return ((mode_ < 2) ? -1 : sending(1,id,cmd,tx_data));
 }
 
 int16_t ScrpSlave::sending(int port,uint8_t id,uint8_t cmd,int16_t tx_data){
@@ -167,7 +166,7 @@
         }
     }else if(stx_flag_[port]){
         uint8_t get_data = serial_[port]->getc();
-        if(get_data == my_id_ || get_data == 255){
+        if(get_data == my_id_ || get_data == 255 || wait_data_[port]){
             id_ok_[port] = true;
             tmp_data_[port][0] = get_data;
             data_count_[port]++;
@@ -177,7 +176,8 @@
     }else if(serial_[port]->getc() == STX){
         stx_flag_[port] = true;
         data_count_[port] = 0;
-        id_ok_[port] = wait_data_[port];//データ返信待ち時はidチェック無し
+        id_ok_[port] = false;
+        //id_ok_[port] = wait_data_[port];//データ返信待ち時はidチェック無し
     }
     return;
 }
--- a/scrp_slave.hpp	Mon Jan 06 11:06:26 2020 +0000
+++ b/scrp_slave.hpp	Fri Jul 24 14:12:15 2020 +0000
@@ -12,6 +12,7 @@
  *example not usb port
  *L432KC : TX = PA_9 , RX = PA_10 , REDE = PA_12 , addr = 0x0803e000
  *F446RE : TX = PC_12 , RX = PD_2 , RDDE = PH_1 , addr = 0x0807ffff
+ *H743ZI : TX = PD_5 , RX = PD_6 , REDE = PD_7 , addr = 0x081ee000
  *<obj>.addCMD(int cmd, bool (*proc)(int rx_data, int& tx_data))
  *でcmdで指定したコマンドを受信したときに呼び出される
  *bool型で引数が(int rx_data, int& tx_data)の関数を指定する。
@@ -19,6 +20,7 @@
 //ScrpSlave slave(SERIAL_TX,SERIAL_RX);
 //ScrpSlave slave(PC_12,PD_2 ,PH_1 ,SERIAL_TX,SERIAL_RX,0x0807ffff);
 //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);
 
 inline int constrain(int x,int a,int b){
     return (x < a ? a : x > b ? b : x);