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