1 /* mbed Microcontroller Library - DigitalInOut
2 * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
6 #ifndef MBED_DIGITALINOUT_H
7 #define MBED_DIGITALINOUT_H
11 #include "PeripheralNames.h"
16 /* Class: DigitalInOut
17 * A digital input/output, used for setting or reading a bi-directional pin
19 class DigitalInOut
: public Base
{
23 /* Constructor: DigitalInOut
24 * Create a DigitalInOut connected to the specified pin
27 * pin - DigitalInOut pin to connect to
29 DigitalInOut(PinName pin
, const char* name
= NULL
);
32 * Set the output, specified as 0 or 1 (int)
35 * value - An integer specifying the pin output value,
36 * 0 for logical 0 and 1 (or any other non-zero value) for logical 1
38 void write(int value
) {
40 _gpio
->FIOSET
= _mask
;
42 _gpio
->FIOCLR
= _mask
;
47 * Return the output setting, represented as 0 or 1 (int)
50 * returns - An integer representing the output setting of the pin if it is an output,
51 * or read the input if set as an input
54 return ((_gpio
->FIOPIN
& _mask
) ? 1 : 0);
69 * Set the input pin mode
72 * mode - PullUp, PullDown, PullNone, OpenDrain
74 void mode(PinMode pull
);
77 /* Function: operator=
78 * A shorthand for <write>
80 DigitalInOut
& operator= (int value
) {
85 DigitalInOut
& operator= (DigitalInOut
& rhs
) {
90 /* Function: operator int()
91 * A shorthand for <read>
99 virtual const struct rpc_method
*get_rpc_methods();
100 static struct rpc_class
*get_rpc_class();
106 LPC_GPIO_TypeDef
*_gpio
;