mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/mbed_overrides.c@189:f392fc9709a3, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 22:31:08 2019 +0000
- Revision:
- 189:f392fc9709a3
- Parent:
- 188:bcfe06ba3d64
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 168:9672193075cf | 1 | /* mbed Microcontroller Library |
AnnaBridge | 168:9672193075cf | 2 | * Copyright (c) 2017, STMicroelectronics |
AnnaBridge | 168:9672193075cf | 3 | * All rights reserved. |
AnnaBridge | 168:9672193075cf | 4 | * |
AnnaBridge | 168:9672193075cf | 5 | * Redistribution and use in source and binary forms, with or without |
AnnaBridge | 168:9672193075cf | 6 | * modification, are permitted provided that the following conditions are met: |
AnnaBridge | 168:9672193075cf | 7 | * |
AnnaBridge | 168:9672193075cf | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
AnnaBridge | 168:9672193075cf | 9 | * this list of conditions and the following disclaimer. |
AnnaBridge | 168:9672193075cf | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
AnnaBridge | 168:9672193075cf | 11 | * this list of conditions and the following disclaimer in the documentation |
AnnaBridge | 168:9672193075cf | 12 | * and/or other materials provided with the distribution. |
AnnaBridge | 168:9672193075cf | 13 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
AnnaBridge | 168:9672193075cf | 14 | * may be used to endorse or promote products derived from this software |
AnnaBridge | 168:9672193075cf | 15 | * without specific prior written permission. |
AnnaBridge | 168:9672193075cf | 16 | * |
AnnaBridge | 168:9672193075cf | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AnnaBridge | 168:9672193075cf | 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
AnnaBridge | 168:9672193075cf | 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 168:9672193075cf | 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
AnnaBridge | 168:9672193075cf | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
AnnaBridge | 168:9672193075cf | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
AnnaBridge | 168:9672193075cf | 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
AnnaBridge | 168:9672193075cf | 24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
AnnaBridge | 168:9672193075cf | 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
AnnaBridge | 168:9672193075cf | 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 168:9672193075cf | 27 | */ |
AnnaBridge | 168:9672193075cf | 28 | #include "cmsis.h" |
AnnaBridge | 168:9672193075cf | 29 | |
AnnaBridge | 187:0387e8f68319 | 30 | int mbed_sdk_inited = 0; |
AnnaBridge | 187:0387e8f68319 | 31 | |
AnnaBridge | 168:9672193075cf | 32 | // This function is called after RAM initialization and before main. |
AnnaBridge | 168:9672193075cf | 33 | void mbed_sdk_init() |
AnnaBridge | 168:9672193075cf | 34 | { |
AnnaBridge | 189:f392fc9709a3 | 35 | #if defined(__ICACHE_PRESENT) /* STM32F7 */ |
AnnaBridge | 181:57724642e740 | 36 | // The mbed_sdk_init can be called either during cold boot or during |
AnnaBridge | 181:57724642e740 | 37 | // application boot after bootloader has been executed. |
AnnaBridge | 181:57724642e740 | 38 | // In case the bootloader has already enabled the cache, |
AnnaBridge | 181:57724642e740 | 39 | // is is needed to not enable it again. |
AnnaBridge | 181:57724642e740 | 40 | if ((SCB->CCR & (uint32_t)SCB_CCR_IC_Msk) == 0) { // If ICache is disabled |
AnnaBridge | 181:57724642e740 | 41 | SCB_EnableICache(); |
AnnaBridge | 181:57724642e740 | 42 | } |
AnnaBridge | 181:57724642e740 | 43 | if ((SCB->CCR & (uint32_t)SCB_CCR_DC_Msk) == 0) { // If DCache is disabled |
AnnaBridge | 181:57724642e740 | 44 | SCB_EnableDCache(); |
AnnaBridge | 181:57724642e740 | 45 | } |
AnnaBridge | 189:f392fc9709a3 | 46 | #endif /* __ICACHE_PRESENT */ |
AnnaBridge | 181:57724642e740 | 47 | |
AnnaBridge | 168:9672193075cf | 48 | // Update the SystemCoreClock variable. |
AnnaBridge | 168:9672193075cf | 49 | SystemCoreClockUpdate(); |
AnnaBridge | 168:9672193075cf | 50 | HAL_Init(); |
AnnaBridge | 168:9672193075cf | 51 | |
AnnaBridge | 168:9672193075cf | 52 | /* Configure the System clock source, PLL Multiplier and Divider factors, |
AnnaBridge | 168:9672193075cf | 53 | AHB/APBx prescalers and Flash settings */ |
AnnaBridge | 168:9672193075cf | 54 | SetSysClock(); |
AnnaBridge | 168:9672193075cf | 55 | SystemCoreClockUpdate(); |
AnnaBridge | 187:0387e8f68319 | 56 | |
AnnaBridge | 188:bcfe06ba3d64 | 57 | /* Start LSI clock for RTC */ |
AnnaBridge | 188:bcfe06ba3d64 | 58 | #if DEVICE_RTC |
AnnaBridge | 188:bcfe06ba3d64 | 59 | #if !MBED_CONF_TARGET_LSE_AVAILABLE |
AnnaBridge | 188:bcfe06ba3d64 | 60 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
AnnaBridge | 188:bcfe06ba3d64 | 61 | |
AnnaBridge | 188:bcfe06ba3d64 | 62 | if (__HAL_RCC_GET_RTC_SOURCE() != RCC_RTCCLKSOURCE_NO_CLK) { |
AnnaBridge | 188:bcfe06ba3d64 | 63 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI; |
AnnaBridge | 188:bcfe06ba3d64 | 64 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; |
AnnaBridge | 188:bcfe06ba3d64 | 65 | RCC_OscInitStruct.LSIState = RCC_LSI_ON; |
AnnaBridge | 188:bcfe06ba3d64 | 66 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { |
AnnaBridge | 188:bcfe06ba3d64 | 67 | error("Init : cannot initialize LSI\n"); |
AnnaBridge | 188:bcfe06ba3d64 | 68 | } |
AnnaBridge | 188:bcfe06ba3d64 | 69 | } |
AnnaBridge | 188:bcfe06ba3d64 | 70 | #endif /* ! MBED_CONF_TARGET_LSE_AVAILABLE */ |
AnnaBridge | 188:bcfe06ba3d64 | 71 | #endif /* DEVICE_RTC */ |
AnnaBridge | 188:bcfe06ba3d64 | 72 | |
AnnaBridge | 187:0387e8f68319 | 73 | mbed_sdk_inited = 1; |
AnnaBridge | 168:9672193075cf | 74 | } |