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_SERIALBASE_H
tushki7 0:60d829a0353a 17 #define MBED_SERIALBASE_H
tushki7 0:60d829a0353a 18
tushki7 0:60d829a0353a 19 #include "platform.h"
tushki7 0:60d829a0353a 20
tushki7 0:60d829a0353a 21 #if DEVICE_SERIAL
tushki7 0:60d829a0353a 22
tushki7 0:60d829a0353a 23 #include "Stream.h"
tushki7 0:60d829a0353a 24 #include "FunctionPointer.h"
tushki7 0:60d829a0353a 25 #include "serial_api.h"
tushki7 0:60d829a0353a 26
tushki7 0:60d829a0353a 27 namespace mbed {
tushki7 0:60d829a0353a 28
tushki7 0:60d829a0353a 29 /** A base class for serial port implementations
tushki7 0:60d829a0353a 30 * Can't be instantiated directly (use Serial or RawSerial)
tushki7 0:60d829a0353a 31 */
tushki7 0:60d829a0353a 32 class SerialBase {
tushki7 0:60d829a0353a 33
tushki7 0:60d829a0353a 34 public:
tushki7 0:60d829a0353a 35 /** Set the baud rate of the serial port
tushki7 0:60d829a0353a 36 *
tushki7 0:60d829a0353a 37 * @param baudrate The baudrate of the serial port (default = 9600).
tushki7 0:60d829a0353a 38 */
tushki7 0:60d829a0353a 39 void baud(int baudrate);
tushki7 0:60d829a0353a 40
tushki7 0:60d829a0353a 41 enum Parity {
tushki7 0:60d829a0353a 42 None = 0,
tushki7 0:60d829a0353a 43 Odd,
tushki7 0:60d829a0353a 44 Even,
tushki7 0:60d829a0353a 45 Forced1,
tushki7 0:60d829a0353a 46 Forced0
tushki7 0:60d829a0353a 47 };
tushki7 0:60d829a0353a 48
tushki7 0:60d829a0353a 49 enum IrqType {
tushki7 0:60d829a0353a 50 RxIrq = 0,
tushki7 0:60d829a0353a 51 TxIrq
tushki7 0:60d829a0353a 52 };
tushki7 0:60d829a0353a 53
tushki7 0:60d829a0353a 54 enum Flow {
tushki7 0:60d829a0353a 55 Disabled = 0,
tushki7 0:60d829a0353a 56 RTS,
tushki7 0:60d829a0353a 57 CTS,
tushki7 0:60d829a0353a 58 RTSCTS
tushki7 0:60d829a0353a 59 };
tushki7 0:60d829a0353a 60
tushki7 0:60d829a0353a 61 /** Set the transmission format used by the serial port
tushki7 0:60d829a0353a 62 *
tushki7 0:60d829a0353a 63 * @param bits The number of bits in a word (5-8; default = 8)
tushki7 0:60d829a0353a 64 * @param parity The parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
tushki7 0:60d829a0353a 65 * @param stop The number of stop bits (1 or 2; default = 1)
tushki7 0:60d829a0353a 66 */
tushki7 0:60d829a0353a 67 void format(int bits=8, Parity parity=SerialBase::None, int stop_bits=1);
tushki7 0:60d829a0353a 68
tushki7 0:60d829a0353a 69 /** Determine if there is a character available to read
tushki7 0:60d829a0353a 70 *
tushki7 0:60d829a0353a 71 * @returns
tushki7 0:60d829a0353a 72 * 1 if there is a character available to read,
tushki7 0:60d829a0353a 73 * 0 otherwise
tushki7 0:60d829a0353a 74 */
tushki7 0:60d829a0353a 75 int readable();
tushki7 0:60d829a0353a 76
tushki7 0:60d829a0353a 77 /** Determine if there is space available to write a character
tushki7 0:60d829a0353a 78 *
tushki7 0:60d829a0353a 79 * @returns
tushki7 0:60d829a0353a 80 * 1 if there is space to write a character,
tushki7 0:60d829a0353a 81 * 0 otherwise
tushki7 0:60d829a0353a 82 */
tushki7 0:60d829a0353a 83 int writeable();
tushki7 0:60d829a0353a 84
tushki7 0:60d829a0353a 85 /** Attach a function to call whenever a serial interrupt is generated
tushki7 0:60d829a0353a 86 *
tushki7 0:60d829a0353a 87 * @param fptr A pointer to a void function, or 0 to set as none
tushki7 0:60d829a0353a 88 * @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
tushki7 0:60d829a0353a 89 */
tushki7 0:60d829a0353a 90 void attach(void (*fptr)(void), IrqType type=RxIrq);
tushki7 0:60d829a0353a 91
tushki7 0:60d829a0353a 92 /** Attach a member function to call whenever a serial interrupt is generated
tushki7 0:60d829a0353a 93 *
tushki7 0:60d829a0353a 94 * @param tptr pointer to the object to call the member function on
tushki7 0:60d829a0353a 95 * @param mptr pointer to the member function to be called
tushki7 0:60d829a0353a 96 * @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
tushki7 0:60d829a0353a 97 */
tushki7 0:60d829a0353a 98 template<typename T>
tushki7 0:60d829a0353a 99 void attach(T* tptr, void (T::*mptr)(void), IrqType type=RxIrq) {
tushki7 0:60d829a0353a 100 if((mptr != NULL) && (tptr != NULL)) {
tushki7 0:60d829a0353a 101 _irq[type].attach(tptr, mptr);
tushki7 0:60d829a0353a 102 serial_irq_set(&_serial, (SerialIrq)type, 1);
tushki7 0:60d829a0353a 103 }
tushki7 0:60d829a0353a 104 }
tushki7 0:60d829a0353a 105
tushki7 0:60d829a0353a 106 /** Generate a break condition on the serial line
tushki7 0:60d829a0353a 107 */
tushki7 0:60d829a0353a 108 void send_break();
tushki7 0:60d829a0353a 109
tushki7 0:60d829a0353a 110 #if DEVICE_SERIAL_FC
tushki7 0:60d829a0353a 111 /** Set the flow control type on the serial port
tushki7 0:60d829a0353a 112 *
tushki7 0:60d829a0353a 113 * @param type the flow control type (Disabled, RTS, CTS, RTSCTS)
tushki7 0:60d829a0353a 114 * @param flow1 the first flow control pin (RTS for RTS or RTSCTS, CTS for CTS)
tushki7 0:60d829a0353a 115 * @param flow2 the second flow control pin (CTS for RTSCTS)
tushki7 0:60d829a0353a 116 */
tushki7 0:60d829a0353a 117 void set_flow_control(Flow type, PinName flow1=NC, PinName flow2=NC);
tushki7 0:60d829a0353a 118 #endif
tushki7 0:60d829a0353a 119
tushki7 0:60d829a0353a 120 static void _irq_handler(uint32_t id, SerialIrq irq_type);
tushki7 0:60d829a0353a 121
tushki7 0:60d829a0353a 122 protected:
tushki7 0:60d829a0353a 123 SerialBase(PinName tx, PinName rx);
tushki7 0:60d829a0353a 124 virtual ~SerialBase() {
tushki7 0:60d829a0353a 125 }
tushki7 0:60d829a0353a 126
tushki7 0:60d829a0353a 127 int _base_getc();
tushki7 0:60d829a0353a 128 int _base_putc(int c);
tushki7 0:60d829a0353a 129
tushki7 0:60d829a0353a 130 serial_t _serial;
tushki7 0:60d829a0353a 131 FunctionPointer _irq[2];
tushki7 0:60d829a0353a 132 int _baud;
tushki7 0:60d829a0353a 133 };
tushki7 0:60d829a0353a 134
tushki7 0:60d829a0353a 135 } // namespace mbed
tushki7 0:60d829a0353a 136
tushki7 0:60d829a0353a 137 #endif
tushki7 0:60d829a0353a 138
tushki7 0:60d829a0353a 139 #endif