@@ -44,6 +44,7 @@ const PowerCC23X0_Config PowerCC23X0_config = {
44
44
#define SYSTIM_CH (idx ) (SYSTIM_O_CH0CC + idx * SYSTIM_CH_STEP)
45
45
#define SYSTIM_TO_RTC_SHIFT 3U
46
46
#define SYSTIM_CH_CNT 5U
47
+ #define RTC_CH_CNT 2U
47
48
#define RTC_NEXT (val , now ) (((val - PowerCC23X0_WAKEDELAYSTANDBY) >> SYSTIM_TO_RTC_SHIFT) + now)
48
49
49
50
#endif
@@ -57,8 +58,10 @@ static void pm_cc23x0_systim_standby_restore(void);
57
58
58
59
/* Global to stash the SysTimer timeouts while we enter standby */
59
60
static uint32_t systim [SYSTIM_CH_CNT ];
61
+ static uint32_t rtc [RTC_CH_CNT ];
60
62
static uintptr_t key ;
61
63
static uint32_t systim_mask ;
64
+ static uint32_t rtc_mask ;
62
65
63
66
/* Shift values to convert between the different resolutions of the SysTimer
64
67
* channels. Channel 0 can technically support either 1us or 250ns. Until the
@@ -83,7 +86,10 @@ static void pm_cc23x0_systim_standby_restore(void)
83
86
ULLSync ();
84
87
85
88
HwiP_clearInterrupt (INT_CPUIRQ16 );
89
+ HwiP_clearInterrupt (INT_CPUIRQ3 );
90
+
86
91
HWREG (EVTSVT_BASE + EVTSVT_O_CPUIRQ16SEL ) = EVTSVT_CPUIRQ16SEL_PUBID_SYSTIM0 ;
92
+ HWREG (EVTSVT_BASE + EVTSVT_O_CPUIRQ3SEL ) = EVTSVT_CPUIRQ16SEL_PUBID_AON_RTC_COMB ;
87
93
88
94
while (HWREG (SYSTIM_BASE + SYSTIM_O_STATUS ) != SYSTIM_STATUS_VAL_RUN ) {
89
95
;
@@ -96,9 +102,19 @@ static void pm_cc23x0_systim_standby_restore(void)
96
102
}
97
103
98
104
HWREG (SYSTIM_BASE + SYSTIM_O_IMASK ) = systim_mask ;
105
+ HWREG (RTC_BASE + RTC_O_IMASK ) = rtc_mask ;
106
+
107
+ if (rtc_mask != 0 ) {
108
+ if (rtc_mask & 0x1 ) {
109
+ HWREG (RTC_BASE + RTC_O_CH0CC8U ) = rtc [0 ];
110
+ }
111
+ if (rtc_mask & 0x2 ) {
112
+ HWREG (RTC_BASE + RTC_O_CH1CC8U ) = rtc [1 ];
113
+ }
114
+ }
115
+
99
116
LRFDApplyClockDependencies ();
100
117
PowerCC23X0_notify (PowerLPF3_AWAKE_STANDBY );
101
-
102
118
HwiP_restore (key );
103
119
}
104
120
#endif
@@ -110,6 +126,7 @@ static void pm_cc23x0_enter_standby(void)
110
126
uint32_t systim_now = 0 ;
111
127
uint32_t systim_next = MAX_SYSTIMER_DELTA ;
112
128
uint32_t systim_delta = 0 ;
129
+ uint32_t rtc_delta = 0 ;
113
130
114
131
key = HwiP_disable ();
115
132
@@ -146,7 +163,23 @@ static void pm_cc23x0_enter_standby(void)
146
163
systim_next = MAX_SYSTIMER_DELTA ;
147
164
}
148
165
166
+ rtc_mask = HWREG (RTC_BASE + RTC_O_IMASK );
167
+ if (rtc_mask != 0 ) {
168
+ rtc_now = HWREG (RTC_BASE + RTC_O_TIME8U );
169
+ if (rtc_mask & 0x1 ) {
170
+ rtc [0 ] = HWREG (RTC_BASE + RTC_O_CH0CC8U );
171
+ rtc_delta = (rtc [0 ] - rtc_now ) << 3 ;
172
+ systim_next = MIN (systim_next , rtc_delta );
173
+ }
174
+ if (rtc_mask & 0x2 ) {
175
+ rtc [1 ] = HWREG (RTC_BASE + RTC_O_CH1CC8U );
176
+ rtc_delta = (rtc [1 ] - rtc_now ) << 3 ;
177
+ systim_next = MIN (systim_next , rtc_delta );
178
+ }
179
+ }
180
+
149
181
if (systim_next > PowerCC23X0_TOTALTIMESTANDBY ) {
182
+ HWREG (EVTSVT_BASE + EVTSVT_O_CPUIRQ3SEL ) = 0 ;
150
183
HWREG (EVTSVT_BASE + EVTSVT_O_CPUIRQ16SEL ) =
151
184
EVTSVT_CPUIRQ16SEL_PUBID_AON_RTC_COMB ;
152
185
HwiP_clearInterrupt (INT_CPUIRQ16 );
0 commit comments