Skip to content

Commit b9824b3

Browse files
committed
Move DMA checks into dmx_config.h and code cleanups
Integrate GD32 DMA/channel checks into common dmx_config.h and remove the now-unused gd32/dmx_dma_check.h header. Update lib-dmx sources: remove obsolete include, add/clarify static_asserts for port limits and DMA availability per MCU, introduce DisableTimerIrqUart helper, and clean up numerous small issues (assert messages, unreachable-return fixes, template spacing, DEBUG_PRINTF format change, and minor formatting). Also bump copyright year in dmx_internal.h.
1 parent faa6925 commit b9824b3

4 files changed

Lines changed: 153 additions & 140 deletions

File tree

common/include/dmx/dmx_config.h

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#ifndef DMX_DMX_CONFIG_H_
2-
#define DMX_DMX_CONFIG_H_
3-
41
/**
52
* @file dmx_config.h
63
*
@@ -26,6 +23,9 @@
2623
* THE SOFTWARE.
2724
*/
2825

26+
#ifndef DMX_DMX_CONFIG_H_
27+
#define DMX_DMX_CONFIG_H_
28+
2929
#include "gd32.h" // IWYU pragma: keep
3030

3131
#if defined(BOARD_GD32F103RC)
@@ -55,13 +55,56 @@
5555
#elif defined(BOARD_DMX4)
5656
#include "board_dmx4.h" // IWYU pragma: keep
5757
#else
58-
#error
58+
#error Board is not defined
5959
#endif
6060

6161
namespace dmx::buffer {
62-
static constexpr auto kSize = 516; // multiple of uint32_t
62+
static constexpr auto kSize = 516;
6363
} // namespace dmx::buffer
64+
static_assert(dmx::buffer::kSize >= 513); // 512 with Start Code
65+
static_assert(dmx::buffer::kSize % 4 == 0); // multiple of uint32_t
6466

65-
#include "gd32/dmx_dma_check.h" // IWYU pragma: keep
67+
// Maximum available USART check
68+
#if defined(GD32F10X_HD) || defined(GD32F10X_CL)
69+
static_assert(DMX_MAX_PORTS <= 4, "Too many ports defined");
70+
#endif
71+
#if defined(GD32F20X_CL)
72+
static_assert(DMX_MAX_PORTS <= 6, "Too many ports defined");
73+
#endif
74+
#if defined(GD32F30X_HD)
75+
static_assert(DMX_MAX_PORTS <= 5, "Too many ports defined");
76+
#endif
77+
78+
// DMA channel check
79+
#if defined(GD32F10X_HD) || defined(GD32F10X_CL)
80+
#if defined(DMX_USE_UART4)
81+
#error There is no DMA channel for UART4
82+
#endif
83+
#if defined(DMX_USE_USART5)
84+
#error USART5 is not available
85+
#endif
86+
#if defined(DMX_USE_UART6)
87+
#error UART6 is not available
88+
#endif
89+
#if defined(DMX_USE_UART7)
90+
#error UART7 is not available
91+
#endif
92+
#endif
93+
94+
#if defined(GD32F20X_CL)
95+
#if defined(DMX_USE_UART4) && defined(DMX_USE_UART7)
96+
#error DMA1 Channel 3
97+
#endif
98+
99+
#if defined(DMX_USE_UART3) && defined(DMX_USE_UART6)
100+
#error DMA1 Channel 4
101+
#endif
102+
#endif
103+
104+
#if defined(GD32F30X_HD)
105+
#if defined(DMX_USE_UART4)
106+
#error There is no DMA channel for UART4
107+
#endif
108+
#endif
66109

67110
#endif // DMX_DMX_CONFIG_H_

lib-dmx/include/gd32/dmx_dma_check.h

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)