Skip to content

Commit 6377556

Browse files
committed
Add GD32 device map and cleanup GD32 sources
Introduce a new `common/scripts/gd32/gd32.json` device definition map for GD32F303, GD32F207, and GD32F407/F450 identification data. In `lib-gd32`, replace the hardcoded system name length with a constexpr-backed value, keep `gd32.h` for IWYU, add a lint suppression for parameter order in `DelayUs`, and modernize the infinite loop to `while (true)`. Also remove the obsolete `lib-board/.clangd` file.
1 parent 39bbd51 commit 6377556

4 files changed

Lines changed: 37 additions & 5 deletions

File tree

common/scripts/gd32/gd32.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"0414": {
3+
"series": "GD32F303",
4+
"uid_base" : "",
5+
"flash": {
6+
"256": "GD32F303XCXX"
7+
}
8+
},
9+
"0418": {
10+
"series": "GD32F207",
11+
"flash": {
12+
"1024": "GD32F207XRXX"
13+
}
14+
},
15+
"0x0419": {
16+
"series": "GD32F407/GD32F450",
17+
"probes": {
18+
"tli_apb2en_bit26": {
19+
"address": "0x40021024",
20+
"bit": 26,
21+
"set": "GD32F450",
22+
"clear": "GD32F407"
23+
}
24+
},
25+
"flash": {
26+
"GD32F407": {
27+
"512": "GD32F407XEXX"
28+
}
29+
}
30+
}
31+
}

lib-board/.clangd

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib-gd32/src/board.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace board {
2929
static constexpr float kCoreTemperatureMin = -40.0;
3030
static constexpr float kCoreTemperatureMax = +85.0;
3131
static constexpr const char kWebsite[] = "https://gd32-dmx.org";
32+
static constexpr char kSysName[] = "Embedded";
3233

3334
const char* Website() {
3435
return kWebsite;
@@ -57,7 +58,7 @@ const char* CpuName(uint8_t& length) {
5758
}
5859

5960
const char* SysName(uint8_t& length) {
60-
length = 8;
61-
return "Embedded";
61+
length = sizeof(kSysName) - 1U;
62+
return kSysName;
6263
}
6364
} // namespace board

lib-gd32/src/delayus.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <cstdint>
3434
#include <cassert>
3535

36-
#include "gd32.h"
36+
#include "gd32.h" // IWYU pragma: keep
3737

3838
static constexpr auto kTicksPerUs = (MCU_CLOCK_FREQ / 1000000U);
3939

@@ -46,6 +46,7 @@ void UdelayInit() {
4646
}
4747

4848
namespace timing {
49+
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
4950
void DelayUs(uint32_t micros, uint32_t offset_micros) {
5051
const auto kTicks = micros * kTicksPerUs;
5152

@@ -58,7 +59,7 @@ void DelayUs(uint32_t micros, uint32_t offset_micros) {
5859
ticks_previous = offset_micros;
5960
}
6061

61-
while (1) {
62+
while (true) {
6263
const auto kTicksNow = DWT->CYCCNT;
6364

6465
if (kTicksNow != ticks_previous) {

0 commit comments

Comments
 (0)