Dependencies:   I2CMotor I2CServo Robot XBee

Dependents:   OBROT_ALL

Committer:
inst
Date:
Fri Nov 13 08:16:11 2015 +0000
Revision:
4:13f38f93942d
Parent:
2:6c60a3006881
;

Who changed what in which revision?

UserRevisionLine numberNew 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 4:13f38f93942d 30 for ( int i = I2CDeviceID::ANGLE_MANAGER; i < Robot::getNumOfI2CDevices(); ++i ){
inst 4:13f38f93942d 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 4:13f38f93942d 37 // XBee
inst 2:6c60a3006881 38 return mI2C[ 2 ];
inst 2:6c60a3006881 39 }