mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_ONSEMI/TARGET_NCS36510/ncs36510_lp_ticker_api.c@189:f392fc9709a3, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 22:31:08 2019 +0000
- Revision:
- 189:f392fc9709a3
- Parent:
- 186:707f6e361f3e
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 149:156823d33999 | 1 | /** |
<> | 149:156823d33999 | 2 | ******************************************************************************* |
<> | 149:156823d33999 | 3 | * @file lpticker.c |
<> | 149:156823d33999 | 4 | * @brief Implementation of a Low Power Ticker functionality based on RTC |
<> | 149:156823d33999 | 5 | * @internal |
<> | 149:156823d33999 | 6 | * @author ON Semiconductor |
<> | 149:156823d33999 | 7 | * $Rev: $ |
<> | 149:156823d33999 | 8 | * $Date: $ |
<> | 149:156823d33999 | 9 | ****************************************************************************** |
Anna Bridge |
186:707f6e361f3e | 10 | * Copyright 2016 Semiconductor Components Industries LLC (d/b/a �ON Semiconductor�). |
<> | 149:156823d33999 | 11 | * All rights reserved. This software and/or documentation is licensed by ON Semiconductor |
<> | 149:156823d33999 | 12 | * under limited terms and conditions. The terms and conditions pertaining to the software |
<> | 149:156823d33999 | 13 | * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf |
Anna Bridge |
186:707f6e361f3e | 14 | * (�ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software�) and |
<> | 149:156823d33999 | 15 | * if applicable the software license agreement. Do not use this software and/or |
<> | 149:156823d33999 | 16 | * documentation unless you have carefully read and you agree to the limited terms and |
<> | 149:156823d33999 | 17 | * conditions. By using this software and/or documentation, you agree to the limited |
<> | 149:156823d33999 | 18 | * terms and conditions. |
<> | 149:156823d33999 | 19 | * |
<> | 149:156823d33999 | 20 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
<> | 149:156823d33999 | 21 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
<> | 149:156823d33999 | 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
<> | 149:156823d33999 | 23 | * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, |
<> | 149:156823d33999 | 24 | * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
<> | 149:156823d33999 | 25 | * @endinternal |
<> | 149:156823d33999 | 26 | * |
<> | 149:156823d33999 | 27 | * @ingroup lpticker |
<> | 149:156823d33999 | 28 | * |
<> | 149:156823d33999 | 29 | * @details |
<> | 149:156823d33999 | 30 | * This is Low Power ticker derived from RTC |
<> | 149:156823d33999 | 31 | * |
<> | 149:156823d33999 | 32 | */ |
<> | 149:156823d33999 | 33 | |
<> | 149:156823d33999 | 34 | #include "device.h" |
Anna Bridge |
186:707f6e361f3e | 35 | #if DEVICE_LPTICKER |
<> | 149:156823d33999 | 36 | |
<> | 149:156823d33999 | 37 | #include "cmsis_nvic.h" |
<> | 149:156823d33999 | 38 | #include "lp_ticker_api.h" |
<> | 149:156823d33999 | 39 | #include "rtc.h" |
<> | 149:156823d33999 | 40 | #include "rtc_map.h" |
<> | 149:156823d33999 | 41 | |
<> | 149:156823d33999 | 42 | /* Initialize the RTC for low power ticker */ |
<> | 149:156823d33999 | 43 | void lp_ticker_init() |
<> | 149:156823d33999 | 44 | { |
<> | 149:156823d33999 | 45 | fRtcInit(); |
<> | 149:156823d33999 | 46 | } |
<> | 149:156823d33999 | 47 | |
<> | 149:156823d33999 | 48 | /* Return the current RTC counter value in us */ |
<> | 149:156823d33999 | 49 | uint32_t lp_ticker_read() |
<> | 149:156823d33999 | 50 | { |
<> | 149:156823d33999 | 51 | return (uint32_t)(fRtcRead() & 0xFFFFFFFF); /* TODO Truncating 64 bit value to 32 bit */ |
<> | 149:156823d33999 | 52 | } |
<> | 149:156823d33999 | 53 | |
<> | 149:156823d33999 | 54 | /* Set interrupt for specified time */ |
<> | 149:156823d33999 | 55 | void lp_ticker_set_interrupt(timestamp_t timestamp) |
<> | 149:156823d33999 | 56 | { |
<> | 149:156823d33999 | 57 | /* The RTC Match register needs to be Set to the RTC alarm value */ |
<> | 149:156823d33999 | 58 | fRtcSetInterrupt(timestamp); |
<> | 149:156823d33999 | 59 | } |
<> | 149:156823d33999 | 60 | |
AnnaBridge | 174:b96e65c34a4d | 61 | void lp_ticker_fire_interrupt(void) |
AnnaBridge | 174:b96e65c34a4d | 62 | { |
AnnaBridge | 174:b96e65c34a4d | 63 | NVIC_SetPendingIRQ(Rtc_IRQn); |
AnnaBridge | 174:b96e65c34a4d | 64 | } |
AnnaBridge | 174:b96e65c34a4d | 65 | |
<> | 149:156823d33999 | 66 | /** Disable low power ticker interrupt |
<> | 149:156823d33999 | 67 | * |
<> | 149:156823d33999 | 68 | */ |
<> | 149:156823d33999 | 69 | void lp_ticker_disable_interrupt(void) |
<> | 149:156823d33999 | 70 | { |
<> | 149:156823d33999 | 71 | fRtcDisableInterrupt(); |
<> | 149:156823d33999 | 72 | } |
<> | 149:156823d33999 | 73 | |
<> | 149:156823d33999 | 74 | /** Clear the low power ticker interrupt |
<> | 149:156823d33999 | 75 | * |
<> | 149:156823d33999 | 76 | */ |
<> | 149:156823d33999 | 77 | void lp_ticker_clear_interrupt(void) |
<> | 149:156823d33999 | 78 | { |
<> | 149:156823d33999 | 79 | fRtcClearInterrupt(); |
<> | 149:156823d33999 | 80 | } |
<> | 149:156823d33999 | 81 | |
Anna Bridge |
186:707f6e361f3e | 82 | #endif /* DEVICE_LPTICKER */ |