Library
Fork of mbed by
BusInOut.h@0:a8fa94490a0a, 2012-09-22 (annotated)
- Committer:
- gokmenascioglu
- Date:
- Sat Sep 22 10:32:07 2012 +0000
- Revision:
- 0:a8fa94490a0a
alican library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gokmenascioglu | 0:a8fa94490a0a | 1 | /* mbed Microcontroller Library - BusInOut |
gokmenascioglu | 0:a8fa94490a0a | 2 | * Copyright (c) 2009 ARM Limited. All rights reserved. |
gokmenascioglu | 0:a8fa94490a0a | 3 | */ |
gokmenascioglu | 0:a8fa94490a0a | 4 | |
gokmenascioglu | 0:a8fa94490a0a | 5 | #ifndef MBED_BUSINOUT_H |
gokmenascioglu | 0:a8fa94490a0a | 6 | #define MBED_BUSINOUT_H |
gokmenascioglu | 0:a8fa94490a0a | 7 | |
gokmenascioglu | 0:a8fa94490a0a | 8 | #include "platform.h" |
gokmenascioglu | 0:a8fa94490a0a | 9 | #include "PinNames.h" |
gokmenascioglu | 0:a8fa94490a0a | 10 | #include "PeripheralNames.h" |
gokmenascioglu | 0:a8fa94490a0a | 11 | #include "Base.h" |
gokmenascioglu | 0:a8fa94490a0a | 12 | #include "DigitalInOut.h" |
gokmenascioglu | 0:a8fa94490a0a | 13 | |
gokmenascioglu | 0:a8fa94490a0a | 14 | namespace mbed { |
gokmenascioglu | 0:a8fa94490a0a | 15 | |
gokmenascioglu | 0:a8fa94490a0a | 16 | /* Class: BusInOut |
gokmenascioglu | 0:a8fa94490a0a | 17 | * A digital input output bus, used for setting the state of a collection of pins |
gokmenascioglu | 0:a8fa94490a0a | 18 | */ |
gokmenascioglu | 0:a8fa94490a0a | 19 | class BusInOut : public Base { |
gokmenascioglu | 0:a8fa94490a0a | 20 | |
gokmenascioglu | 0:a8fa94490a0a | 21 | public: |
gokmenascioglu | 0:a8fa94490a0a | 22 | |
gokmenascioglu | 0:a8fa94490a0a | 23 | /* Group: Configuration Methods */ |
gokmenascioglu | 0:a8fa94490a0a | 24 | |
gokmenascioglu | 0:a8fa94490a0a | 25 | /* Constructor: BusInOut |
gokmenascioglu | 0:a8fa94490a0a | 26 | * Create an BusInOut, connected to the specified pins |
gokmenascioglu | 0:a8fa94490a0a | 27 | * |
gokmenascioglu | 0:a8fa94490a0a | 28 | * Variables: |
gokmenascioglu | 0:a8fa94490a0a | 29 | * p<n> - DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC) |
gokmenascioglu | 0:a8fa94490a0a | 30 | * |
gokmenascioglu | 0:a8fa94490a0a | 31 | * Note: |
gokmenascioglu | 0:a8fa94490a0a | 32 | * It is only required to specify as many pin variables as is required |
gokmenascioglu | 0:a8fa94490a0a | 33 | * for the bus; the rest will default to NC (not connected) |
gokmenascioglu | 0:a8fa94490a0a | 34 | */ |
gokmenascioglu | 0:a8fa94490a0a | 35 | BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC, |
gokmenascioglu | 0:a8fa94490a0a | 36 | PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC, |
gokmenascioglu | 0:a8fa94490a0a | 37 | PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC, |
gokmenascioglu | 0:a8fa94490a0a | 38 | PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC, |
gokmenascioglu | 0:a8fa94490a0a | 39 | const char *name = NULL); |
gokmenascioglu | 0:a8fa94490a0a | 40 | |
gokmenascioglu | 0:a8fa94490a0a | 41 | BusInOut(PinName pins[16], const char *name = NULL); |
gokmenascioglu | 0:a8fa94490a0a | 42 | |
gokmenascioglu | 0:a8fa94490a0a | 43 | virtual ~BusInOut(); |
gokmenascioglu | 0:a8fa94490a0a | 44 | |
gokmenascioglu | 0:a8fa94490a0a | 45 | /* Group: Access Methods */ |
gokmenascioglu | 0:a8fa94490a0a | 46 | |
gokmenascioglu | 0:a8fa94490a0a | 47 | /* Function: write |
gokmenascioglu | 0:a8fa94490a0a | 48 | * Write the value to the output bus |
gokmenascioglu | 0:a8fa94490a0a | 49 | * |
gokmenascioglu | 0:a8fa94490a0a | 50 | * Variables: |
gokmenascioglu | 0:a8fa94490a0a | 51 | * value - An integer specifying a bit to write for every corresponding DigitalInOut pin |
gokmenascioglu | 0:a8fa94490a0a | 52 | */ |
gokmenascioglu | 0:a8fa94490a0a | 53 | void write(int value); |
gokmenascioglu | 0:a8fa94490a0a | 54 | |
gokmenascioglu | 0:a8fa94490a0a | 55 | |
gokmenascioglu | 0:a8fa94490a0a | 56 | /* Function: read |
gokmenascioglu | 0:a8fa94490a0a | 57 | * Read the value currently output on the bus |
gokmenascioglu | 0:a8fa94490a0a | 58 | * |
gokmenascioglu | 0:a8fa94490a0a | 59 | * Variables: |
gokmenascioglu | 0:a8fa94490a0a | 60 | * returns - An integer with each bit corresponding to associated DigitalInOut pin setting |
gokmenascioglu | 0:a8fa94490a0a | 61 | */ |
gokmenascioglu | 0:a8fa94490a0a | 62 | int read(); |
gokmenascioglu | 0:a8fa94490a0a | 63 | |
gokmenascioglu | 0:a8fa94490a0a | 64 | /* Function: output |
gokmenascioglu | 0:a8fa94490a0a | 65 | * Set as an output |
gokmenascioglu | 0:a8fa94490a0a | 66 | */ |
gokmenascioglu | 0:a8fa94490a0a | 67 | void output(); |
gokmenascioglu | 0:a8fa94490a0a | 68 | |
gokmenascioglu | 0:a8fa94490a0a | 69 | /* Function: input |
gokmenascioglu | 0:a8fa94490a0a | 70 | * Set as an input |
gokmenascioglu | 0:a8fa94490a0a | 71 | */ |
gokmenascioglu | 0:a8fa94490a0a | 72 | void input(); |
gokmenascioglu | 0:a8fa94490a0a | 73 | |
gokmenascioglu | 0:a8fa94490a0a | 74 | /* Function: mode |
gokmenascioglu | 0:a8fa94490a0a | 75 | * Set the input pin mode |
gokmenascioglu | 0:a8fa94490a0a | 76 | * |
gokmenascioglu | 0:a8fa94490a0a | 77 | * Variables: |
gokmenascioglu | 0:a8fa94490a0a | 78 | * mode - PullUp, PullDown, PullNone |
gokmenascioglu | 0:a8fa94490a0a | 79 | */ |
gokmenascioglu | 0:a8fa94490a0a | 80 | void mode(PinMode pull); |
gokmenascioglu | 0:a8fa94490a0a | 81 | |
gokmenascioglu | 0:a8fa94490a0a | 82 | #ifdef MBED_OPERATORS |
gokmenascioglu | 0:a8fa94490a0a | 83 | /* Group: Access Method Shorthand */ |
gokmenascioglu | 0:a8fa94490a0a | 84 | |
gokmenascioglu | 0:a8fa94490a0a | 85 | /* Function: operator= |
gokmenascioglu | 0:a8fa94490a0a | 86 | * A shorthand for <write> |
gokmenascioglu | 0:a8fa94490a0a | 87 | */ |
gokmenascioglu | 0:a8fa94490a0a | 88 | BusInOut& operator= (int v); |
gokmenascioglu | 0:a8fa94490a0a | 89 | BusInOut& operator= (BusInOut& rhs); |
gokmenascioglu | 0:a8fa94490a0a | 90 | |
gokmenascioglu | 0:a8fa94490a0a | 91 | /* Function: operator int() |
gokmenascioglu | 0:a8fa94490a0a | 92 | * A shorthand for <read> |
gokmenascioglu | 0:a8fa94490a0a | 93 | */ |
gokmenascioglu | 0:a8fa94490a0a | 94 | operator int(); |
gokmenascioglu | 0:a8fa94490a0a | 95 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 96 | |
gokmenascioglu | 0:a8fa94490a0a | 97 | #ifdef MBED_RPC |
gokmenascioglu | 0:a8fa94490a0a | 98 | virtual const struct rpc_method *get_rpc_methods(); |
gokmenascioglu | 0:a8fa94490a0a | 99 | static struct rpc_class *get_rpc_class(); |
gokmenascioglu | 0:a8fa94490a0a | 100 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 101 | |
gokmenascioglu | 0:a8fa94490a0a | 102 | protected: |
gokmenascioglu | 0:a8fa94490a0a | 103 | |
gokmenascioglu | 0:a8fa94490a0a | 104 | DigitalInOut* _pin[16]; |
gokmenascioglu | 0:a8fa94490a0a | 105 | |
gokmenascioglu | 0:a8fa94490a0a | 106 | #ifdef MBED_RPC |
gokmenascioglu | 0:a8fa94490a0a | 107 | static void construct(const char *arguments, char *res); |
gokmenascioglu | 0:a8fa94490a0a | 108 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 109 | |
gokmenascioglu | 0:a8fa94490a0a | 110 | }; |
gokmenascioglu | 0:a8fa94490a0a | 111 | |
gokmenascioglu | 0:a8fa94490a0a | 112 | } // namespace mbed |
gokmenascioglu | 0:a8fa94490a0a | 113 | |
gokmenascioglu | 0:a8fa94490a0a | 114 | #endif |
gokmenascioglu | 0:a8fa94490a0a | 115 |