Skip to content

Commit 25d3cf5

Browse files
committed
Refactor HwClock and logic_analyzer, fix snprintf/printf
Refactored HwClock class to use more descriptive member variable names and updated all usages accordingly. Standardized logic_analyzer API to PascalCase and updated function calls. Fixed snprintf/vsnprintf implementation and buffer handling in printf.cpp and uart0.cpp. Updated section clearing variable names in hal_init.cpp and improved logic_analyzer initialization. Minor copyright and assertion additions.
1 parent 11f9adf commit 25d3cf5

10 files changed

Lines changed: 112 additions & 111 deletions

File tree

lib-clib/src/printf.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
#include <cstring>
3131
#include <climits>
3232

33-
namespace console {
33+
namespace console
34+
{
3435
void Putc(int);
3536
}
3637

@@ -553,32 +554,30 @@ extern "C"
553554
return i;
554555
}
555556

556-
int snprintf(char* str, size_t size, const char* fmt, ...) // NOLINT
557+
int vsnprintf(char* str, size_t size, const char* fmt, va_list ap) // NOLINT
557558
{
558-
va_list arp;
559+
if (size == 0)
560+
{
561+
outptr = nullptr; // don't write anywhere
562+
return Vprintf(0, fmt, ap); // just count
563+
}
559564

560565
outptr = str;
561-
va_start(arp, fmt);
562-
563-
auto i = Vprintf((int)size, fmt, arp);
564566

565-
va_end(arp);
567+
auto i = Vprintf((int)size, fmt, ap);
566568

567569
*outptr = 0;
568570
outptr = nullptr;
569571

570572
return i;
571573
}
572574

573-
int vsnprintf(char* str, size_t size, const char* fmt, va_list ap) // NOLINT
575+
int snprintf(char* str, size_t size, const char* fmt, ...) // NOLINT
574576
{
575-
outptr = str;
576-
577-
auto i = Vprintf((int)size, fmt, ap);
578-
579-
*outptr = 0;
580-
outptr = nullptr;
581-
577+
va_list ap;
578+
va_start(ap, fmt);
579+
int i = vsnprintf(str, size, fmt, ap);
580+
va_end(ap);
582581
return i;
583582
}
584583
}

