SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 09:08:29 2019 +0000
Revision:
0:aa3fc5ad02f7
SPKT

Who changed what in which revision?

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