diff options
author | Michael Hope <michael.hope@linaro.org> | 2010-09-29 20:45:57 +1300 |
---|---|---|
committer | Michael Hope <michael.hope@linaro.org> | 2010-09-29 20:45:57 +1300 |
commit | 6fcd4cd306dbecf56f5b0b506a3c23762d1219fa (patch) | |
tree | 467125eca5a2e6706001cad8e09bc475e58a12d9 /wirish/wirish_digital.c | |
parent | 368e4fc1662c2594b2a0908900713a2555a3ed8e (diff) | |
parent | adde11b099ff5dad176e410279d21feac39d2c7e (diff) | |
download | librambutan-6fcd4cd306dbecf56f5b0b506a3c23762d1219fa.tar.gz librambutan-6fcd4cd306dbecf56f5b0b506a3c23762d1219fa.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'wirish/wirish_digital.c')
-rw-r--r-- | wirish/wirish_digital.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/wirish/wirish_digital.c b/wirish/wirish_digital.c index c93c786..f4868da 100644 --- a/wirish/wirish_digital.c +++ b/wirish/wirish_digital.c @@ -1,4 +1,4 @@ -/* ***************************************************************************** +/****************************************************************************** * The MIT License * * Copyright (c) 2010 Perry Hung. @@ -20,10 +20,10 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * ****************************************************************************/ + *****************************************************************************/ /** - * @brief + * @brief Arduino-compatible digital I/O implementation. */ #include "wirish.h" @@ -32,8 +32,9 @@ void pinMode(uint8 pin, WiringPinMode mode) { uint8 outputMode; - if (pin >= NR_GPIO_PINS) + if (pin >= NR_GPIO_PINS) { return; + } switch(mode) { case OUTPUT: @@ -58,6 +59,9 @@ void pinMode(uint8 pin, WiringPinMode mode) { case PWM: outputMode = GPIO_MODE_AF_OUTPUT_PP; break; + case PWM_OPEN_DRAIN: + outputMode = GPIO_MODE_AF_OUTPUT_OD; + break; default: ASSERT(0); return; @@ -68,14 +72,17 @@ void pinMode(uint8 pin, WiringPinMode mode) { uint32 digitalRead(uint8 pin) { - if (pin >= NR_GPIO_PINS) + if (pin >= NR_GPIO_PINS) { return 0; + } + return gpio_read_bit(PIN_MAP[pin].port, PIN_MAP[pin].pin); } void digitalWrite(uint8 pin, uint8 val) { - if (pin >= NR_GPIO_PINS) + if (pin >= NR_GPIO_PINS) { return; + } gpio_write_bit(PIN_MAP[pin].port, PIN_MAP[pin].pin, val); } |