mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Fri Oct 05 09:16:41 2012 +0000
Revision:
0:8024c367e29f
Child:
8:c14af7958ef5
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 - DigitalIn
emilmont 0:8024c367e29f 2 * Copyright (c) 2006-2011 ARM Limited. All rights reserved.
emilmont 0:8024c367e29f 3 */
emilmont 0:8024c367e29f 4 #ifndef MBED_DIGITALIN_H
emilmont 0:8024c367e29f 5 #define MBED_DIGITALIN_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: DigitalIn
emilmont 0:8024c367e29f 15 * A digital input, used for reading the state of a pin
emilmont 0:8024c367e29f 16 *
emilmont 0:8024c367e29f 17 * Example:
emilmont 0:8024c367e29f 18 * > // Flash an LED while a DigitalIn is true
emilmont 0:8024c367e29f 19 * >
emilmont 0:8024c367e29f 20 * > #include "mbed.h"
emilmont 0:8024c367e29f 21 * >
emilmont 0:8024c367e29f 22 * > DigitalIn enable(p5);
emilmont 0:8024c367e29f 23 * > DigitalOut led(LED1);
emilmont 0:8024c367e29f 24 * >
emilmont 0:8024c367e29f 25 * > int main() {
emilmont 0:8024c367e29f 26 * > while(1) {
emilmont 0:8024c367e29f 27 * > if(enable) {
emilmont 0:8024c367e29f 28 * > led = !led;
emilmont 0:8024c367e29f 29 * > }
emilmont 0:8024c367e29f 30 * > wait(0.25);
emilmont 0:8024c367e29f 31 * > }
emilmont 0:8024c367e29f 32 * > }
emilmont 0:8024c367e29f 33 */
emilmont 0:8024c367e29f 34 class DigitalIn : public Base {
emilmont 0:8024c367e29f 35
emilmont 0:8024c367e29f 36 public:
emilmont 0:8024c367e29f 37
emilmont 0:8024c367e29f 38 /* Constructor: DigitalIn
emilmont 0:8024c367e29f 39 * Create a DigitalIn connected to the specified pin
emilmont 0:8024c367e29f 40 *
emilmont 0:8024c367e29f 41 * Variables:
emilmont 0:8024c367e29f 42 * pin - DigitalIn pin to connect to
emilmont 0:8024c367e29f 43 * name - (optional) A string to identify the object
emilmont 0:8024c367e29f 44 */
emilmont 0:8024c367e29f 45 DigitalIn(PinName pin, const char *name = NULL);
emilmont 0:8024c367e29f 46
emilmont 0:8024c367e29f 47 /* Function: read
emilmont 0:8024c367e29f 48 * Read the input, represented as 0 or 1 (int)
emilmont 0:8024c367e29f 49 *
emilmont 0:8024c367e29f 50 * Variables:
emilmont 0:8024c367e29f 51 * returns - An integer representing the state of the input pin,
emilmont 0:8024c367e29f 52 * 0 for logical 0 and 1 for logical 1
emilmont 0:8024c367e29f 53 */
emilmont 0:8024c367e29f 54 int read();
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 int()
emilmont 0:8024c367e29f 66 * An operator shorthand for <read()>
emilmont 0:8024c367e29f 67 */
emilmont 0:8024c367e29f 68 operator int() {
emilmont 0:8024c367e29f 69 return read();
emilmont 0:8024c367e29f 70 }
emilmont 0:8024c367e29f 71
emilmont 0:8024c367e29f 72 #endif
emilmont 0:8024c367e29f 73
emilmont 0:8024c367e29f 74 #ifdef MBED_RPC
emilmont 0:8024c367e29f 75 virtual const struct rpc_method *get_rpc_methods();
emilmont 0:8024c367e29f 76 static struct rpc_class *get_rpc_class();
emilmont 0:8024c367e29f 77 #endif
emilmont 0:8024c367e29f 78
emilmont 0:8024c367e29f 79 protected:
emilmont 0:8024c367e29f 80 gpio_object gpio;
emilmont 0:8024c367e29f 81 };
emilmont 0:8024c367e29f 82
emilmont 0:8024c367e29f 83 } // namespace mbed
emilmont 0:8024c367e29f 84
emilmont 0:8024c367e29f 85 #endif
emilmont 0:8024c367e29f 86