From 5d1185472b58034d288d276aa6a3d079099671c4 Mon Sep 17 00:00:00 2001 From: smckown Date: Sun, 7 Sep 2008 18:21:30 +0000 Subject: [PATCH] Add getOut() and getOutRaw() methods. get() and getRaw() work off PORTxIN. But there are times when PORTxIN and PORTx (PxOUT) may be different, such as is the case when using pull-up or pull-down resistors via PORTxREN (PxREN) available on newer msp430's. --- tos/chips/msp430/pins/HplMsp430GeneralIO.nc | 19 +++++++++++++++++++ tos/chips/msp430/pins/HplMsp430GeneralIOP.nc | 3 +++ .../msp430/pins/HplMsp430GeneralIORenP.nc | 3 +++ 3 files changed, 25 insertions(+) diff --git a/tos/chips/msp430/pins/HplMsp430GeneralIO.nc b/tos/chips/msp430/pins/HplMsp430GeneralIO.nc index 3615b3ab..f9e42e43 100644 --- a/tos/chips/msp430/pins/HplMsp430GeneralIO.nc +++ b/tos/chips/msp430/pins/HplMsp430GeneralIO.nc @@ -43,6 +43,20 @@ interface HplMsp430GeneralIO */ async command void toggle(); + /** + * Get the port OUT status that contains the pin. + * + * @return Status of the port that contains the given pin. The x'th + * pin on the port will be represented in the x'th bit. + */ + async command uint8_t getOutRaw(); + + /** + * Read pin OUT value. + * + * @return TRUE if pin is high, FALSE otherwise. + */ + async command bool getOut(); /** * Get the port status that contains the pin. * @@ -97,5 +111,10 @@ interface HplMsp430GeneralIO * Disable pullup/pulldown resistor. */ async command void disableRen(); + + /** + * Return true if pullup/pulldown resistor is enabled + */ + async command bool isRen(); } diff --git a/tos/chips/msp430/pins/HplMsp430GeneralIOP.nc b/tos/chips/msp430/pins/HplMsp430GeneralIOP.nc index 976eb519..78104ac3 100644 --- a/tos/chips/msp430/pins/HplMsp430GeneralIOP.nc +++ b/tos/chips/msp430/pins/HplMsp430GeneralIOP.nc @@ -45,6 +45,8 @@ implementation async command void IO.set() { atomic PORTx |= (0x01 << pin); } async command void IO.clr() { atomic PORTx &= ~(0x01 << pin); } async command void IO.toggle() { atomic PORTx ^= (0x01 << pin); } + async command uint8_t IO.getOutRaw() { return PORTx & (0x01 << pin); } + async command bool IO.getOut() { return IO.getOutRaw() != 0; } async command uint8_t IO.getRaw() { return PORTxIN & (0x01 << pin); } async command bool IO.get() { return (call IO.getRaw() != 0); } async command void IO.makeInput() { atomic PORTxDIR &= ~(0x01 << pin); } @@ -57,4 +59,5 @@ implementation async command bool IO.isIOFunc() { return (PORTxSEL & (0x01<