fft

Dependencies:   BSP_DISCO_F746NG SDFileSystem_Warning_Fixed

Committer:
MikamiUitOpen
Date:
Sun Oct 09 10:11:14 2016 +0000
Revision:
0:3e46577dc273
1

Who changed what in which revision?

UserRevisionLine numberNew 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 #ifndef MBED_PORTIN_H
MikamiUitOpen 0:3e46577dc273 17 #define MBED_PORTIN_H
MikamiUitOpen 0:3e46577dc273 18
MikamiUitOpen 0:3e46577dc273 19 #include "platform.h"
MikamiUitOpen 0:3e46577dc273 20
MikamiUitOpen 0:3e46577dc273 21 #if DEVICE_PORTIN
MikamiUitOpen 0:3e46577dc273 22
MikamiUitOpen 0:3e46577dc273 23 #include "port_api.h"
MikamiUitOpen 0:3e46577dc273 24
MikamiUitOpen 0:3e46577dc273 25 namespace mbed {
MikamiUitOpen 0:3e46577dc273 26
MikamiUitOpen 0:3e46577dc273 27 /** A multiple pin digital input
MikamiUitOpen 0:3e46577dc273 28 *
MikamiUitOpen 0:3e46577dc273 29 * Example:
MikamiUitOpen 0:3e46577dc273 30 * @code
MikamiUitOpen 0:3e46577dc273 31 * // Switch on an LED if any of mbed pins 21-26 is high
MikamiUitOpen 0:3e46577dc273 32 *
MikamiUitOpen 0:3e46577dc273 33 * #include "mbed.h"
MikamiUitOpen 0:3e46577dc273 34 *
MikamiUitOpen 0:3e46577dc273 35 * PortIn p(Port2, 0x0000003F); // p21-p26
MikamiUitOpen 0:3e46577dc273 36 * DigitalOut ind(LED4);
MikamiUitOpen 0:3e46577dc273 37 *
MikamiUitOpen 0:3e46577dc273 38 * int main() {
MikamiUitOpen 0:3e46577dc273 39 * while(1) {
MikamiUitOpen 0:3e46577dc273 40 * int pins = p.read();
MikamiUitOpen 0:3e46577dc273 41 * if(pins) {
MikamiUitOpen 0:3e46577dc273 42 * ind = 1;
MikamiUitOpen 0:3e46577dc273 43 * } else {
MikamiUitOpen 0:3e46577dc273 44 * ind = 0;
MikamiUitOpen 0:3e46577dc273 45 * }
MikamiUitOpen 0:3e46577dc273 46 * }
MikamiUitOpen 0:3e46577dc273 47 * }
MikamiUitOpen 0:3e46577dc273 48 * @endcode
MikamiUitOpen 0:3e46577dc273 49 */
MikamiUitOpen 0:3e46577dc273 50 class PortIn {
MikamiUitOpen 0:3e46577dc273 51 public:
MikamiUitOpen 0:3e46577dc273 52
MikamiUitOpen 0:3e46577dc273 53 /** Create an PortIn, connected to the specified port
MikamiUitOpen 0:3e46577dc273 54 *
MikamiUitOpen 0:3e46577dc273 55 * @param port Port to connect to (Port0-Port5)
MikamiUitOpen 0:3e46577dc273 56 * @param mask A bitmask to identify which bits in the port should be included (0 - ignore)
MikamiUitOpen 0:3e46577dc273 57 */
MikamiUitOpen 0:3e46577dc273 58 PortIn(PortName port, int mask = 0xFFFFFFFF) {
MikamiUitOpen 0:3e46577dc273 59 port_init(&_port, port, mask, PIN_INPUT);
MikamiUitOpen 0:3e46577dc273 60 }
MikamiUitOpen 0:3e46577dc273 61
MikamiUitOpen 0:3e46577dc273 62 /** Read the value currently output on the port
MikamiUitOpen 0:3e46577dc273 63 *
MikamiUitOpen 0:3e46577dc273 64 * @returns
MikamiUitOpen 0:3e46577dc273 65 * An integer with each bit corresponding to associated port pin setting
MikamiUitOpen 0:3e46577dc273 66 */
MikamiUitOpen 0:3e46577dc273 67 int read() {
MikamiUitOpen 0:3e46577dc273 68 return port_read(&_port);
MikamiUitOpen 0:3e46577dc273 69 }
MikamiUitOpen 0:3e46577dc273 70
MikamiUitOpen 0:3e46577dc273 71 /** Set the input pin mode
MikamiUitOpen 0:3e46577dc273 72 *
MikamiUitOpen 0:3e46577dc273 73 * @param mode PullUp, PullDown, PullNone, OpenDrain
MikamiUitOpen 0:3e46577dc273 74 */
MikamiUitOpen 0:3e46577dc273 75 void mode(PinMode mode) {
MikamiUitOpen 0:3e46577dc273 76 port_mode(&_port, mode);
MikamiUitOpen 0:3e46577dc273 77 }
MikamiUitOpen 0:3e46577dc273 78
MikamiUitOpen 0:3e46577dc273 79 /** A shorthand for read()
MikamiUitOpen 0:3e46577dc273 80 */
MikamiUitOpen 0:3e46577dc273 81 operator int() {
MikamiUitOpen 0:3e46577dc273 82 return read();
MikamiUitOpen 0:3e46577dc273 83 }
MikamiUitOpen 0:3e46577dc273 84
MikamiUitOpen 0:3e46577dc273 85 private:
MikamiUitOpen 0:3e46577dc273 86 port_t _port;
MikamiUitOpen 0:3e46577dc273 87 };
MikamiUitOpen 0:3e46577dc273 88
MikamiUitOpen 0:3e46577dc273 89 } // namespace mbed
MikamiUitOpen 0:3e46577dc273 90
MikamiUitOpen 0:3e46577dc273 91 #endif
MikamiUitOpen 0:3e46577dc273 92
MikamiUitOpen 0:3e46577dc273 93 #endif