Skip to content

Commit d6e9312

Browse files
committed
Refactor DMX port configs and GD32 IDs
Replaced per-board DMX UART/dir pin constants with unified `port::Info` definitions and added the new `gd32/dmx_port.h` include across DMX board headers, including TX-only handling for GD32F450VI. Updated `.clang-tidy` by adjusting enabled/disabled checks and adding template/constant naming rules. Also expanded and corrected GD32 MCU identifier mappings in `common/scripts/gd32/gd32.json` (new F303 variants and corrected package/part-name mappings).
1 parent 430a32e commit d6e9312

7 files changed

Lines changed: 57 additions & 68 deletions

File tree

.clang-tidy

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Checks: >
66
modernize-*,
77
readability-*,
88
-readability-convert-member-functions-to-static,
9+
-readability-use-std-min-max,
910
-modernize-avoid-c-arrays,
10-
-modernize-loop-convert,
1111
-modernize-use-trailing-return-type,
12+
-modernize-use-std-print,
1213
misc-unused-include
1314
1415
CheckOptions:
@@ -78,6 +79,22 @@ CheckOptions:
7879
- key: readability-identifier-naming.TreatAsConstant
7980
value: 'constexpr'
8081

82+
- key: readability-identifier-naming.VariableConstantCase
83+
value: CamelCase
84+
- key: readability-identifier-naming.VariableConstantPrefix
85+
value: k
86+
87+
- key: readability-identifier-naming.TypeTemplateParameterCase
88+
value: CamelCase
89+
90+
- key: readability-identifier-naming.ValueTemplateParameterCase
91+
value: CamelCase
92+
- key: readability-identifier-naming.ValueTemplateParameterPrefix
93+
value: k
94+
95+
- key: readability-identifier-naming.TemplateTemplateParameterCase
96+
value: CamelCase
97+
8198
WarningsAsErrors: ''
8299
HeaderFilterRegex: '.*'
83100
FormatStyle: none

common/include/dmx/board_bw_opidmx4.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <cstdint>
3030

3131
#include "gd32.h" // IWYU pragma: keep
32+
#include "gd32/dmx_port.h"
3233

3334
#define DMX_MAX_PORTS 4
3435

@@ -42,21 +43,9 @@ inline constexpr uint32_t kPorts = DMX_MAX_PORTS;
4243
#define DMX_USE_UART4
4344
#define DMX_USE_USART5
4445

45-
inline constexpr auto kUsart0Port = 3; // OPi One UART0
46-
inline constexpr auto kUsart2Port = 2; // OPi One UART3
47-
inline constexpr auto kUart4Port = 0; // OPi One UART1 Pin 38 TX, Pin 40 RX
48-
inline constexpr auto kUsart5Port = 1; // OPi One UART2
49-
50-
inline constexpr auto kDirPort0GpioPort = GPIOA; // OPi One UART1
51-
inline constexpr auto kDirPort0GpioPin = GPIO_PIN_4; // GPIO_EXT_32
52-
53-
inline constexpr auto kDirPort1GpioPort = GPIOA; // OPi One UART2
54-
inline constexpr auto kDirPort1GpioPin = GPIO_PIN_11; // GPIO_EXT_22
55-
56-
inline constexpr auto kDirPort2GpioPort = GPIOB; // OPi One UART3
57-
inline constexpr auto kDirPort2GpioPin = GPIO_PIN_10; // GPIO_EXT_12
58-
59-
inline constexpr auto kDirPort3GpioPort = GPIOA; // OPi One UART0
60-
inline constexpr auto kDirPort3GpioPin = GPIO_PIN_5; // GPIO_EXT_31
46+
inline constexpr port::Info kPort0 = {.uart = gd32::Uart::kUart4, .port = GPIOA, .pin = GPIO_PIN_4, .usage = port::Usage::kTxRx};
47+
inline constexpr port::Info kPort1 = {.uart = gd32::Uart::kUart5, .port = GPIOA, .pin = GPIO_PIN_11, .usage = port::Usage::kTxRx};
48+
inline constexpr port::Info kPort2 = {.uart = gd32::Uart::kUart2, .port = GPIOB, .pin = GPIO_PIN_10, .usage = port::Usage::kTxRx};
49+
inline constexpr port::Info kPort3 = {.uart = gd32::Uart::kUart0, .port = GPIOA, .pin = GPIO_PIN_5, .usage = port::Usage::kTxRx};
6150
} // namespace dmx::config
6251
#endif // DMX_BOARD_BW_OPIDMX4_H_

