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