Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9c4d2a4
Bump GD32F30x SPL to v3.0.3 and API fixes
vanvught Jun 23, 2026
1e76278
gd32: add firmware ops and tidy includes
vanvught Jun 23, 2026
b4b5316
Add GD32F30X_XD support and cleanup pragmas
vanvught Jun 23, 2026
0afa0bd
Fix DMX input indexing and simplify timer clears
vanvught Jun 23, 2026
071752a
Remove redundant cast in TIMER6 IRQ handler
vanvught Jun 23, 2026
4544ab8
Remove redundant cast in UART transmit assignments
vanvught Jun 23, 2026
a2329fe
Adjust compiler warning flags for GD32 builds
vanvught Jun 28, 2026
0707690
Tidy debug_dump header and NDEBUG stub
vanvught Jun 28, 2026
fb94154
Tighten enum and integer type conversions
vanvught Jun 28, 2026
1e73fcd
Use uint8_t in RTC BCD conversion helpers
vanvught Jun 28, 2026
e8cba32
Adjust GD32 build warning handling
vanvught Jun 28, 2026
926e8c1
Update GD32F30x CMSIS HAL to v3.0.3
vanvught Jun 29, 2026
46ee22d
Cast UART0 DMA count to uint16_t
vanvught Jun 29, 2026
791202f
Fix copyright emails and improve parameter names
vanvught Jul 3, 2026
b154fed
Reorganize LCD config to config::lcd namespace
vanvught Jul 3, 2026
d63dbf8
Centralize GD32 unique ID access
vanvught Jul 3, 2026
e267701
Add DMX slot timing constants
vanvught Jul 3, 2026
80c96cb
Normalize header brace style
vanvught Jul 3, 2026
adc476d
Add GD32 device info lookups
vanvught Jul 3, 2026
ea564b6
Drop obsolete include paths from .cproject
vanvught Jul 3, 2026
6cada70
Add GD32 device mapping JSON
vanvught Jul 3, 2026
29c9d13
Annotate DMX API and tidy GD32 utilities
vanvught Jul 12, 2026
026ff4f
Use GD32 identifiers for device detection
vanvught Jul 15, 2026
a5579d7
Add GD32 TRNG support
vanvught Jul 15, 2026
28c8f63
Use shared build script in CI workflow
vanvught Jul 15, 2026
37c4285
Adopt C++23 and tidy UTC helpers
vanvught Jul 15, 2026
e8d5635
Refactor Global to free functions, misc fixes
vanvught Jul 15, 2026
8b4417d
Feed watchdog in debug heap logging
vanvught Jul 15, 2026
5efb861
Clean up main.cpp and fix widget mode printf
vanvught Jul 15, 2026
5cc360b
Refactor configstore.h formatting and API
vanvught Jul 15, 2026
b554117
Fix format specifiers and minor code cleanup
vanvught Jul 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install arm-none-eabi
run: sudo apt install gcc-arm-none-eabi
- name: make gd32_dmx_usb_pro
- name: version
run: arm-none-eabi-g++ --version
- name: build all
run: |
cd gd32_dmx_usb_pro
make -f Makefile.GD32 clean
make -f Makefile.GD32
cd -
- name: make gd32_rdm_responder
run: |
cd gd32_rdm_responder
make -f Makefile.GD32 clean
make -f Makefile.GD32
cd -
cd scripts
./build_all.sh
3 changes: 1 addition & 2 deletions common/include/common/utils/utils_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

#include <type_traits>