lib-gd32/include/logic_analyzer.h

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
/* Copyright (C) 2022-2025 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* Permission is hereby granted, free of Charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
99
* in the Software without restriction, including without limitation the rights
1010
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -31,16 +31,16 @@
3131

3232
namespace logic_analyzer
3333
{
34-
inline void init()
34+
inline void Init()
3535
{
3636
#if defined(LOGIC_ANALYZER)
3737
#if defined(LOGIC_ANALYZER_CH0_GPIO_PINx)
3838
rcu_periph_clock_enable(LOGIC_ANALYZER_CH0_RCU_GPIOx);
3939
#if defined(GPIO_INIT)
4040
gpio_init(LOGIC_ANALYZER_CH0_GPIOx, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LOGIC_ANALYZER_CH0_GPIO_PINx);
4141
#else
42-
gpio_mode_set(LOGIC_ANALYZER_CH0_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH0_GPIO_PINx);
43-
gpio_output_options_set(LOGIC_ANALYZER_CH0_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH0_GPIO_PINx);
42+
gpio_modeSet(LOGIC_ANALYZER_CH0_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH0_GPIO_PINx);
43+
gpio_output_optionsSet(LOGIC_ANALYZER_CH0_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH0_GPIO_PINx);
4444
#endif
4545
GPIO_BC(LOGIC_ANALYZER_CH0_GPIOx) = LOGIC_ANALYZER_CH0_GPIO_PINx;
4646
#endif
@@ -50,8 +50,8 @@ inline void init()
5050
#if defined(GPIO_INIT)
5151
gpio_init(LOGIC_ANALYZER_CH1_GPIOx, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LOGIC_ANALYZER_CH1_GPIO_PINx);
5252
#else
53-
gpio_mode_set(LOGIC_ANALYZER_CH1_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH1_GPIO_PINx);
54-
gpio_output_options_set(LOGIC_ANALYZER_CH1_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH1_GPIO_PINx);
53+
gpio_modeSet(LOGIC_ANALYZER_CH1_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH1_GPIO_PINx);
54+
gpio_output_optionsSet(LOGIC_ANALYZER_CH1_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH1_GPIO_PINx);
5555
#endif
5656
GPIO_BC(LOGIC_ANALYZER_CH1_GPIOx) = LOGIC_ANALYZER_CH1_GPIO_PINx;
5757
#endif
@@ -61,8 +61,8 @@ inline void init()
6161
#if defined(GPIO_INIT)
6262
gpio_init(LOGIC_ANALYZER_CH2_GPIOx, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LOGIC_ANALYZER_CH2_GPIO_PINx);
6363
#else
64-
gpio_mode_set(LOGIC_ANALYZER_CH2_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH2_GPIO_PINx);
65-
gpio_output_options_set(LOGIC_ANALYZER_CH2_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH2_GPIO_PINx);
64+
gpio_modeSet(LOGIC_ANALYZER_CH2_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH2_GPIO_PINx);
65+
gpio_output_optionsSet(LOGIC_ANALYZER_CH2_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH2_GPIO_PINx);
6666
#endif
6767
GPIO_BC(LOGIC_ANALYZER_CH2_GPIOx) = LOGIC_ANALYZER_CH2_GPIO_PINx;
6868
#endif
@@ -72,8 +72,8 @@ inline void init()
7272
#if defined(GPIO_INIT)
7373
gpio_init(LOGIC_ANALYZER_CH3_GPIOx, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LOGIC_ANALYZER_CH3_GPIO_PINx);
7474
#else
75-
gpio_mode_set(LOGIC_ANALYZER_CH3_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH3_GPIO_PINx);
76-
gpio_output_options_set(LOGIC_ANALYZER_CH3_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH3_GPIO_PINx);
75+
gpio_modeSet(LOGIC_ANALYZER_CH3_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH3_GPIO_PINx);
76+
gpio_output_optionsSet(LOGIC_ANALYZER_CH3_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH3_GPIO_PINx);
7777
#endif
7878
GPIO_BC(LOGIC_ANALYZER_CH3_GPIOx) = LOGIC_ANALYZER_CH3_GPIO_PINx;
7979
#endif
@@ -83,8 +83,8 @@ inline void init()
8383
#if defined(GPIO_INIT)
8484
gpio_init(LOGIC_ANALYZER_CH4_GPIOx, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LOGIC_ANALYZER_CH4_GPIO_PINx);
8585
#else
86-
gpio_mode_set(LOGIC_ANALYZER_CH4_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH4_GPIO_PINx);
87-
gpio_output_options_set(LOGIC_ANALYZER_CH4_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH4_GPIO_PINx);
86+
gpio_modeSet(LOGIC_ANALYZER_CH4_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH4_GPIO_PINx);
87+
gpio_output_optionsSet(LOGIC_ANALYZER_CH4_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH4_GPIO_PINx);
8888
#endif
8989
GPIO_BC(LOGIC_ANALYZER_CH4_GPIOx) = LOGIC_ANALYZER_CH4_GPIO_PINx;
9090
#endif
@@ -94,8 +94,8 @@ inline void init()
9494
#if defined(GPIO_INIT)
9595
gpio_init(LOGIC_ANALYZER_CH5_GPIOx, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LOGIC_ANALYZER_CH5_GPIO_PINx);
9696
#else
97-
gpio_mode_set(LOGIC_ANALYZER_CH5_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH5_GPIO_PINx);
98-
gpio_output_options_set(LOGIC_ANALYZER_CH5_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH5_GPIO_PINx);
97+
gpio_modeSet(LOGIC_ANALYZER_CH5_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH5_GPIO_PINx);
98+
gpio_output_optionsSet(LOGIC_ANALYZER_CH5_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH5_GPIO_PINx);
9999
#endif
100100
GPIO_BC(LOGIC_ANALYZER_CH5_GPIOx) = LOGIC_ANALYZER_CH5_GPIO_PINx;
101101
#endif
@@ -105,8 +105,8 @@ inline void init()
105105
#if defined(GPIO_INIT)
106106
gpio_init(LOGIC_ANALYZER_CH6_GPIOx, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LOGIC_ANALYZER_CH6_GPIO_PINx);
107107
#else
108-
gpio_mode_set(LOGIC_ANALYZER_CH6_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH6_GPIO_PINx);
109-
gpio_output_options_set(LOGIC_ANALYZER_CH6_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH6_GPIO_PINx);
108+
gpio_modeSet(LOGIC_ANALYZER_CH6_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH6_GPIO_PINx);
109+
gpio_output_optionsSet(LOGIC_ANALYZER_CH6_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH6_GPIO_PINx);
110110
#endif
111111
GPIO_BC(LOGIC_ANALYZER_CH6_GPIOx) = LOGIC_ANALYZER_CH6_GPIO_PINx;
112112
#endif
@@ -116,120 +116,120 @@ inline void init()
116116
#if defined(GPIO_INIT)
117117
gpio_init(LOGIC_ANALYZER_CH7_GPIOx, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LOGIC_ANALYZER_CH7_GPIO_PINx);
118118
#else
119-
gpio_mode_set(LOGIC_ANALYZER_CH7_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH7_GPIO_PINx);
120-
gpio_output_options_set(LOGIC_ANALYZER_CH7_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH7_GPIO_PINx);
119+
gpio_modeSet(LOGIC_ANALYZER_CH7_GPIOx, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LOGIC_ANALYZER_CH7_GPIO_PINx);
120+
gpio_output_optionsSet(LOGIC_ANALYZER_CH7_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED, LOGIC_ANALYZER_CH7_GPIO_PINx);
121121
#endif
122122
GPIO_BC(LOGIC_ANALYZER_CH7_GPIOx) = LOGIC_ANALYZER_CH7_GPIO_PINx;
123123
#endif
124124
#endif
125125
}
126126

127-
inline void ch0_clear()
127+
inline void Ch0Clear()
128128
{
129129
#if defined(LOGIC_ANALYZER_CH0_GPIO_PINx) && defined(LOGIC_ANALYZER)
130130
GPIO_BC(LOGIC_ANALYZER_CH0_GPIOx) = LOGIC_ANALYZER_CH0_GPIO_PINx;
131131
#endif
132132
}
133133

134-
inline void ch0_set()
134+
inline void Ch0Set()
135135
{
136136
#if defined(LOGIC_ANALYZER_CH0_GPIO_PINx) && defined(LOGIC_ANALYZER)
137137
GPIO_BOP(LOGIC_ANALYZER_CH0_GPIOx) = LOGIC_ANALYZER_CH0_GPIO_PINx;
138138
#endif
139139
}
140140

141-
inline void ch1_clear()
141+
inline void Ch1Clear()
142142
{
143143
#if defined(LOGIC_ANALYZER_CH1_GPIO_PINx) && defined(LOGIC_ANALYZER)
144144
GPIO_BC(LOGIC_ANALYZER_CH1_GPIOx) = LOGIC_ANALYZER_CH1_GPIO_PINx;
145145
#endif
146146
}
147147

148-
inline void ch1_set()
148+
inline void Ch1Set()
149149
{
150150
#if defined(LOGIC_ANALYZER_CH1_GPIO_PINx) && defined(LOGIC_ANALYZER)
151151
GPIO_BOP(LOGIC_ANALYZER_CH1_GPIOx) = LOGIC_ANALYZER_CH1_GPIO_PINx;
152152
#endif
153153
}
154154

155-
inline void ch2_clear()
155+
inline void Ch2Clear()
156156
{
157157
#if defined(LOGIC_ANALYZER_CH2_GPIO_PINx) && defined(LOGIC_ANALYZER)
158158
GPIO_BC(LOGIC_ANALYZER_CH2_GPIOx) = LOGIC_ANALYZER_CH2_GPIO_PINx;
159159
#endif
160160
}
161161

162-
inline void ch2_set()
162+
inline void Ch2Set()
163163
{
164164
#if defined(LOGIC_ANALYZER_CH2_GPIO_PINx) && defined(LOGIC_ANALYZER)
165165
GPIO_BOP(LOGIC_ANALYZER_CH2_GPIOx) = LOGIC_ANALYZER_CH2_GPIO_PINx;
166166
#endif
167167
}
168168

169-
inline void ch3_clear()
169+
inline void Ch3Clear()
170170
{
171171
#if defined(LOGIC_ANALYZER_CH3_GPIO_PINx) && defined(LOGIC_ANALYZER)
172172
GPIO_BC(LOGIC_ANALYZER_CH3_GPIOx) = LOGIC_ANALYZER_CH3_GPIO_PINx;
173173
#endif
174174
}
175175

176-
inline void ch3_set()
176+
inline void Ch3Set()
177177
{
178178
#if defined(LOGIC_ANALYZER_CH3_GPIO_PINx) && defined(LOGIC_ANALYZER)
179179
GPIO_BOP(LOGIC_ANALYZER_CH3_GPIOx) = LOGIC_ANALYZER_CH3_GPIO_PINx;
180180
#endif
181181
}
182182

183-
inline void ch4_clear()
183+
inline void Ch4Clear()
184184
{
185185
#if defined(LOGIC_ANALYZER_CH4_GPIO_PINx) && defined(LOGIC_ANALYZER)
186186
GPIO_BC(LOGIC_ANALYZER_CH4_GPIOx) = LOGIC_ANALYZER_CH4_GPIO_PINx;
187187
#endif
188188
}
189189

190-
inline void ch4_set()
190+
inline void Ch4Set()
191191
{
192192
#if defined(LOGIC_ANALYZER_CH4_GPIO_PINx) && defined(LOGIC_ANALYZER)
193193
GPIO_BOP(LOGIC_ANALYZER_CH4_GPIOx) = LOGIC_ANALYZER_CH4_GPIO_PINx;
194194
#endif
195195
}
196196

197-
inline void ch5_clear()
197+
inline void Ch5Clear()
198198
{
199199
#if defined(LOGIC_ANALYZER_CH5_GPIO_PINx) && defined(LOGIC_ANALYZER)
200200
GPIO_BC(LOGIC_ANALYZER_CH5_GPIOx) = LOGIC_ANALYZER_CH5_GPIO_PINx;
201201
#endif
202202
}
203203

204-
inline void ch5_set()
204+
inline void Ch5Set()
205205
{
206206
#if defined(LOGIC_ANALYZER_CH5_GPIO_PINx) && defined(LOGIC_ANALYZER)
207207
GPIO_BOP(LOGIC_ANALYZER_CH5_GPIOx) = LOGIC_ANALYZER_CH5_GPIO_PINx;
208208
#endif
209209
}
210210

211-
inline void ch6_clear()
211+
inline void Ch6Clear()
212212
{
213213
#if defined(LOGIC_ANALYZER_CH6_GPIO_PINx) && defined(LOGIC_ANALYZER)
214214
GPIO_BC(LOGIC_ANALYZER_CH6_GPIOx) = LOGIC_ANALYZER_CH6_GPIO_PINx;
215215
#endif
216216
}
217217

218-
inline void ch6_set()
218+
inline void Ch6Set()
219219
{
220220
#if defined(LOGIC_ANALYZER_CH6_GPIO_PINx) && defined(LOGIC_ANALYZER)
221221
GPIO_BOP(LOGIC_ANALYZER_CH6_GPIOx) = LOGIC_ANALYZER_CH6_GPIO_PINx;
222222
#endif
223223
}
224224

225-
inline void ch7_clear()
225+
inline void Ch7Clear()
226226
{
227227
#if defined(LOGIC_ANALYZER_CH7_GPIO_PINx) && defined(LOGIC_ANALYZER)
228228
GPIO_BC(LOGIC_ANALYZER_CH7_GPIOx) = LOGIC_ANALYZER_CH7_GPIO_PINx;
229229
#endif
230230
}
231231

232-
inline void ch7_set()
232+
inline void Ch7Set()
233233
{
234234
#if defined(LOGIC_ANALYZER_CH7_GPIO_PINx) && defined(LOGIC_ANALYZER)
235235
GPIO_BOP(LOGIC_ANALYZER_CH7_GPIOx) = LOGIC_ANALYZER_CH7_GPIO_PINx;

lib-gd32/src/gd32_bkp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525

2626
#if defined(GD32F4XX) || defined(GD32H7XX)
27+
#include <cassert>
2728
#include "gd32.h"
2829

2930
void bkp_data_write(bkp_data_register_enum register_number, uint16_t data)

lib-gd32/src/uart0/uart0.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ int Printf(const char* fmt, ...)
6464

6565
va_start(arp, fmt);
6666

67-
int i = vsnprintf(s_buffer, sizeof(s_buffer) - 1, fmt, arp);
67+
int i = vsnprintf(s_buffer, sizeof(s_buffer), fmt, arp);
68+
s_buffer[sizeof(s_buffer) - 1] = '\0';
6869

6970
va_end(arp);
7071

lib-hal/include/hwclock.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class HwClock
5858

5959
bool AlarmGet(struct tm* time) { return RtcGetAlarm(time); }
6060

61-
void AlarmEnable(bool enable) { m_bRtcAlarmEnabled = enable; }
61+
void AlarmEnable(bool enable) { alarm_enabled_ = enable; }
6262

63-
bool AlarmIsEnabled() const { return m_bRtcAlarmEnabled; }
63+
bool AlarmIsEnabled() const { return alarm_enabled_; }
6464

6565
bool IsConnected() const { return is_connected_; }
6666

@@ -88,13 +88,13 @@ class HwClock
8888
void PCF8563SetAlarmMode();
8989

9090
private:
91-
uint32_t m_nSetDelayMicros{0};
92-
uint32_t m_nLastHcToSysMillis{0};
91+
uint32_t delay_micros_{0};
92+
uint32_t last_hc_to_sys_millis_{0};
9393
uint8_t address_{0};
94-
rtc::Type m_Type{rtc::Type::kUnknown};
94+
rtc::Type type_{rtc::Type::kUnknown};
9595
bool is_connected_{false};
96-
bool m_bRtcAlarmEnabled{false};
97-
bool m_bRtcAlarmPending{false};
96+
bool alarm_enabled_{false};
97+
bool alarm_pending_{false};
9898

9999
static inline HwClock* s_this;
100100
};

lib-hal/rtc/gd32/hwclockrtc.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ void HwClock::RtcProbe()
159159
#endif
160160
}
161161

162-
m_Type = rtc::Type::kSocInternal;
162+
type_ = rtc::Type::kSocInternal;
163163
is_connected_ = true;
164-
m_nLastHcToSysMillis = millis();
164+
last_hc_to_sys_millis_ = millis();
165165

166166
DEBUG_EXIT();
167167
}
@@ -219,7 +219,7 @@ bool HwClock::RtcSetAlarm(const struct tm* tm_time)
219219
DEBUG_ENTRY();
220220
assert(tm_time != nullptr);
221221

222-
DEBUG_PRINTF("secs=%d, mins=%d, hours=%d, mday=%d, mon=%d, year=%d, wday=%d, enabled=%d", tm_time->tm_sec, tm_time->tm_min, tm_time->tm_hour, tm_time->tm_mday, tm_time->tm_mon, tm_time->tm_year, tm_time->tm_wday, m_bRtcAlarmEnabled);
222+
DEBUG_PRINTF("secs=%d, mins=%d, hours=%d, mday=%d, mon=%d, year=%d, wday=%d, enabled=%d", tm_time->tm_sec, tm_time->tm_min, tm_time->tm_hour, tm_time->tm_mday, tm_time->tm_mon, tm_time->tm_year, tm_time->tm_wday, alarm_enabled_);
223223

224224
#if defined(GD32F4XX) || defined(GD32H7XX)
225225
rtc_alarm_disable(RTC_ALARM0);
@@ -235,7 +235,7 @@ bool HwClock::RtcSetAlarm(const struct tm* tm_time)
235235

236236
rtc_alarm_config(RTC_ALARM0, &rtc_alarm);
237237

238-
if (m_bRtcAlarmEnabled)
238+
if (alarm_enabled_)
239239
{
240240
rtc_interrupt_enable(RTC_INT_ALARM0);
241241
rtc_alarm_enable(RTC_ALARM0);
@@ -274,11 +274,11 @@ bool HwClock::RtcGetAlarm(struct tm* tm_time)
274274
tm_time->tm_mday = BCD2DEC(rtc_alarm.alarm_day);
275275
#else
276276
const auto kSeconds = static_cast<time_t>((RTC_ALRMH << 16U) | RTC_ALRML);
277-
const auto* pTm = localtime(&kSeconds);
278-
memcpy(tm_time, pTm, sizeof(struct tm));
277+
const auto* lt = localtime(&kSeconds);
278+
memcpy(tm_time, lt, sizeof(struct tm));
279279
#endif
280280

281-
DEBUG_PRINTF("secs=%d, mins=%d, hours=%d, mday=%d, mon=%d, year=%d, wday=%d, enabled=%d", tm_time->tm_sec, tm_time->tm_min, tm_time->tm_hour, tm_time->tm_mday, tm_time->tm_mon, tm_time->tm_year, tm_time->tm_wday, m_bRtcAlarmEnabled);
281+
DEBUG_PRINTF("secs=%d, mins=%d, hours=%d, mday=%d, mon=%d, year=%d, wday=%d, enabled=%d", tm_time->tm_sec, tm_time->tm_min, tm_time->tm_hour, tm_time->tm_mday, tm_time->tm_mon, tm_time->tm_year, tm_time->tm_wday, alarm_enabled_);
282282

283283
DEBUG_EXIT();
284284
return true;

0 commit comments

Comments
 (0)