| 1 | /* mbed Microcontroller Library - DigitalIn |
|---|
| 2 | * Copyright (c) 2007-2009 ARM Limited. All rights reserved. |
|---|
| 3 | */ |
|---|
| 4 | |
|---|
| 5 | #ifndef MBED_BUSIN_H |
|---|
| 6 | #define MBED_BUSIN_H |
|---|
| 7 | |
|---|
| 8 | #include "platform.h" |
|---|
| 9 | #include "PinNames.h" |
|---|
| 10 | #include "PeripheralNames.h" |
|---|
| 11 | #include "Base.h" |
|---|
| 12 | #include "DigitalIn.h" |
|---|
| 13 | |
|---|
| 14 | namespace mbed { |
|---|
| 15 | |
|---|
| 16 | /* Class: BusIn |
|---|
| 17 | * A digital input bus, used for reading the state of a collection of pins |
|---|
| 18 | */ |
|---|
| 19 | class BusIn : public Base { |
|---|
| 20 | |
|---|
| 21 | public: |
|---|
| 22 | |
|---|
| 23 | /* Group: Configuration Methods */ |
|---|
| 24 | |
|---|
| 25 | /* Constructor: BusIn |
|---|
| 26 | * Create an BusIn, connected to the specified pins |
|---|
| 27 | * |
|---|
| 28 | * Variables: |
|---|
| 29 | * p<n> - DigitalIn pin to connect to bus bit <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 | BusIn(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 | BusIn(PinName pins[16], const char *name = NULL); |
|---|
| 42 | |
|---|
| 43 | virtual ~BusIn(); |
|---|
| 44 | |
|---|
| 45 | /* Group: Access Methods */ |
|---|
| 46 | |
|---|
| 47 | /* Function: read |
|---|
| 48 | * Read the value of the input bus |
|---|
| 49 | * |
|---|
| 50 | * Variables: |
|---|
| 51 | * returns - An integer with each bit corresponding to the value read from the associated DigitalIn pin |
|---|
| 52 | */ |
|---|
| 53 | int read(); |
|---|
| 54 | |
|---|
| 55 | #ifdef MBED_OPERATORS |
|---|
| 56 | /* Group: Access Method Shorthand */ |
|---|
| 57 | |
|---|
| 58 | /* Function: operator int() |
|---|
| 59 | * A shorthand for <read> |
|---|
| 60 | */ |
|---|
| 61 | operator int(); |
|---|
| 62 | #endif |
|---|
| 63 | |
|---|
| 64 | #ifdef MBED_RPC |
|---|
| 65 | virtual const struct rpc_method *get_rpc_methods(); |
|---|
| 66 | static struct rpc_class *get_rpc_class(); |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | protected: |
|---|
| 70 | |
|---|
| 71 | DigitalIn* _pin[16]; |
|---|
| 72 | |
|---|
| 73 | #ifdef MBED_RPC |
|---|
| 74 | static void construct(const char *arguments, char *res); |
|---|
| 75 | #endif |
|---|
| 76 | |
|---|
| 77 | }; |
|---|
| 78 | |
|---|
| 79 | } // namespace mbed |
|---|
| 80 | |
|---|
| 81 | #endif |
|---|
| 82 | |
|---|