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:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

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