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 - DigitalInOut
emilmont 0:8024c367e29f 2 * Copyright (c) 2006-2011 ARM Limited. All rights reserved.
emilmont 0:8024c367e29f 3 */
emilmont 0:8024c367e29f 4 #ifndef MBED_DIGITALINOUT_H
emilmont 0:8024c367e29f 5 #define MBED_DIGITALINOUT_H
emilmont 0:8024c367e29f 6
emilmont 0:8024c367e29f 7 #include "platform.h"
emilmont 0:8024c367e29f 8 #include "Base.h"
emilmont 0:8024c367e29f 9
emilmont 0:8024c367e29f 10 #include "gpio_api.h"
emilmont 0:8024c367e29f 11
emilmont 0:8024c367e29f 12 namespace mbed {
emilmont 0:8024c367e29f 13
emilmont 0:8024c367e29f 14 /* Class: DigitalInOut
emilmont 0:8024c367e29f 15 * A digital input/output, used for setting or reading a bi-directional pin
emilmont 0:8024c367e29f 16 */
emilmont 0:8024c367e29f 17 class DigitalInOut : public Base {
emilmont 0:8024c367e29f 18
emilmont 0:8024c367e29f 19 public:
emilmont 0:8024c367e29f 20 /* Constructor: DigitalInOut
emilmont 0:8024c367e29f 21 * Create a DigitalInOut connected to the specified pin
emilmont 0:8024c367e29f 22 *
emilmont 0:8024c367e29f 23 * Variables:
emilmont 0:8024c367e29f 24 * pin - DigitalInOut pin to connect to
emilmont 0:8024c367e29f 25 */
emilmont 0:8024c367e29f 26 DigitalInOut(PinName pin, const char* name = NULL);
emilmont 0:8024c367e29f 27
emilmont 0:8024c367e29f 28 /* Function: write
emilmont 0:8024c367e29f 29 * Set the output, specified as 0 or 1 (int)
emilmont 0:8024c367e29f 30 *
emilmont 0:8024c367e29f 31 * Variables:
emilmont 0:8024c367e29f 32 * value - An integer specifying the pin output value,
emilmont 0:8024c367e29f 33 * 0 for logical 0 and 1 (or any other non-zero value) for logical 1
emilmont 0:8024c367e29f 34 */
emilmont 0:8024c367e29f 35 void write(int value);
emilmont 0:8024c367e29f 36
emilmont 0:8024c367e29f 37 /* Function: read
emilmont 0:8024c367e29f 38 * Return the output setting, represented as 0 or 1 (int)
emilmont 0:8024c367e29f 39 *
emilmont 0:8024c367e29f 40 * Variables:
emilmont 0:8024c367e29f 41 * returns - An integer representing the output setting of the pin if it is an output,
emilmont 0:8024c367e29f 42 * or read the input if set as an input
emilmont 0:8024c367e29f 43 */
emilmont 0:8024c367e29f 44 int read();
emilmont 0:8024c367e29f 45
emilmont 0:8024c367e29f 46 /* Function: output
emilmont 0:8024c367e29f 47 * Set as an output
emilmont 0:8024c367e29f 48 */
emilmont 0:8024c367e29f 49 void output();
emilmont 0:8024c367e29f 50
emilmont 0:8024c367e29f 51 /* Function: input
emilmont 0:8024c367e29f 52 * Set as an input
emilmont 0:8024c367e29f 53 */
emilmont 0:8024c367e29f 54 void input();
emilmont 0:8024c367e29f 55
emilmont 0:8024c367e29f 56 /* Function: mode
emilmont 0:8024c367e29f 57 * Set the input pin mode
emilmont 0:8024c367e29f 58 *
emilmont 0:8024c367e29f 59 * Variables:
emilmont 0:8024c367e29f 60 * mode - PullUp, PullDown, PullNone, OpenDrain
emilmont 0:8024c367e29f 61 */
emilmont 0:8024c367e29f 62 void mode(PinMode pull);
emilmont 0:8024c367e29f 63
emilmont 0:8024c367e29f 64 #ifdef MBED_OPERATORS
emilmont 0:8024c367e29f 65 /* Function: operator=
emilmont 0:8024c367e29f 66 * A shorthand for <write>
emilmont 0:8024c367e29f 67 */
emilmont 0:8024c367e29f 68 DigitalInOut& operator= (int value) {
emilmont 0:8024c367e29f 69 write(value);
emilmont 0:8024c367e29f 70 return *this;
emilmont 0:8024c367e29f 71 }
emilmont 0:8024c367e29f 72
emilmont 0:8024c367e29f 73 DigitalInOut& operator= (DigitalInOut& rhs) {
emilmont 0:8024c367e29f 74 write(rhs.read());
emilmont 0:8024c367e29f 75 return *this;
emilmont 0:8024c367e29f 76 }
emilmont 0:8024c367e29f 77
emilmont 0:8024c367e29f 78 /* Function: operator int()
emilmont 0:8024c367e29f 79 * A shorthand for <read>
emilmont 0:8024c367e29f 80 */
emilmont 0:8024c367e29f 81 operator int() {
emilmont 0:8024c367e29f 82 return read();
emilmont 0:8024c367e29f 83 }
emilmont 0:8024c367e29f 84 #endif
emilmont 0:8024c367e29f 85
emilmont 0:8024c367e29f 86 #ifdef MBED_RPC
emilmont 0:8024c367e29f 87 virtual const struct rpc_method *get_rpc_methods();
emilmont 0:8024c367e29f 88 static struct rpc_class *get_rpc_class();
emilmont 0:8024c367e29f 89 #endif
emilmont 0:8024c367e29f 90
emilmont 0:8024c367e29f 91 protected:
emilmont 0:8024c367e29f 92 gpio_object gpio;
emilmont 0:8024c367e29f 93 };
emilmont 0:8024c367e29f 94
emilmont 0:8024c367e29f 95 } // namespace mbed
emilmont 0:8024c367e29f 96
emilmont 0:8024c367e29f 97 #endif