Describes predefine macros for mbed online compiler (armcc)

Committer:
MACRUM
Date:
Thu Mar 16 21:58:09 2017 +0900
Revision:
6:40e873bbc5f7
Add licence header info

Who changed what in which revision?

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