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_INTERRUPTIN_H
tushki7 0:60d829a0353a 17 #define MBED_INTERRUPTIN_H
tushki7 0:60d829a0353a 18
tushki7 0:60d829a0353a 19 #include "platform.h"
tushki7 0:60d829a0353a 20
tushki7 0:60d829a0353a 21 #if DEVICE_INTERRUPTIN
tushki7 0:60d829a0353a 22
tushki7 0:60d829a0353a 23 #include "gpio_api.h"
tushki7 0:60d829a0353a 24 #include "gpio_irq_api.h"
tushki7 0:60d829a0353a 25 #include "FunctionPointer.h"
tushki7 0:60d829a0353a 26
tushki7 0:60d829a0353a 27 namespace mbed {
tushki7 0:60d829a0353a 28
tushki7 0:60d829a0353a 29 /** A digital interrupt input, used to call a function on a rising or falling edge
tushki7 0:60d829a0353a 30 *
tushki7 0:60d829a0353a 31 * Example:
tushki7 0:60d829a0353a 32 * @code
tushki7 0:60d829a0353a 33 * // Flash an LED while waiting for events
tushki7 0:60d829a0353a 34 *
tushki7 0:60d829a0353a 35 * #include "mbed.h"
tushki7 0:60d829a0353a 36 *
tushki7 0:60d829a0353a 37 * InterruptIn event(p16);
tushki7 0:60d829a0353a 38 * DigitalOut led(LED1);
tushki7 0:60d829a0353a 39 *
tushki7 0:60d829a0353a 40 * void trigger() {
tushki7 0:60d829a0353a 41 * printf("triggered!\n");
tushki7 0:60d829a0353a 42 * }
tushki7 0:60d829a0353a 43 *
tushki7 0:60d829a0353a 44 * int main() {
tushki7 0:60d829a0353a 45 * event.rise(&trigger);
tushki7 0:60d829a0353a 46 * while(1) {
tushki7 0:60d829a0353a 47 * led = !led;
tushki7 0:60d829a0353a 48 * wait(0.25);
tushki7 0:60d829a0353a 49 * }
tushki7 0:60d829a0353a 50 * }
tushki7 0:60d829a0353a 51 * @endcode
tushki7 0:60d829a0353a 52 */
tushki7 0:60d829a0353a 53 class InterruptIn {
tushki7 0:60d829a0353a 54
tushki7 0:60d829a0353a 55 public:
tushki7 0:60d829a0353a 56
tushki7 0:60d829a0353a 57 /** Create an InterruptIn connected to the specified pin
tushki7 0:60d829a0353a 58 *
tushki7 0:60d829a0353a 59 * @param pin InterruptIn pin to connect to
tushki7 0:60d829a0353a 60 * @param name (optional) A string to identify the object
tushki7 0:60d829a0353a 61 */
tushki7 0:60d829a0353a 62 InterruptIn(PinName pin);
tushki7 0:60d829a0353a 63 virtual ~InterruptIn();
tushki7 0:60d829a0353a 64
tushki7 0:60d829a0353a 65 int read();
tushki7 0:60d829a0353a 66 #ifdef MBED_OPERATORS
tushki7 0:60d829a0353a 67 operator int();
tushki7 0:60d829a0353a 68
tushki7 0:60d829a0353a 69 #endif
tushki7 0:60d829a0353a 70
tushki7 0:60d829a0353a 71 /** Attach a function to call when a rising edge occurs on the input
tushki7 0:60d829a0353a 72 *
tushki7 0:60d829a0353a 73 * @param fptr A pointer to a void function, or 0 to set as none
tushki7 0:60d829a0353a 74 */
tushki7 0:60d829a0353a 75 void rise(void (*fptr)(void));
tushki7 0:60d829a0353a 76
tushki7 0:60d829a0353a 77 /** Attach a member function to call when a rising edge occurs on the input
tushki7 0:60d829a0353a 78 *
tushki7 0:60d829a0353a 79 * @param tptr pointer to the object to call the member function on
tushki7 0:60d829a0353a 80 * @param mptr pointer to the member function to be called
tushki7 0:60d829a0353a 81 */
tushki7 0:60d829a0353a 82 template<typename T>
tushki7 0:60d829a0353a 83 void rise(T* tptr, void (T::*mptr)(void)) {
tushki7 0:60d829a0353a 84 _rise.attach(tptr, mptr);
tushki7 0:60d829a0353a 85 gpio_irq_set(&gpio_irq, IRQ_RISE, 1);
tushki7 0:60d829a0353a 86 }
tushki7 0:60d829a0353a 87
tushki7 0:60d829a0353a 88 /** Attach a function to call when a falling edge occurs on the input
tushki7 0:60d829a0353a 89 *
tushki7 0:60d829a0353a 90 * @param fptr A pointer to a void function, or 0 to set as none
tushki7 0:60d829a0353a 91 */
tushki7 0:60d829a0353a 92 void fall(void (*fptr)(void));
tushki7 0:60d829a0353a 93
tushki7 0:60d829a0353a 94 /** Attach a member function to call when a falling edge occurs on the input
tushki7 0:60d829a0353a 95 *
tushki7 0:60d829a0353a 96 * @param tptr pointer to the object to call the member function on
tushki7 0:60d829a0353a 97 * @param mptr pointer to the member function to be called
tushki7 0:60d829a0353a 98 */
tushki7 0:60d829a0353a 99 template<typename T>
tushki7 0:60d829a0353a 100 void fall(T* tptr, void (T::*mptr)(void)) {
tushki7 0:60d829a0353a 101 _fall.attach(tptr, mptr);
tushki7 0:60d829a0353a 102 gpio_irq_set(&gpio_irq, IRQ_FALL, 1);
tushki7 0:60d829a0353a 103 }
tushki7 0:60d829a0353a 104
tushki7 0:60d829a0353a 105 /** Set the input pin mode
tushki7 0:60d829a0353a 106 *
tushki7 0:60d829a0353a 107 * @param mode PullUp, PullDown, PullNone
tushki7 0:60d829a0353a 108 */
tushki7 0:60d829a0353a 109 void mode(PinMode pull);
tushki7 0:60d829a0353a 110
tushki7 0:60d829a0353a 111 /** Enable IRQ. This method depends on hw implementation, might enable one
tushki7 0:60d829a0353a 112 * port interrupts. For further information, check gpio_irq_enable().
tushki7 0:60d829a0353a 113 */
tushki7 0:60d829a0353a 114 void enable_irq();
tushki7 0:60d829a0353a 115
tushki7 0:60d829a0353a 116 /** Disable IRQ. This method depends on hw implementation, might disable one
tushki7 0:60d829a0353a 117 * port interrupts. For further information, check gpio_irq_disable().
tushki7 0:60d829a0353a 118 */
tushki7 0:60d829a0353a 119 void disable_irq();
tushki7 0:60d829a0353a 120
tushki7 0:60d829a0353a 121 static void _irq_handler(uint32_t id, gpio_irq_event event);
tushki7 0:60d829a0353a 122
tushki7 0:60d829a0353a 123 protected:
tushki7 0:60d829a0353a 124 gpio_t gpio;
tushki7 0:60d829a0353a 125 gpio_irq_t gpio_irq;
tushki7 0:60d829a0353a 126
tushki7 0:60d829a0353a 127 FunctionPointer _rise;
tushki7 0:60d829a0353a 128 FunctionPointer _fall;
tushki7 0:60d829a0353a 129 };
tushki7 0:60d829a0353a 130
tushki7 0:60d829a0353a 131 } // namespace mbed
tushki7 0:60d829a0353a 132
tushki7 0:60d829a0353a 133 #endif
tushki7 0:60d829a0353a 134
tushki7 0:60d829a0353a 135 #endif