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.
Revision 1:946468f68668, committed 2017-09-08
- Comitter:
- Komazawa_sun
- Date:
- Fri Sep 08 08:43:32 2017 +0000
- Parent:
- 0:4eb718005c1b
- Commit message:
- ???;
Changed in this revision
| ApprI2CSlave.cpp | Show annotated file Show diff for this revision Revisions of this file |
| ApprI2CSlave.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ApprI2CSlave.cpp Fri Sep 08 04:02:22 2017 +0000
+++ b/ApprI2CSlave.cpp Fri Sep 08 08:43:32 2017 +0000
@@ -6,6 +6,7 @@
_my_type = my_type_;
_slave = slave_;
_slave->address(addr_);
+ res_data = 0;
}
void ApprI2CSlave::write(uint8_t data)
@@ -22,27 +23,26 @@
int ApprI2CSlave::read()
{
char buffer[3] = {};
- int res_data = 0;
- printf("%d\r\n",_slave->receive());
if(I2CSlave::WriteAddressed == _slave->receive())
+ {
+ //printf("receive_now\r\n");
_slave->read(buffer, 3);
-
- if((alpha_a::ID)buffer[0] == _my_id)
- {
- switch((alpha_a::f_type)buffer[1])
+ if((alpha_a::ID)buffer[0] == _my_id)
{
- case alpha_a::sig:
- res_data = (signed int)buffer[2];
- break;
- case alpha_a::unsig:
- res_data = (unsigned int)buffer[2];
- break;
- };
+ switch((alpha_a::f_type)buffer[1])
+ {
+ case alpha_a::sig:
+ res_data = (signed int)buffer[2];
+ break;
+ case alpha_a::unsig:
+ res_data = (unsigned int)buffer[2];
+ break;
+ };
- return res_data;
+ }
}
- else
- {
- return res_data;
- }
+
+
+
+ return res_data;
}
\ No newline at end of file
--- a/ApprI2CSlave.h Fri Sep 08 04:02:22 2017 +0000
+++ b/ApprI2CSlave.h Fri Sep 08 08:43:32 2017 +0000
@@ -17,6 +17,7 @@
alpha_a::f_type _my_type;
I2CSlave *_slave;
int _my_addr;
+ int res_data;
};