CC26xx Driver Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
aon_rtc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aon_rtc.h
3 * Revised: 2015-01-14 12:12:44 +0100 (on, 14 jan 2015)
4 * Revision: 42373
5 *
6 * Description: Defines and prototypes for the AON RTC
7 *
8 * Copyright (c) 2015, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 //*****************************************************************************
40 //
43 //
44 //*****************************************************************************
45 
46 #ifndef __AON_RTC_H__
47 #define __AON_RTC_H__
48 
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59 
60 #include <stdbool.h>
61 #include <stdint.h>
62 #include <inc/hw_types.h>
63 #include <inc/hw_memmap.h>
64 #include <inc/hw_aon_rtc.h>
65 #include <driverlib/debug.h>
66 
67 //*****************************************************************************
68 //
69 // Support for DriverLib in ROM:
70 // This section renames all functions that are not "static inline", so that
71 // calling these functions will default to implementation in flash. At the end
72 // of this file a second renaming will change the defaults to implementation in
73 // ROM for available functions.
74 //
75 // To force use of the implementation in flash, e.g. for debugging:
76 // - Globally: Define DRIVERLIB_NOROM at project level
77 // - Per function: Use prefix "NOROM_" when calling the function
78 //
79 // Do not define DRIVERLIB_GENERATE_ROM!
80 //
81 //*****************************************************************************
82 #ifndef DRIVERLIB_GENERATE_ROM
83  #define AONRTCStatus NOROM_AONRTCStatus
84  #define AONRTCEventClear NOROM_AONRTCEventClear
85  #define AONRTCEventGet NOROM_AONRTCEventGet
86  #define AONRTCModeCh1Set NOROM_AONRTCModeCh1Set
87  #define AONRTCModeCh1Get NOROM_AONRTCModeCh1Get
88  #define AONRTCModeCh2Set NOROM_AONRTCModeCh2Set
89  #define AONRTCModeCh2Get NOROM_AONRTCModeCh2Get
90  #define AONRTCChannelEnable NOROM_AONRTCChannelEnable
91  #define AONRTCChannelDisable NOROM_AONRTCChannelDisable
92  #define AONRTCCompareValueSet NOROM_AONRTCCompareValueSet
93  #define AONRTCCompareValueGet NOROM_AONRTCCompareValueGet
94 #endif
95 
96 //*****************************************************************************
97 //
98 // Values that can be passed to most of the AON_RTC APIs as the ui32Channel
99 // parameter.
100 //
101 //*****************************************************************************
102 #define AON_RTC_CH_NONE 0x0 // RTC No channel
103 #define AON_RTC_CH0 0x1 // RTC Channel 0
104 #define AON_RTC_CH1 0x2 // RTC Channel 1
105 #define AON_RTC_CH2 0x4 // RTC Channel 2
106 #define AON_RTC_ACTIVE 0x8 // RTC Active
107 
108 //*****************************************************************************
109 //
110 // Values that can be passed to AONRTCConfigDelay as the ui32Delay parameter.
111 //
112 //*****************************************************************************
113 #define AON_RTC_CONFIG_DELAY_NODELAY 0 // NO DELAY
114 #define AON_RTC_CONFIG_DELAY_1 1 // Delay of 1 clk cycle
115 #define AON_RTC_CONFIG_DELAY_2 2 // Delay of 2 clk cycles
116 #define AON_RTC_CONFIG_DELAY_4 3 // Delay of 4 clk cycles
117 #define AON_RTC_CONFIG_DELAY_8 4 // Delay of 8 clk cycles
118 #define AON_RTC_CONFIG_DELAY_16 5 // Delay of 16 clk cycles
119 #define AON_RTC_CONFIG_DELAY_32 6 // Delay of 32 clk cycles
120 #define AON_RTC_CONFIG_DELAY_48 7 // Delay of 48 clk cycles
121 #define AON_RTC_CONFIG_DELAY_64 8 // Delay of 64 clk cycles
122 #define AON_RTC_CONFIG_DELAY_80 9 // Delay of 80 clk cycles
123 #define AON_RTC_CONFIG_DELAY_96 10 // Delay of 96 clk cycles
124 #define AON_RTC_CONFIG_DELAY_112 11 // Delay of 112 clk cycles
125 #define AON_RTC_CONFIG_DELAY_128 12 // Delay of 128 clk cycles
126 #define AON_RTC_CONFIG_DELAY_144 13 // Delay of 144 clk cycles
127 #define AON_RTC_CONFIG_DELAY_160 14 // Delay of 160 clk cycles
128 #define AON_RTC_CONFIG_DELAY_176 15 // Delay of 176 clk cycles
129 
130 //*****************************************************************************
131 //
132 // Values that can be passed to AONRTCSetModeCH1 as the ui32Mode
133 // parameter.
134 //
135 //*****************************************************************************
136 #define AON_RTC_MODE_CH1_CAPTURE 1 // Capture mode
137 #define AON_RTC_MODE_CH1_COMPARE 0 // Compare Mode
138 
139 //*****************************************************************************
140 //
141 // Values that can be passed to AONRTCSetModeCH2 as the ui32Mode
142 // parameter.
143 //
144 //*****************************************************************************
145 #define AON_RTC_MODE_CH2_CONTINUOUS 1 // Continuous mode
146 #define AON_RTC_MODE_CH2_NORMALCOMPARE 0 // Normal compare mode
147 
148 //*****************************************************************************
149 //
150 // API Functions and prototypes
151 //
152 //*****************************************************************************
153 
154 //*****************************************************************************
155 //
166 //
167 //*****************************************************************************
168 __STATIC_INLINE void
170 {
171  //
172  // Enable RTC.
173  //
175 }
176 
177 //*****************************************************************************
178 //
189 //
190 //*****************************************************************************
191 __STATIC_INLINE void
193 {
194  //
195  // Disable RTC
196  //
198 }
199 
200 //*****************************************************************************
201 //
220 //
221 //*****************************************************************************
222 extern uint32_t AONRTCStatus(void);
223 
224 //*****************************************************************************
225 //
231 //
232 //*****************************************************************************
233 __STATIC_INLINE void
235 {
236  //
237  // Reset RTC.
238  //
240 }
241 
242 //*****************************************************************************
243 //
272 //
273 //*****************************************************************************
274 __STATIC_INLINE void
275 AONRTCDelayConfig(uint32_t ui32Delay)
276 {
277  uint32_t ui32Cfg;
278 
279  //
280  // Check the arguments.
281  //
282  ASSERT(ui32Delay <= AON_RTC_CONFIG_DELAY_176);
283 
284 
285  ui32Cfg = HWREG(AON_RTC_BASE + AON_RTC_O_CTL);
286  ui32Cfg &= ~(AON_RTC_CTL_EV_DELAY_M);
287  ui32Cfg |= (ui32Delay << AON_RTC_CTL_EV_DELAY_S);
288 
289  HWREG(AON_RTC_BASE + AON_RTC_O_CTL) = ui32Cfg;
290 }
291 
292 //*****************************************************************************
293 //
309 //
310 //*****************************************************************************
311 __STATIC_INLINE void
312 AONRTCCombinedEventConfig(uint32_t ui32Channels)
313 {
314  uint32_t ui32Cfg;
315 
316  //
317  // Check the arguments.
318  //
319  ASSERT(ui32Channels & (AON_RTC_CH0 | AON_RTC_CH1 | AON_RTC_CH2));
320 
321  ui32Cfg = HWREG(AON_RTC_BASE + AON_RTC_O_CTL);
322  ui32Cfg &= ~(AON_RTC_CTL_COMB_EV_MASK_M);
323  ui32Cfg |= (ui32Channels << AON_RTC_CTL_COMB_EV_MASK_S);
324 
325  HWREG(AON_RTC_BASE + AON_RTC_O_CTL) = ui32Cfg;
326 }
327 
328 //*****************************************************************************
329 //
341 //
342 //*****************************************************************************
343 extern void AONRTCEventClear(uint32_t ui32Channel);
344 
345 //*****************************************************************************
346 //
360 //
361 //*****************************************************************************
362 extern bool AONRTCEventGet(uint32_t ui32Channel);
363 
364 //*****************************************************************************
365 //
378 //
379 //*****************************************************************************
380 __STATIC_INLINE uint32_t
382 {
383  //
384  // The following read gets the seconds, but also latches the fractional
385  // part.
386  //
387  return(HWREG(AON_RTC_BASE + AON_RTC_O_SEC));
388 }
389 
390 //*****************************************************************************
391 //
404 //
405 //*****************************************************************************
406 __STATIC_INLINE uint32_t
408 {
409  //
410  // Note: AONRTCSecGet() must be called before this function to get a
411  // consistent reading.
412  //
413  return(HWREG(AON_RTC_BASE + AON_RTC_O_SUBSEC));
414 }
415 
416 //*****************************************************************************
417 //
432 //
433 //*****************************************************************************
434 __STATIC_INLINE uint32_t
436 {
437  //
438  // Note: AONRTCSecGet() must be called before this function to get a
439  // consistent reading.
440  //
441  return(HWREG(AON_RTC_BASE + AON_RTC_O_SUBSECINC));
442 }
443 
444 //*****************************************************************************
445 //
462 //
463 //*****************************************************************************
464 extern void AONRTCModeCh1Set(uint32_t ui32Mode);
465 
466 //*****************************************************************************
467 //
479 //
480 //*****************************************************************************
481 extern uint32_t AONRTCModeCh1Get(void);
482 
483 //*****************************************************************************
484 //
504 //
505 //*****************************************************************************
506 extern void AONRTCModeCh2Set(uint32_t ui32Mode);
507 
508 //*****************************************************************************
509 //
524 //
525 //*****************************************************************************
526 extern uint32_t AONRTCModeCh2Get(void);
527 
528 //*****************************************************************************
529 //
546 //
547 //*****************************************************************************
548 extern void AONRTCChannelEnable(uint32_t ui32Channel);
549 
550 //*****************************************************************************
551 //
568 //
569 //*****************************************************************************
570 extern void AONRTCChannelDisable(uint32_t ui32Channel);
571 
572 //*****************************************************************************
573 //
593 //
594 //*****************************************************************************
595 extern void AONRTCCompareValueSet(uint32_t ui32Channel,
596  uint32_t ui32CompValue);
597 
598 //*****************************************************************************
599 //
611 //
612 //*****************************************************************************
613 extern uint32_t AONRTCCompareValueGet(uint32_t ui32Channel);
614 
615 //*****************************************************************************
616 //
628 //
629 //*****************************************************************************
630 __STATIC_INLINE uint32_t
632 {
633  uint32_t ui32CurrentSec ;
634  uint32_t ui32CurrentSubSec ;
635 
636  //
637  // Make sure that SEC is read before SUBSEC since SUBSEC will be
638  // latched by hardware when SEC is read and hence guarantee that
639  // the two registers represents the same timestamp.
640  //
641  ui32CurrentSec = HWREG( AON_RTC_BASE + AON_RTC_O_SEC );
642  ui32CurrentSubSec = HWREG( AON_RTC_BASE + AON_RTC_O_SUBSEC );
643 
644  return (( ui32CurrentSec << 16 ) | ( ui32CurrentSubSec >> 16 ));
645 }
646 
647 //*****************************************************************************
648 //
661 //
662 //*****************************************************************************
663 __STATIC_INLINE void
664 AONRTCIncValueCh2Set(uint32_t ui32IncValue)
665 {
666  HWREG(AON_RTC_BASE + AON_RTC_O_CH2CMPINC) = ui32IncValue;
667 }
668 
669 //*****************************************************************************
670 //
683 //
684 //*****************************************************************************
685 __STATIC_INLINE uint32_t
687 {
688  return (HWREG(AON_RTC_BASE + AON_RTC_O_CH2CMPINC));
689 }
690 
691 //*****************************************************************************
692 //
701 //
702 //*****************************************************************************
703 __STATIC_INLINE uint32_t
705 {
706  return (HWREG(AON_RTC_BASE + AON_RTC_O_CH1CAPT));
707 }
708 
709 //*****************************************************************************
710 //
711 // Support for DriverLib in ROM:
712 // Redirect to implementation in ROM when available.
713 //
714 //*****************************************************************************
715 #ifndef DRIVERLIB_NOROM
716  #include <driverlib/rom.h>
717  #ifdef ROM_AONRTCStatus
718  #undef AONRTCStatus
719  #define AONRTCStatus ROM_AONRTCStatus
720  #endif
721  #ifdef ROM_AONRTCEventClear
722  #undef AONRTCEventClear
723  #define AONRTCEventClear ROM_AONRTCEventClear
724  #endif
725  #ifdef ROM_AONRTCEventGet
726  #undef AONRTCEventGet
727  #define AONRTCEventGet ROM_AONRTCEventGet
728  #endif
729  #ifdef ROM_AONRTCModeCh1Set
730  #undef AONRTCModeCh1Set
731  #define AONRTCModeCh1Set ROM_AONRTCModeCh1Set
732  #endif
733  #ifdef ROM_AONRTCModeCh1Get
734  #undef AONRTCModeCh1Get
735  #define AONRTCModeCh1Get ROM_AONRTCModeCh1Get
736  #endif
737  #ifdef ROM_AONRTCModeCh2Set
738  #undef AONRTCModeCh2Set
739  #define AONRTCModeCh2Set ROM_AONRTCModeCh2Set
740  #endif
741  #ifdef ROM_AONRTCModeCh2Get
742  #undef AONRTCModeCh2Get
743  #define AONRTCModeCh2Get ROM_AONRTCModeCh2Get
744  #endif
745  #ifdef ROM_AONRTCChannelEnable
746  #undef AONRTCChannelEnable
747  #define AONRTCChannelEnable ROM_AONRTCChannelEnable
748  #endif
749  #ifdef ROM_AONRTCChannelDisable
750  #undef AONRTCChannelDisable
751  #define AONRTCChannelDisable ROM_AONRTCChannelDisable
752  #endif
753  #ifdef ROM_AONRTCCompareValueSet
754  #undef AONRTCCompareValueSet
755  #define AONRTCCompareValueSet ROM_AONRTCCompareValueSet
756  #endif
757  #ifdef ROM_AONRTCCompareValueGet
758  #undef AONRTCCompareValueGet
759  #define AONRTCCompareValueGet ROM_AONRTCCompareValueGet
760  #endif
761 #endif
762 
763 //*****************************************************************************
764 //
765 // Mark the end of the C bindings section for C++ compilers.
766 //
767 //*****************************************************************************
768 #ifdef __cplusplus
769 }
770 #endif
771 
772 #endif // __AON_RTC_H__
773 
774 //*****************************************************************************
775 //
778 //
779 //*****************************************************************************
#define AON_RTC_CH1
Definition: aon_rtc.h:104
uint32_t AONRTCModeCh1Get(void)
Get operational mode of channel 1.
Definition: aon_rtc.c:195
void AONRTCCompareValueSet(uint32_t ui32Channel, uint32_t ui32CompValue)
Set the compare value for the given channel.
Definition: aon_rtc.c:313
bool AONRTCEventGet(uint32_t ui32Channel)
Get event status for a specified channel.
Definition: aon_rtc.c:137
uint32_t AONRTCCompareValueGet(uint32_t ui32Channel)
Get the compare value for the given channel.
Definition: aon_rtc.c:342
__STATIC_INLINE void AONRTCReset(void)
Reset the RTC.
Definition: aon_rtc.h:234
void AONRTCModeCh2Set(uint32_t ui32Mode)
Set operational mode of channel 2.
Definition: aon_rtc.c:213
#define ASSERT(expr)
Definition: debug.h:65
void AONRTCChannelDisable(uint32_t ui32Channel)
Disable event operation for the specified channel.
Definition: aon_rtc.c:284
__STATIC_INLINE void AONRTCDelayConfig(uint32_t ui32Delay)
Configure Event Delay for the RTC.
Definition: aon_rtc.h:275
#define AON_RTC_CH2
Definition: aon_rtc.h:105
__STATIC_INLINE uint32_t AONRTCSecGet(void)
Get nominal seconds of RTC free-running timer.
Definition: aon_rtc.h:381
#define AON_RTC_CONFIG_DELAY_176
Definition: aon_rtc.h:128
__STATIC_INLINE uint32_t AONRTCFractionGet(void)
Get fractional part of RTC free-running timer.
Definition: aon_rtc.h:407
uint32_t AONRTCStatus(void)
Check if the AON Real Time Clock is running.
Definition: aon_rtc.c:78
__STATIC_INLINE uint32_t AONRTCIncValueCh2Get(void)
Get the channel2 increment value when operating in continuous mode.
Definition: aon_rtc.h:686
__STATIC_INLINE uint32_t AONRTCCaptureValueCh1Get(void)
Get the channel 1 capture value.
Definition: aon_rtc.h:704
#define AON_RTC_CH0
Definition: aon_rtc.h:103
uint32_t AONRTCModeCh2Get(void)
Get operational mode of channel 2.
Definition: aon_rtc.c:237
void AONRTCEventClear(uint32_t ui32Channel)
Clear event from a specified channel.
Definition: aon_rtc.c:108
__STATIC_INLINE void AONRTCIncValueCh2Set(uint32_t ui32IncValue)
Set the channel 2 increment value when operating in continuous mode.
Definition: aon_rtc.h:664
void AONRTCModeCh1Set(uint32_t ui32Mode)
Set operational mode of channel 1.
Definition: aon_rtc.c:171
void AONRTCChannelEnable(uint32_t ui32Channel)
Enable event operation for the specified channel.
Definition: aon_rtc.c:255
__STATIC_INLINE void AONRTCEnable(void)
Enable the RTC.
Definition: aon_rtc.h:169
__STATIC_INLINE void AONRTCDisable(void)
Disable the RTC.
Definition: aon_rtc.h:192
__STATIC_INLINE uint32_t AONRTCCurrentCompareValueGet(void)
Get the current value of the RTC counter in a format compatible to the compare registers.
Definition: aon_rtc.h:631
__STATIC_INLINE void AONRTCCombinedEventConfig(uint32_t ui32Channels)
Configure the source of the combined event.
Definition: aon_rtc.h:312
__STATIC_INLINE uint32_t AONRTCSubSecIncrGet(void)
Get the sub second increment of the RTC.
Definition: aon_rtc.h:435