Final version.

Dependencies:   F746_GUI F746_SAI_IO UIT_FFT_Real

Fork of F746_Spectrogram by 不韋 呂

Committer:
MikamiUitOpen
Date:
Sun Oct 02 10:51:10 2016 +0000
Revision:
4:c1beacfc42c7
5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 4:c1beacfc42c7 1 /* mbed Microcontroller Library
MikamiUitOpen 4:c1beacfc42c7 2 * Copyright (c) 2006-2013 ARM Limited
MikamiUitOpen 4:c1beacfc42c7 3 *
MikamiUitOpen 4:c1beacfc42c7 4 * Licensed under the Apache License, Version 2.0 (the "License");
MikamiUitOpen 4:c1beacfc42c7 5 * you may not use this file except in compliance with the License.
MikamiUitOpen 4:c1beacfc42c7 6 * You may obtain a copy of the License at
MikamiUitOpen 4:c1beacfc42c7 7 *
MikamiUitOpen 4:c1beacfc42c7 8 * http://www.apache.org/licenses/LICENSE-2.0
MikamiUitOpen 4:c1beacfc42c7 9 *
MikamiUitOpen 4:c1beacfc42c7 10 * Unless required by applicable law or agreed to in writing, software
MikamiUitOpen 4:c1beacfc42c7 11 * distributed under the License is distributed on an "AS IS" BASIS,
MikamiUitOpen 4:c1beacfc42c7 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikamiUitOpen 4:c1beacfc42c7 13 * See the License for the specific language governing permissions and
MikamiUitOpen 4:c1beacfc42c7 14 * limitations under the License.
MikamiUitOpen 4:c1beacfc42c7 15 */
MikamiUitOpen 4:c1beacfc42c7 16 #ifndef MBED_INTERRUPTIN_H
MikamiUitOpen 4:c1beacfc42c7 17 #define MBED_INTERRUPTIN_H
MikamiUitOpen 4:c1beacfc42c7 18
MikamiUitOpen 4:c1beacfc42c7 19 #include "platform.h"
MikamiUitOpen 4:c1beacfc42c7 20
MikamiUitOpen 4:c1beacfc42c7 21 #if DEVICE_INTERRUPTIN
MikamiUitOpen 4:c1beacfc42c7 22
MikamiUitOpen 4:c1beacfc42c7 23 #include "gpio_api.h"
MikamiUitOpen 4:c1beacfc42c7 24 #include "gpio_irq_api.h"
MikamiUitOpen 4:c1beacfc42c7 25 #include "FunctionPointer.h"
MikamiUitOpen 4:c1beacfc42c7 26
MikamiUitOpen 4:c1beacfc42c7 27 namespace mbed {
MikamiUitOpen 4:c1beacfc42c7 28
MikamiUitOpen 4:c1beacfc42c7 29 /** A digital interrupt input, used to call a function on a rising or falling edge
MikamiUitOpen 4:c1beacfc42c7 30 *
MikamiUitOpen 4:c1beacfc42c7 31 * Example:
MikamiUitOpen 4:c1beacfc42c7 32 * @code
MikamiUitOpen 4:c1beacfc42c7 33 * // Flash an LED while waiting for events
MikamiUitOpen 4:c1beacfc42c7 34 *
MikamiUitOpen 4:c1beacfc42c7 35 * #include "mbed.h"
MikamiUitOpen 4:c1beacfc42c7 36 *
MikamiUitOpen 4:c1beacfc42c7 37 * InterruptIn event(p16);
MikamiUitOpen 4:c1beacfc42c7 38 * DigitalOut led(LED1);
MikamiUitOpen 4:c1beacfc42c7 39 *
MikamiUitOpen 4:c1beacfc42c7 40 * void trigger() {
MikamiUitOpen 4:c1beacfc42c7 41 * printf("triggered!\n");
MikamiUitOpen 4:c1beacfc42c7 42 * }
MikamiUitOpen 4:c1beacfc42c7 43 *
MikamiUitOpen 4:c1beacfc42c7 44 * int main() {
MikamiUitOpen 4:c1beacfc42c7 45 * event.rise(&trigger);
MikamiUitOpen 4:c1beacfc42c7 46 * while(1) {
MikamiUitOpen 4:c1beacfc42c7 47 * led = !led;
MikamiUitOpen 4:c1beacfc42c7 48 * wait(0.25);
MikamiUitOpen 4:c1beacfc42c7 49 * }
MikamiUitOpen 4:c1beacfc42c7 50 * }
MikamiUitOpen 4:c1beacfc42c7 51 * @endcode
MikamiUitOpen 4:c1beacfc42c7 52 */
MikamiUitOpen 4:c1beacfc42c7 53 class InterruptIn {
MikamiUitOpen 4:c1beacfc42c7 54
MikamiUitOpen 4:c1beacfc42c7 55 public:
MikamiUitOpen 4:c1beacfc42c7 56
MikamiUitOpen 4:c1beacfc42c7 57 /** Create an InterruptIn connected to the specified pin
MikamiUitOpen 4:c1beacfc42c7 58 *
MikamiUitOpen 4:c1beacfc42c7 59 * @param pin InterruptIn pin to connect to
MikamiUitOpen 4:c1beacfc42c7 60 * @param name (optional) A string to identify the object
MikamiUitOpen 4:c1beacfc42c7 61 */
MikamiUitOpen 4:c1beacfc42c7 62 InterruptIn(PinName pin);
MikamiUitOpen 4:c1beacfc42c7 63 virtual ~InterruptIn();
MikamiUitOpen 4:c1beacfc42c7 64
MikamiUitOpen 4:c1beacfc42c7 65 int read();
MikamiUitOpen 4:c1beacfc42c7 66 #ifdef MBED_OPERATORS
MikamiUitOpen 4:c1beacfc42c7 67 operator int();
MikamiUitOpen 4:c1beacfc42c7 68
MikamiUitOpen 4:c1beacfc42c7 69 #endif
MikamiUitOpen 4:c1beacfc42c7 70
MikamiUitOpen 4:c1beacfc42c7 71 /** Attach a function to call when a rising edge occurs on the input
MikamiUitOpen 4:c1beacfc42c7 72 *
MikamiUitOpen 4:c1beacfc42c7 73 * @param fptr A pointer to a void function, or 0 to set as none
MikamiUitOpen 4:c1beacfc42c7 74 */
MikamiUitOpen 4:c1beacfc42c7 75 void rise(void (*fptr)(void));
MikamiUitOpen 4:c1beacfc42c7 76
MikamiUitOpen 4:c1beacfc42c7 77 /** Attach a member function to call when a rising edge occurs on the input
MikamiUitOpen 4:c1beacfc42c7 78 *
MikamiUitOpen 4:c1beacfc42c7 79 * @param tptr pointer to the object to call the member function on
MikamiUitOpen 4:c1beacfc42c7 80 * @param mptr pointer to the member function to be called
MikamiUitOpen 4:c1beacfc42c7 81 */
MikamiUitOpen 4:c1beacfc42c7 82 template<typename T>
MikamiUitOpen 4:c1beacfc42c7 83 void rise(T* tptr, void (T::*mptr)(void)) {
MikamiUitOpen 4:c1beacfc42c7 84 _rise.attach(tptr, mptr);
MikamiUitOpen 4:c1beacfc42c7 85 gpio_irq_set(&gpio_irq, IRQ_RISE, 1);
MikamiUitOpen 4:c1beacfc42c7 86 }
MikamiUitOpen 4:c1beacfc42c7 87
MikamiUitOpen 4:c1beacfc42c7 88 /** Attach a function to call when a falling edge occurs on the input
MikamiUitOpen 4:c1beacfc42c7 89 *
MikamiUitOpen 4:c1beacfc42c7 90 * @param fptr A pointer to a void function, or 0 to set as none
MikamiUitOpen 4:c1beacfc42c7 91 */
MikamiUitOpen 4:c1beacfc42c7 92 void fall(void (*fptr)(void));
MikamiUitOpen 4:c1beacfc42c7 93
MikamiUitOpen 4:c1beacfc42c7 94 /** Attach a member function to call when a falling edge occurs on the input
MikamiUitOpen 4:c1beacfc42c7 95 *
MikamiUitOpen 4:c1beacfc42c7 96 * @param tptr pointer to the object to call the member function on
MikamiUitOpen 4:c1beacfc42c7 97 * @param mptr pointer to the member function to be called
MikamiUitOpen 4:c1beacfc42c7 98 */
MikamiUitOpen 4:c1beacfc42c7 99 template<typename T>
MikamiUitOpen 4:c1beacfc42c7 100 void fall(T* tptr, void (T::*mptr)(void)) {
MikamiUitOpen 4:c1beacfc42c7 101 _fall.attach(tptr, mptr);
MikamiUitOpen 4:c1beacfc42c7 102 gpio_irq_set(&gpio_irq, IRQ_FALL, 1);
MikamiUitOpen 4:c1beacfc42c7 103 }
MikamiUitOpen 4:c1beacfc42c7 104
MikamiUitOpen 4:c1beacfc42c7 105 /** Set the input pin mode
MikamiUitOpen 4:c1beacfc42c7 106 *
MikamiUitOpen 4:c1beacfc42c7 107 * @param mode PullUp, PullDown, PullNone
MikamiUitOpen 4:c1beacfc42c7 108 */
MikamiUitOpen 4:c1beacfc42c7 109 void mode(PinMode pull);
MikamiUitOpen 4:c1beacfc42c7 110
MikamiUitOpen 4:c1beacfc42c7 111 /** Enable IRQ. This method depends on hw implementation, might enable one
MikamiUitOpen 4:c1beacfc42c7 112 * port interrupts. For further information, check gpio_irq_enable().
MikamiUitOpen 4:c1beacfc42c7 113 */
MikamiUitOpen 4:c1beacfc42c7 114 void enable_irq();
MikamiUitOpen 4:c1beacfc42c7 115
MikamiUitOpen 4:c1beacfc42c7 116 /** Disable IRQ. This method depends on hw implementation, might disable one
MikamiUitOpen 4:c1beacfc42c7 117 * port interrupts. For further information, check gpio_irq_disable().
MikamiUitOpen 4:c1beacfc42c7 118 */
MikamiUitOpen 4:c1beacfc42c7 119 void disable_irq();
MikamiUitOpen 4:c1beacfc42c7 120
MikamiUitOpen 4:c1beacfc42c7 121 static void _irq_handler(uint32_t id, gpio_irq_event event);
MikamiUitOpen 4:c1beacfc42c7 122
MikamiUitOpen 4:c1beacfc42c7 123 protected:
MikamiUitOpen 4:c1beacfc42c7 124 gpio_t gpio;
MikamiUitOpen 4:c1beacfc42c7 125 gpio_irq_t gpio_irq;
MikamiUitOpen 4:c1beacfc42c7 126
MikamiUitOpen 4:c1beacfc42c7 127 FunctionPointer _rise;
MikamiUitOpen 4:c1beacfc42c7 128 FunctionPointer _fall;
MikamiUitOpen 4:c1beacfc42c7 129 };
MikamiUitOpen 4:c1beacfc42c7 130
MikamiUitOpen 4:c1beacfc42c7 131 } // namespace mbed
MikamiUitOpen 4:c1beacfc42c7 132
MikamiUitOpen 4:c1beacfc42c7 133 #endif
MikamiUitOpen 4:c1beacfc42c7 134
MikamiUitOpen 4:c1beacfc42c7 135 #endif