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.

Committer:
Anna Bridge
Date:
Wed Jan 17 16:13:02 2018 +0000
Revision:
160:5571c4ff569f
Parent:
123:b0220dba8be7
Child:
163:e59c8e839560
mbed library. Release version 158

Who changed what in which revision?

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