A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.
mbed/BusIn.h@0:60d829a0353a, 2015-04-11 (annotated)
- Committer:
- tushki7
- Date:
- Sat Apr 11 04:08:13 2015 +0000
- Revision:
- 0:60d829a0353a
A simple 128x32 LCD program to quickstart with LCD on ARM mbed IoT Starter kit. Mbed Application Shield is required if using FRDM-K64F platform.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tushki7 | 0:60d829a0353a | 1 | /* mbed Microcontroller Library |
tushki7 | 0:60d829a0353a | 2 | * Copyright (c) 2006-2013 ARM Limited |
tushki7 | 0:60d829a0353a | 3 | * |
tushki7 | 0:60d829a0353a | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
tushki7 | 0:60d829a0353a | 5 | * you may not use this file except in compliance with the License. |
tushki7 | 0:60d829a0353a | 6 | * You may obtain a copy of the License at |
tushki7 | 0:60d829a0353a | 7 | * |
tushki7 | 0:60d829a0353a | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
tushki7 | 0:60d829a0353a | 9 | * |
tushki7 | 0:60d829a0353a | 10 | * Unless required by applicable law or agreed to in writing, software |
tushki7 | 0:60d829a0353a | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
tushki7 | 0:60d829a0353a | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
tushki7 | 0:60d829a0353a | 13 | * See the License for the specific language governing permissions and |
tushki7 | 0:60d829a0353a | 14 | * limitations under the License. |
tushki7 | 0:60d829a0353a | 15 | */ |
tushki7 | 0:60d829a0353a | 16 | #ifndef MBED_BUSIN_H |
tushki7 | 0:60d829a0353a | 17 | #define MBED_BUSIN_H |
tushki7 | 0:60d829a0353a | 18 | |
tushki7 | 0:60d829a0353a | 19 | #include "platform.h" |
tushki7 | 0:60d829a0353a | 20 | #include "DigitalIn.h" |
tushki7 | 0:60d829a0353a | 21 | |
tushki7 | 0:60d829a0353a | 22 | namespace mbed { |
tushki7 | 0:60d829a0353a | 23 | |
tushki7 | 0:60d829a0353a | 24 | /** A digital input bus, used for reading the state of a collection of pins |
tushki7 | 0:60d829a0353a | 25 | */ |
tushki7 | 0:60d829a0353a | 26 | class BusIn { |
tushki7 | 0:60d829a0353a | 27 | |
tushki7 | 0:60d829a0353a | 28 | public: |
tushki7 | 0:60d829a0353a | 29 | /* Group: Configuration Methods */ |
tushki7 | 0:60d829a0353a | 30 | |
tushki7 | 0:60d829a0353a | 31 | /** Create an BusIn, connected to the specified pins |
tushki7 | 0:60d829a0353a | 32 | * |
tushki7 | 0:60d829a0353a | 33 | * @param <n> DigitalIn pin to connect to bus bit <n> (p5-p30, NC) |
tushki7 | 0:60d829a0353a | 34 | * |
tushki7 | 0:60d829a0353a | 35 | * @note |
tushki7 | 0:60d829a0353a | 36 | * It is only required to specify as many pin variables as is required |
tushki7 | 0:60d829a0353a | 37 | * for the bus; the rest will default to NC (not connected) |
tushki7 | 0:60d829a0353a | 38 | */ |
tushki7 | 0:60d829a0353a | 39 | BusIn(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC, |
tushki7 | 0:60d829a0353a | 40 | PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC, |
tushki7 | 0:60d829a0353a | 41 | PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC, |
tushki7 | 0:60d829a0353a | 42 | PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC); |
tushki7 | 0:60d829a0353a | 43 | |
tushki7 | 0:60d829a0353a | 44 | BusIn(PinName pins[16]); |
tushki7 | 0:60d829a0353a | 45 | |
tushki7 | 0:60d829a0353a | 46 | virtual ~BusIn(); |
tushki7 | 0:60d829a0353a | 47 | |
tushki7 | 0:60d829a0353a | 48 | /** Read the value of the input bus |
tushki7 | 0:60d829a0353a | 49 | * |
tushki7 | 0:60d829a0353a | 50 | * @returns |
tushki7 | 0:60d829a0353a | 51 | * An integer with each bit corresponding to the value read from the associated DigitalIn pin |
tushki7 | 0:60d829a0353a | 52 | */ |
tushki7 | 0:60d829a0353a | 53 | int read(); |
tushki7 | 0:60d829a0353a | 54 | |
tushki7 | 0:60d829a0353a | 55 | /** Set the input pin mode |
tushki7 | 0:60d829a0353a | 56 | * |
tushki7 | 0:60d829a0353a | 57 | * @param mode PullUp, PullDown, PullNone |
tushki7 | 0:60d829a0353a | 58 | */ |
tushki7 | 0:60d829a0353a | 59 | void mode(PinMode pull); |
tushki7 | 0:60d829a0353a | 60 | |
tushki7 | 0:60d829a0353a | 61 | /** Binary mask of bus pins connected to actual pins (not NC pins) |
tushki7 | 0:60d829a0353a | 62 | * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1 |
tushki7 | 0:60d829a0353a | 63 | * |
tushki7 | 0:60d829a0353a | 64 | * @returns |
tushki7 | 0:60d829a0353a | 65 | * Binary mask of connected pins |
tushki7 | 0:60d829a0353a | 66 | */ |
tushki7 | 0:60d829a0353a | 67 | int mask() { |
tushki7 | 0:60d829a0353a | 68 | return _nc_mask; |
tushki7 | 0:60d829a0353a | 69 | } |
tushki7 | 0:60d829a0353a | 70 | |
tushki7 | 0:60d829a0353a | 71 | #ifdef MBED_OPERATORS |
tushki7 | 0:60d829a0353a | 72 | /** A shorthand for read() |
tushki7 | 0:60d829a0353a | 73 | */ |
tushki7 | 0:60d829a0353a | 74 | operator int(); |
tushki7 | 0:60d829a0353a | 75 | |
tushki7 | 0:60d829a0353a | 76 | /** Access to particular bit in random-iterator fashion |
tushki7 | 0:60d829a0353a | 77 | */ |
tushki7 | 0:60d829a0353a | 78 | DigitalIn & operator[] (int index); |
tushki7 | 0:60d829a0353a | 79 | #endif |
tushki7 | 0:60d829a0353a | 80 | |
tushki7 | 0:60d829a0353a | 81 | protected: |
tushki7 | 0:60d829a0353a | 82 | DigitalIn* _pin[16]; |
tushki7 | 0:60d829a0353a | 83 | |
tushki7 | 0:60d829a0353a | 84 | /** Mask of bus's NC pins |
tushki7 | 0:60d829a0353a | 85 | * If bit[n] is set to 1 - pin is connected |
tushki7 | 0:60d829a0353a | 86 | * if bit[n] is cleared - pin is not connected (NC) |
tushki7 | 0:60d829a0353a | 87 | */ |
tushki7 | 0:60d829a0353a | 88 | int _nc_mask; |
tushki7 | 0:60d829a0353a | 89 | |
tushki7 | 0:60d829a0353a | 90 | /* disallow copy constructor and assignment operators */ |
tushki7 | 0:60d829a0353a | 91 | private: |
tushki7 | 0:60d829a0353a | 92 | BusIn(const BusIn&); |
tushki7 | 0:60d829a0353a | 93 | BusIn & operator = (const BusIn&); |
tushki7 | 0:60d829a0353a | 94 | }; |
tushki7 | 0:60d829a0353a | 95 | |
tushki7 | 0:60d829a0353a | 96 | } // namespace mbed |
tushki7 | 0:60d829a0353a | 97 | |
tushki7 | 0:60d829a0353a | 98 | #endif |