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:
148:fd96258d940d
Child:
163:e59c8e839560
Release 151 of the mbed library.

Who changed what in which revision?

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