Skip to content

Commit 825bb38

Browse files
committed
Improve assertions, update copyrights & formatting
Replace bare assert(0) usages with assert(false && "<message>") or assert(false) to provide clearer diagnostics and mark unreachable cases. Update copyright years to include 2026 across several GD32/HAL files. Apply minor whitespace, include ordering and formatting fixes, adjust NDEBUG handling in pixel DMX JSON code, and small API/indentation cleanups. Affected files include artnet, e131, gd32, hal and pixeldmx source/header files.
1 parent cdddf8a commit 825bb38

14 files changed

Lines changed: 321 additions & 56 deletions

File tree

gd32_emac_artnet_pixel_multi/include/software_version_id.h

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

lib-artnet/src/controller/artnetcontroller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ void ArtNetController::ActiveUniversesAdd(uint16_t universe)
534534

535535
if (m_nActiveUniverses == (sizeof(s_active_universes) / sizeof(s_active_universes[0])))
536536
{
537-
assert(0);
537+
assert(false);
538538
return;
539539
}
540540

lib-artnet/src/node/artnetnode.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @file artnetnode.cpp
33
*
44
*/
5-
65
/* Copyright (C) 2016-2026 by Arjan van Vught mailto:info@gd32-dmx.org
76
*
87
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -557,13 +556,13 @@ void ArtNetNode::SetFailSafe(artnet::FailSafe fail_safe)
557556

558557
case artnet::FailSafe::kRecord:
559558
#if defined(ARTNET_HAVE_FAILSAFE_RECORD)
560-
assert(0);
559+
assert(false && "case artnet::FailSafe::kRecord");
561560
__builtin_unreachable();
562561
#endif
563562
break;
564563

565564
default:
566-
[[unlikely]] assert(0);
565+
[[unlikely]] assert(false && "Invalid fail_safe");
567566
__builtin_unreachable();
568567
break;
569568
}
@@ -672,7 +671,7 @@ void ArtNetNode::SetNetworkDataLossCondition()
672671
#endif
673672
break;
674673
default:
675-
assert(0);
674+
assert(false && "Invalid kNetworkloss");
676675
break;
677676
}
678677

lib-e131/src/node/e131bridge.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include "hal_panelled.h"
5050
#include "hal_statusled.h"
5151
#include "hal.h"
52-
#include "firmware/debug/debug_debug.h"
52+
#include "firmware/debug/debug_debug.h"
5353

5454
E131Bridge::E131Bridge()
5555
{
@@ -79,7 +79,7 @@ E131Bridge::E131Bridge()
7979
#if defined(E131_HAVE_DMXIN) || defined(NODE_SHOWFILE)
8080
char source_name[e131::kSourceNameLength];
8181
uint8_t length;
82-
snprintf(source_name, e131::kSourceNameLength, "%.48s %s", network::iface::HostName(), hal::BoardName(length));
82+
snprintf(source_name, e131::kSourceNameLength, "%.48s %s", network::iface::HostName(), hal::BoardName(length));
8383
SetSourceName(source_name);
8484

8585
hal::UuidCopy(cid_);
@@ -348,12 +348,12 @@ void E131Bridge::SetUniverse(uint32_t port_index, uint16_t universe)
348348

349349
assert(port_index < dmxnode::kMaxPorts);
350350
assert((universe >= e131::universe::kDefault) && (universe <= e131::universe::kMax));
351-
351+
352352
if (bridge_.port[port_index].universe == universe)
353353
{
354-
DEBUG_EXIT();
355-
return;
356-
}
354+
DEBUG_EXIT();
355+
return;
356+
}
357357

358358
if (bridge_.port[port_index].direction == dmxnode::PortDirection::kOutput)
359359
{
@@ -363,14 +363,14 @@ void E131Bridge::SetUniverse(uint32_t port_index, uint16_t universe)
363363

364364
bridge_.port[port_index].universe = universe;
365365
input_port_[port_index].multicast_ip = e131::UniverseToMulticastIp(universe);
366-
367-
#if defined(E131_HAVE_DMXIN)
366+
367+
#if defined(E131_HAVE_DMXIN)
368368
if (state_.status == e131bridge::Status::kOn)
369369
{
370-
SetLocalMerging();
371-
}
372-
#endif
373-
370+
SetLocalMerging();
371+
}
372+
#endif
373+
374374
DEBUG_EXIT();
375375
}
376376

@@ -440,13 +440,13 @@ void E131Bridge::SetDirection(uint32_t port_index, dmxnode::PortDirection port_d
440440

441441
bridge_.port[port_index].direction = dmxnode::PortDirection::kOutput;
442442
}
443-
444-
#if defined(E131_HAVE_DMXIN)
443+
444+
#if defined(E131_HAVE_DMXIN)
445445
if (state_.status == e131bridge::Status::kOn)
446446
{
447-
SetLocalMerging();
448-
}
449-
#endif
447+
SetLocalMerging();
448+
}
449+
#endif
450450
}
451451

452452
#if defined(E131_HAVE_DMXIN)
@@ -1066,7 +1066,7 @@ void E131Bridge::SetNetworkDataLossCondition(bool source_a, bool source_b)
10661066
break;
10671067
default:
10681068
DEBUG_PRINTF("state_.failsafe=%u", static_cast<uint32_t>(state_.failsafe));
1069-
assert(0);
1069+
assert(false && "Invalid state_.failsafe");
10701070
break;
10711071
}
10721072
}
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
/**
2+
* @file gd32f207c_eval.h
3+
*
4+
*/
5+
/* Copyright (C) 2021-2024 by Arjan van Vught mailto:info@gd32-dmx.org
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
26+
#ifndef BOARD_GD32F207C_EVAL_H_
27+
#define BOARD_GD32F207C_EVAL_H_
28+
29+
#include <stdint.h>
30+
31+
#if !defined(BOARD_GD32F207C_EVAL)
32+
# error This file should not be included
33+
#endif
34+
35+
#if defined (MCU_GD32F20X_MCU_H_)
36+
# error This file should be included later
37+
#endif
38+
39+
/**
40+
* LEDs
41+
*/
42+
43+
#define LED1_GPIO_PINx GPIO_PIN_0
44+
#define LED1_GPIOx GPIOC
45+
#define LED1_RCU_GPIOx RCU_GPIOC
46+
47+
#define LED2_GPIO_PINx GPIO_PIN_2
48+
#define LED2_GPIOx GPIOC
49+
#define LED2_RCU_GPIOx RCU_GPIOC
50+
51+
#define LED3_GPIO_PINx GPIO_PIN_0
52+
#define LED3_GPIOx GPIOE
53+
#define LED3_RCU_GPIOx RCU_GPIOE
54+
55+
#define LED4_GPIO_PINx GPIO_PIN_1
56+
#define LED4_GPIOx GPIOE
57+
#define LED4_RCU_GPIOx RCU_GPIOE
58+
59+
#define LED_BLINK_PIN LED1_GPIO_PINx
60+
#define LED_BLINK_GPIO_PORT LED1_GPIOx
61+
#define LED_BLINK_GPIO_CLK LED1_RCU_GPIOx
62+
63+
/**
64+
* KEYs
65+
*/
66+
67+
#define KEY1_PINx GPIO_PIN_0
68+
#define KEY1_GPIOx GPIOA
69+
#define KEY1_RCU_GPIOx RCU_GPIOA
70+
71+
#define KEY2_PINx GPIO_PIN_13
72+
#define KEY2_GPIOx GPIOC
73+
#define KEY2_RCU_GPIOx RCU_GPIOC
74+
75+
#define KEY3_PINx GPIO_PIN_14
76+
#define KEY3_GPIOx GPIOB
77+
#define KEY3_RCU_GPIOx RCU_GPIOB
78+
79+
#define KEY_BOOTLOADER_TFTP_GPIO_PINx KEY2_PINx
80+
#define KEY_BOOTLOADER_TFTP_GPIOx KEY2_GPIOx
81+
#define KEY_BOOTLOADER_TFTP_RCU_GPIOx KEY2_RCU_GPIOx
82+
83+
/**
84+
* I2C
85+
*/
86+
87+
#define I2C_REMAP GPIO_I2C0_REMAP
88+
#define I2C_PERIPH I2C0_PERIPH
89+
#define I2C_RCU_I2Cx I2C0_RCU_I2C0
90+
#define I2C_SCL_GPIOx I2C0_SCL_GPIOx
91+
#define I2C_SCL_RCU_GPIOx I2C0_SCL_RCU_GPIOx
92+
#define I2C_SDA_GPIOx I2C0_SDA_GPIOx
93+
#define I2C_SDA_RCU_GPIOx I2C0_SDA_RCU_GPIOx
94+
#define I2C_SCL_GPIO_PINx I2C0_SCL_GPIO_PINx
95+
#define I2C_SDA_GPIO_PINx I2C0_SDA_GPIO_PINx
96+
97+
/**
98+
* SPI
99+
*/
100+
101+
#define SPI_PERIPH SPI2_PERIPH
102+
#define SPI_RCU_SPIx SPI2_RCU_SPI2
103+
#define SPI_NSS_GPIOx SPI2_NSS_GPIOx
104+
#define SPI_NSS_RCU_GPIOx SPI2_NSS_RCU_GPIOx
105+
#define SPI_NSS_GPIO_PINx SPI2_NSS_GPIO_PINx
106+
#define SPI_RCU_SPIx SPI2_RCU_SPI2
107+
#define SPI_GPIOx SPI2_GPIOx
108+
#define SPI_RCU_GPIOx SPI2_RCU_GPIOx
109+
#define SPI_SCK_GPIO_PINx SPI2_SCK_GPIO_PINx
110+
#define SPI_MISO_GPIO_PINx SPI2_MISO_GPIO_PINx
111+
#define SPI_MOSI_GPIO_PINx SPI2_MOSI_GPIO_PINx
112+
#define SPI_IO2_PIN SPI2_IO2_GPIO_PINx
113+
#define SPI_IO3_PIN SPI2_IO3_GPIO_PINx
114+
#define SPI_DMAx SPI2_DMAx
115+
#define SPI_DMA_CHx SPI2_TX_DMA_CHx
116+
117+
/**
118+
* I2S
119+
*/
120+
121+
#define I2S_PERIPH SPI2_PERIPH
122+
#define I2S_RCU_SPIx SPI2_RCU_SPI2
123+
#define I2S_RCU_GPIOx SPI2_RCU_GPIOx
124+
#define I2S_GPIOx SPI2_GPIOx
125+
#define I2S_CK_GPIO_PINx SPI2_SCK_GPIO_PINx
126+
#define I2S_SD_GPIO_PINx SPI2_MOSI_GPIO_PINx
127+
#define I2S_WS_RCU_GPIOx SPI2_NSS_RCU_GPIOx
128+
#define I2S_WS_GPIOx SPI2_NSS_GPIOx
129+
#define I2S_WS_GPIO_PINx SPI2_NSS_GPIO_PINx
130+
#define I2S_DMAx SPI2_DMAx
131+
#define I2S_DMA_CHx SPI2_TX_DMA_CHx
132+
133+
/**
134+
* U(S)ART
135+
*/
136+
137+
// #define USART0_REMAP
138+
#define USART1_REMAP
139+
#define USART2_FULL_REMAP
140+
// #define USART2_PARTIAL_REMAP
141+
// #define UART3_REMAP
142+
// #define USART5_REMAP
143+
// #define UART6_REMAP
144+
145+
/**
146+
* Panel LEDs
147+
*/
148+
149+
#ifdef __cplusplus
150+
151+
namespace hal::panelled {
152+
static constexpr uint32_t ACTIVITY = 0;
153+
static constexpr uint32_t ARTNET = 0;
154+
static constexpr uint32_t DDP = 0;
155+
static constexpr uint32_t SACN = 0;
156+
static constexpr uint32_t LTC_IN = 0;
157+
static constexpr uint32_t LTC_OUT = 0;
158+
static constexpr uint32_t MIDI_IN = 0;
159+
static constexpr uint32_t MIDI_OUT = 0;
160+
static constexpr uint32_t OSC_IN = 0;
161+
static constexpr uint32_t OSC_OUT = 0;
162+
static constexpr uint32_t TCNET = 0;
163+
// DMX
164+
static constexpr uint32_t PORT_A_RX = 0;
165+
static constexpr uint32_t PORT_A_TX = 0;
166+
} // namespace hal::panelled
167+
168+
#endif
169+
170+
/**
171+
* SPI flash
172+
*/
173+
174+
#define SPI_FLASH_CS_GPIOx GPIOE
175+
#define SPI_FLASH_CS_RCU_GPIOx RCU_GPIOE
176+
#define SPI_FLASH_CS_GPIO_PINx GPIO_PIN_3
177+
178+
/*
179+
#define SPI_FLASH_WP_GPIO_PINx SPI_IO3_PIN
180+
#define SPI_FLASH_HOLD_GPIO_PINx SPI_IO4_PIN
181+
*/
182+
183+
/**
184+
* USB
185+
*/
186+
187+
#define USB_HOST_VBUS_GPIOx GPIOD
188+
#define USB_HOST_VBUS_RCU_GPIOx RCU_GPIOD
189+
#define USB_HOST_VBUS_GPIO_PINx GPIO_PIN_13
190+
191+
/**
192+
* EXT PHY
193+
*/
194+
195+
#define LINK_CHECK_GPIO_CLK RCU_GPIOB
196+
#define LINK_CHECK_GPIO_PORT GPIOB
197+
#define LINK_CHECK_GPIO_PIN GPIO_PIN_0
198+
#define LINK_CHECK_EXTI_LINE EXTI_0
199+
#define LINK_CHECK_EXTI_IRQn EXTI0_IRQn
200+
#define LINK_CHECK_IRQ_HANDLE EXTI0_IRQHandler
201+
202+
#define LINK_CHECK_EXTI_CLK RCU_AF
203+
#define LINK_CHECK_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOB
204+
#define LINK_CHECK_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_0
205+
#define LINK_CHECK_EXTI_SOURCE_CONFIG gpio_exti_source_select
206+
#define LINK_CHECK_GPIO_CONFIG gpio_init(LINK_CHECK_GPIO_PORT, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, LINK_CHECK_GPIO_PIN);
207+
208+
/**
209+
* MCU and BOARD name
210+
*/
211+
212+
#define GD32_MCU_NAME "GD32F207"
213+
#define GD32_BOARD_NAME "GD32F207C_EVAL"
214+
215+
#include "mcu/gd32f207_mcu.h"
216+
#include "gd32_gpio.h"
217+
218+
#define GD32_BOARD_LED1 GD32_PORT_TO_GPIO(GD32_GPIO_PORTC, 0)
219+
#define GD32_BOARD_LED2 GD32_PORT_TO_GPIO(GD32_GPIO_PORTC, 2)
220+
#define GD32_BOARD_LED3 GD32_PORT_TO_GPIO(GD32_GPIO_PORTE, 0)
221+
#define GD32_BOARD_LED4 GD32_PORT_TO_GPIO(GD32_GPIO_PORTE, 1)
222+
#define GD32_BOARD_STATUS_LED GD32_BOARD_LED1
223+
224+
/**
225+
* LCD
226+
*/
227+
228+
#define DISPLAYTIMEOUT_GPIO GD32_PORT_TO_GPIO(GD32_GPIO_PORTC, 13) // KEY2
229+
230+
#define DISPLAYTIMEOUT_GPIO_CLK RCU_GPIOC
231+
#define DISPLAYTIMEOUT_GPIO_PORT GPIOC
232+
#define DISPLAYTIMEOUT_GPIO_PIN GPIO_PIN_13
233+
#define DISPLAYTIMEOUT_EXTI_LINE EXTI_13
234+
#define DISPLAYTIMEOUT_EXTI_IRQn EXTI10_15_IRQn
235+
#define DISPLAYTIMEOUT_IRQ_HANDLE EXTI10_15_IRQHandler
236+
237+
#define DISPLAYTIMEOUT_EXTI_CLK RCU_AF
238+
#define DISPLAYTIMEOUT_EXTI_PORT_SOURCE GPIO_PORT_SOURCE_GPIOB
239+
#define DISPLAYTIMEOUT_EXTI_PIN_SOURCE GPIO_PIN_SOURCE_13
240+
#define DISPLAYTIMEOUT_EXTI_SOURCE_CONFIG gpio_exti_source_select
241+
#define DISPLAYTIMEOUT_GPIO_CONFIG gpio_init(DISPLAYTIMEOUT_GPIO_PORT, GPIO_MODE_IPU, GPIO_OSPEED_50MHZ, DISPLAYTIMEOUT_GPIO_PIN);
242+
243+
244+
/**
245+
* Pixel DMX
246+
*/
247+
248+
#define PIXELDMXSTARTSTOP_GPIO GD32_BOARD_LED2
249+
250+
/**
251+
* SPI LCD
252+
*/
253+
254+
#define SPI_LCD_RST_PIN GD32_PORT_TO_GPIO(GD32_GPIO_PORTA, 6)
255+
#define SPI_LCD_DC_GPIO GD32_PORT_TO_GPIO(GD32_GPIO_PORTA, 14)
256+
#define SPI_LCD_BL_GPIO GD32_PORT_TO_GPIO(GD32_GPIO_PORTA, 11)
257+
#if defined(SPI_LCD_HAVE_CS_GPIO)
258+
# define SPI_LCD_CS_GPIO GD32_PORT_TO_GPIO(GD32_GPIO_PORTA, 15)
259+
#endif
260+
261+
/**
262+
* FT8xx LCD
263+
*/
264+
265+
#define FT8XX_LCD_DC_GPIO GD32_PORT_TO_GPIO(GD32_GPIO_PORTA, 14)
266+
#define FT8XX_LCD_CS_GPIO GD32_PORT_TO_GPIO(GD32_GPIO_PORTA, 15)
267+
268+
#include "gpio_header.h"
269+
270+
#endif /* BOARD_GD32F207C_EVAL_H_ */

0 commit comments

Comments
 (0)