mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Tue Oct 23 09:20:18 2012 +0000
Revision:
7:73c5efe92a6c
Parent:
2:e9a661555b58
Child:
8:c14af7958ef5
Make the C++ library completely TARGET independent.; Implement "gpio_irq_api" and "port_api" to KL25Z.

Who changed what in which revision?

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