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:
149:156823d33999
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
<> 144:ef7eb2e8f9f7 1 /* mbed Microcontroller Library
<> 144:ef7eb2e8f9f7 2 * Copyright (c) 2006-2014 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_PINNAMES_H
<> 144:ef7eb2e8f9f7 17 #define MBED_PINNAMES_H
<> 144:ef7eb2e8f9f7 18
<> 144:ef7eb2e8f9f7 19 #include "cmsis.h"
<> 144:ef7eb2e8f9f7 20
<> 144:ef7eb2e8f9f7 21 #ifdef __cplusplus
<> 144:ef7eb2e8f9f7 22 extern "C" {
<> 144:ef7eb2e8f9f7 23 #endif
<> 144:ef7eb2e8f9f7 24
<> 144:ef7eb2e8f9f7 25 typedef enum {
<> 144:ef7eb2e8f9f7 26 PIN_INPUT,
<> 144:ef7eb2e8f9f7 27 PIN_OUTPUT
<> 144:ef7eb2e8f9f7 28 } PinDirection;
<> 144:ef7eb2e8f9f7 29
<> 144:ef7eb2e8f9f7 30 #define PORT_SHIFT 16
<> 144:ef7eb2e8f9f7 31 #define PIN_SHIFT 9
<> 144:ef7eb2e8f9f7 32
<> 144:ef7eb2e8f9f7 33 typedef enum {
<> 144:ef7eb2e8f9f7 34 // LPC11U68 Pin Names (PORT[19:16] + PIN[15:9] + IOCON offset[8:0])
<> 144:ef7eb2e8f9f7 35
<> 144:ef7eb2e8f9f7 36 P0_0 = (0 << PORT_SHIFT) | (0 << PIN_SHIFT) | 0x000,
<> 144:ef7eb2e8f9f7 37 P0_1 = (0 << PORT_SHIFT) | (1 << PIN_SHIFT) | 0x004,
<> 144:ef7eb2e8f9f7 38 P0_2 = (0 << PORT_SHIFT) | (2 << PIN_SHIFT) | 0x008,
<> 144:ef7eb2e8f9f7 39 P0_3 = (0 << PORT_SHIFT) | (3 << PIN_SHIFT) | 0x00C,
<> 144:ef7eb2e8f9f7 40 P0_4 = (0 << PORT_SHIFT) | (4 << PIN_SHIFT) | 0x010,
<> 144:ef7eb2e8f9f7 41 P0_5 = (0 << PORT_SHIFT) | (5 << PIN_SHIFT) | 0x014,
<> 144:ef7eb2e8f9f7 42 P0_6 = (0 << PORT_SHIFT) | (6 << PIN_SHIFT) | 0x018,
<> 144:ef7eb2e8f9f7 43 P0_7 = (0 << PORT_SHIFT) | (7 << PIN_SHIFT) | 0x01C,
<> 144:ef7eb2e8f9f7 44 P0_8 = (0 << PORT_SHIFT) | (8 << PIN_SHIFT) | 0x020,
<> 144:ef7eb2e8f9f7 45 P0_9 = (0 << PORT_SHIFT) | (9 << PIN_SHIFT) | 0x024,
<> 144:ef7eb2e8f9f7 46 P0_10= (0 << PORT_SHIFT) | (10<< PIN_SHIFT) | 0x028,
<> 144:ef7eb2e8f9f7 47 P0_11= (0 << PORT_SHIFT) | (11<< PIN_SHIFT) | 0x02C,
<> 144:ef7eb2e8f9f7 48 P0_12= (0 << PORT_SHIFT) | (12<< PIN_SHIFT) | 0x030,
<> 144:ef7eb2e8f9f7 49 P0_13= (0 << PORT_SHIFT) | (13<< PIN_SHIFT) | 0x034,
<> 144:ef7eb2e8f9f7 50 P0_14= (0 << PORT_SHIFT) | (14<< PIN_SHIFT) | 0x038,
<> 144:ef7eb2e8f9f7 51 P0_15= (0 << PORT_SHIFT) | (15<< PIN_SHIFT) | 0x03C,
<> 144:ef7eb2e8f9f7 52 P0_16= (0 << PORT_SHIFT) | (16<< PIN_SHIFT) | 0x040,
<> 144:ef7eb2e8f9f7 53 P0_17= (0 << PORT_SHIFT) | (17<< PIN_SHIFT) | 0x044,
<> 144:ef7eb2e8f9f7 54 P0_18= (0 << PORT_SHIFT) | (18<< PIN_SHIFT) | 0x048,
<> 144:ef7eb2e8f9f7 55 P0_19= (0 << PORT_SHIFT) | (19<< PIN_SHIFT) | 0x04C,
<> 144:ef7eb2e8f9f7 56 P0_20= (0 << PORT_SHIFT) | (20<< PIN_SHIFT) | 0x050,
<> 144:ef7eb2e8f9f7 57 P0_21= (0 << PORT_SHIFT) | (21<< PIN_SHIFT) | 0x054,
<> 144:ef7eb2e8f9f7 58 P0_22= (0 << PORT_SHIFT) | (22<< PIN_SHIFT) | 0x058,
<> 144:ef7eb2e8f9f7 59 P0_23= (0 << PORT_SHIFT) | (23<< PIN_SHIFT) | 0x05C,
<> 144:ef7eb2e8f9f7 60
<> 144:ef7eb2e8f9f7 61 P1_0 = (1 << PORT_SHIFT) | (0 << PIN_SHIFT) | 0x060,
<> 144:ef7eb2e8f9f7 62 P1_1 = (1 << PORT_SHIFT) | (1 << PIN_SHIFT) | 0x064,
<> 144:ef7eb2e8f9f7 63 P1_2 = (1 << PORT_SHIFT) | (2 << PIN_SHIFT) | 0x068,
<> 144:ef7eb2e8f9f7 64 P1_3 = (1 << PORT_SHIFT) | (3 << PIN_SHIFT) | 0x06C,
<> 144:ef7eb2e8f9f7 65 P1_4 = (1 << PORT_SHIFT) | (4 << PIN_SHIFT) | 0x070,
<> 144:ef7eb2e8f9f7 66 P1_5 = (1 << PORT_SHIFT) | (5 << PIN_SHIFT) | 0x074,
<> 144:ef7eb2e8f9f7 67 P1_6 = (1 << PORT_SHIFT) | (6 << PIN_SHIFT) | 0x078,
<> 144:ef7eb2e8f9f7 68 P1_7 = (1 << PORT_SHIFT) | (7 << PIN_SHIFT) | 0x07C,
<> 144:ef7eb2e8f9f7 69 P1_8 = (1 << PORT_SHIFT) | (8 << PIN_SHIFT) | 0x080,
<> 144:ef7eb2e8f9f7 70 P1_9 = (1 << PORT_SHIFT) | (9 << PIN_SHIFT) | 0x084,
<> 144:ef7eb2e8f9f7 71 P1_10= (1 << PORT_SHIFT) | (10<< PIN_SHIFT) | 0x088,
<> 144:ef7eb2e8f9f7 72 P1_11= (1 << PORT_SHIFT) | (11<< PIN_SHIFT) | 0x08C,
<> 144:ef7eb2e8f9f7 73 P1_12= (1 << PORT_SHIFT) | (12<< PIN_SHIFT) | 0x090,
<> 144:ef7eb2e8f9f7 74 P1_13= (1 << PORT_SHIFT) | (13<< PIN_SHIFT) | 0x094,
<> 144:ef7eb2e8f9f7 75 P1_14= (1 << PORT_SHIFT) | (14<< PIN_SHIFT) | 0x098,
<> 144:ef7eb2e8f9f7 76 P1_15= (1 << PORT_SHIFT) | (15<< PIN_SHIFT) | 0x09C,
<> 144:ef7eb2e8f9f7 77 P1_16= (1 << PORT_SHIFT) | (16<< PIN_SHIFT) | 0x0A0,
<> 144:ef7eb2e8f9f7 78 P1_17= (1 << PORT_SHIFT) | (17<< PIN_SHIFT) | 0x0A4,
<> 144:ef7eb2e8f9f7 79 P1_18= (1 << PORT_SHIFT) | (18<< PIN_SHIFT) | 0x0A8,
<> 144:ef7eb2e8f9f7 80 P1_19= (1 << PORT_SHIFT) | (19<< PIN_SHIFT) | 0x0AC,
<> 144:ef7eb2e8f9f7 81 P1_20= (1 << PORT_SHIFT) | (20<< PIN_SHIFT) | 0x0B0,
<> 144:ef7eb2e8f9f7 82 P1_21= (1 << PORT_SHIFT) | (21<< PIN_SHIFT) | 0x0B4,
<> 144:ef7eb2e8f9f7 83 P1_22= (1 << PORT_SHIFT) | (22<< PIN_SHIFT) | 0x0B8,
<> 144:ef7eb2e8f9f7 84 P1_23= (1 << PORT_SHIFT) | (23<< PIN_SHIFT) | 0x0BC,
<> 144:ef7eb2e8f9f7 85 P1_24= (1 << PORT_SHIFT) | (24<< PIN_SHIFT) | 0x0C0,
<> 144:ef7eb2e8f9f7 86 P1_25= (1 << PORT_SHIFT) | (25<< PIN_SHIFT) | 0x0C4,
<> 144:ef7eb2e8f9f7 87 P1_26= (1 << PORT_SHIFT) | (26<< PIN_SHIFT) | 0x0C8,
<> 144:ef7eb2e8f9f7 88 P1_27= (1 << PORT_SHIFT) | (27<< PIN_SHIFT) | 0x0CC,
<> 144:ef7eb2e8f9f7 89 P1_28= (1 << PORT_SHIFT) | (28<< PIN_SHIFT) | 0x0D0,
<> 144:ef7eb2e8f9f7 90 P1_29= (1 << PORT_SHIFT) | (29<< PIN_SHIFT) | 0x0D4,
<> 144:ef7eb2e8f9f7 91 P1_30= (1 << PORT_SHIFT) | (30<< PIN_SHIFT) | 0x0D8,
<> 144:ef7eb2e8f9f7 92 P1_31= (1 << PORT_SHIFT) | (31<< PIN_SHIFT) | 0x0DC,
<> 144:ef7eb2e8f9f7 93
<> 144:ef7eb2e8f9f7 94 P2_0 = (2 << PORT_SHIFT) | (0 << PIN_SHIFT) | 0x0F0,
<> 144:ef7eb2e8f9f7 95 P2_1 = (2 << PORT_SHIFT) | (1 << PIN_SHIFT) | 0x0F4,
<> 144:ef7eb2e8f9f7 96 P2_2 = (2 << PORT_SHIFT) | (2 << PIN_SHIFT) | 0x0FC,
<> 144:ef7eb2e8f9f7 97 P2_3 = (2 << PORT_SHIFT) | (3 << PIN_SHIFT) | 0x100,
<> 144:ef7eb2e8f9f7 98 P2_4 = (2 << PORT_SHIFT) | (4 << PIN_SHIFT) | 0x104,
<> 144:ef7eb2e8f9f7 99 P2_5 = (2 << PORT_SHIFT) | (5 << PIN_SHIFT) | 0x108,
<> 144:ef7eb2e8f9f7 100 P2_6 = (2 << PORT_SHIFT) | (6 << PIN_SHIFT) | 0x10C,
<> 144:ef7eb2e8f9f7 101 P2_7 = (2 << PORT_SHIFT) | (7 << PIN_SHIFT) | 0x110,
<> 144:ef7eb2e8f9f7 102 P2_8 = (2 << PORT_SHIFT) | (8 << PIN_SHIFT) | 0x114,
<> 144:ef7eb2e8f9f7 103 P2_9 = (2 << PORT_SHIFT) | (9 << PIN_SHIFT) | 0x118,
<> 144:ef7eb2e8f9f7 104 P2_10= (2 << PORT_SHIFT) | (10<< PIN_SHIFT) | 0x11C,
<> 144:ef7eb2e8f9f7 105 P2_11= (2 << PORT_SHIFT) | (11<< PIN_SHIFT) | 0x120,
<> 144:ef7eb2e8f9f7 106 P2_12= (2 << PORT_SHIFT) | (12<< PIN_SHIFT) | 0x124,
<> 144:ef7eb2e8f9f7 107 P2_13= (2 << PORT_SHIFT) | (13<< PIN_SHIFT) | 0x128,
<> 144:ef7eb2e8f9f7 108 P2_14= (2 << PORT_SHIFT) | (14<< PIN_SHIFT) | 0x12C,
<> 144:ef7eb2e8f9f7 109 P2_15= (2 << PORT_SHIFT) | (15<< PIN_SHIFT) | 0x130,
<> 144:ef7eb2e8f9f7 110 P2_16= (2 << PORT_SHIFT) | (16<< PIN_SHIFT) | 0x134,
<> 144:ef7eb2e8f9f7 111 P2_17= (2 << PORT_SHIFT) | (17<< PIN_SHIFT) | 0x138,
<> 144:ef7eb2e8f9f7 112 P2_18= (2 << PORT_SHIFT) | (18<< PIN_SHIFT) | 0x13C,
<> 144:ef7eb2e8f9f7 113 P2_19= (2 << PORT_SHIFT) | (19<< PIN_SHIFT) | 0x140,
<> 144:ef7eb2e8f9f7 114 P2_20= (2 << PORT_SHIFT) | (20<< PIN_SHIFT) | 0x144,
<> 144:ef7eb2e8f9f7 115 P2_21= (2 << PORT_SHIFT) | (21<< PIN_SHIFT) | 0x148,
<> 144:ef7eb2e8f9f7 116 P2_22= (2 << PORT_SHIFT) | (22<< PIN_SHIFT) | 0x14C,
<> 144:ef7eb2e8f9f7 117 P2_23= (2 << PORT_SHIFT) | (23<< PIN_SHIFT) | 0x150,
<> 144:ef7eb2e8f9f7 118
<> 144:ef7eb2e8f9f7 119 LED_RED = P2_17,
<> 144:ef7eb2e8f9f7 120 LED_GREEN = P2_16,
<> 144:ef7eb2e8f9f7 121 LED_BLUE = P2_18,
<> 144:ef7eb2e8f9f7 122
<> 144:ef7eb2e8f9f7 123 // mbed original LED naming
<> 144:ef7eb2e8f9f7 124 LED1 = LED_RED,
<> 144:ef7eb2e8f9f7 125 LED2 = LED_GREEN,
<> 144:ef7eb2e8f9f7 126 LED3 = LED_BLUE,
<> 144:ef7eb2e8f9f7 127 LED4 = LED_BLUE,
<> 144:ef7eb2e8f9f7 128
<> 144:ef7eb2e8f9f7 129 // Serial to USB pins
<> 144:ef7eb2e8f9f7 130 USBTX = P0_19,
<> 144:ef7eb2e8f9f7 131 USBRX = P0_18,
<> 144:ef7eb2e8f9f7 132
<> 144:ef7eb2e8f9f7 133 // Arduino Shield Receptacles Names
<> 144:ef7eb2e8f9f7 134 D0 = P0_18,
<> 144:ef7eb2e8f9f7 135 D1 = P0_19,
<> 144:ef7eb2e8f9f7 136 D2 = P1_18,
<> 144:ef7eb2e8f9f7 137 D3 = P1_24,
<> 144:ef7eb2e8f9f7 138 D4 = P1_19,
<> 144:ef7eb2e8f9f7 139 D5 = P1_26,
<> 144:ef7eb2e8f9f7 140 D6 = P1_27,
<> 144:ef7eb2e8f9f7 141 D7 = P1_25,
<> 144:ef7eb2e8f9f7 142 D8 = P1_28,
<> 144:ef7eb2e8f9f7 143 D9 = P2_3,
<> 144:ef7eb2e8f9f7 144 D10= P0_2,
<> 144:ef7eb2e8f9f7 145 D11= P0_9,
<> 144:ef7eb2e8f9f7 146 D12= P0_8,
<> 144:ef7eb2e8f9f7 147 D13= P1_29,
<> 144:ef7eb2e8f9f7 148 D14= P0_5,
<> 144:ef7eb2e8f9f7 149 D15= P0_4,
<> 144:ef7eb2e8f9f7 150
<> 144:ef7eb2e8f9f7 151 A0 = P1_9,
<> 144:ef7eb2e8f9f7 152 A1 = P0_14,
<> 144:ef7eb2e8f9f7 153 A2 = P0_13,
<> 144:ef7eb2e8f9f7 154 A3 = P0_12,
<> 144:ef7eb2e8f9f7 155 A4 = P0_5, // same port as SDA
<> 144:ef7eb2e8f9f7 156 A5 = P0_4, // same port as SCL
<> 144:ef7eb2e8f9f7 157 SDA= P0_5, // same port as A4
<> 144:ef7eb2e8f9f7 158 SCL= P0_4, // same port as A5
<> 144:ef7eb2e8f9f7 159
<> 144:ef7eb2e8f9f7 160 // Not connected
<> 144:ef7eb2e8f9f7 161 NC = (int)0xFFFFFFFF,
<> 144:ef7eb2e8f9f7 162 } PinName;
<> 144:ef7eb2e8f9f7 163
<> 144:ef7eb2e8f9f7 164 typedef enum {
<> 144:ef7eb2e8f9f7 165 PullUp = 2,
<> 144:ef7eb2e8f9f7 166 PullDown = 1,
<> 144:ef7eb2e8f9f7 167 PullNone = 0,
<> 144:ef7eb2e8f9f7 168 Repeater = 3,
<> 144:ef7eb2e8f9f7 169 OpenDrain = 4,
<> 144:ef7eb2e8f9f7 170 PullDefault = PullDown
<> 144:ef7eb2e8f9f7 171 } PinMode;
<> 144:ef7eb2e8f9f7 172
<> 144:ef7eb2e8f9f7 173 #define STDIO_UART_TX USBTX
<> 144:ef7eb2e8f9f7 174 #define STDIO_UART_RX USBRX
<> 144:ef7eb2e8f9f7 175 #define STDIO_UART UART_0
<> 144:ef7eb2e8f9f7 176
<> 144:ef7eb2e8f9f7 177 #ifdef __cplusplus
<> 144:ef7eb2e8f9f7 178 }
<> 144:ef7eb2e8f9f7 179 #endif
<> 144:ef7eb2e8f9f7 180
<> 144:ef7eb2e8f9f7 181 #endif