Lab 1 Program C
Fork of mbed by
Diff: DigitalOut.h
- Revision:
- 27:7110ebee3484
- Parent:
- 18:b3c9f16cbb96
- Child:
- 43:aff670d0d510
diff -r 63bcd7ba4912 -r 7110ebee3484 DigitalOut.h --- a/DigitalOut.h Fri Feb 11 10:33:02 2011 +0000 +++ b/DigitalOut.h Tue Nov 29 14:59:27 2011 +0000 @@ -1,6 +1,5 @@ /* mbed Microcontroller Library - DigitalOut - * Copyright (c) 2006-2009 ARM Limited. All rights reserved. - * sford + * Copyright (c) 2006-2011 ARM Limited. All rights reserved. */ #ifndef MBED_DIGITALOUT_H @@ -49,11 +48,24 @@ * 0 for logical 0 and 1 (or any other non-zero value) for logical 1 */ void write(int value) { + +#if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) + if(value) { _gpio->FIOSET = _mask; } else { _gpio->FIOCLR = _mask; } + +#elif defined(TARGET_LPC11U24) + + if(value) { + LPC_GPIO->SET[_index] = _mask; + } else { + LPC_GPIO->CLR[_index] = _mask; + } +#endif + } /* Function: read @@ -64,7 +76,12 @@ * 0 for logical 0 and 1 for logical 1 */ int read() { +#if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) return ((_gpio->FIOPIN & _mask) ? 1 : 0); +#elif defined(TARGET_LPC11U24) + return ((LPC_GPIO->PIN[_index] & _mask) ? 1 : 0); +#endif + } @@ -100,7 +117,13 @@ protected: PinName _pin; + +#if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) LPC_GPIO_TypeDef *_gpio; +#elif defined(TARGET_LPC11U24) + int _index; +#endif + uint32_t _mask;