Skip to content

Commit 80cfdd7

Browse files
committed
gd32: update includes, IRQs, and timer flag clears
Add compiler options and tidy up GD32 platform code: - Add common/make/gd32/Gd32FirmwareOps.mk with GD32FIRMWAREOPS warnings flags. - Change include handling to use -isystem for CMSIS and lib-gd32 headers, reorder/include common and project include paths (common/make/gd32/Includes.mk). - Remove redundant static_cast<uint32_t> when clearing TIMER_INTF flags in lib-dmx/src/gd32/dmx.cpp, lib-gd32/src/softuart0/uart0.cpp, and lib-gd32/src/timer6.cpp. - Add IRQ naming support for GD32F30X_XD in uart0.cpp. - Simplify gd32xxxx.h by removing GCC diagnostic push/pop pragmas and add support for GD32F30X_XD in MCU selection. These changes reduce noisy casts, improve include handling for third-party headers, and add device/IRQ support.
1 parent 807627c commit 80cfdd7

6 files changed

Lines changed: 29 additions & 39 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$(info "Gd32FirmwareOpts.mk")
2+
3+
GD32FIRMWAREOPS=-Wno-error=unused-parameter -Wno-error=unused-but-set-variable -Wno-error=conversion -Wno-error=old-style-cast

common/make/gd32/Includes.mk

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
$(info "Includes.mk")
22

3-
INCLUDES:=-I./include
4-
INCLUDES+=-I../common/include -I../include
5-
INCLUDES+=-I../firmware-template-gd32/include
6-
INCLUDES+=-I../CMSIS/Core/Include
7-
INCLUDES+=-I../lib-gd32/${FAMILY}/${FAMILY_UC}_standard_peripheral/Include
8-
INCLUDES+=-I../lib-gd32/${FAMILY}/CMSIS/GD/${FAMILY_UC}/Include
9-
INCLUDES+=-I../lib-gd32/include
3+
INCLUDES:=-I../include
4+
INCLUDES+=-isystem ../CMSIS/Core/Include
5+
INCLUDES+=-isystem ../lib-gd32/${FAMILY}/${FAMILY_UC}_standard_peripheral/Include
6+
INCLUDES+=-isystem ../lib-gd32/${FAMILY}/CMSIS/GD/${FAMILY_UC}/Include
7+
INCLUDES+=-isystem ../lib-gd32/include
8+
INCLUDES+=-isystem ../firmware-template-gd32/include
9+
INCLUDES+=-I../common/include
1010
INCLUDES+=-I../lib-hwclock/include
11+
INCLUDES+=-I./include
1112

1213
INCLUDES+=$(addprefix -I,$(EXTRA_INCLUDES))
1314

@@ -104,5 +105,5 @@ ifdef USB_HOST_MSC
104105
INCLUDES+=-I../lib-fatfs
105106
endif
106107

107-
INCLUDES:= $(strip -I../${PROJECT}/include $(sort $(INCLUDES)))
108+
#INCLUDES:= $(strip -I../${PROJECT}/include $(sort $(INCLUDES)))
108109
$(info $$INCLUDES [${INCLUDES}])

lib-dmx/src/gd32/dmx.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ void TIMER1_IRQHandler() {
494494
}
495495
}
496496

497-
TIMER_INTF(TIMER1) = static_cast<uint32_t>(~TIMER_INT_FLAG_CH0);
497+
TIMER_INTF(TIMER1) = (~TIMER_INT_FLAG_CH0);
498498
}
499499
#endif // defined(DMX_USE_USART0)
500500
// USART 1
@@ -561,7 +561,7 @@ void TIMER1_IRQHandler() {
561561
}
562562
}
563563

564-
TIMER_INTF(TIMER1) = static_cast<uint32_t>(~TIMER_INT_FLAG_CH1);
564+
TIMER_INTF(TIMER1) = (~TIMER_INT_FLAG_CH1);
565565
}
566566
#endif // defined(DMX_USE_USART1)
567567
// USART 2
@@ -629,7 +629,7 @@ void TIMER1_IRQHandler() {
629629
}
630630
}
631631

632-
TIMER_INTF(TIMER1) = static_cast<uint32_t>(~TIMER_INT_FLAG_CH2);
632+
TIMER_INTF(TIMER1) = (~TIMER_INT_FLAG_CH2);
633633
}
634634
#endif // defined(DMX_USE_USART2)
635635
// UART 3
@@ -695,7 +695,7 @@ void TIMER1_IRQHandler() {
695695
}
696696
}
697697

698-
TIMER_INTF(TIMER1) = static_cast<uint32_t>(~TIMER_INT_FLAG_CH3);
698+
TIMER_INTF(TIMER1) = (~TIMER_INT_FLAG_CH3);
699699
}
700700
#endif // defined(DMX_USE_UART3)
701701
// Clear all remaining interrupt flags (safety measure)
@@ -770,7 +770,7 @@ void TIMER4_IRQHandler() {
770770
}
771771
}
772772

