mbed library sources. Supersedes mbed-src. RTC working even after reset

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Fri Sep 02 15:07:44 2016 +0100
Revision:
144:ef7eb2e8f9f7
Parent:
0:9b334a45a8ff
This updates the lib to the mbed lib v125

Who changed what in which revision?

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