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

Fork of mbed-dev by mbed official

Committer:
olympux
Date:
Wed Sep 28 20:59:47 2016 +0000
Revision:
148:161ebc35dc3a
Parent:
144:ef7eb2e8f9f7
RTC working

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_BUSOUT_H
<> 144:ef7eb2e8f9f7 17 #define MBED_BUSOUT_H
<> 144:ef7eb2e8f9f7 18
<> 144:ef7eb2e8f9f7 19 #include "DigitalOut.h"
<> 144:ef7eb2e8f9f7 20 #include "PlatformMutex.h"
<> 144:ef7eb2e8f9f7 21
<> 144:ef7eb2e8f9f7 22 namespace mbed {
<> 144:ef7eb2e8f9f7 23
<> 144:ef7eb2e8f9f7 24 /** A digital output bus, used for setting the state of a collection of pins
<> 144:ef7eb2e8f9f7 25 */
<> 144:ef7eb2e8f9f7 26 class BusOut {
<> 144:ef7eb2e8f9f7 27
<> 144:ef7eb2e8f9f7 28 public:
<> 144:ef7eb2e8f9f7 29
<> 144:ef7eb2e8f9f7 30 /** Create an BusOut, connected to the specified pins
<> 144:ef7eb2e8f9f7 31 *
<> 144:ef7eb2e8f9f7 32 * @param p<n> DigitalOut pin to connect to bus bit <n> (p5-p30, NC)
<> 144:ef7eb2e8f9f7 33 *
<> 144:ef7eb2e8f9f7 34 * @Note Synchronization level: Thread safe
<> 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 BusOut(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 BusOut(PinName pins[16]);
<> 144:ef7eb2e8f9f7 46
<> 144:ef7eb2e8f9f7 47 virtual ~BusOut();
<> 144:ef7eb2e8f9f7 48
<> 144:ef7eb2e8f9f7 49 /** Write the value to the output bus
<> 144:ef7eb2e8f9f7 50 *
<> 144:ef7eb2e8f9f7 51 * @param value An integer specifying a bit to write for every corresponding DigitalOut pin
<> 144:ef7eb2e8f9f7 52 */
<> 144:ef7eb2e8f9f7 53 void write(int value);
<> 144:ef7eb2e8f9f7 54
<> 144:ef7eb2e8f9f7 55 /** Read the value currently output on the bus
<> 144:ef7eb2e8f9f7 56 *
<> 144:ef7eb2e8f9f7 57 * @returns
<> 144:ef7eb2e8f9f7 58 * An integer with each bit corresponding to associated DigitalOut pin setting
<> 144:ef7eb2e8f9f7 59 */
<> 144:ef7eb2e8f9f7 60 int read();
<> 144:ef7eb2e8f9f7 61
<> 144:ef7eb2e8f9f7 62 /** Binary mask of bus pins connected to actual pins (not NC pins)
<> 144:ef7eb2e8f9f7 63 * 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 64 *
<> 144:ef7eb2e8f9f7 65 * @returns
<> 144:ef7eb2e8f9f7 66 * Binary mask of connected pins
<> 144:ef7eb2e8f9f7 67 */
<> 144:ef7eb2e8f9f7 68 int mask() {
<> 144:ef7eb2e8f9f7 69 // No lock needed since _nc_mask is not modified outside the constructor
<> 144:ef7eb2e8f9f7 70 return _nc_mask;
<> 144:ef7eb2e8f9f7 71 }
<> 144:ef7eb2e8f9f7 72
<> 144:ef7eb2e8f9f7 73 /** A shorthand for write()
<> 144:ef7eb2e8f9f7 74 */
<> 144:ef7eb2e8f9f7 75 BusOut& operator= (int v);
<> 144:ef7eb2e8f9f7 76 BusOut& operator= (BusOut& rhs);
<> 144:ef7eb2e8f9f7 77
<> 144:ef7eb2e8f9f7 78 /** Access to particular bit in random-iterator fashion
<> 144:ef7eb2e8f9f7 79 */
<> 144:ef7eb2e8f9f7 80 DigitalOut& operator[] (int index);
<> 144:ef7eb2e8f9f7 81
<> 144:ef7eb2e8f9f7 82 /** A shorthand for read()
<> 144:ef7eb2e8f9f7 83 */
<> 144:ef7eb2e8f9f7 84 operator int();
<> 144:ef7eb2e8f9f7 85
<> 144:ef7eb2e8f9f7 86 protected:
<> 144:ef7eb2e8f9f7 87 virtual void lock();
<> 144:ef7eb2e8f9f7 88 virtual void unlock();
<> 144:ef7eb2e8f9f7 89 DigitalOut* _pin[16];
<> 144:ef7eb2e8f9f7 90
<> 144:ef7eb2e8f9f7 91 /** Mask of bus's NC pins
<> 144:ef7eb2e8f9f7 92 * If bit[n] is set to 1 - pin is connected
<> 144:ef7eb2e8f9f7 93 * if bit[n] is cleared - pin is not connected (NC)
<> 144:ef7eb2e8f9f7 94 */
<> 144:ef7eb2e8f9f7 95 int _nc_mask;
<> 144:ef7eb2e8f9f7 96
<> 144:ef7eb2e8f9f7 97 PlatformMutex _mutex;
<> 144:ef7eb2e8f9f7 98
<> 144:ef7eb2e8f9f7 99 /* disallow copy constructor and assignment operators */
<> 144:ef7eb2e8f9f7 100 private:
<> 144:ef7eb2e8f9f7 101 BusOut(const BusOut&);
<> 144:ef7eb2e8f9f7 102 BusOut & operator = (const BusOut&);
<> 144:ef7eb2e8f9f7 103 };
<> 144:ef7eb2e8f9f7 104
<> 144:ef7eb2e8f9f7 105 } // namespace mbed
<> 144:ef7eb2e8f9f7 106
<> 144:ef7eb2e8f9f7 107 #endif