Lab 1 Program C
Fork of mbed by
Diff: DigitalIn.h
- Revision:
- 18:b3c9f16cbb96
- Parent:
- 11:1c1ebd0324fa
- Child:
- 19:e6be4cd80aad
--- a/DigitalIn.h Tue Dec 01 14:24:15 2009 +0000 +++ b/DigitalIn.h Mon May 17 14:18:54 2010 +0000 @@ -53,7 +53,10 @@ * returns - An integer representing the state of the input pin, * 0 for logical 0 and 1 for logical 1 */ - int read(); + int read() { + return ((_gpio->FIOPIN & _mask) ? 1 : 0); + } + /* Function: mode * Set the input pin mode @@ -67,7 +70,10 @@ /* Function: operator int() * An operator shorthand for <read()> */ - operator int(); + operator int() { + return read(); + } + #endif #ifdef MBED_RPC @@ -77,7 +83,9 @@ protected: - PinName _pin; + PinName _pin; + LPC_GPIO_TypeDef *_gpio; + uint32_t _mask; };