773-
TIMER_INTF(TIMER4) = static_cast<uint32_t>(~TIMER_INT_FLAG_CH0);
773+
TIMER_INTF(TIMER4) = (~TIMER_INT_FLAG_CH0);
774774
}
775775
#endif // defined(DMX_USE_UART4)
776776
// USART 5
@@ -839,7 +839,7 @@ void TIMER4_IRQHandler() {
839839
}
840840
}
841841

842-
TIMER_INTF(TIMER4) = static_cast<uint32_t>(~TIMER_INT_FLAG_CH1);
842+
TIMER_INTF(TIMER4) = (~TIMER_INT_FLAG_CH1);
843843
}
844844
#endif // defined(DMX_USE_USART5)
845845
// UART 6
@@ -898,7 +898,7 @@ void TIMER4_IRQHandler() {
898898
}
899899
}
900900

901-
TIMER_INTF(TIMER4) = static_cast<uint32_t>(~TIMER_INT_FLAG_CH2);
901+
TIMER_INTF(TIMER4) = (~TIMER_INT_FLAG_CH2);
902902
}
903903
#endif // defined(DMX_USE_UART6)
904904
// UART 7
@@ -957,7 +957,7 @@ void TIMER4_IRQHandler() {
957957
}
958958
}
959959

960-
TIMER_INTF(TIMER4) = static_cast<uint32_t>(~TIMER_INT_FLAG_CH3);
960+
TIMER_INTF(TIMER4) = (~TIMER_INT_FLAG_CH3);
961961
}
962962
#endif // defined(DMX_USE_UART7)
963963
// Clear all remaining interrupt flags (safety measure)
@@ -979,7 +979,7 @@ void TIMER6_IRQHandler() {
979979
}
980980

981981
// Clear all remaining interrupt flags (safety measure)
982-
TIMER_INTF(TIMER6) = static_cast<uint32_t>(~kIntFlag);
982+
TIMER_INTF(TIMER6) = (~kIntFlag);
983983
}
984984

985985
// USART 0

lib-gd32/include/gd32xxxx.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,11 @@
2626
#ifndef GD32FXXX_H_
2727
#define GD32FXXX_H_
2828

29-
// Needed for GD32 Firmware and CMSIS
30-
31-
#ifdef __cplusplus
32-
#pragma GCC diagnostic push
33-
#pragma GCC diagnostic ignored "-Wuseless-cast"
34-
#pragma GCC diagnostic ignored "-Wold-style-cast"
35-
#pragma GCC diagnostic ignored "-Wconversion"
36-
#pragma GCC diagnostic ignored "-Wsign-conversion"
37-
#if __cplusplus > 201402
38-
// error: compound assignment with 'volatile'-qualified left operand is
39-
// deprecated
40-
#pragma GCC diagnostic ignored "-Wvolatile"
41-
#endif
42-
#endif
43-
4429
#if defined(GD32F10X_HD) || defined(GD32F10X_CL)
4530
#include "gd32f10x.h" // IWYU pragma: keep
4631
#elif defined(GD32F20X_CL)
4732
#include "gd32f20x.h" // IWYU pragma: keep
48-
#elif defined(GD32F30X_HD)
33+
#elif defined(GD32F30X_HD) || defined(GD32F30X_XD)
4934
#include "gd32f30x.h" // IWYU pragma: keep
5035
#elif defined(GD32F407) || defined(GD32F450) || defined(GD32F470)
5136
#include "gd32f4xx.h" // IWYU pragma: keep
@@ -56,8 +41,4 @@
5641
#error MCU is not supported
5742
#endif
5843

59-
#ifdef __cplusplus
60-
#pragma GCC diagnostic pop
61-
#endif
62-
6344
#endif // GD32FXXX_H_ */

lib-gd32/src/softuart0/uart0.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@
3535
#elif defined(GD32F30X)
3636
#define TIMERx TIMER7
3737
#define RCU_TIMERx RCU_TIMER7
38+
#if defined (GD32F30X_XD)
39+
#define TIMERx_IRQHandler TIMER7_UP_TIMER12_IRQHandler
40+
#define TIMERx_IRQn TIMER7_UP_TIMER12_IRQn
41+
#else
3842
#define TIMERx_IRQHandler TIMER7_UP_IRQHandler
3943
#define TIMERx_IRQn TIMER7_UP_IRQn
44+
#endif
4045
#else
4146
#define TIMERx TIMER9
4247
#define RCU_TIMERx RCU_TIMER9
@@ -147,7 +152,7 @@ void TIMERx_IRQHandler() {
147152
}
148153
}
149154

150-
TIMER_INTF(TIMERx) = static_cast<uint32_t>(~kIntFlag);
155+
TIMER_INTF(TIMERx) = ~kIntFlag;
151156
}
152157
#if defined(SOFTUART0_ENABLE_RX)
153158
void SOFTUART_RX_EXTIx_IRQHandler() {

lib-gd32/src/timer6.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void TIMER6_IRQHandler() {
4141
gv_seconds.uptime = gv_seconds.uptime + 1;
4242
}
4343

44-
TIMER_INTF(TIMER6) = static_cast<uint32_t>(~kIntFlag);
44+
TIMER_INTF(TIMER6) = ~kIntFlag;
4545
}
4646
#endif
4747
}

0 commit comments

Comments
 (0)