mirror of https://github.com/ARMmbed/mbed-os.git
* Changed Bus operator[]() parameter from unsigned int to int to match mbed code
guidelines. * Uncommented assertions in operators and added check for operator[] index < 0. * Moved one operator from private to public, this was a typo thing.pull/808/head
parent
32cea97577
commit
7d54c82331
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
/** Access to particular bit in random-iterator fashion
|
||||
*/
|
||||
DigitalIn & operator[] (unsigned int index);
|
||||
DigitalIn & operator[] (int index);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -90,6 +90,10 @@ public:
|
|||
BusInOut& operator= (int v);
|
||||
BusInOut& operator= (BusInOut& rhs);
|
||||
|
||||
/** Access to particular bit in random-iterator fashion
|
||||
*/
|
||||
DigitalInOut& operator[] (int index);
|
||||
|
||||
/** A shorthand for read()
|
||||
*/
|
||||
operator int();
|
||||
|
@ -108,7 +112,6 @@ protected:
|
|||
private:
|
||||
BusInOut(const BusInOut&);
|
||||
BusInOut & operator = (const BusInOut&);
|
||||
DigitalInOut& operator[] (unsigned int index);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
/** Access to particular bit in random-iterator fashion
|
||||
*/
|
||||
DigitalOut& operator[] (unsigned int index);
|
||||
DigitalOut& operator[] (int index);
|
||||
|
||||
/** A shorthand for read()
|
||||
*/
|
||||
|
|
|
@ -72,9 +72,9 @@ BusIn::operator int() {
|
|||
return read();
|
||||
}
|
||||
|
||||
DigitalIn& BusIn::operator[] (unsigned int index) {
|
||||
//MBED_ASSERT(index >= MBED_BUS_SIZE);
|
||||
//MBED_ASSERT(_pin[index]);
|
||||
DigitalIn& BusIn::operator[] (int index) {
|
||||
MBED_ASSERT(index < 0 || index >= MBED_BUS_SIZE);
|
||||
MBED_ASSERT(_pin[index]);
|
||||
if (index >= 16 || _pin[index] == NULL) {
|
||||
return din_dummy;
|
||||
}
|
||||
|
|
|
@ -102,9 +102,9 @@ BusInOut& BusInOut::operator= (BusInOut& rhs) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
DigitalInOut& BusInOut::operator[] (unsigned int index) {
|
||||
//MBED_ASSERT(index >= MBED_BUS_SIZE);
|
||||
//MBED_ASSERT(_pin[index]);
|
||||
DigitalInOut& BusInOut::operator[] (int index) {
|
||||
MBED_ASSERT(index < 0 || index >= MBED_BUS_SIZE);
|
||||
MBED_ASSERT(_pin[index]);
|
||||
if (index >= 16 || _pin[index] == NULL) {
|
||||
return dinout_dummy;
|
||||
}
|
||||
|
|
|
@ -78,9 +78,9 @@ BusOut& BusOut::operator= (BusOut& rhs) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
DigitalOut& BusOut::operator[] (unsigned int index) {
|
||||
//MBED_ASSERT(index >= MBED_BUS_SIZE);
|
||||
//MBED_ASSERT(_pin[index]);
|
||||
DigitalOut& BusOut::operator[] (int index) {
|
||||
MBED_ASSERT(index < 0 || index >= MBED_BUS_SIZE);
|
||||
MBED_ASSERT(_pin[index]);
|
||||
if (index >= 16 || _pin[index] == NULL) {
|
||||
return dout_dummy;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue