mbed-os

Fork of mbed-os by erkin yucel

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 /* mbed Microcontroller Library
elessair 0:f269e3021894 2 * Copyright (c) 2015, STMicroelectronics
elessair 0:f269e3021894 3 * All rights reserved.
elessair 0:f269e3021894 4 *
elessair 0:f269e3021894 5 * Redistribution and use in source and binary forms, with or without
elessair 0:f269e3021894 6 * modification, are permitted provided that the following conditions are met:
elessair 0:f269e3021894 7 *
elessair 0:f269e3021894 8 * 1. Redistributions of source code must retain the above copyright notice,
elessair 0:f269e3021894 9 * this list of conditions and the following disclaimer.
elessair 0:f269e3021894 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
elessair 0:f269e3021894 11 * this list of conditions and the following disclaimer in the documentation
elessair 0:f269e3021894 12 * and/or other materials provided with the distribution.
elessair 0:f269e3021894 13 * 3. Neither the name of STMicroelectronics nor the names of its contributors
elessair 0:f269e3021894 14 * may be used to endorse or promote products derived from this software
elessair 0:f269e3021894 15 * without specific prior written permission.
elessair 0:f269e3021894 16 *
elessair 0:f269e3021894 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
elessair 0:f269e3021894 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
elessair 0:f269e3021894 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
elessair 0:f269e3021894 20 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
elessair 0:f269e3021894 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
elessair 0:f269e3021894 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
elessair 0:f269e3021894 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
elessair 0:f269e3021894 24 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
elessair 0:f269e3021894 25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
elessair 0:f269e3021894 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elessair 0:f269e3021894 27 */
elessair 0:f269e3021894 28 #include "cmsis.h"
elessair 0:f269e3021894 29 #include "us_ticker_api.h"
elessair 0:f269e3021894 30
elessair 0:f269e3021894 31 HAL_StatusTypeDef HAL_Init(void);
elessair 0:f269e3021894 32
elessair 0:f269e3021894 33 // This function is called after RAM initialization and before main.
elessair 0:f269e3021894 34 void mbed_sdk_init()
elessair 0:f269e3021894 35 {
elessair 0:f269e3021894 36 // Update the SystemCoreClock variable.
elessair 0:f269e3021894 37 SystemCoreClockUpdate();
elessair 0:f269e3021894 38 #if !defined(TOOLCHAIN_GCC_ARM)
elessair 0:f269e3021894 39 // Need to restart HAL driver after the RAM is initialized
elessair 0:f269e3021894 40 HAL_Init();
elessair 0:f269e3021894 41 #endif
elessair 0:f269e3021894 42 }
elessair 0:f269e3021894 43
elessair 0:f269e3021894 44
elessair 0:f269e3021894 45 /**
elessair 0:f269e3021894 46 * @brief This function provides accurate delay (in milliseconds) based
elessair 0:f269e3021894 47 * on variable incremented.
elessair 0:f269e3021894 48 * @note This function is the modified version of the __weak version contained in
elessair 0:f269e3021894 49 * stm32f7xx_hal.c, using us_ticker
elessair 0:f269e3021894 50 * @param Delay: specifies the delay time length, in milliseconds.
elessair 0:f269e3021894 51 * @retval None
elessair 0:f269e3021894 52 */
elessair 0:f269e3021894 53 void HAL_Delay(__IO uint32_t Delay)
elessair 0:f269e3021894 54 {
elessair 0:f269e3021894 55 uint32_t start = us_ticker_read();
elessair 0:f269e3021894 56 while ((us_ticker_read() - start) < (uint32_t)(Delay * 1000));
elessair 0:f269e3021894 57 }
elessair 0:f269e3021894 58