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: I2CMotor I2CServo Robot XBee
I2CDevice.cpp@2:6c60a3006881, 2015-10-14 (annotated)
- Committer:
- inst
- Date:
- Wed Oct 14 03:50:56 2015 +0000
- Revision:
- 2:6c60a3006881
- Parent:
- 1:01d881dc1170
- Child:
- 4:13f38f93942d
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| inst | 1:01d881dc1170 | 1 | #include "I2CDevice.h" |
| inst | 2:6c60a3006881 | 2 | #include "OBROT.h" |
| inst | 2:6c60a3006881 | 3 | #include "mbed.h" |
| inst | 2:6c60a3006881 | 4 | #include "Robot.h" |
| inst | 1:01d881dc1170 | 5 | |
| inst | 2:6c60a3006881 | 6 | I2C* I2CDevice::mI2C[] = { |
| inst | 2:6c60a3006881 | 7 | NULL, |
| inst | 2:6c60a3006881 | 8 | NULL, |
| inst | 2:6c60a3006881 | 9 | NULL |
| inst | 2:6c60a3006881 | 10 | }; |
| inst | 2:6c60a3006881 | 11 | const PinName I2CDevice::mSDA[] = { |
| inst | 2:6c60a3006881 | 12 | D14, |
| inst | 2:6c60a3006881 | 13 | D3, |
| inst | 2:6c60a3006881 | 14 | D5 |
| inst | 2:6c60a3006881 | 15 | }; |
| inst | 2:6c60a3006881 | 16 | const PinName I2CDevice::mSCL[] = { |
| inst | 2:6c60a3006881 | 17 | D15, |
| inst | 2:6c60a3006881 | 18 | D6, |
| inst | 2:6c60a3006881 | 19 | D7 |
| inst | 2:6c60a3006881 | 20 | }; |
| inst | 2:6c60a3006881 | 21 | const uint32_t I2CDevice::mNumOfI2C = 3; |
| inst | 2:6c60a3006881 | 22 | |
| inst | 2:6c60a3006881 | 23 | I2C* I2CDevice::getI2C() const{ |
| inst | 2:6c60a3006881 | 24 | for ( int i = I2CDeviceID::STEERING_MOTOR_0; i <= I2CDeviceID::STEERING_SERVO_2; ++i ){ |
| inst | 2:6c60a3006881 | 25 | // Steering |
| inst | 2:6c60a3006881 | 26 | if ( mAddress == OBROT::mI2CDeviceAddress[ i ] ){ |
| inst | 2:6c60a3006881 | 27 | return mI2C[ 0 ]; |
| inst | 2:6c60a3006881 | 28 | } |
| inst | 2:6c60a3006881 | 29 | } |
| inst | 2:6c60a3006881 | 30 | for ( int i = I2CDeviceID::ANGLE_MANAGER; i < Robot::mNumOfI2CDevice; ++i ){ |
| inst | 2:6c60a3006881 | 31 | // NOT Steering and XBee |
| inst | 2:6c60a3006881 | 32 | if ( mAddress == OBROT::mI2CDeviceAddress[ i ] ){ |
| inst | 2:6c60a3006881 | 33 | return mI2C[ 1 ]; |
| inst | 2:6c60a3006881 | 34 | } |
| inst | 2:6c60a3006881 | 35 | } |
| inst | 2:6c60a3006881 | 36 | |
| inst | 2:6c60a3006881 | 37 | return mI2C[ 2 ]; |
| inst | 2:6c60a3006881 | 38 | } |