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_BUSIN_H
MACRUM 6:40e873bbc5f7 17 #define MBED_BUSIN_H
MACRUM 6:40e873bbc5f7 18
MACRUM 6:40e873bbc5f7 19 #include "platform/platform.h"
MACRUM 6:40e873bbc5f7 20 #include "drivers/DigitalIn.h"
MACRUM 6:40e873bbc5f7 21 #include "platform/PlatformMutex.h"
MACRUM 6:40e873bbc5f7 22
MACRUM 6:40e873bbc5f7 23 namespace mbed {
MACRUM 6:40e873bbc5f7 24 /** \addtogroup drivers */
MACRUM 6:40e873bbc5f7 25 /** @{*/
MACRUM 6:40e873bbc5f7 26
MACRUM 6:40e873bbc5f7 27 /** A digital input bus, used for reading the state of a collection of pins
MACRUM 6:40e873bbc5f7 28 *
MACRUM 6:40e873bbc5f7 29 * @Note Synchronization level: Thread safe
MACRUM 6:40e873bbc5f7 30 */
MACRUM 6:40e873bbc5f7 31 class BusIn {
MACRUM 6:40e873bbc5f7 32
MACRUM 6:40e873bbc5f7 33 public:
MACRUM 6:40e873bbc5f7 34 /* Group: Configuration Methods */
MACRUM 6:40e873bbc5f7 35
MACRUM 6:40e873bbc5f7 36 /** Create an BusIn, connected to the specified pins
MACRUM 6:40e873bbc5f7 37 *
MACRUM 6:40e873bbc5f7 38 * @param <n> DigitalIn pin to connect to bus bit <n> (p5-p30, NC)
MACRUM 6:40e873bbc5f7 39 *
MACRUM 6:40e873bbc5f7 40 * @note
MACRUM 6:40e873bbc5f7 41 * It is only required to specify as many pin variables as is required
MACRUM 6:40e873bbc5f7 42 * for the bus; the rest will default to NC (not connected)
MACRUM 6:40e873bbc5f7 43 */
MACRUM 6:40e873bbc5f7 44 BusIn(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
MACRUM 6:40e873bbc5f7 45 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
MACRUM 6:40e873bbc5f7 46 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
MACRUM 6:40e873bbc5f7 47 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
MACRUM 6:40e873bbc5f7 48
MACRUM 6:40e873bbc5f7 49 BusIn(PinName pins[16]);
MACRUM 6:40e873bbc5f7 50
MACRUM 6:40e873bbc5f7 51 virtual ~BusIn();
MACRUM 6:40e873bbc5f7 52
MACRUM 6:40e873bbc5f7 53 /** Read the value of the input bus
MACRUM 6:40e873bbc5f7 54 *
MACRUM 6:40e873bbc5f7 55 * @returns
MACRUM 6:40e873bbc5f7 56 * An integer with each bit corresponding to the value read from the associated DigitalIn pin
MACRUM 6:40e873bbc5f7 57 */
MACRUM 6:40e873bbc5f7 58 int read();
MACRUM 6:40e873bbc5f7 59
MACRUM 6:40e873bbc5f7 60 /** Set the input pin mode
MACRUM 6:40e873bbc5f7 61 *
MACRUM 6:40e873bbc5f7 62 * @param mode PullUp, PullDown, PullNone
MACRUM 6:40e873bbc5f7 63 */
MACRUM 6:40e873bbc5f7 64 void mode(PinMode pull);
MACRUM 6:40e873bbc5f7 65
MACRUM 6:40e873bbc5f7 66 /** Binary mask of bus pins connected to actual pins (not NC pins)
MACRUM 6:40e873bbc5f7 67 * 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 68 *
MACRUM 6:40e873bbc5f7 69 * @returns
MACRUM 6:40e873bbc5f7 70 * Binary mask of connected pins
MACRUM 6:40e873bbc5f7 71 */
MACRUM 6:40e873bbc5f7 72 int mask() {
MACRUM 6:40e873bbc5f7 73 // No lock needed since _nc_mask is not modified outside the constructor
MACRUM 6:40e873bbc5f7 74 return _nc_mask;
MACRUM 6:40e873bbc5f7 75 }
MACRUM 6:40e873bbc5f7 76
MACRUM 6:40e873bbc5f7 77 /** A shorthand for read()
MACRUM 6:40e873bbc5f7 78 */
MACRUM 6:40e873bbc5f7 79 operator int();
MACRUM 6:40e873bbc5f7 80
MACRUM 6:40e873bbc5f7 81 /** Access to particular bit in random-iterator fashion
MACRUM 6:40e873bbc5f7 82 */
MACRUM 6:40e873bbc5f7 83 DigitalIn & operator[] (int index);
MACRUM 6:40e873bbc5f7 84
MACRUM 6:40e873bbc5f7 85 protected:
MACRUM 6:40e873bbc5f7 86 DigitalIn* _pin[16];
MACRUM 6:40e873bbc5f7 87
MACRUM 6:40e873bbc5f7 88 /** Mask of bus's NC pins
MACRUM 6:40e873bbc5f7 89 * If bit[n] is set to 1 - pin is connected
MACRUM 6:40e873bbc5f7 90 * if bit[n] is cleared - pin is not connected (NC)
MACRUM 6:40e873bbc5f7 91 */
MACRUM 6:40e873bbc5f7 92 int _nc_mask;
MACRUM 6:40e873bbc5f7 93
MACRUM 6:40e873bbc5f7 94 PlatformMutex _mutex;
MACRUM 6:40e873bbc5f7 95
MACRUM 6:40e873bbc5f7 96 /* disallow copy constructor and assignment operators */
MACRUM 6:40e873bbc5f7 97 private:
MACRUM 6:40e873bbc5f7 98 virtual void lock();
MACRUM 6:40e873bbc5f7 99 virtual void unlock();
MACRUM 6:40e873bbc5f7 100 BusIn(const BusIn&);
MACRUM 6:40e873bbc5f7 101 BusIn & operator = (const BusIn&);
MACRUM 6:40e873bbc5f7 102 };
MACRUM 6:40e873bbc5f7 103
MACRUM 6:40e873bbc5f7 104 } // namespace mbed
MACRUM 6:40e873bbc5f7 105
MACRUM 6:40e873bbc5f7 106 #endif
MACRUM 6:40e873bbc5f7 107
MACRUM 6:40e873bbc5f7 108 /** @}*/