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.

Dependencies:   C12832

Committer:
tushki7
Date:
Sun Apr 12 15:45:52 2015 +0000
Revision:
1:eb68c94a8ee5
Parent:
0:60d829a0353a
A simple 128x32 LCD program with ARM mbed IoT Starter Kit;

Who changed what in which revision?

UserRevisionLine numberNew 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_BUSINOUT_H
tushki7 0:60d829a0353a 17 #define MBED_BUSINOUT_H
tushki7 0:60d829a0353a 18
tushki7 0:60d829a0353a 19 #include "DigitalInOut.h"
tushki7 0:60d829a0353a 20
tushki7 0:60d829a0353a 21 namespace mbed {
tushki7 0:60d829a0353a 22
tushki7 0:60d829a0353a 23 /** A digital input output bus, used for setting the state of a collection of pins
tushki7 0:60d829a0353a 24 */
tushki7 0:60d829a0353a 25 class BusInOut {
tushki7 0:60d829a0353a 26
tushki7 0:60d829a0353a 27 public:
tushki7 0:60d829a0353a 28
tushki7 0:60d829a0353a 29 /** Create an BusInOut, connected to the specified pins
tushki7 0:60d829a0353a 30 *
tushki7 0:60d829a0353a 31 * @param p<n> DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
tushki7 0:60d829a0353a 32 *
tushki7 0:60d829a0353a 33 * @note
tushki7 0:60d829a0353a 34 * It is only required to specify as many pin variables as is required
tushki7 0:60d829a0353a 35 * for the bus; the rest will default to NC (not connected)
tushki7 0:60d829a0353a 36 */
tushki7 0:60d829a0353a 37 BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
tushki7 0:60d829a0353a 38 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
tushki7 0:60d829a0353a 39 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
tushki7 0:60d829a0353a 40 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
tushki7 0:60d829a0353a 41
tushki7 0:60d829a0353a 42 BusInOut(PinName pins[16]);
tushki7 0:60d829a0353a 43
tushki7 0:60d829a0353a 44 virtual ~BusInOut();
tushki7 0:60d829a0353a 45
tushki7 0:60d829a0353a 46 /* Group: Access Methods */
tushki7 0:60d829a0353a 47
tushki7 0:60d829a0353a 48 /** Write the value to the output bus
tushki7 0:60d829a0353a 49 *
tushki7 0:60d829a0353a 50 * @param value An integer specifying a bit to write for every corresponding DigitalInOut pin
tushki7 0:60d829a0353a 51 */
tushki7 0:60d829a0353a 52 void write(int value);
tushki7 0:60d829a0353a 53
tushki7 0:60d829a0353a 54 /** Read the value currently output on the bus
tushki7 0:60d829a0353a 55 *
tushki7 0:60d829a0353a 56 * @returns
tushki7 0:60d829a0353a 57 * An integer with each bit corresponding to associated DigitalInOut pin setting
tushki7 0:60d829a0353a 58 */
tushki7 0:60d829a0353a 59 int read();
tushki7 0:60d829a0353a 60
tushki7 0:60d829a0353a 61 /** Set as an output
tushki7 0:60d829a0353a 62 */
tushki7 0:60d829a0353a 63 void output();
tushki7 0:60d829a0353a 64
tushki7 0:60d829a0353a 65 /** Set as an input
tushki7 0:60d829a0353a 66 */
tushki7 0:60d829a0353a 67 void input();
tushki7 0:60d829a0353a 68
tushki7 0:60d829a0353a 69 /** Set the input pin mode
tushki7 0:60d829a0353a 70 *
tushki7 0:60d829a0353a 71 * @param mode PullUp, PullDown, PullNone
tushki7 0:60d829a0353a 72 */
tushki7 0:60d829a0353a 73 void mode(PinMode pull);
tushki7 0:60d829a0353a 74
tushki7 0:60d829a0353a 75 /** Binary mask of bus pins connected to actual pins (not NC pins)
tushki7 0:60d829a0353a 76 * 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 77 *
tushki7 0:60d829a0353a 78 * @returns
tushki7 0:60d829a0353a 79 * Binary mask of connected pins
tushki7 0:60d829a0353a 80 */
tushki7 0:60d829a0353a 81 int mask() {
tushki7 0:60d829a0353a 82 return _nc_mask;
tushki7 0:60d829a0353a 83 }
tushki7 0:60d829a0353a 84
tushki7 0:60d829a0353a 85 #ifdef MBED_OPERATORS
tushki7 0:60d829a0353a 86 /** A shorthand for write()
tushki7 0:60d829a0353a 87 */
tushki7 0:60d829a0353a 88 BusInOut& operator= (int v);
tushki7 0:60d829a0353a 89 BusInOut& operator= (BusInOut& rhs);
tushki7 0:60d829a0353a 90
tushki7 0:60d829a0353a 91 /** Access to particular bit in random-iterator fashion
tushki7 0:60d829a0353a 92 */
tushki7 0:60d829a0353a 93 DigitalInOut& operator[] (int index);
tushki7 0:60d829a0353a 94
tushki7 0:60d829a0353a 95 /** A shorthand for read()
tushki7 0:60d829a0353a 96 */
tushki7 0:60d829a0353a 97 operator int();
tushki7 0:60d829a0353a 98 #endif
tushki7 0:60d829a0353a 99
tushki7 0:60d829a0353a 100 protected:
tushki7 0:60d829a0353a 101 DigitalInOut* _pin[16];
tushki7 0:60d829a0353a 102
tushki7 0:60d829a0353a 103 /** Mask of bus's NC pins
tushki7 0:60d829a0353a 104 * If bit[n] is set to 1 - pin is connected
tushki7 0:60d829a0353a 105 * if bit[n] is cleared - pin is not connected (NC)
tushki7 0:60d829a0353a 106 */
tushki7 0:60d829a0353a 107 int _nc_mask;
tushki7 0:60d829a0353a 108
tushki7 0:60d829a0353a 109 /* disallow copy constructor and assignment operators */
tushki7 0:60d829a0353a 110 private:
tushki7 0:60d829a0353a 111 BusInOut(const BusInOut&);
tushki7 0:60d829a0353a 112 BusInOut & operator = (const BusInOut&);
tushki7 0:60d829a0353a 113 };
tushki7 0:60d829a0353a 114
tushki7 0:60d829a0353a 115 } // namespace mbed
tushki7 0:60d829a0353a 116
tushki7 0:60d829a0353a 117 #endif