SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 21:37:21 2019 +0000
Revision:
0:8ede47d38d10
SPKT

Who changed what in which revision?

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