Plese use this class with my "i2cslave" class.

Dependents:   2016_mother_3 WRS2019_master WRS2020_mecanum_node WRS2021_mecanum_driver

Files at this revision

API Documentation at this revision

Comitter:
sgrsn
Date:
Mon Aug 23 17:00:24 2021 +0000
Parent:
6:bc6d5a6e9fe1
Commit message:
Update

Changed in this revision

i2cmaster.cpp Show annotated file Show diff for this revision Revisions of this file
i2cmaster.h Show annotated file Show diff for this revision Revisions of this file
diff -r bc6d5a6e9fe1 -r 446cf4690750 i2cmaster.cpp
--- a/i2cmaster.cpp	Thu Jul 12 10:16:10 2018 +0000
+++ b/i2cmaster.cpp	Mon Aug 23 17:00:24 2021 +0000
@@ -29,19 +29,19 @@
 {
     frequency(400000);
 }
-bool i2c::writeSomeData(char addr, char reg, int32_t data ,int size)
+bool i2c::writeSomeData(char addr, char reg, int32_t data ,uint8_t size)
 {
     char tmp[size];
     for(int i = 0; i < size; i++)
     {
         tmp[i] = (data >> (i*8)) & 0xFF;
     }
-    char DATA[2] = {reg,size};
+    char DATA[2] = {reg, size};
     bool N = I2C::write(addr, DATA, 2);
     N|= I2C::write(addr, tmp, size);
     return N;
 }
-bool i2c::getSlaveRegistarData(char addr, char reg, int32_t *data ,int size)
+bool i2c::getSlaveRegistarData(char addr, char reg, int32_t *data ,uint8_t size)
 {
     char DATA[2] = {reg,size};
     bool N = I2C::write(addr,DATA,2);
diff -r bc6d5a6e9fe1 -r 446cf4690750 i2cmaster.h
--- a/i2cmaster.h	Thu Jul 12 10:16:10 2018 +0000
+++ b/i2cmaster.h	Mon Aug 23 17:00:24 2021 +0000
@@ -7,8 +7,8 @@
 {
     public:
     i2c(PinName p1,PinName p2);
-    bool writeSomeData(char addr,char reg, int32_t data ,int size);
-    bool getSlaveRegistarData(char addr, char reg, int32_t *data ,int size);
+    bool writeSomeData(char addr,char reg, int32_t data ,uint8_t size);
+    bool getSlaveRegistarData(char addr, char reg, int32_t *data ,uint8_t size);
 };
 
 #endif
\ No newline at end of file