Modified for BG96
Fork of mbed-dev by
Diff: targets/TARGET_STM/rtc_api_hal.h
- Revision:
- 186:707f6e361f3e
- Parent:
- 181:57724642e740
--- a/targets/TARGET_STM/rtc_api_hal.h Thu Apr 19 17:12:19 2018 +0100 +++ b/targets/TARGET_STM/rtc_api_hal.h Fri Jun 22 16:45:37 2018 +0100 @@ -1,6 +1,6 @@ /* mbed Microcontroller Library ******************************************************************************* -* Copyright (c) 2017, STMicroelectronics +* Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,15 +31,8 @@ #ifndef MBED_RTC_API_HAL_H #define MBED_RTC_API_HAL_H -#include <stdint.h> #include "rtc_api.h" -#include "ticker_api.h" #include "lp_ticker_api.h" -#include "us_ticker_api.h" -#include "hal_tick.h" -#include "mbed_critical.h" -#include "mbed_error.h" -#include "mbed_debug.h" #ifdef __cplusplus extern "C" { @@ -51,17 +44,26 @@ #define RTC_CLOCK LSI_VALUE #endif -/** Read RTC time with subsecond precision. - * - * @return Time is microsecond - */ -uint32_t rtc_read_us(void); +#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM +/* PREDIV_A : 7-bit asynchronous prescaler */ +/* PREDIV_A is set to set LPTICKER frequency to RTC_CLOCK/4 */ +#define PREDIV_A_VALUE 3 -/** Program a wake up timer event in delta microseconds. +/** Read RTC counter with sub second precision + * + * @return LP ticker counter + */ +uint32_t rtc_read_lp(void); + +/** Program a wake up timer event * - * @param delta The time to wait + * @param timestamp: counter to set */ -void rtc_set_wake_up_timer(uint32_t delta); +void rtc_set_wake_up_timer(timestamp_t timestamp); + +/** Call RTC Wake Up IT + */ +void rtc_fire_interrupt(void); /** Disable the wake up timer event. * @@ -69,13 +71,24 @@ */ void rtc_deactivate_wake_up_timer(void); +#else /* DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM */ + +/* PREDIV_A : 7-bit asynchronous prescaler */ +/* PREDIV_A is set to the maximum value to improve the consumption */ +#define PREDIV_A_VALUE 127 + +#endif /* DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM */ + +/* PREDIV_S : 15-bit synchronous prescaler */ +/* PREDIV_S is set in order to get a 1 Hz clock */ +#define PREDIV_S_VALUE RTC_CLOCK / (PREDIV_A_VALUE + 1) - 1 + /** Synchronise the RTC shadow registers. * * Must be called after a deepsleep. */ void rtc_synchronize(void); - #ifdef __cplusplus } #endif