svn / mbed / trunk / BusInOut.h

Revision 29, 2.6 kB (checked in by emilmont, 6 months ago)

New Libraries 11.11

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