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/RawSerial.h@1:eb68c94a8ee5, 2015-04-12 (annotated)
- 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?
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_RAW_SERIAL_H |
tushki7 | 0:60d829a0353a | 17 | #define MBED_RAW_SERIAL_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 "SerialBase.h" |
tushki7 | 0:60d829a0353a | 24 | #include "serial_api.h" |
tushki7 | 0:60d829a0353a | 25 | |
tushki7 | 0:60d829a0353a | 26 | namespace mbed { |
tushki7 | 0:60d829a0353a | 27 | |
tushki7 | 0:60d829a0353a | 28 | /** A serial port (UART) for communication with other serial devices |
tushki7 | 0:60d829a0353a | 29 | * This is a variation of the Serial class that doesn't use streams, |
tushki7 | 0:60d829a0353a | 30 | * thus making it safe to use in interrupt handlers with the RTOS. |
tushki7 | 0:60d829a0353a | 31 | * |
tushki7 | 0:60d829a0353a | 32 | * Can be used for Full Duplex communication, or Simplex by specifying |
tushki7 | 0:60d829a0353a | 33 | * one pin as NC (Not Connected) |
tushki7 | 0:60d829a0353a | 34 | * |
tushki7 | 0:60d829a0353a | 35 | * Example: |
tushki7 | 0:60d829a0353a | 36 | * @code |
tushki7 | 0:60d829a0353a | 37 | * // Send a char to the PC |
tushki7 | 0:60d829a0353a | 38 | * |
tushki7 | 0:60d829a0353a | 39 | * #include "mbed.h" |
tushki7 | 0:60d829a0353a | 40 | * |
tushki7 | 0:60d829a0353a | 41 | * RawSerial pc(USBTX, USBRX); |
tushki7 | 0:60d829a0353a | 42 | * |
tushki7 | 0:60d829a0353a | 43 | * int main() { |
tushki7 | 0:60d829a0353a | 44 | * pc.putc('A'); |
tushki7 | 0:60d829a0353a | 45 | * } |
tushki7 | 0:60d829a0353a | 46 | * @endcode |
tushki7 | 0:60d829a0353a | 47 | */ |
tushki7 | 0:60d829a0353a | 48 | class RawSerial: public SerialBase { |
tushki7 | 0:60d829a0353a | 49 | |
tushki7 | 0:60d829a0353a | 50 | public: |
tushki7 | 0:60d829a0353a | 51 | /** Create a RawSerial port, connected to the specified transmit and receive pins |
tushki7 | 0:60d829a0353a | 52 | * |
tushki7 | 0:60d829a0353a | 53 | * @param tx Transmit pin |
tushki7 | 0:60d829a0353a | 54 | * @param rx Receive pin |
tushki7 | 0:60d829a0353a | 55 | * |
tushki7 | 0:60d829a0353a | 56 | * @note |
tushki7 | 0:60d829a0353a | 57 | * Either tx or rx may be specified as NC if unused |
tushki7 | 0:60d829a0353a | 58 | */ |
tushki7 | 0:60d829a0353a | 59 | RawSerial(PinName tx, PinName rx); |
tushki7 | 0:60d829a0353a | 60 | |
tushki7 | 0:60d829a0353a | 61 | /** Write a char to the serial port |
tushki7 | 0:60d829a0353a | 62 | * |
tushki7 | 0:60d829a0353a | 63 | * @param c The char to write |
tushki7 | 0:60d829a0353a | 64 | * |
tushki7 | 0:60d829a0353a | 65 | * @returns The written char or -1 if an error occured |
tushki7 | 0:60d829a0353a | 66 | */ |
tushki7 | 0:60d829a0353a | 67 | int putc(int c); |
tushki7 | 0:60d829a0353a | 68 | |
tushki7 | 0:60d829a0353a | 69 | /** Read a char from the serial port |
tushki7 | 0:60d829a0353a | 70 | * |
tushki7 | 0:60d829a0353a | 71 | * @returns The char read from the serial port |
tushki7 | 0:60d829a0353a | 72 | */ |
tushki7 | 0:60d829a0353a | 73 | int getc(); |
tushki7 | 0:60d829a0353a | 74 | |
tushki7 | 0:60d829a0353a | 75 | /** Write a string to the serial port |
tushki7 | 0:60d829a0353a | 76 | * |
tushki7 | 0:60d829a0353a | 77 | * @param str The string to write |
tushki7 | 0:60d829a0353a | 78 | * |
tushki7 | 0:60d829a0353a | 79 | * @returns 0 if the write succeeds, EOF for error |
tushki7 | 0:60d829a0353a | 80 | */ |
tushki7 | 0:60d829a0353a | 81 | int puts(const char *str); |
tushki7 | 0:60d829a0353a | 82 | |
tushki7 | 0:60d829a0353a | 83 | int printf(const char *format, ...); |
tushki7 | 0:60d829a0353a | 84 | }; |
tushki7 | 0:60d829a0353a | 85 | |
tushki7 | 0:60d829a0353a | 86 | } // namespace mbed |
tushki7 | 0:60d829a0353a | 87 | |
tushki7 | 0:60d829a0353a | 88 | #endif |
tushki7 | 0:60d829a0353a | 89 | |
tushki7 | 0:60d829a0353a | 90 | #endif |