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
rolf.meyer@arm.com 11:1c1ebd0324fa 1 /* mbed Microcontroller Library - DigitalIn
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_BUSIN_H
simon.ford@mbed.co.uk 0:82220227f4fa 6 #define MBED_BUSIN_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 "DigitalIn.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: BusIn
simon.ford@mbed.co.uk 0:82220227f4fa 17 * A digital input bus, used for reading the state of a collection of pins
simon.ford@mbed.co.uk 0:82220227f4fa 18 */
simon.ford@mbed.co.uk 0:82220227f4fa 19 class BusIn : 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 */
simon.ford@mbed.co.uk 0:82220227f4fa 24
rolf.meyer@arm.com 11:1c1ebd0324fa 25 /* Constructor: BusIn
rolf.meyer@arm.com 11:1c1ebd0324fa 26 * Create an BusIn, 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> - DigitalIn 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)
rolf.meyer@arm.com 11:1c1ebd0324fa 34 */
rolf.meyer@arm.com 11:1c1ebd0324fa 35 BusIn(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 5:62573be585e9 40
rolf.meyer@arm.com 11:1c1ebd0324fa 41 BusIn(PinName pins[16], const char *name = NULL);
simon.ford@mbed.co.uk 0:82220227f4fa 42
simon.ford@mbed.co.uk 0:82220227f4fa 43 virtual ~BusIn();
simon.ford@mbed.co.uk 0:82220227f4fa 44
simon.ford@mbed.co.uk 0:82220227f4fa 45 /* Group: Access Methods */
simon.ford@mbed.co.uk 0:82220227f4fa 46
simon.ford@mbed.co.uk 0:82220227f4fa 47 /* Function: read
simon.ford@mbed.co.uk 0:82220227f4fa 48 * Read the value of the input bus
simon.ford@mbed.co.uk 0:82220227f4fa 49 *
simon.ford@mbed.co.uk 0:82220227f4fa 50 * Variables:
simon.ford@mbed.co.uk 0:82220227f4fa 51 * returns - An integer with each bit corresponding to the value read from the associated DigitalIn pin
simon.ford@mbed.co.uk 0:82220227f4fa 52 */
simon.ford@mbed.co.uk 0:82220227f4fa 53 int read();
rolf.meyer@arm.com 11:1c1ebd0324fa 54
rolf.meyer@arm.com 11:1c1ebd0324fa 55 #ifdef MBED_OPERATORS
rolf.meyer@arm.com 11:1c1ebd0324fa 56 /* Group: Access Method Shorthand */
simon.ford@mbed.co.uk 0:82220227f4fa 57
rolf.meyer@arm.com 11:1c1ebd0324fa 58 /* Function: operator int()
rolf.meyer@arm.com 11:1c1ebd0324fa 59 * A shorthand for <read>
rolf.meyer@arm.com 11:1c1ebd0324fa 60 */
rolf.meyer@arm.com 11:1c1ebd0324fa 61 operator int();
rolf.meyer@arm.com 11:1c1ebd0324fa 62 #endif
simon.ford@mbed.co.uk 4:5d1359a283bc 63
rolf.meyer@arm.com 11:1c1ebd0324fa 64 #ifdef MBED_RPC
simon.ford@mbed.co.uk 5:62573be585e9 65 virtual const struct rpc_method *get_rpc_methods();
simon.ford@mbed.co.uk 5:62573be585e9 66 static struct rpc_class *get_rpc_class();
rolf.meyer@arm.com 11:1c1ebd0324fa 67 #endif
simon.ford@mbed.co.uk 5:62573be585e9 68
simon.ford@mbed.co.uk 0:82220227f4fa 69 protected:
simon.ford@mbed.co.uk 0:82220227f4fa 70
rolf.meyer@arm.com 11:1c1ebd0324fa 71 DigitalIn* _pin[16];
simon.ford@mbed.co.uk 5:62573be585e9 72
rolf.meyer@arm.com 11:1c1ebd0324fa 73 #ifdef MBED_RPC
rolf.meyer@arm.com 11:1c1ebd0324fa 74 static void construct(const char *arguments, char *res);
rolf.meyer@arm.com 11:1c1ebd0324fa 75 #endif
rolf.meyer@arm.com 11:1c1ebd0324fa 76
simon.ford@mbed.co.uk 0:82220227f4fa 77 };
simon.ford@mbed.co.uk 0:82220227f4fa 78
rolf.meyer@arm.com 11:1c1ebd0324fa 79 } // namespace mbed
simon.ford@mbed.co.uk 0:82220227f4fa 80
simon.ford@mbed.co.uk 1:6b7f447ca868 81 #endif
simon.ford@mbed.co.uk 1:6b7f447ca868 82