mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Fri Oct 05 09:16:41 2012 +0000
Revision:
0:8024c367e29f
Child:
2:e9a661555b58
First release of the mbed libraries for KL25Z

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 0:8024c367e29f 1 /* mbed Microcontroller Library - PortInOut
emilmont 0:8024c367e29f 2 * Copyright (c) 2006-2011 ARM Limited. All rights reserved.
emilmont 0:8024c367e29f 3 */
emilmont 0:8024c367e29f 4
emilmont 0:8024c367e29f 5 #ifndef MBED_PORTINOUT_H
emilmont 0:8024c367e29f 6 #define MBED_PORTINOUT_H
emilmont 0:8024c367e29f 7
emilmont 0:8024c367e29f 8 #include "device.h"
emilmont 0:8024c367e29f 9
emilmont 0:8024c367e29f 10 #if DEVICE_PORTINOUT
emilmont 0:8024c367e29f 11
emilmont 0:8024c367e29f 12 #include "PortNames.h"
emilmont 0:8024c367e29f 13 #include "PinNames.h"
emilmont 0:8024c367e29f 14
emilmont 0:8024c367e29f 15 namespace mbed {
emilmont 0:8024c367e29f 16
emilmont 0:8024c367e29f 17 /* Class: PortInOut
emilmont 0:8024c367e29f 18 * A multiple pin digital in/out used to set/read multiple bi-directional pins
emilmont 0:8024c367e29f 19 */
emilmont 0:8024c367e29f 20 class PortInOut {
emilmont 0:8024c367e29f 21 public:
emilmont 0:8024c367e29f 22
emilmont 0:8024c367e29f 23 /* Constructor: PortInOut
emilmont 0:8024c367e29f 24 * Create an PortInOut, connected to the specified port
emilmont 0:8024c367e29f 25 *
emilmont 0:8024c367e29f 26 * Variables:
emilmont 0:8024c367e29f 27 * port - Port to connect to (Port0-Port5)
emilmont 0:8024c367e29f 28 * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
emilmont 0:8024c367e29f 29 */
emilmont 0:8024c367e29f 30 PortInOut(PortName port, int mask = 0xFFFFFFFF);
emilmont 0:8024c367e29f 31
emilmont 0:8024c367e29f 32 /* Function: write
emilmont 0:8024c367e29f 33 * Write the value to the output port
emilmont 0:8024c367e29f 34 *
emilmont 0:8024c367e29f 35 * Variables:
emilmont 0:8024c367e29f 36 * value - An integer specifying a bit to write for every corresponding port pin
emilmont 0:8024c367e29f 37 */
emilmont 0:8024c367e29f 38 void write(int value);
emilmont 0:8024c367e29f 39
emilmont 0:8024c367e29f 40 /* Function: read
emilmont 0:8024c367e29f 41 * Read the value currently output on the port
emilmont 0:8024c367e29f 42 *
emilmont 0:8024c367e29f 43 * Variables:
emilmont 0:8024c367e29f 44 * returns - An integer with each bit corresponding to associated port pin setting
emilmont 0:8024c367e29f 45 */
emilmont 0:8024c367e29f 46 int read();
emilmont 0:8024c367e29f 47
emilmont 0:8024c367e29f 48 /* Function: output
emilmont 0:8024c367e29f 49 * Set as an output
emilmont 0:8024c367e29f 50 */
emilmont 0:8024c367e29f 51 void output();
emilmont 0:8024c367e29f 52
emilmont 0:8024c367e29f 53 /* Function: input
emilmont 0:8024c367e29f 54 * Set as an input
emilmont 0:8024c367e29f 55 */
emilmont 0:8024c367e29f 56 void input();
emilmont 0:8024c367e29f 57
emilmont 0:8024c367e29f 58 /* Function: mode
emilmont 0:8024c367e29f 59 * Set the input pin mode
emilmont 0:8024c367e29f 60 *
emilmont 0:8024c367e29f 61 * Variables:
emilmont 0:8024c367e29f 62 * mode - PullUp, PullDown, PullNone, OpenDrain
emilmont 0:8024c367e29f 63 */
emilmont 0:8024c367e29f 64 void mode(PinMode mode);
emilmont 0:8024c367e29f 65
emilmont 0:8024c367e29f 66 /* Function: operator=
emilmont 0:8024c367e29f 67 * A shorthand for <write>
emilmont 0:8024c367e29f 68 */
emilmont 0:8024c367e29f 69 PortInOut& operator= (int value) {
emilmont 0:8024c367e29f 70 write(value);
emilmont 0:8024c367e29f 71 return *this;
emilmont 0:8024c367e29f 72 }
emilmont 0:8024c367e29f 73
emilmont 0:8024c367e29f 74 PortInOut& operator= (PortInOut& rhs) {
emilmont 0:8024c367e29f 75 write(rhs.read());
emilmont 0:8024c367e29f 76 return *this;
emilmont 0:8024c367e29f 77 }
emilmont 0:8024c367e29f 78
emilmont 0:8024c367e29f 79 /* Function: operator int()
emilmont 0:8024c367e29f 80 * A shorthand for <read>
emilmont 0:8024c367e29f 81 */
emilmont 0:8024c367e29f 82 operator int() {
emilmont 0:8024c367e29f 83 return read();
emilmont 0:8024c367e29f 84 }
emilmont 0:8024c367e29f 85
emilmont 0:8024c367e29f 86 private:
emilmont 0:8024c367e29f 87 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
emilmont 0:8024c367e29f 88 LPC_GPIO_TypeDef *_gpio;
emilmont 0:8024c367e29f 89 #endif
emilmont 0:8024c367e29f 90 PortName _port;
emilmont 0:8024c367e29f 91 uint32_t _mask;
emilmont 0:8024c367e29f 92 };
emilmont 0:8024c367e29f 93
emilmont 0:8024c367e29f 94 } // namespace mbed
emilmont 0:8024c367e29f 95
emilmont 0:8024c367e29f 96 #endif
emilmont 0:8024c367e29f 97
emilmont 0:8024c367e29f 98 #endif