Skip to content

Commit ae519a6

Browse files
committed
Refactor DMX UART mapping and port usage
Introduces a new `dmx::port::Info` model (`dmx_port.h`) to centralize per-port UART/GPIO/usage metadata, then rewires DMX/RDM IRQ, DMA, direction, and send paths to derive port indices from UART at compile time with uniqueness checks. This removes legacy `DmxPortToUart` mapping, adds TX/RX-only behavior guards, and updates direction/data handling to respect per-port usage. The change also modernizes UART helpers under `gd32::` (`UartBegin`, flag/interrupt helpers, `gd32::Uart` enum), fixes `has_continuous_output_` naming, and introduces reusable E1.20 message-length constants used in RDM parsing.
1 parent ffda3b1 commit ae519a6

10 files changed

Lines changed: 562 additions & 505 deletions

File tree

lib-dmx/include/gd32/dmx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Dmx {
120120
uint32_t transmit_length_[dmx::config::max::kPorts];
121121
uint16_t transmit_slots_{dmx::kChannelsMax};
122122
dmx::Direction port_direction_[dmx::config::max::kPorts];
123-
bool has_continuos_output_{false};
123+
bool has_continuous_output_{false};
124124

125125
inline static Dmx* s_this;
126126
};

lib-dmx/include/gd32/dmx_port.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @file dmx_port.h
3+
*
4+
*/
5+
6+
#ifndef GD32_DMX_PORT_H_
7+
#define GD32_DMX_PORT_H_
8+
9+
#include <cstdint>
10+
#include "gd32_uart.h"
11+
12+
namespace dmx::port {
13+
enum class Usage { kTxRx = 0, kTxOnly = 1, kRxOnly = 2 };
14+
15+
struct Info {
16+
gd32::Uart uart;
17+
uint32_t port;
18+
uint32_t pin;
19+
Usage usage;
20+
};
21+
} // namespace dmx::port
22+
23+
#endif // GD32_DMX_PORT_H_

0 commit comments

Comments
 (0)