X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tos%2Fchips%2Fmsp430%2Fpins%2FHplMsp430GeneralIOP.nc;h=191d4f21b9d631f3b60fd1dc6f7699849b10d000;hb=48666eab550362c629ba4dcb7d107b9d44b9ba6c;hp=b532f812fcd8ddb33bf5a29d50d84fb7a79e1b91;hpb=1a329382c4f4556fd52d85f4e3f4a67e54911682;p=tinyos-2.x.git diff --git a/tos/chips/msp430/pins/HplMsp430GeneralIOP.nc b/tos/chips/msp430/pins/HplMsp430GeneralIOP.nc index b532f812..191d4f21 100644 --- a/tos/chips/msp430/pins/HplMsp430GeneralIOP.nc +++ b/tos/chips/msp430/pins/HplMsp430GeneralIOP.nc @@ -31,20 +31,22 @@ generic module HplMsp430GeneralIOP( uint8_t port_dir_addr, uint8_t port_sel_addr, uint8_t pin - ) + ) @safe() { provides interface HplMsp430GeneralIO as IO; } implementation { - #define PORTxIN (*(volatile TYPE_PORT_IN*)port_in_addr) - #define PORTx (*(volatile TYPE_PORT_OUT*)port_out_addr) - #define PORTxDIR (*(volatile TYPE_PORT_DIR*)port_dir_addr) - #define PORTxSEL (*(volatile TYPE_PORT_SEL*)port_sel_addr) + #define PORTxIN (*TCAST(volatile TYPE_PORT_IN* ONE, port_in_addr)) + #define PORTx (*TCAST(volatile TYPE_PORT_OUT* ONE, port_out_addr)) + #define PORTxDIR (*TCAST(volatile TYPE_PORT_DIR* ONE, port_dir_addr)) + #define PORTxSEL (*TCAST(volatile TYPE_PORT_SEL* ONE, port_sel_addr)) 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 (call 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); } @@ -55,4 +57,7 @@ implementation async command bool IO.isModuleFunc() { return (PORTxSEL & (0x01<