mbed library sources. Supersedes mbed-src. Fixed broken STM32F1xx RTC on rtc_api.c

Dependents:   Nucleo_F103RB_RTC_battery_bkup_pwr_off_okay

Fork of mbed-dev by mbed official

Committer:
maxxir
Date:
Tue Nov 07 16:46:29 2017 +0000
Revision:
177:619788de047e
Parent:
168:9672193075cf
To fix broken RTC on Nucleo_F103RB / STM32F103 BluePill etc..;  Used direct RTC register manipulation for STM32F1xx;  rtc_read() && rtc_write()  (native rtc_init() - works good);  also added stub for non-working on STM32F1xx rtc_read_subseconds().

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_INTERRUPTIN_H
<> 149:156823d33999 17 #define MBED_INTERRUPTIN_H
<> 149:156823d33999 18
<> 149:156823d33999 19 #include "platform/platform.h"
<> 149:156823d33999 20
AnnaBridge 167:e84263d55307 21 #if defined (DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
<> 149:156823d33999 22
<> 149:156823d33999 23 #include "hal/gpio_api.h"
<> 149:156823d33999 24 #include "hal/gpio_irq_api.h"
<> 149:156823d33999 25 #include "platform/Callback.h"
<> 160:d5399cc887bb 26 #include "platform/mbed_critical.h"
<> 160:d5399cc887bb 27 #include "platform/mbed_toolchain.h"
AnnaBridge 168:9672193075cf 28 #include "platform/NonCopyable.h"
<> 149:156823d33999 29
<> 149:156823d33999 30 namespace mbed {
<> 149:156823d33999 31 /** \addtogroup drivers */
<> 149:156823d33999 32
<> 149:156823d33999 33 /** A digital interrupt input, used to call a function on a rising or falling edge
<> 149:156823d33999 34 *
AnnaBridge 167:e84263d55307 35 * @note Synchronization level: Interrupt safe
<> 149:156823d33999 36 *
<> 149:156823d33999 37 * Example:
<> 149:156823d33999 38 * @code
<> 149:156823d33999 39 * // Flash an LED while waiting for events
<> 149:156823d33999 40 *
<> 149:156823d33999 41 * #include "mbed.h"
<> 149:156823d33999 42 *
<> 149:156823d33999 43 * InterruptIn event(p16);
<> 149:156823d33999 44 * DigitalOut led(LED1);
<> 149:156823d33999 45 *
<> 149:156823d33999 46 * void trigger() {
<> 149:156823d33999 47 * printf("triggered!\n");
<> 149:156823d33999 48 * }
<> 149:156823d33999 49 *
<> 149:156823d33999 50 * int main() {
<> 149:156823d33999 51 * event.rise(&trigger);
<> 149:156823d33999 52 * while(1) {
<> 149:156823d33999 53 * led = !led;
<> 149:156823d33999 54 * wait(0.25);
<> 149:156823d33999 55 * }
<> 149:156823d33999 56 * }
<> 149:156823d33999 57 * @endcode
AnnaBridge 167:e84263d55307 58 * @ingroup drivers
<> 149:156823d33999 59 */
AnnaBridge 168:9672193075cf 60 class InterruptIn : private NonCopyable<InterruptIn> {
<> 149:156823d33999 61
<> 149:156823d33999 62 public:
<> 149:156823d33999 63
<> 149:156823d33999 64 /** Create an InterruptIn connected to the specified pin
<> 149:156823d33999 65 *
<> 149:156823d33999 66 * @param pin InterruptIn pin to connect to
<> 149:156823d33999 67 */
<> 149:156823d33999 68 InterruptIn(PinName pin);
<> 149:156823d33999 69 virtual ~InterruptIn();
<> 149:156823d33999 70
<> 149:156823d33999 71 /** Read the input, represented as 0 or 1 (int)
<> 149:156823d33999 72 *
<> 149:156823d33999 73 * @returns
<> 149:156823d33999 74 * An integer representing the state of the input pin,
<> 149:156823d33999 75 * 0 for logical 0, 1 for logical 1
<> 149:156823d33999 76 */
<> 149:156823d33999 77 int read();
<> 149:156823d33999 78
<> 149:156823d33999 79 /** An operator shorthand for read()
<> 149:156823d33999 80 */
<> 149:156823d33999 81 operator int();
<> 149:156823d33999 82
<> 149:156823d33999 83
<> 149:156823d33999 84 /** Attach a function to call when a rising edge occurs on the input
<> 149:156823d33999 85 *
<> 149:156823d33999 86 * @param func A pointer to a void function, or 0 to set as none
<> 149:156823d33999 87 */
<> 149:156823d33999 88 void rise(Callback<void()> func);
<> 149:156823d33999 89
<> 149:156823d33999 90 /** Attach a member function to call when a rising edge occurs on the input
<> 149:156823d33999 91 *
<> 149:156823d33999 92 * @param obj pointer to the object to call the member function on
<> 149:156823d33999 93 * @param method pointer to the member function to be called
<> 149:156823d33999 94 * @deprecated
<> 149:156823d33999 95 * The rise function does not support cv-qualifiers. Replaced by
<> 149:156823d33999 96 * rise(callback(obj, method)).
<> 149:156823d33999 97 */
<> 149:156823d33999 98 template<typename T, typename M>
<> 149:156823d33999 99 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 149:156823d33999 100 "The rise function does not support cv-qualifiers. Replaced by "
<> 149:156823d33999 101 "rise(callback(obj, method)).")
<> 149:156823d33999 102 void rise(T *obj, M method) {
<> 149:156823d33999 103 core_util_critical_section_enter();
<> 149:156823d33999 104 rise(callback(obj, method));
<> 149:156823d33999 105 core_util_critical_section_exit();
<> 149:156823d33999 106 }
<> 149:156823d33999 107
<> 149:156823d33999 108 /** Attach a function to call when a falling edge occurs on the input
<> 149:156823d33999 109 *
<> 149:156823d33999 110 * @param func A pointer to a void function, or 0 to set as none
<> 149:156823d33999 111 */
<> 149:156823d33999 112 void fall(Callback<void()> func);
<> 149:156823d33999 113
<> 149:156823d33999 114 /** Attach a member function to call when a falling edge occurs on the input
<> 149:156823d33999 115 *
<> 149:156823d33999 116 * @param obj pointer to the object to call the member function on
<> 149:156823d33999 117 * @param method pointer to the member function to be called
<> 149:156823d33999 118 * @deprecated
<> 149:156823d33999 119 * The rise function does not support cv-qualifiers. Replaced by
<> 149:156823d33999 120 * rise(callback(obj, method)).
<> 149:156823d33999 121 */
<> 149:156823d33999 122 template<typename T, typename M>
<> 149:156823d33999 123 MBED_DEPRECATED_SINCE("mbed-os-5.1",
<> 149:156823d33999 124 "The fall function does not support cv-qualifiers. Replaced by "
<> 149:156823d33999 125 "fall(callback(obj, method)).")
<> 149:156823d33999 126 void fall(T *obj, M method) {
<> 149:156823d33999 127 core_util_critical_section_enter();
<> 149:156823d33999 128 fall(callback(obj, method));
<> 149:156823d33999 129 core_util_critical_section_exit();
<> 149:156823d33999 130 }
<> 149:156823d33999 131
<> 149:156823d33999 132 /** Set the input pin mode
<> 149:156823d33999 133 *
AnnaBridge 167:e84263d55307 134 * @param pull PullUp, PullDown, PullNone
<> 149:156823d33999 135 */
<> 149:156823d33999 136 void mode(PinMode pull);
<> 149:156823d33999 137
<> 149:156823d33999 138 /** Enable IRQ. This method depends on hw implementation, might enable one
<> 149:156823d33999 139 * port interrupts. For further information, check gpio_irq_enable().
<> 149:156823d33999 140 */
<> 149:156823d33999 141 void enable_irq();
<> 149:156823d33999 142
<> 149:156823d33999 143 /** Disable IRQ. This method depends on hw implementation, might disable one
<> 149:156823d33999 144 * port interrupts. For further information, check gpio_irq_disable().
<> 149:156823d33999 145 */
<> 149:156823d33999 146 void disable_irq();
<> 149:156823d33999 147
<> 149:156823d33999 148 static void _irq_handler(uint32_t id, gpio_irq_event event);
<> 149:156823d33999 149
<> 149:156823d33999 150 protected:
<> 149:156823d33999 151 gpio_t gpio;
<> 149:156823d33999 152 gpio_irq_t gpio_irq;
<> 149:156823d33999 153
<> 149:156823d33999 154 Callback<void()> _rise;
<> 149:156823d33999 155 Callback<void()> _fall;
<> 149:156823d33999 156 };
<> 149:156823d33999 157
<> 149:156823d33999 158 } // namespace mbed
<> 149:156823d33999 159
<> 149:156823d33999 160 #endif
<> 149:156823d33999 161
<> 149:156823d33999 162 #endif