namespace common
{
namespace common {
// Converts an enum class value to its underlying integer type.
template <typename Enum>
constexpr auto ToValue(Enum e) noexcept -> std::underlying_type_t<Enum> {
Expand Down
46 changes: 15 additions & 31 deletions common/include/common/utils/utils_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,80 +31,64 @@

#include "common/utils/utils_enum.h" // Ensure this provides ToValue and FromValue

namespace common
{

namespace common {
template <typename E>
requires std::is_enum_v<E>
constexpr E operator|(E lhs, E rhs)
{
constexpr E operator|(E lhs, E rhs) {
return static_cast<E>(ToValue(lhs) | ToValue(rhs));
}

template <typename E>
requires std::is_enum_v<E>
constexpr E operator&(E lhs, E rhs)
{
constexpr E operator&(E lhs, E rhs) {
return static_cast<E>(ToValue(lhs) & ToValue(rhs));
}

template <typename E>
requires std::is_enum_v<E>
constexpr E operator~(E e)
{
constexpr E operator~(E e) {
return static_cast<E>(~ToValue(e));
}

template <typename E>
requires std::is_enum_v<E>
constexpr E& operator|=(E& lhs, E rhs)
{
constexpr E& operator|=(E& lhs, E rhs) {
lhs = lhs | rhs;
return lhs;
}

template <typename E>
requires std::is_enum_v<E>
constexpr E& operator&=(E& lhs, E rhs)
{
constexpr E& operator&=(E& lhs, E rhs) {
lhs = lhs & rhs;
return lhs;
}

template <typename E>
requires std::is_enum_v<E>
constexpr void SetFlag(uint32_t& flags, E bit, bool enable)
{
if (enable)
{
constexpr void SetFlag(uint32_t& flags, E bit, bool enable) {
if (enable) {
flags |= ToValue(bit);
}
else
{
} else {
flags &= ~ToValue(bit);
}
}

template <typename E>
requires std::is_enum_v<E>
constexpr uint32_t SetFlagValue(uint32_t flags, E bit, bool enable)
{
if (enable)
{
constexpr uint32_t SetFlagValue(uint32_t flags, E bit, bool enable) {
if (enable) {
return flags | ToValue(bit);
}
else
{
return flags & ~ToValue(bit);
}

return flags & ~ToValue(bit);
}

template <typename E>
requires std::is_enum_v<E>
requires std::is_enum_v<E>
constexpr bool IsFlagSet(uint32_t flags, E bit) {
return (flags & ToValue(bit)) != 0;
}

} // namespace common

#endif // COMMON_UTILS_UTILS_FLAGS_H_
#endif // COMMON_UTILS_UTILS_FLAGS_H_
14 changes: 5 additions & 9 deletions common/include/common/utils/utils_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,23 @@
#include <cstdint>

// Compile-time FNV-1a 32-bit hash
consteval uint32_t Fnv1a32(const char* str, uint8_t length)
{
consteval uint32_t Fnv1a32(const char* str, uint8_t length) {
uint32_t hash = 0x811c9dc5u;
for (uint8_t i = 0; i < length; ++i)
{
for (uint8_t i = 0; i < length; ++i) {
hash ^= static_cast<uint8_t>(str[i]);
hash *= 0x01000193u;
}
return hash;
}

// Runtime version for raw filenames
inline uint32_t Fnv1a32Runtime(const char* str, uint32_t length)
{
inline uint32_t Fnv1a32Runtime(const char* str, uint32_t length) {
uint32_t hash = 0x811c9dc5u;
for (uint32_t i = 0; i < length; ++i)
{
for (uint32_t i = 0; i < length; ++i) {
hash ^= static_cast<uint8_t>(str[i]);
hash *= 0x01000193u;
}
return hash;
}

#endif // COMMON_UTILS_UTILS_HASH_H_
#endif // COMMON_UTILS_UTILS_HASH_H_
11 changes: 5 additions & 6 deletions common/include/common/utils/utils_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@

#include <cstdint>

namespace common
{
template <class S> void PortSet(uint32_t port_index, S s, uint16_t& n)
{
namespace common {
template <class S>
void PortSet(uint32_t port_index, S s, uint16_t& n) {
uint16_t value = n; // Create a local copy
value &= static_cast<uint16_t>(~(0x3 << (port_index * 2)));
value |= static_cast<uint16_t>((static_cast<uint32_t>(s) & 0x3) << (port_index * 2));
n = value; // Write back to the original field
}

template <class S> S PortGet(uint32_t port_index, uint16_t n)
{
template <class S>
S PortGet(uint32_t port_index, uint16_t n) {
return static_cast<S>((n >> (port_index * 2)) & 0x3);
}
} // namespace common
Expand Down
9 changes: 3 additions & 6 deletions common/include/common/utils/utils_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@

#include <cstdint>

namespace common
{
constexpr uint32_t ConstStrLen(const char* s)
{
namespace common {
constexpr uint32_t ConstStrLen(const char* str) {
uint32_t len = 0;
while (s[len] != '\0')
{
while (str[len] != '\0') {
++len;
}
return len;
Expand Down
56 changes: 21 additions & 35 deletions common/include/firmware/debug/debug_dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file debug_dump.h
*
*/
/* Copyright (C) 2018-2025 by Arjan van Vught mailto:info@gd32-dmx.org
/* Copyright (C) 2018-2026 by Arjan van Vught mailto:info@gd32-dmx.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -31,78 +31,64 @@
#include <ctype.h>

#if defined(H3)
namespace uart0
{
namespace uart0 {
int Printf(const char* fmt, ...);
}
#define printf uart0::Printf // NOLINT
#endif

namespace debug
{
namespace dump
{
namespace debug {
namespace dump {
inline constexpr uint32_t kCharsPerLine = 16;
}
#ifdef NDEBUG
inline void Dump([[maybe_unused]] const void* data, [[maybe_unused]] uint32_t size) {}
static inline void Dump([[maybe_unused]] const void* data, [[maybe_unused]] uint32_t size) {}
#else
inline void Dump(const void* data, uint32_t size)
{
inline void Dump(const void* data, uint32_t size) {
uint32_t chars = 0;
const auto* p = reinterpret_cast<const uint8_t*>(data);
const auto* ptr = reinterpret_cast<const uint8_t*>(data);

printf("%p:%d\n", data, size);
printf("%p:%u\n", data, static_cast<int>(size));

do
{
do {
uint32_t chars_this_line = 0;

printf("%04x ", chars);
printf("%04x ", static_cast<unsigned>(chars));

const auto* q = p;
const auto* q = ptr;

while ((chars_this_line < dump::kCharsPerLine) && (chars < size))
{
if (chars_this_line % 8 == 0)
{
while ((chars_this_line < dump::kCharsPerLine) && (chars < size)) {
if (chars_this_line % 8 == 0) {
printf(" ");
}

printf("%02x ", *p);
printf("%02x ", *ptr);

chars_this_line++;
chars++;
p++;
ptr++;
}

auto chars_dot_line = chars_this_line;

for (; chars_this_line < dump::kCharsPerLine; chars_this_line++)
{
if (chars_this_line % 8 == 0)
{
for (; chars_this_line < dump::kCharsPerLine; chars_this_line++) {
if (chars_this_line % 8 == 0) {
printf(" ");
}
printf(" ");
}

chars_this_line = 0;

while (chars_this_line < chars_dot_line)
{
if (chars_this_line % 8 == 0)
{
while (chars_this_line < chars_dot_line) {
if (chars_this_line % 8 == 0) {
printf(" ");
}

int ch = *q;
if (isprint(ch))
{
if (isprint(ch)) {
printf("%c", ch);
}
else
{
} else {
printf(".");
}

Expand Down
4 changes: 2 additions & 2 deletions common/include/firmware/debug/debug_i2cdetect.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Detect() {
puts("\n 0 1 2 3 4 5 6 7 8 9 a b c d e f");

for (uint32_t i = 0; i < 128; i = (i + 16)) {
printf("%02x: ", i);
printf("%02x: ", static_cast<unsigned>(i));
for (uint32_t j = 0; j < 16; j++) {
// Skip unwanted addresses
if ((i + j < kFirst) || (i + j > kLast)) {
Expand All @@ -53,7 +53,7 @@ void Detect() {
}

if (::i2c::IsConnected(static_cast<uint8_t>(i + j))) {
printf("%02x ", i + j);
printf("%02x ", static_cast<unsigned>(i + j));
} else {
printf("-- ");
}
Expand Down
20 changes: 10 additions & 10 deletions common/include/firmware/debug/debug_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ inline void Print() {
assert(end > start);
const auto kSize = static_cast<uint32_t>(end - start);

auto* p = start;
const auto* ptr = start;

while (p < end) {
if (*p != kMagicWord) {
while (ptr < end) {
if (*ptr != kMagicWord) {
break;
}
p++;
ptr++;
}

const auto kUsedBytes = static_cast<uint32_t>(4 * (end - p));
const auto kFreeBytes = static_cast<uint32_t>(4 * (p - start));
const auto kFreePct = (static_cast<uint32_t>(p - start) * 100U) / kSize;
const auto kUsedBytes = static_cast<uint32_t>(4 * (end - ptr));
const auto kFreeBytes = static_cast<uint32_t>(4 * (ptr - start));
const auto kFreePct = (static_cast<uint32_t>(ptr - start) * 100U) / kSize;

if (s_used_bytes_previous != kUsedBytes) {
s_used_bytes_previous = kUsedBytes;
Expand All @@ -70,9 +70,9 @@ inline void Print() {
}

#ifndef NDEBUG
printf("Stack: Size %uKB, [%p:%p:%p], Used: %u, Free: %u [%u]", kSize / (1024 / 4), start, p, end, kUsedBytes, kFreeBytes, kFreePct);
printf("Stack: Size %uKB, [%p:%p:%p], Used: %u, Free: %u [%u]", static_cast<unsigned>(kSize / (1024 / 4)), reinterpret_cast<const void *>(start), reinterpret_cast<const void *>(ptr), reinterpret_cast<const void *>(end), static_cast<unsigned>(kUsedBytes), static_cast<unsigned>(kFreeBytes), static_cast<unsigned>(kFreePct));
#else
printf("Stack: Size %uKB, Used: %u, Free: %u", kSize / (1024 / 4), kUsedBytes, kFreeBytes);
printf("Stack: Size %uKB, Used: %u, Free: %u", static_cast<unsigned>(kSize / (1024 / 4)), static_cast<unsigned>(kUsedBytes), static_cast<unsigned>(kFreeBytes));
#endif
printf("\x1b[39m\n");
}
Expand All @@ -81,7 +81,7 @@ inline void Print() {
inline void Run() {
static uint32_t s_millis_previous;
const auto kMillis = timing::Millis();
if (kMillis - s_millis_previous >= 1000) {
if (kMillis - s_millis_previous >= 1000U) {
s_millis_previous = kMillis;
Print();
}
Expand Down
Loading
Loading