1 /* mbed Microcontroller Library - PortOut
2 * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
12 #include "PortNames.h"
16 * A multiple pin digital out
19 * > // Toggle all four LEDs
23 * > // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23
24 * > #define LED_MASK 0x00B40000
26 * > PortOut ledport(Port1, LED_MASK);
30 * > ledport = LED_MASK;
40 /* Constructor: PortOut
41 * Create an PortOut, connected to the specified port
44 * port - Port to connect to (Port0-Port5)
45 * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
47 PortOut(PortName port, int mask = 0xFFFFFFFF);
50 * Write the value to the output port
53 * value - An integer specifying a bit to write for every corresponding PortOut pin
55 void write(int value) {
56 _gpio->FIOPIN = (_gpio->FIOPIN & ~_mask) | (value & _mask);
60 * Read the value currently output on the port
63 * returns - An integer with each bit corresponding to associated PortOut pin setting
66 return _gpio->FIOPIN & _mask;
69 /* Function: operator=
70 * A shorthand for <write>
72 PortOut& operator= (int value) {
77 PortOut& operator= (PortOut& rhs) {
82 /* Function: operator int()
83 * A shorthand for <read>
90 LPC_GPIO_TypeDef *_gpio;