This is my quadcopter prototype software, still in development!

Committer:
Anaesthetix
Date:
Tue Jul 23 14:01:42 2013 +0000
Revision:
1:ac68f0368a77
Parent:
0:978110f7f027
Other accelerometer added

Who changed what in which revision?

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