The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_UBLOX_EVA_NINA/TARGET_NORDIC/TARGET_NRF5/common_rtc.h@151:675da3299148, 2017-09-15 (annotated)
- Committer:
- AnnaBridge
- Date:
- Fri Sep 15 14:46:57 2017 +0100
- Revision:
- 151:675da3299148
- Parent:
- 132:9baf128c2fab
- Child:
- 163:e59c8e839560
Release 151 of the mbed library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 132:9baf128c2fab | 1 | /* mbed Microcontroller Library |
<> | 132:9baf128c2fab | 2 | * Copyright (c) 2015 ARM Limited |
<> | 132:9baf128c2fab | 3 | * |
<> | 132:9baf128c2fab | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 132:9baf128c2fab | 5 | * you may not use this file except in compliance with the License. |
<> | 132:9baf128c2fab | 6 | * You may obtain a copy of the License at |
<> | 132:9baf128c2fab | 7 | * |
<> | 132:9baf128c2fab | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 132:9baf128c2fab | 9 | * |
<> | 132:9baf128c2fab | 10 | * Unless required by applicable law or agreed to in writing, software |
<> | 132:9baf128c2fab | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 132:9baf128c2fab | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 132:9baf128c2fab | 13 | * See the License for the specific language governing permissions and |
<> | 132:9baf128c2fab | 14 | * limitations under the License. |
<> | 132:9baf128c2fab | 15 | */ |
<> | 132:9baf128c2fab | 16 | |
<> | 132:9baf128c2fab | 17 | #ifndef COMMON_RTC_H |
<> | 132:9baf128c2fab | 18 | #define COMMON_RTC_H |
<> | 132:9baf128c2fab | 19 | |
<> | 132:9baf128c2fab | 20 | #include "nrf_rtc.h" |
<> | 132:9baf128c2fab | 21 | |
<> | 132:9baf128c2fab | 22 | #define RTC_COUNTER_BITS 24u |
<> | 132:9baf128c2fab | 23 | |
<> | 132:9baf128c2fab | 24 | // Instance 0 is reserved for SoftDevice. |
<> | 132:9baf128c2fab | 25 | // Instance 1 is used as a common one for us_ticker, lp_ticker and (in case |
<> | 132:9baf128c2fab | 26 | // of NRF51) as an alternative tick source for RTOS. |
<> | 132:9baf128c2fab | 27 | // ["us_ticker.c" uses hard coded addresses of the 'NRF_RTC1->EVENT_COMPARE[1]' |
<> | 132:9baf128c2fab | 28 | // register in inline assembly implementations of COMMON_RTC_IRQ_HANDLER, |
<> | 132:9baf128c2fab | 29 | // please remember to update those in case of doing changes here] |
<> | 132:9baf128c2fab | 30 | #define COMMON_RTC_INSTANCE NRF_RTC1 |
<> | 132:9baf128c2fab | 31 | #define COMMON_RTC_IRQ_HANDLER RTC1_IRQHandler |
<> | 132:9baf128c2fab | 32 | #define US_TICKER_CC_CHANNEL 0 |
<> | 132:9baf128c2fab | 33 | #define OS_TICK_CC_CHANNEL 1 |
<> | 132:9baf128c2fab | 34 | #define LP_TICKER_CC_CHANNEL 2 |
<> | 132:9baf128c2fab | 35 | |
<> | 132:9baf128c2fab | 36 | #define COMMON_RTC_EVENT_COMPARE(channel) \ |
<> | 132:9baf128c2fab | 37 | CONCAT_2(NRF_RTC_EVENT_COMPARE_, channel) |
<> | 132:9baf128c2fab | 38 | #define COMMON_RTC_INT_COMPARE_MASK(channel) \ |
<> | 132:9baf128c2fab | 39 | CONCAT_3(NRF_RTC_INT_COMPARE, channel, _MASK) |
<> | 132:9baf128c2fab | 40 | |
<> | 132:9baf128c2fab | 41 | #define US_TICKER_EVENT COMMON_RTC_EVENT_COMPARE(US_TICKER_CC_CHANNEL) |
<> | 132:9baf128c2fab | 42 | #define US_TICKER_INT_MASK COMMON_RTC_INT_COMPARE_MASK(US_TICKER_CC_CHANNEL) |
<> | 132:9baf128c2fab | 43 | #define OS_TICK_EVENT COMMON_RTC_EVENT_COMPARE(OS_TICK_CC_CHANNEL) |
<> | 132:9baf128c2fab | 44 | #define OS_TICK_INT_MASK COMMON_RTC_INT_COMPARE_MASK(OS_TICK_CC_CHANNEL) |
<> | 132:9baf128c2fab | 45 | #define LP_TICKER_EVENT COMMON_RTC_EVENT_COMPARE(LP_TICKER_CC_CHANNEL) |
<> | 132:9baf128c2fab | 46 | #define LP_TICKER_INT_MASK COMMON_RTC_INT_COMPARE_MASK(LP_TICKER_CC_CHANNEL) |
<> | 132:9baf128c2fab | 47 | |
<> | 132:9baf128c2fab | 48 | extern bool m_common_rtc_enabled; |
<> | 132:9baf128c2fab | 49 | extern uint32_t volatile m_common_rtc_overflows; |
<> | 132:9baf128c2fab | 50 | |
<> | 132:9baf128c2fab | 51 | void common_rtc_init(void); |
<> | 132:9baf128c2fab | 52 | uint32_t common_rtc_32bit_ticks_get(void); |
<> | 132:9baf128c2fab | 53 | uint64_t common_rtc_64bit_us_get(void); |
<> | 132:9baf128c2fab | 54 | void common_rtc_set_interrupt(uint32_t us_timestamp, uint32_t cc_channel, |
<> | 132:9baf128c2fab | 55 | uint32_t int_mask); |
<> | 132:9baf128c2fab | 56 | |
<> | 132:9baf128c2fab | 57 | #endif // COMMON_RTC_H |