mbed library sources. Supersedes mbed-src. removed serial

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Fri Oct 28 11:17:30 2016 +0100
Revision:
149:156823d33999
This updates the lib to the mbed lib v128

NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.

Who changed what in which revision?

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