common/include/dmx/board_dmx3.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <cstdint>
3030

3131
#include "gd32.h" // IWYU pragma: keep
32+
#include "gd32/dmx_port.h"
3233

3334
#define DMX_MAX_PORTS 3
3435

@@ -41,17 +42,8 @@ inline constexpr uint32_t kPorts = DMX_MAX_PORTS;
4142
#define DMX_USE_UART4
4243
#define DMX_USE_USART5
4344

44-
inline constexpr auto kUsart2Port = 0;
45-
inline constexpr auto kUart4Port = 1;
46-
inline constexpr auto kUsart5Port = 2;
47-
48-
inline constexpr auto kDirPort0GpioPort = GPIOB;
49-
inline constexpr auto kDirPort0GpioPin = GPIO_PIN_10;
50-
51-
inline constexpr auto kDirPort1GpioPort = GPIOA;
52-
inline constexpr auto kDirPort1GpioPin = GPIO_PIN_5;
53-
54-
inline constexpr auto kDirPort2GpioPort = GPIOB;
55-
inline constexpr auto kDirPort2GpioPin = GPIO_PIN_14;
45+
inline constexpr port::Info kPort0 = {.uart = gd32::Uart::kUart2, .port = GPIOB, .pin = GPIO_PIN_10, .usage = port::Usage::kTxRx};
46+
inline constexpr port::Info kPort1 = {.uart = gd32::Uart::kUart4, .port = GPIOA, .pin = GPIO_PIN_5, .usage = port::Usage::kTxRx};
47+
inline constexpr port::Info kPort2 = {.uart = gd32::Uart::kUart5, .port = GPIOB, .pin = GPIO_PIN_14, .usage = port::Usage::kTxRx};
5648
} // namespace dmx::config
5749
#endif // DMX_BOARD_DMX3_H_

common/include/dmx/board_dmx4.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <cstdint>
3030

3131
#include "gd32.h" // IWYU pragma: keep
32+
#include "gd32/dmx_port.h"
3233

3334
#define DMX_MAX_PORTS 4
3435

@@ -42,21 +43,9 @@ inline constexpr uint32_t kPorts = DMX_MAX_PORTS;
4243
#define DMX_USE_UART4
4344
#define DMX_USE_USART5
4445

45-
inline constexpr auto kUsart0Port = 0;
46-
inline constexpr auto kUsart2Port = 1;
47-
inline constexpr auto kUart4Port = 2;
48-
inline constexpr auto kUsart5Port = 3;
49-
50-
inline constexpr auto kDirPort0GpioPort = GPIOA;
51-
inline constexpr auto kDirPort0GpioPin = GPIO_PIN_4;
52-
53-
inline constexpr auto kDirPort1GpioPort = GPIOB;
54-
inline constexpr auto kDirPort1GpioPin = GPIO_PIN_10;
55-
56-
inline constexpr auto kDirPort2GpioPort = GPIOA;
57-
inline constexpr auto kDirPort2GpioPin = GPIO_PIN_5;
58-
59-
inline constexpr auto kDirPort3GpioPort = GPIOB;
60-
inline constexpr auto kDirPort3GpioPin = GPIO_PIN_14;
46+
inline constexpr port::Info kPort0 = {.uart = gd32::Uart::kUart0, .port = GPIOA, .pin = GPIO_PIN_4, .usage = port::Usage::kTxRx};
47+
inline constexpr port::Info kPort1 = {.uart = gd32::Uart::kUart2, .port = GPIOB, .pin = GPIO_PIN_10, .usage = port::Usage::kTxRx};
48+
inline constexpr port::Info kPort2 = {.uart = gd32::Uart::kUart4, .port = GPIOA, .pin = GPIO_PIN_5, .usage = port::Usage::kTxRx};
49+
inline constexpr port::Info kPort3 = {.uart = gd32::Uart::kUart5, .port = GPIOB, .pin = GPIO_PIN_14, .usage = port::Usage::kTxRx};
6150
} // namespace dmx::config
6251
#endif // DMX_BOARD_DMX4_H_

common/include/dmx/board_gd32f407re.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <cstdint>
3030

