fft
Dependencies: BSP_DISCO_F746NG SDFileSystem_Warning_Fixed
mbed_src_STM32F7/common/InterruptIn.cpp@0:3e46577dc273, 2016-10-09 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sun Oct 09 10:11:14 2016 +0000
- Revision:
- 0:3e46577dc273
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:3e46577dc273 | 1 | /* mbed Microcontroller Library |
MikamiUitOpen | 0:3e46577dc273 | 2 | * Copyright (c) 2006-2013 ARM Limited |
MikamiUitOpen | 0:3e46577dc273 | 3 | * |
MikamiUitOpen | 0:3e46577dc273 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
MikamiUitOpen | 0:3e46577dc273 | 5 | * you may not use this file except in compliance with the License. |
MikamiUitOpen | 0:3e46577dc273 | 6 | * You may obtain a copy of the License at |
MikamiUitOpen | 0:3e46577dc273 | 7 | * |
MikamiUitOpen | 0:3e46577dc273 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
MikamiUitOpen | 0:3e46577dc273 | 9 | * |
MikamiUitOpen | 0:3e46577dc273 | 10 | * Unless required by applicable law or agreed to in writing, software |
MikamiUitOpen | 0:3e46577dc273 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
MikamiUitOpen | 0:3e46577dc273 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
MikamiUitOpen | 0:3e46577dc273 | 13 | * See the License for the specific language governing permissions and |
MikamiUitOpen | 0:3e46577dc273 | 14 | * limitations under the License. |
MikamiUitOpen | 0:3e46577dc273 | 15 | */ |
MikamiUitOpen | 0:3e46577dc273 | 16 | #include "InterruptIn.h" |
MikamiUitOpen | 0:3e46577dc273 | 17 | |
MikamiUitOpen | 0:3e46577dc273 | 18 | #if DEVICE_INTERRUPTIN |
MikamiUitOpen | 0:3e46577dc273 | 19 | |
MikamiUitOpen | 0:3e46577dc273 | 20 | namespace mbed { |
MikamiUitOpen | 0:3e46577dc273 | 21 | |
MikamiUitOpen | 0:3e46577dc273 | 22 | InterruptIn::InterruptIn(PinName pin) : gpio(), |
MikamiUitOpen | 0:3e46577dc273 | 23 | gpio_irq(), |
MikamiUitOpen | 0:3e46577dc273 | 24 | _rise(), |
MikamiUitOpen | 0:3e46577dc273 | 25 | _fall() { |
MikamiUitOpen | 0:3e46577dc273 | 26 | gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this); |
MikamiUitOpen | 0:3e46577dc273 | 27 | gpio_init_in(&gpio, pin); |
MikamiUitOpen | 0:3e46577dc273 | 28 | } |
MikamiUitOpen | 0:3e46577dc273 | 29 | |
MikamiUitOpen | 0:3e46577dc273 | 30 | InterruptIn::~InterruptIn() { |
MikamiUitOpen | 0:3e46577dc273 | 31 | gpio_irq_free(&gpio_irq); |
MikamiUitOpen | 0:3e46577dc273 | 32 | } |
MikamiUitOpen | 0:3e46577dc273 | 33 | |
MikamiUitOpen | 0:3e46577dc273 | 34 | int InterruptIn::read() { |
MikamiUitOpen | 0:3e46577dc273 | 35 | return gpio_read(&gpio); |
MikamiUitOpen | 0:3e46577dc273 | 36 | } |
MikamiUitOpen | 0:3e46577dc273 | 37 | |
MikamiUitOpen | 0:3e46577dc273 | 38 | void InterruptIn::mode(PinMode pull) { |
MikamiUitOpen | 0:3e46577dc273 | 39 | gpio_mode(&gpio, pull); |
MikamiUitOpen | 0:3e46577dc273 | 40 | } |
MikamiUitOpen | 0:3e46577dc273 | 41 | |
MikamiUitOpen | 0:3e46577dc273 | 42 | void InterruptIn::rise(void (*fptr)(void)) { |
MikamiUitOpen | 0:3e46577dc273 | 43 | if (fptr) { |
MikamiUitOpen | 0:3e46577dc273 | 44 | _rise.attach(fptr); |
MikamiUitOpen | 0:3e46577dc273 | 45 | gpio_irq_set(&gpio_irq, IRQ_RISE, 1); |
MikamiUitOpen | 0:3e46577dc273 | 46 | } else { |
MikamiUitOpen | 0:3e46577dc273 | 47 | _rise.attach(NULL); |
MikamiUitOpen | 0:3e46577dc273 | 48 | gpio_irq_set(&gpio_irq, IRQ_RISE, 0); |
MikamiUitOpen | 0:3e46577dc273 | 49 | } |
MikamiUitOpen | 0:3e46577dc273 | 50 | } |
MikamiUitOpen | 0:3e46577dc273 | 51 | |
MikamiUitOpen | 0:3e46577dc273 | 52 | void InterruptIn::fall(void (*fptr)(void)) { |
MikamiUitOpen | 0:3e46577dc273 | 53 | if (fptr) { |
MikamiUitOpen | 0:3e46577dc273 | 54 | _fall.attach(fptr); |
MikamiUitOpen | 0:3e46577dc273 | 55 | gpio_irq_set(&gpio_irq, IRQ_FALL, 1); |
MikamiUitOpen | 0:3e46577dc273 | 56 | } else { |
MikamiUitOpen | 0:3e46577dc273 | 57 | _fall.attach(NULL); |
MikamiUitOpen | 0:3e46577dc273 | 58 | gpio_irq_set(&gpio_irq, IRQ_FALL, 0); |
MikamiUitOpen | 0:3e46577dc273 | 59 | } |
MikamiUitOpen | 0:3e46577dc273 | 60 | } |
MikamiUitOpen | 0:3e46577dc273 | 61 | |
MikamiUitOpen | 0:3e46577dc273 | 62 | void InterruptIn::_irq_handler(uint32_t id, gpio_irq_event event) { |
MikamiUitOpen | 0:3e46577dc273 | 63 | InterruptIn *handler = (InterruptIn*)id; |
MikamiUitOpen | 0:3e46577dc273 | 64 | switch (event) { |
MikamiUitOpen | 0:3e46577dc273 | 65 | case IRQ_RISE: handler->_rise.call(); break; |
MikamiUitOpen | 0:3e46577dc273 | 66 | case IRQ_FALL: handler->_fall.call(); break; |
MikamiUitOpen | 0:3e46577dc273 | 67 | case IRQ_NONE: break; |
MikamiUitOpen | 0:3e46577dc273 | 68 | } |
MikamiUitOpen | 0:3e46577dc273 | 69 | } |
MikamiUitOpen | 0:3e46577dc273 | 70 | |
MikamiUitOpen | 0:3e46577dc273 | 71 | void InterruptIn::enable_irq() { |
MikamiUitOpen | 0:3e46577dc273 | 72 | gpio_irq_enable(&gpio_irq); |
MikamiUitOpen | 0:3e46577dc273 | 73 | } |
MikamiUitOpen | 0:3e46577dc273 | 74 | |
MikamiUitOpen | 0:3e46577dc273 | 75 | void InterruptIn::disable_irq() { |
MikamiUitOpen | 0:3e46577dc273 | 76 | gpio_irq_disable(&gpio_irq); |
MikamiUitOpen | 0:3e46577dc273 | 77 | } |
MikamiUitOpen | 0:3e46577dc273 | 78 | |
MikamiUitOpen | 0:3e46577dc273 | 79 | #ifdef MBED_OPERATORS |
MikamiUitOpen | 0:3e46577dc273 | 80 | InterruptIn::operator int() { |
MikamiUitOpen | 0:3e46577dc273 | 81 | return read(); |
MikamiUitOpen | 0:3e46577dc273 | 82 | } |
MikamiUitOpen | 0:3e46577dc273 | 83 | #endif |
MikamiUitOpen | 0:3e46577dc273 | 84 | |
MikamiUitOpen | 0:3e46577dc273 | 85 | } // namespace mbed |
MikamiUitOpen | 0:3e46577dc273 | 86 | |
MikamiUitOpen | 0:3e46577dc273 | 87 | #endif |