Skip to content

Commit 807627c

Browse files
committed
Add UART wrapper and adjust GD32 headers
Add a new lib-gd32/include/uart.h wrapper exposing inline uart helpers and constants for GD32. Update various file headers/comments (hal_* -> board_*, font_cp437.h header tag). Use gpio::Write in ILI9341 SetBackLight. Suppress -Wunused-parameter for GD32H7 includes. Add EXTRA_INCLUDES to lib-hwclock/Rules.mk to ensure lib-board includes are available during build.
1 parent daaaccc commit 807627c

9 files changed

Lines changed: 76 additions & 6 deletions

File tree

lib-board/include/board_statusled.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file hal_statusled.h
2+
* @file board_statusled.h
33
*
44
*/
55
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org

lib-board/src/gd32/board_init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file hal_init.cpp
2+
* @file board_init.cpp
33
*
44
*/
55
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org

lib-board/src/gd32/board_reboot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file hal_reboot.cpp
2+
* @file board_reboot.cpp
33
*
44
*/
55
/* Copyright (C) 2025-2026 by Arjan van Vught mailto:info@gd32-dmx.org

lib-board/src/gd32/board_statusled.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file hal_statusled.cpp
2+
* @file board_statusled.cpp
33
*
44
*/
55
/* Copyright (C) 2025 by Arjan van Vught mailto:info@gd32-dmx.org

lib-device/src/font_cp437.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file font_cp437.cpp
2+
* @file font_cp437.h
33
*
44
*/
55
/* Copyright (C) 2019-2026 by Arjan van Vught mailto:info@gd32-dmx.org

lib-display/include/spi/ili9341.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class ILI9341 : public Paint {
205205
rotate_ = nRotation;
206206
}
207207

208-
void SetBackLight(uint32_t value) { FUNC_PREFIX(GpioWrite(SPI_LCD_BL_GPIO, value == 0 ? LOW : HIGH)); }
208+
void SetBackLight(uint32_t value) { gpio::Write(SPI_LCD_BL_GPIO, value == 0 ? LOW : HIGH); }
209209

210210
void EnableDisplay(bool enable) { WriteCommand(enable ? ili9341::cmd::DISPON : ili9341::cmd::DISPOFF); }
211211

lib-gd32/include/gd32xxxx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#elif defined(GD32F407) || defined(GD32F450) || defined(GD32F470)
5151
#include "gd32f4xx.h" // IWYU pragma: keep
5252
#elif defined(GD32H757) || defined(GD32H759)
53+
#pragma GCC diagnostic ignored "-Wunused-parameter"
5354
#include "gd32h7xx.h" // IWYU pragma: keep
5455
#else
5556
#error MCU is not supported

lib-gd32/include/uart.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* @file uart.h
3+
* @brief GD32
4+
*/
5+
/* Copyright (C) 2026 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 UART_H_
27+
#define UART_H_
28+
29+
#include "gd32_uart.h"
30+
31+
namespace uart {
32+
inline constexpr auto BITS_8 = gd32::kUartBits8;
33+
inline constexpr auto BITS_9 = gd32::kUartBits9;
34+
35+
inline constexpr auto PARITY_NONE = gd32::kUartParityNone;
36+
inline constexpr auto PARITY_ODD = gd32::kUartParityOdd;
37+
inline constexpr auto PARITY_EVEN = gd32::kUartParityEven;
38+
39+
inline constexpr auto STOP_1BIT = gd32::kUartStop1Bit;
40+
inline constexpr auto STOP_2BITS = gd32::kUartStop2Bits;
41+
42+
inline void Begin(uint32_t uart_base, uint32_t baudrate, uint32_t bits, uint32_t parity, uint32_t stop_bits) {
43+
Gd32UartBegin(uart_base, baudrate, bits, parity, stop_bits);
44+
}
45+
46+
inline void SetBaudrate(uint32_t uart_base, uint32_t baudrate) {
47+
Gd32UartSetBaudrate(uart_base, baudrate);
48+
}
49+
50+
inline void Transmit(uint32_t uart_base, const uint8_t* data, uint32_t length) {
51+
Gd32UartTransmit(uart_base, data, length);
52+
}
53+
54+
inline void TransmitString(uint32_t uart_base, const char* data) {
55+
Gd32UartTransmitString(uart_base, data);
56+
}
57+
58+
inline uint32_t GetRxFifoLevel(uint32_t uart_base) {
59+
return Gd32UartGetRxFifoLevel(uart_base);
60+
}
61+
62+
inline uint8_t GetRxData(uint32_t uart_base) {
63+
return Gd32UartGetRxData(uart_base);
64+
}
65+
} // namespace uart
66+
67+
#endif // UART_H_

lib-hwclock/Rules.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
$(info $$MAKE_FLAGS [${MAKE_FLAGS}])
22

3+
EXTRA_INCLUDES+=../lib-board/include
4+
35
ifneq ($(MAKE_FLAGS),)
46
ifneq (,$(findstring DISABLE_INTERNAL_RTC,$(MAKE_FLAGS)))
57
EXTRA_SRCDIR+=src/i2c

0 commit comments

Comments
 (0)