Skip to content

Commit 5dbc843

Browse files
committed
Update GD32F20x peripheral library to v3.0.0
Syncs the GD32F20x standard peripheral driver set from V2.5.0 to V3.0.0, including updated file metadata and broad driver-level fixes. The update corrects register definitions and typos (notably in CAN), refactors DAC APIs/macros to the newer channel-based interface, and adds/adjusts APIs such as SPI format-error clearing and IRQ typing in MISC. It also improves robustness across multiple modules by tightening status/flag handling, adding timeout-aware error paths, and converting several previously unconditional returns/loops into explicit success/error flows. ENET, FWDGT, CAU/HAU, FMC, and other peripherals received behavioral and consistency updates aligned with the newer upstream driver release.
1 parent 66bf243 commit 5dbc843

60 files changed

Lines changed: 1173 additions & 972 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib-gd32/gd32f20x/GD32F20x_standard_peripheral/Include/gd32f20x_adc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
\file gd32f20x_adc.h
33
\brief definitions for the ADC
44
5-
\version 2023-06-30, V2.5.0, firmware for GD32F20x
5+
\version 2026-02-06, V3.0.0, firmware for GD32F20x
66
*/
77

88
/*
9-
Copyright (c) 2023, GigaDevice Semiconductor Inc.
9+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
1010
1111
Redistribution and use in source and binary forms, with or without modification,
1212
are permitted provided that the following conditions are met:

lib-gd32/gd32f20x/GD32F20x_standard_peripheral/Include/gd32f20x_bkp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
\file gd32f20x_bkp.h
33
\brief definitions for the BKP
44
5-
\version 2023-06-30, V2.5.0, firmware for GD32F20x
5+
\version 2026-02-06, V3.0.0, firmware for GD32F20x
66
*/
77

88
/*
9-
Copyright (c) 2023, GigaDevice Semiconductor Inc.
9+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
1010
1111
Redistribution and use in source and binary forms, with or without modification,
1212
are permitted provided that the following conditions are met:

lib-gd32/gd32f20x/GD32F20x_standard_peripheral/Include/gd32f20x_can.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
\file gd32f20x_can.h
33
\brief definitions for the CAN
44
5-
\version 2023-06-30, V2.5.0, firmware for GD32F20x
5+
\version 2026-02-06, V3.0.0, firmware for GD32F20x
66
*/
77

88
/*
9-
Copyright (c) 2023, GigaDevice Semiconductor Inc.
9+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
1010
1111
Redistribution and use in source and binary forms, with or without modification,
1212
are permitted provided that the following conditions are met:
@@ -98,7 +98,7 @@ OF SUCH DAMAGE.
9898
#define CAN_F20DATA0(canx) REG32((canx) + 0x000002E0U) /*!< CAN filter 20 data 0 register */
9999
#define CAN_F21DATA0(canx) REG32((canx) + 0x000002E8U) /*!< CAN filter 21 data 0 register */
100100
#define CAN_F22DATA0(canx) REG32((canx) + 0x000002F0U) /*!< CAN filter 22 data 0 register */
101-
#define CAN_F23DATA0(canx) REG32((canx) + 0x000003F8U) /*!< CAN filter 23 data 0 register */
101+
#define CAN_F23DATA0(canx) REG32((canx) + 0x000002F8U) /*!< CAN filter 23 data 0 register */
102102
#define CAN_F24DATA0(canx) REG32((canx) + 0x00000300U) /*!< CAN filter 24 data 0 register */
103103
#define CAN_F25DATA0(canx) REG32((canx) + 0x00000308U) /*!< CAN filter 25 data 0 register */
104104
#define CAN_F26DATA0(canx) REG32((canx) + 0x00000310U) /*!< CAN filter 26 data 0 register */
@@ -120,7 +120,7 @@ OF SUCH DAMAGE.
120120
#define CAN_F14DATA1(canx) REG32((canx) + 0x000002B4U) /*!< CAN filter 14 data 1 register */
121121
#define CAN_F15DATA1(canx) REG32((canx) + 0x000002BCU) /*!< CAN filter 15 data 1 register */
122122
#define CAN_F16DATA1(canx) REG32((canx) + 0x000002C4U) /*!< CAN filter 16 data 1 register */
123-
#define CAN_F17DATA1(canx) REG32((canx) + 0x0000024CU) /*!< CAN filter 17 data 1 register */
123+
#define CAN_F17DATA1(canx) REG32((canx) + 0x000002CCU) /*!< CAN filter 17 data 1 register */
124124
#define CAN_F18DATA1(canx) REG32((canx) + 0x000002D4U) /*!< CAN filter 18 data 1 register */
125125
#define CAN_F19DATA1(canx) REG32((canx) + 0x000002DCU) /*!< CAN filter 19 data 1 register */
126126
#define CAN_F20DATA1(canx) REG32((canx) + 0x000002E4U) /*!< CAN filter 20 data 1 register */
@@ -392,7 +392,7 @@ typedef enum {
392392
CAN_INT_FLAG_WERR = CAN_REGIDX_BITS(ERR_REG_OFFSET, 0U, 8U), /*!< warning error interrupt flag */
393393
} can_interrupt_flag_enum;
394394