3131
#include "gd32.h" // IWYU pragma: keep
32+
#include "gd32/dmx_port.h"
3233

3334
#define DMX_MAX_PORTS 2
3435

@@ -40,13 +41,7 @@ inline constexpr uint32_t kPorts = DMX_MAX_PORTS;
4041
#define DMX_USE_USART2
4142
#define DMX_USE_USART5
4243

43-
inline constexpr auto kUsart2Port = 0;
44-
inline constexpr auto kUsart5Port = 1;
45-
46-
inline constexpr auto kDirPort0GpioPort = GPIOB;
47-
inline constexpr auto kDirPort0GpioPin = GPIO_PIN_10;
48-
49-
inline constexpr auto kDirPort1GpioPort = GPIOA;
50-
inline constexpr auto kDirPort1GpioPin = GPIO_PIN_11;
44+
inline constexpr port::Info kPort0 = {.uart = gd32::Uart::kUart2, .port = GPIOB, .pin = GPIO_PIN_10, .usage = port::Usage::kTxRx}; // GPIO_EXT_12
45+
inline constexpr port::Info kPort1 = {.uart = gd32::Uart::kUart5, .port = GPIOA, .pin = GPIO_PIN_11, .usage = port::Usage::kTxRx}; // GPIO_EXT_22
5146
} // namespace dmx::config
5247
#endif // DMX_BOARD_GD32F407RE_H_

common/include/dmx/board_gd32f450vi.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <cstdint>
3030

3131
#include "gd32.h" // IWYU pragma: keep
32+
#include "gd32/dmx_port.h"
3233

3334
#define DMX_MAX_PORTS 2
3435

@@ -40,13 +41,7 @@ inline constexpr uint32_t kPorts = DMX_MAX_PORTS;
4041
#define DMX_USE_USART2
4142
#define DMX_USE_USART5
4243

43-
inline constexpr auto kUsart2Port = 0;
44-
inline constexpr auto kUsart5Port = 1;
45-
46-
inline constexpr auto kDirPort0GpioPort = GPIOD;
47-
inline constexpr auto kDirPort0GpioPin = GPIO_PIN_0; ///< Not used
48-
49-
inline constexpr auto kDirPort1GpioPort = GPIOD;
50-
inline constexpr auto kDirPort1GpioPin = GPIO_PIN_1; ///< Not used
44+
inline constexpr port::Info kPort0 = {.uart = gd32::Uart::kUart2, .port = 0, .pin = 0, .usage = port::Usage::kTxOnly};
45+
inline constexpr port::Info kPort1 = {.uart = gd32::Uart::kUart5, .port = 0, .pin = 0, .usage = port::Usage::kTxOnly};
5146
} // namespace dmx::config
5247
#endif // DMX_BOARD_GD32F450VI_H_

common/scripts/gd32/gd32.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
{
22
"0414": {
33
"identifiers": {
4+
"3RCB": {
5+
"series": "GD32F103",
6+
"flash": {
7+
"256": "GD32F103RCXX"
8+
}
9+
},
410
"3RCF": {
511
"series": "GD32F303",
612
"flash": {
7-
"256": "GD32F303RCXX"
13+
"256": "GD32F303XCXX"
814
}
915
},
10-
"3RCB": {
11-
"series": "GD32F103",
16+
"3VCF": {
17+
"series": "GD32F303",
1218
"flash": {
13-
"256": "GD32F103RCXX"
19+
"256": "GD32F303XCXX"
20+
}
21+
},
22+
"3VEF": {
23+
"series": "GD32F303",
24+
"flash": {
25+
"512": "GD32F303XEXX"
1426
}
1527
}
1628
}
@@ -20,13 +32,13 @@
2032
"7RCB": {
2133
"series": "GD32F107",
2234
"flash": {
23-
"256": "GD32F107RCXX"
35+
"256": "GD32F107XCXX"
2436
}
2537
},
2638
"7RGC": {
2739
"series": "GD32F207",
2840
"flash": {
29-
"1024": "GD32F207RGXX"
41+
"1024": "GD32F207XGXX"
3042
}
3143
}
3244
}
@@ -36,7 +48,7 @@
3648
"7REE": {
3749
"series": "GD32F407",
3850
"flash": {
39-
"512": "GD32F407REXX"
51+
"512": "GD32F407XEXX"
4052
}
4153
},
4254
"9VIE": {

0 commit comments

Comments
 (0)