Lab 1 Program C

Dependents:   Lab1C

Fork of mbed by -deleted-

Committer:
emilmont
Date:
Tue Nov 29 14:59:27 2011 +0000
Revision:
27:7110ebee3484
Parent:
11:1c1ebd0324fa
Child:
43:aff670d0d510
New Libraries 11.11

Who changed what in which revision?

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