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