395-
/* CAN initiliaze parameters structure */
395+
/* CAN initialize parameters structure */
396396
typedef struct {
397397
uint8_t working_mode; /*!< CAN working mode */
398398
uint8_t resync_jump_width; /*!< CAN resynchronization jump width */
@@ -415,7 +415,7 @@ typedef struct {
415415
uint8_t tx_ft; /*!< type of frame, data or remote */
416416
uint8_t tx_dlen; /*!< data length */
417417
uint8_t tx_data[8]; /*!< transmit data */
418-
} can_trasnmit_message_struct;
418+
} can_transmit_message_struct;
419419

420420
/* CAN receive message structure */
421421
typedef struct {
@@ -450,7 +450,7 @@ typedef enum {
450450
CAN_ERROR_BITRECESSIVE, /*!< bit recessive error */
451451
CAN_ERROR_BITDOMINANTER, /*!< bit dominant error */
452452
CAN_ERROR_CRC, /*!< CRC error */
453-
CAN_ERROR_SOFTWARECFG, /*!< software configure */
453+
CAN_ERROR_SOFTWARECFG, /*!< software configuration */
454454
} can_error_enum;
455455

456456
/* transmit states */
@@ -462,7 +462,7 @@ typedef enum {
462462
} can_transmit_state_enum;
463463

464464
typedef enum {
465-
CAN_INIT_STRUCT = 0, /* CAN initialize parameters struct */
465+
CAN_INIT_STRUCT = 0U, /* CAN initialize parameters struct */
466466
CAN_FILTER_STRUCT, /* CAN filter parameters struct */
467467
CAN_TX_MESSAGE_STRUCT, /* CAN transmit message struct */
468468
CAN_RX_MESSAGE_STRUCT, /* CAN receive message struct */
@@ -586,7 +586,7 @@ typedef enum {
586586
#define CAN_SILENT_MODE ((uint8_t)0x02U) /*!< silent communication mode */
587587
#define CAN_SILENT_LOOPBACK_MODE ((uint8_t)0x03U) /*!< loopback and silent communication mode */
588588

589-
/* CAN resynchronisation jump width */
589+
/* CAN resynchronization jump width */
590590
#define CAN_BT_SJW_1TQ ((uint8_t)0x00U) /*!< 1 time quanta */
591591
#define CAN_BT_SJW_2TQ ((uint8_t)0x01U) /*!< 2 time quanta */
592592
#define CAN_BT_SJW_3TQ ((uint8_t)0x02U) /*!< 3 time quanta */
@@ -663,6 +663,9 @@ typedef enum {
663663
/* CAN timeout */
664664
#define CAN_TIMEOUT ((uint32_t)0x0000FFFFU) /*!< timeout value */
665665

666+
/* CAN mailbox empty status mask */
667+
#define CAN_ALL_MAILBOX_EMPTY ((uint32_t)0x1C000000U) /*!< CAN mailbox empty status mask */
668+
666669
/* interrupt enable bits */
667670
#define CAN_INT_TME CAN_INTEN_TMEIE /*!< transmit mailbox empty interrupt enable */
668671
#define CAN_INT_RFNE0 CAN_INTEN_RFNEIE0 /*!< receive FIFO0 not empty interrupt enable */
@@ -705,11 +708,11 @@ void can_time_trigger_mode_disable(uint32_t can_periph);
705708

706709
/* transmit functions */
707710
/* transmit CAN message */
708-
uint8_t can_message_transmit(uint32_t can_periph, can_trasnmit_message_struct *transmit_message);
711+
uint8_t can_message_transmit(uint32_t can_periph, can_transmit_message_struct *transmit_message);
709712
/* get CAN transmit state */
710713
can_transmit_state_enum can_transmit_states(uint32_t can_periph, uint8_t mailbox_number);
711714
/* stop CAN transmission */
712-
void can_transmission_stop(uint32_t can_periph, uint8_t mailbox_number);
715+
ErrStatus can_transmission_stop(uint32_t can_periph, uint8_t mailbox_number);
713716
/* CAN receive message */
714717
void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_message_struct *receive_message);
715718
/* CAN release FIFO */

lib-gd32/gd32f20x/GD32F20x_standard_peripheral/Include/gd32f20x_cau.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
\file gd32f20x_cau.h
33
\brief definitions for the CAU
44
5-
\version 2023-06-30, V2.5.0, firmware for GD32F20x
5+
\version 2026-02-06, V3.0.0, firmware for GD32F20x
66
*/
77

88
/*
9-
Copyright (c) 2023, GigaDevice Semiconductor Inc.
9+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
1010
1111
Redistribution and use in source and binary forms, with or without modification,
1212
are permitted provided that the following conditions are met:
@@ -182,8 +182,8 @@ typedef struct {
182182
#define CAU_INT_OUTFIFO CAU_INTEN_OINTEN /*!< OUT FIFO Interrupt */
183183

184184
/* cau_stat1 register value */
185-
#define CAU_FLAG_INFIFO (CAU_STAT1_ISTA | ((uint32_t)0x00000020U)) /*!< IN FIFO flag status */
186-
#define CAU_FLAG_OUTFIFO (CAU_STAT1_OSTA | ((uint32_t)0x00000020U)) /*!< OUT FIFO flag status */
185+
#define CAU_FLAG_INFIFO (CAU_STAT1_ISTA | BIT(31)) /*!< IN FIFO flag status */
186+
#define CAU_FLAG_OUTFIFO (CAU_STAT1_OSTA | BIT(31)) /*!< OUT FIFO flag status */
187187

188188
/* cau_intf register value */
189189
#define CAU_INT_FLAG_INFIFO CAU_INTF_IINTF /*!< IN FIFO interrupt status */

lib-gd32/gd32f20x/GD32F20x_standard_peripheral/Include/gd32f20x_crc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
\file gd32f20x_crc.h
33
\brief definitions for the CRC
44
5-
\version 2023-06-30, V2.5.0, firmware for GD32F20x
5+
\version 2026-02-06, V3.0.0, firmware for GD32F20x
66
*/
77

88
/*
9-
Copyright (c) 2023, GigaDevice Semiconductor Inc.
9+
Copyright (c) 2026, GigaDevice Semiconductor Inc.
1010
1111
Redistribution and use in source and binary forms, with or without modification,
1212
are permitted provided that the following conditions are met:

0 commit comments

Comments
 (0)