PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)
Dependents: YATTT sd_map_test cPong SnowDemo ... more
BusOut.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_BUSOUT_H 00017 #define MBED_BUSOUT_H 00018 00019 #include "DigitalOut.h" 00020 00021 namespace mbed { 00022 00023 /** A digital output bus, used for setting the state of a collection of pins 00024 */ 00025 class BusOut { 00026 00027 public: 00028 00029 /** Create an BusOut, connected to the specified pins 00030 * 00031 * @param p<n> DigitalOut pin to connect to bus bit <n> (p5-p30, NC) 00032 * 00033 * @note 00034 * It is only required to specify as many pin variables as is required 00035 * for the bus; the rest will default to NC (not connected) 00036 */ 00037 BusOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC, 00038 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC, 00039 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC, 00040 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC); 00041 00042 BusOut(PinName pins[16]); 00043 00044 virtual ~BusOut(); 00045 00046 /** Write the value to the output bus 00047 * 00048 * @param value An integer specifying a bit to write for every corresponding DigitalOut pin 00049 */ 00050 void write(int value); 00051 00052 /** Read the value currently output on the bus 00053 * 00054 * @returns 00055 * An integer with each bit corresponding to associated DigitalOut pin setting 00056 */ 00057 int read(); 00058 00059 /** Binary mask of bus pins connected to actual pins (not NC pins) 00060 * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1 00061 * 00062 * @returns 00063 * Binary mask of connected pins 00064 */ 00065 int mask() { 00066 return _nc_mask; 00067 } 00068 00069 #ifdef MBED_OPERATORS 00070 /** A shorthand for write() 00071 */ 00072 BusOut& operator= (int v); 00073 BusOut& operator= (BusOut& rhs); 00074 00075 /** Access to particular bit in random-iterator fashion 00076 */ 00077 DigitalOut& operator[] (int index); 00078 00079 /** A shorthand for read() 00080 */ 00081 operator int(); 00082 #endif 00083 00084 protected: 00085 DigitalOut* _pin[16]; 00086 00087 /** Mask of bus's NC pins 00088 * If bit[n] is set to 1 - pin is connected 00089 * if bit[n] is cleared - pin is not connected (NC) 00090 */ 00091 int _nc_mask; 00092 00093 /* disallow copy constructor and assignment operators */ 00094 private: 00095 BusOut(const BusOut&); 00096 BusOut & operator = (const BusOut&); 00097 }; 00098 00099 } // namespace mbed 00100 00101 #endif
Generated on Tue Jul 12 2022 11:20:30 by 1.7.2