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