help :(

Dependencies:   FFT

Committer:
annieluo2
Date:
Wed Dec 02 18:02:03 2020 +0000
Revision:
0:d6c9b09b4042
boo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
annieluo2 0:d6c9b09b4042 1 /* mbed Microcontroller Library
annieluo2 0:d6c9b09b4042 2 * Copyright (c) 2006-2013 ARM Limited
annieluo2 0:d6c9b09b4042 3 *
annieluo2 0:d6c9b09b4042 4 * Licensed under the Apache License, Version 2.0 (the "License");
annieluo2 0:d6c9b09b4042 5 * you may not use this file except in compliance with the License.
annieluo2 0:d6c9b09b4042 6 * You may obtain a copy of the License at
annieluo2 0:d6c9b09b4042 7 *
annieluo2 0:d6c9b09b4042 8 * http://www.apache.org/licenses/LICENSE-2.0
annieluo2 0:d6c9b09b4042 9 *
annieluo2 0:d6c9b09b4042 10 * Unless required by applicable law or agreed to in writing, software
annieluo2 0:d6c9b09b4042 11 * distributed under the License is distributed on an "AS IS" BASIS,
annieluo2 0:d6c9b09b4042 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
annieluo2 0:d6c9b09b4042 13 * See the License for the specific language governing permissions and
annieluo2 0:d6c9b09b4042 14 * limitations under the License.
annieluo2 0:d6c9b09b4042 15 */
annieluo2 0:d6c9b09b4042 16 #ifndef MBED_BUSOUT_H
annieluo2 0:d6c9b09b4042 17 #define MBED_BUSOUT_H
annieluo2 0:d6c9b09b4042 18
annieluo2 0:d6c9b09b4042 19 #include "drivers/DigitalOut.h"
annieluo2 0:d6c9b09b4042 20 #include "platform/PlatformMutex.h"
annieluo2 0:d6c9b09b4042 21
annieluo2 0:d6c9b09b4042 22 namespace mbed {
annieluo2 0:d6c9b09b4042 23 /** \addtogroup drivers */
annieluo2 0:d6c9b09b4042 24 /** @{*/
annieluo2 0:d6c9b09b4042 25
annieluo2 0:d6c9b09b4042 26 /** A digital output bus, used for setting the state of a collection of pins
annieluo2 0:d6c9b09b4042 27 */
annieluo2 0:d6c9b09b4042 28 class BusOut {
annieluo2 0:d6c9b09b4042 29
annieluo2 0:d6c9b09b4042 30 public:
annieluo2 0:d6c9b09b4042 31
annieluo2 0:d6c9b09b4042 32 /** Create an BusOut, connected to the specified pins
annieluo2 0:d6c9b09b4042 33 *
annieluo2 0:d6c9b09b4042 34 * @param p<n> DigitalOut pin to connect to bus bit <n> (p5-p30, NC)
annieluo2 0:d6c9b09b4042 35 *
annieluo2 0:d6c9b09b4042 36 * @Note Synchronization level: Thread safe
annieluo2 0:d6c9b09b4042 37 *
annieluo2 0:d6c9b09b4042 38 * @note
annieluo2 0:d6c9b09b4042 39 * It is only required to specify as many pin variables as is required
annieluo2 0:d6c9b09b4042 40 * for the bus; the rest will default to NC (not connected)
annieluo2 0:d6c9b09b4042 41 */
annieluo2 0:d6c9b09b4042 42 BusOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
annieluo2 0:d6c9b09b4042 43 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
annieluo2 0:d6c9b09b4042 44 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
annieluo2 0:d6c9b09b4042 45 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
annieluo2 0:d6c9b09b4042 46
annieluo2 0:d6c9b09b4042 47 BusOut(PinName pins[16]);
annieluo2 0:d6c9b09b4042 48
annieluo2 0:d6c9b09b4042 49 virtual ~BusOut();
annieluo2 0:d6c9b09b4042 50
annieluo2 0:d6c9b09b4042 51 /** Write the value to the output bus
annieluo2 0:d6c9b09b4042 52 *
annieluo2 0:d6c9b09b4042 53 * @param value An integer specifying a bit to write for every corresponding DigitalOut pin
annieluo2 0:d6c9b09b4042 54 */
annieluo2 0:d6c9b09b4042 55 void write(int value);
annieluo2 0:d6c9b09b4042 56
annieluo2 0:d6c9b09b4042 57 /** Read the value currently output on the bus
annieluo2 0:d6c9b09b4042 58 *
annieluo2 0:d6c9b09b4042 59 * @returns
annieluo2 0:d6c9b09b4042 60 * An integer with each bit corresponding to associated DigitalOut pin setting
annieluo2 0:d6c9b09b4042 61 */
annieluo2 0:d6c9b09b4042 62 int read();
annieluo2 0:d6c9b09b4042 63
annieluo2 0:d6c9b09b4042 64 /** Binary mask of bus pins connected to actual pins (not NC pins)
annieluo2 0:d6c9b09b4042 65 * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
annieluo2 0:d6c9b09b4042 66 *
annieluo2 0:d6c9b09b4042 67 * @returns
annieluo2 0:d6c9b09b4042 68 * Binary mask of connected pins
annieluo2 0:d6c9b09b4042 69 */
annieluo2 0:d6c9b09b4042 70 int mask() {
annieluo2 0:d6c9b09b4042 71 // No lock needed since _nc_mask is not modified outside the constructor
annieluo2 0:d6c9b09b4042 72 return _nc_mask;
annieluo2 0:d6c9b09b4042 73 }
annieluo2 0:d6c9b09b4042 74
annieluo2 0:d6c9b09b4042 75 /** A shorthand for write()
annieluo2 0:d6c9b09b4042 76 */
annieluo2 0:d6c9b09b4042 77 BusOut& operator= (int v);
annieluo2 0:d6c9b09b4042 78 BusOut& operator= (BusOut& rhs);
annieluo2 0:d6c9b09b4042 79
annieluo2 0:d6c9b09b4042 80 /** Access to particular bit in random-iterator fashion
annieluo2 0:d6c9b09b4042 81 */
annieluo2 0:d6c9b09b4042 82 DigitalOut& operator[] (int index);
annieluo2 0:d6c9b09b4042 83
annieluo2 0:d6c9b09b4042 84 /** A shorthand for read()
annieluo2 0:d6c9b09b4042 85 */
annieluo2 0:d6c9b09b4042 86 operator int();
annieluo2 0:d6c9b09b4042 87
annieluo2 0:d6c9b09b4042 88 protected:
annieluo2 0:d6c9b09b4042 89 virtual void lock();
annieluo2 0:d6c9b09b4042 90 virtual void unlock();
annieluo2 0:d6c9b09b4042 91 DigitalOut* _pin[16];
annieluo2 0:d6c9b09b4042 92
annieluo2 0:d6c9b09b4042 93 /** Mask of bus's NC pins
annieluo2 0:d6c9b09b4042 94 * If bit[n] is set to 1 - pin is connected
annieluo2 0:d6c9b09b4042 95 * if bit[n] is cleared - pin is not connected (NC)
annieluo2 0:d6c9b09b4042 96 */
annieluo2 0:d6c9b09b4042 97 int _nc_mask;
annieluo2 0:d6c9b09b4042 98
annieluo2 0:d6c9b09b4042 99 PlatformMutex _mutex;
annieluo2 0:d6c9b09b4042 100
annieluo2 0:d6c9b09b4042 101 /* disallow copy constructor and assignment operators */
annieluo2 0:d6c9b09b4042 102 private:
annieluo2 0:d6c9b09b4042 103 BusOut(const BusOut&);
annieluo2 0:d6c9b09b4042 104 BusOut & operator = (const BusOut&);
annieluo2 0:d6c9b09b4042 105 };
annieluo2 0:d6c9b09b4042 106
annieluo2 0:d6c9b09b4042 107 } // namespace mbed
annieluo2 0:d6c9b09b4042 108
annieluo2 0:d6c9b09b4042 109 #endif
annieluo2 0:d6c9b09b4042 110
annieluo2 0:d6c9b09b4042 111 /** @}*/