Fork of the official mbed C/C++ SDK provides the software platform and libraries to build your applications. The fork has the documentation converted to Doxygen format

Dependents:   NervousPuppySprintOne NervousPuppySprint2602 Robot WarehouseBot1 ... more

Fork of mbed by mbed official

Revision:
18:b3c9f16cbb96
Parent:
11:1c1ebd0324fa
Child:
27:7110ebee3484
--- a/DigitalOut.h	Tue Dec 01 14:24:15 2009 +0000
+++ b/DigitalOut.h	Mon May 17 14:18:54 2010 +0000
@@ -48,7 +48,13 @@
      *  value - An integer specifying the pin output value, 
      *      0 for logical 0 and 1 (or any other non-zero value) for logical 1 
      */
-    void write(int value);
+    void write(int value) {
+        if(value) {
+            _gpio->FIOSET = _mask;
+        } else {
+            _gpio->FIOCLR = _mask;
+        }
+    }
 
     /* Function: read
      *  Return the output setting, represented as 0 or 1 (int)
@@ -57,19 +63,33 @@
      *  returns - An integer representing the output setting of the pin, 
      *      0 for logical 0 and 1 for logical 1
      */
-    int read();
+    int read() {
+        return ((_gpio->FIOPIN & _mask) ? 1 : 0);
+    }
+
 
 #ifdef MBED_OPERATORS
     /* Function: operator=
      *  A shorthand for <write>
      */
-    DigitalOut& operator= (int value);
-    DigitalOut& operator= (DigitalOut& rhs);
+    DigitalOut& operator= (int value) {
+        write(value);
+        return *this;
+    }
+
+    DigitalOut& operator= (DigitalOut& rhs) {
+        write(rhs.read());
+        return *this;
+    }
+
     
     /* Function: operator int()
      *  A shorthand for <read>
      */
-    operator int();
+    operator int() {
+        return read();
+    }
+
 #endif
 
 #ifdef MBED_RPC
@@ -79,7 +99,10 @@
 
 protected:
 
-    PinName _pin;
+    PinName             _pin;
+    LPC_GPIO_TypeDef    *_gpio;
+    uint32_t            _mask;
+
 
 };