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:
AnnaBridge
Date:
Fri Sep 15 14:46:57 2017 +0100
Revision:
151:675da3299148
Parent:
143:86740a56073b
Child:
163:e59c8e839560
Release 151 of the mbed library.

Who changed what in which revision?

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