Skip to content

Commit 346b78d

Browse files
committed
gd32: standardize hwClock naming & error handling
Cleanup and small fixes in GD32 HAL and EMAC code: add missing <cstddef> include and remove duplicate, rename HwClock instance to hw_clock for consistent naming, add CONFIG_CLIB_USE_NULL branch to skip console initialization, and switch EMAC error reporting to network::Error (include network_private.h and remove redundant console::Error declaration). These changes centralize error handling and tidy up includes/initialization.
1 parent d67b681 commit 346b78d

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

lib-hal/src/gd32/hal_init.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* THE SOFTWARE.
2424
*/
2525

26+
#include <cstddef>
27+
2628
#if !defined(_TIME_STAMP_DAY_)
2729
#define _TIME_STAMP_DAY_ 0
2830
#endif
@@ -33,7 +35,6 @@
3335
#define _TIME_STAMP_YEAR_ (2026 - 1900)
3436
#endif
3537

36-
#include <cstddef>
3738
#if defined(DEBUG_HAL)
3839
#undef NDEBUG
3940
#endif
@@ -97,7 +98,7 @@ void Timer7Config();
9798

9899
#if !defined(DISABLE_RTC)
99100
#include "hwclock.h"
100-
static HwClock hwClock;
101+
static HwClock hw_clock;
101102
#endif
102103

103104
extern unsigned char _sdmx; // NOLINT
@@ -122,6 +123,7 @@ void Init() {
122123

123124
#if defined(CONFIG_CLIB_USE_UART0)
124125
uart0::Init();
126+
#elif defined(CONFIG_CLIB_USE_NULL)
125127
#else
126128
console::Init();
127129
#endif

lib-network/src/emac/gd32/emac.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@
4040
#endif
4141
#include "firmware/debug/debug_debug.h"
4242
#include "gd32.h" // IWYU pragma: keep
43-
44-
namespace console {
45-
void Error(const char*);
46-
}
43+
#include "../src/core/network_private.h"
4744

4845
extern void EnetGpioConfig();
4946
extern enet_descriptors_struct txdesc_tab[ENET_TXBUF_NUM];
@@ -86,7 +83,7 @@ void __attribute__((cold)) Config() {
8683
enet_software_reset(ENETx);
8784

8885
if (!emac::phy::Config(PHY_ADDRESS)) {
89-
console::Error("emac::phy::Config(PHY_ADDRESS)\n");
86+
network::Error(__func__, "emac::phy::Config(PHY_ADDRESS)");
9087
}
9188

9289
DEBUG_EXIT();

0 commit comments

Comments
 (0)