Lab 1 Program C
Fork of mbed by
DigitalInOut.h@11:1c1ebd0324fa, 2009-08-28 (annotated)
- Committer:
- rolf.meyer@arm.com
- Date:
- Fri Aug 28 12:10:11 2009 +0000
- Revision:
- 11:1c1ebd0324fa
- Child:
- 18:b3c9f16cbb96
A shiny new version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rolf.meyer@arm.com | 11:1c1ebd0324fa | 1 | /* mbed Microcontroller Library - DigitalInOut |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 2 | * Copyright (c) 2006-2009 ARM Limited. All rights reserved. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 3 | * sford |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 4 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 5 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 6 | #ifndef MBED_DIGITALINOUT_H |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 7 | #define MBED_DIGITALINOUT_H |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 8 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 9 | #include "platform.h" |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 10 | #include "PinNames.h" |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 11 | #include "PeripheralNames.h" |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 12 | #include "Base.h" |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 13 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 14 | namespace mbed { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 15 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 16 | /* Class: DigitalInOut |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 17 | * A digital input/output, used for setting or reading a bi-directional pin |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 18 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 19 | class DigitalInOut : public Base { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 20 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 21 | public: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 22 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 23 | /* Constructor: DigitalInOut |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 24 | * Create a DigitalInOut connected to the specified pin |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 25 | * |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 26 | * Variables: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 27 | * pin - DigitalInOut pin to connect to |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 28 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 29 | DigitalInOut(PinName pin, const char* name = NULL); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 30 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 31 | /* Function: write |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 32 | * Set the output, specified as 0 or 1 (int) |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 33 | * |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 34 | * Variables: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 35 | * value - An integer specifying the pin output value, |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 36 | * 0 for logical 0 and 1 (or any other non-zero value) for logical 1 |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 37 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 38 | void write(int value); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 39 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 40 | /* Function: read |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 41 | * Return the output setting, represented as 0 or 1 (int) |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 42 | * |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 43 | * Variables: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 44 | * returns - An integer representing the output setting of the pin if it is an output, |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 45 | * or read the input if set as an input |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 46 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 47 | int read(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 48 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 49 | /* Function: output |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 50 | * Set as an output |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 51 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 52 | void output(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 53 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 54 | /* Function: input |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 55 | * Set as an input |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 56 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 57 | void input(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 58 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 59 | /* Function: mode |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 60 | * Set the input pin mode |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 61 | * |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 62 | * Variables: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 63 | * mode - PullUp, PullDown, PullNone |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 64 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 65 | void mode(PinMode pull); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 66 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 67 | #ifdef MBED_OPERATORS |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 68 | /* Function: operator= |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 69 | * A shorthand for <write> |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 70 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 71 | DigitalInOut& operator= (int v); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 72 | DigitalInOut& operator= (DigitalInOut& rhs); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 73 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 74 | /* Function: operator int() |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 75 | * A shorthand for <read> |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 76 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 77 | operator int(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 78 | #endif |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 79 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 80 | #ifdef MBED_RPC |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 81 | virtual const struct rpc_method *get_rpc_methods(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 82 | static struct rpc_class *get_rpc_class(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 83 | #endif |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 84 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 85 | protected: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 86 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 87 | PinName _pin; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 88 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 89 | }; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 90 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 91 | } // namespace mbed |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 92 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 93 | #endif |