Modified for BG96

Fork of mbed-dev by mbed official

Committer:
Anna Bridge
Date:
Fri Jun 22 16:45:37 2018 +0100
Revision:
186:707f6e361f3e
Parent:
181:57724642e740
mbed-dev library. Release version 162

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 154:37f96f9d4de2 1 /* mbed Microcontroller Library
<> 154:37f96f9d4de2 2 *******************************************************************************
Anna Bridge 186:707f6e361f3e 3 * Copyright (c) 2018, STMicroelectronics
<> 154:37f96f9d4de2 4 * All rights reserved.
<> 154:37f96f9d4de2 5 *
<> 154:37f96f9d4de2 6 * Redistribution and use in source and binary forms, with or without
<> 154:37f96f9d4de2 7 * modification, are permitted provided that the following conditions are met:
<> 154:37f96f9d4de2 8 *
<> 154:37f96f9d4de2 9 * 1. Redistributions of source code must retain the above copyright notice,
<> 154:37f96f9d4de2 10 * this list of conditions and the following disclaimer.
<> 154:37f96f9d4de2 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
<> 154:37f96f9d4de2 12 * this list of conditions and the following disclaimer in the documentation
<> 154:37f96f9d4de2 13 * and/or other materials provided with the distribution.
<> 154:37f96f9d4de2 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
<> 154:37f96f9d4de2 15 * may be used to endorse or promote products derived from this software
<> 154:37f96f9d4de2 16 * without specific prior written permission.
<> 154:37f96f9d4de2 17 *
<> 154:37f96f9d4de2 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
<> 154:37f96f9d4de2 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<> 154:37f96f9d4de2 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 154:37f96f9d4de2 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
<> 154:37f96f9d4de2 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<> 154:37f96f9d4de2 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
<> 154:37f96f9d4de2 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
<> 154:37f96f9d4de2 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
<> 154:37f96f9d4de2 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<> 154:37f96f9d4de2 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 154:37f96f9d4de2 28 *******************************************************************************
<> 154:37f96f9d4de2 29 */
<> 154:37f96f9d4de2 30
<> 154:37f96f9d4de2 31 #ifndef MBED_RTC_API_HAL_H
<> 154:37f96f9d4de2 32 #define MBED_RTC_API_HAL_H
<> 154:37f96f9d4de2 33
<> 154:37f96f9d4de2 34 #include "rtc_api.h"
Anna Bridge 180:96ed750bd169 35 #include "lp_ticker_api.h"
<> 154:37f96f9d4de2 36
<> 154:37f96f9d4de2 37 #ifdef __cplusplus
<> 154:37f96f9d4de2 38 extern "C" {
<> 154:37f96f9d4de2 39 #endif
<> 154:37f96f9d4de2 40
Anna Bridge 180:96ed750bd169 41 #if MBED_CONF_TARGET_LSE_AVAILABLE
Anna Bridge 180:96ed750bd169 42 #define RTC_CLOCK LSE_VALUE
Anna Bridge 180:96ed750bd169 43 #else
Anna Bridge 180:96ed750bd169 44 #define RTC_CLOCK LSI_VALUE
Anna Bridge 180:96ed750bd169 45 #endif
<> 154:37f96f9d4de2 46
Anna Bridge 186:707f6e361f3e 47 #if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
Anna Bridge 186:707f6e361f3e 48 /* PREDIV_A : 7-bit asynchronous prescaler */
Anna Bridge 186:707f6e361f3e 49 /* PREDIV_A is set to set LPTICKER frequency to RTC_CLOCK/4 */
Anna Bridge 186:707f6e361f3e 50 #define PREDIV_A_VALUE 3
<> 154:37f96f9d4de2 51
Anna Bridge 186:707f6e361f3e 52 /** Read RTC counter with sub second precision
Anna Bridge 186:707f6e361f3e 53 *
Anna Bridge 186:707f6e361f3e 54 * @return LP ticker counter
Anna Bridge 186:707f6e361f3e 55 */
Anna Bridge 186:707f6e361f3e 56 uint32_t rtc_read_lp(void);
Anna Bridge 186:707f6e361f3e 57
Anna Bridge 186:707f6e361f3e 58 /** Program a wake up timer event
<> 154:37f96f9d4de2 59 *
Anna Bridge 186:707f6e361f3e 60 * @param timestamp: counter to set
<> 154:37f96f9d4de2 61 */
Anna Bridge 186:707f6e361f3e 62 void rtc_set_wake_up_timer(timestamp_t timestamp);
Anna Bridge 186:707f6e361f3e 63
Anna Bridge 186:707f6e361f3e 64 /** Call RTC Wake Up IT
Anna Bridge 186:707f6e361f3e 65 */
Anna Bridge 186:707f6e361f3e 66 void rtc_fire_interrupt(void);
<> 154:37f96f9d4de2 67
<> 154:37f96f9d4de2 68 /** Disable the wake up timer event.
<> 154:37f96f9d4de2 69 *
<> 154:37f96f9d4de2 70 * The wake up timer use auto reload, you have to deactivate it manually.
<> 154:37f96f9d4de2 71 */
<> 154:37f96f9d4de2 72 void rtc_deactivate_wake_up_timer(void);
<> 154:37f96f9d4de2 73
Anna Bridge 186:707f6e361f3e 74 #else /* DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM */
Anna Bridge 186:707f6e361f3e 75
Anna Bridge 186:707f6e361f3e 76 /* PREDIV_A : 7-bit asynchronous prescaler */
Anna Bridge 186:707f6e361f3e 77 /* PREDIV_A is set to the maximum value to improve the consumption */
Anna Bridge 186:707f6e361f3e 78 #define PREDIV_A_VALUE 127
Anna Bridge 186:707f6e361f3e 79
Anna Bridge 186:707f6e361f3e 80 #endif /* DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM */
Anna Bridge 186:707f6e361f3e 81
Anna Bridge 186:707f6e361f3e 82 /* PREDIV_S : 15-bit synchronous prescaler */
Anna Bridge 186:707f6e361f3e 83 /* PREDIV_S is set in order to get a 1 Hz clock */
Anna Bridge 186:707f6e361f3e 84 #define PREDIV_S_VALUE RTC_CLOCK / (PREDIV_A_VALUE + 1) - 1
Anna Bridge 186:707f6e361f3e 85
<> 154:37f96f9d4de2 86 /** Synchronise the RTC shadow registers.
<> 154:37f96f9d4de2 87 *
<> 154:37f96f9d4de2 88 * Must be called after a deepsleep.
<> 154:37f96f9d4de2 89 */
<> 154:37f96f9d4de2 90 void rtc_synchronize(void);
<> 154:37f96f9d4de2 91
<> 154:37f96f9d4de2 92 #ifdef __cplusplus
<> 154:37f96f9d4de2 93 }
<> 154:37f96f9d4de2 94 #endif
<> 154:37f96f9d4de2 95
<> 154:37f96f9d4de2 96 #endif