Skip to content

Commit 4d1c1b6

Browse files
committed
hal: gd32a503: apply patches
apply fllowing patches for hal: - drop I2CCLK_MAX/I2CCLK_MIN - add `gd32_` prefix for timer_init - add ifdef to BIT macro - remove nvic_vector_table_set function call - rename CAN_xxx_MODE to GD32_CAN_xxx_MODE Signed-off-by: YuLong Yao <[email protected]>
1 parent d64b1c8 commit 4d1c1b6

File tree

7 files changed

+36
-35
lines changed

7 files changed

+36
-35
lines changed

gd32a50x/cmsis/gd/gd32a50x/include/gd32a50x.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
190190
#define REG32(addr) (*(volatile uint32_t *)(uint32_t)(addr))
191191
#define REG16(addr) (*(volatile uint16_t *)(uint32_t)(addr))
192192
#define REG8(addr) (*(volatile uint8_t *)(uint32_t)(addr))
193+
#ifndef BIT
193194
#define BIT(x) ((uint32_t)((uint32_t)0x01U<<(x)))
195+
#endif /* BIT */
194196
#define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
195197
#define GET_BITS(regval, start, end) (((regval) & BITS((start),(end))) >> (start))
196198

gd32a50x/cmsis/gd/gd32a50x/source/system_gd32a50x.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ void SystemInit(void)
157157
RCU_BDCTL |= RCU_BDCTL_LXTALBPS;
158158
}
159159
}
160-
161-
#ifdef VECT_TAB_SRAM
162-
nvic_vector_table_set(NVIC_VECTTAB_RAM, VECT_TAB_OFFSET);
163-
#else
164-
nvic_vector_table_set(NVIC_VECTTAB_FLASH, VECT_TAB_OFFSET);
165-
#endif
166160
}
167161

168162
/*!

gd32a50x/standard_peripheral/include/gd32a50x_can.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,12 @@ typedef enum {
724724

725725
/* operation modes */
726726
typedef enum {
727-
CAN_NORMAL_MODE = 0U, /*!< normal mode */
728-
CAN_MONITOR_MODE = 1U, /*!< monitor mode */
729-
CAN_LOOPBACK_SILENT_MODE = 2U, /*!< loopback mode */
730-
CAN_INACTIVE_MODE = 3U, /*!< inactive mode */
731-
CAN_DISABLE_MODE = 4U, /*!< disable mode */
732-
CAN_PN_MODE = 5U /*!< Pretended Networking mode */
727+
GD32_CAN_NORMAL_MODE = 0U, /*!< normal mode */
728+
GD32_CAN_MONITOR_MODE = 1U, /*!< monitor mode */
729+
GD32_CAN_LOOPBACK_SILENT_MODE = 2U, /*!< loopback mode */
730+
GD32_CAN_INACTIVE_MODE = 3U, /*!< inactive mode */
731+
GD32_CAN_DISABLE_MODE = 4U, /*!< disable mode */
732+
GD32_CAN_PN_MODE = 5U /*!< Pretended Networking mode */
733733
} can_operation_modes_enum;
734734

735735
/* initiliaze parameter type */

gd32a50x/standard_peripheral/include/gd32a50x_i2c.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ typedef enum {
269269
#define I2C_FLAG_I2CBSY I2C_STAT_I2CBSY /*!< busy flag */
270270
#define I2C_FLAG_TR I2C_STAT_TR /*!< whether the I2C is a transmitter or a receiver in slave mode */
271271

272+
#define I2CCLK_MAX ((uint32_t)0x0000003FU)/*!< i2cclk maximum value */
273+
#define I2CCLK_MIN ((uint32_t)0x00000002U)/*!< i2cclk minimum value for standard mode */
274+
#define I2CCLK_FM_MIN ((uint32_t)0x00000008U)/*!< i2cclk minimum value for fast mode */
275+
#define I2CCLK_FM_PLUS_MIN ((uint32_t)0x00000018U)/*!< i2cclk minimum value for fast mode plus */
276+
272277
/* function declarations */
273278
/* initialization functions */
274279
/* reset I2C */

gd32a50x/standard_peripheral/include/gd32a50x_timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ void timer_deinit(uint32_t timer_periph);
937937
/* initialize TIMER init parameter struct */
938938
void timer_struct_para_init(timer_parameter_struct *initpara);
939939
/* initialize TIMER counter */
940-
void timer_init(uint32_t timer_periph, timer_parameter_struct *initpara);
940+
void gd32_timer_init(uint32_t timer_periph, timer_parameter_struct *initpara);
941941
/* enable a TIMER */
942942
void timer_enable(uint32_t timer_periph);
943943
/* disable a TIMER */

gd32a50x/standard_peripheral/source/gd32a50x_can.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ void can_private_filter_config(uint32_t can_periph, uint32_t index, uint32_t fil
359359
\param[in] can_periph: CANx(x=0,1)
360360
\param[in] mode: the mode to enter
361361
only one parameter can be selected which is shown as below:
362-
\arg CAN_NORMAL_MODE: normal mode
363-
\arg CAN_MONITOR_MODE: monitor mode
364-
\arg CAN_LOOPBACK_SILENT_MODE: loopback mode
365-
\arg CAN_INACTIVE_MODE: inactive mode
366-
\arg CAN_DISABLE_MODE: disable mode
367-
\arg CAN_PN_MODE: Pretended Networking mode
362+
\arg GD32_CAN_NORMAL_MODE: normal mode
363+
\arg GD32_CAN_MONITOR_MODE: monitor mode
364+
\arg GD32_CAN_LOOPBACK_SILENT_MODE: loopback mode
365+
\arg GD32_CAN_INACTIVE_MODE: inactive mode
366+
\arg GD32_CAN_DISABLE_MODE: disable mode
367+
\arg GD32_CAN_PN_MODE: Pretended Networking mode
368368
\param[out] none
369369
\retval ERROR or SUCCESS
370370
*/
@@ -391,33 +391,33 @@ ErrStatus can_operation_mode_enter(uint32_t can_periph, can_operation_modes_enum
391391

392392
/* configure the modes */
393393
switch(mode) {
394-
case CAN_NORMAL_MODE:
394+
case GD32_CAN_NORMAL_MODE:
395395
CAN_CTL1(can_periph) &= ~(CAN_CTL1_LSCMOD | CAN_CTL1_MMOD);
396396
break;
397-
case CAN_MONITOR_MODE:
397+
case GD32_CAN_MONITOR_MODE:
398398
CAN_CTL1(can_periph) &= ~CAN_CTL1_LSCMOD;
399399
CAN_CTL1(can_periph) |= CAN_CTL1_MMOD;
400400
break;
401-
case CAN_LOOPBACK_SILENT_MODE:
401+
case GD32_CAN_LOOPBACK_SILENT_MODE:
402402
CAN_CTL1(can_periph) &= ~CAN_CTL1_MMOD;
403403
CAN_CTL0(can_periph) &= ~CAN_CTL0_SRDIS;
404404
CAN_FDCTL(can_periph) &= ~CAN_FDCTL_TDCEN;
405405
CAN_CTL1(can_periph) |= CAN_CTL1_LSCMOD;
406406
break;
407-
case CAN_INACTIVE_MODE:
407+
case GD32_CAN_INACTIVE_MODE:
408408
break;
409-
case CAN_DISABLE_MODE:
409+
case GD32_CAN_DISABLE_MODE:
410410
CAN_CTL0(can_periph) |= CAN_CTL0_CANDIS;
411411
break;
412-
case CAN_PN_MODE:
412+
case GD32_CAN_PN_MODE:
413413
CAN_CTL0(can_periph) |= (CAN_CTL0_PNEN | CAN_CTL0_PNMOD);
414414
break;
415415
default:
416416
break;
417417
}
418418

419419
/* exit INACTIVE mode */
420-
if(CAN_INACTIVE_MODE != mode) {
420+
if(GD32_CAN_INACTIVE_MODE != mode) {
421421
/* exit inactive mode */
422422
CAN_CTL0(can_periph) &= ~(CAN_CTL0_HALT | CAN_CTL0_INAMOD);
423423
timeout = CAN_DELAY;
@@ -429,7 +429,7 @@ ErrStatus can_operation_mode_enter(uint32_t can_periph, can_operation_modes_enum
429429
}
430430
}
431431

432-
if(CAN_PN_MODE == mode) {
432+
if(GD32_CAN_PN_MODE == mode) {
433433
timeout = CAN_DELAY;
434434
while((0U == (CAN_CTL0(can_periph) & CAN_CTL0_PNS)) && (timeout)) {
435435
timeout--;
@@ -450,25 +450,25 @@ ErrStatus can_operation_mode_enter(uint32_t can_periph, can_operation_modes_enum
450450
can_operation_modes_enum can_operation_mode_get(uint32_t can_periph)
451451
{
452452
uint32_t reg;
453-
can_operation_modes_enum state = CAN_NORMAL_MODE;
453+
can_operation_modes_enum state = GD32_CAN_NORMAL_MODE;
454454

455455
reg = CAN_CTL0(can_periph);
456456
reg &= (CAN_CTL0_NRDY | CAN_CTL0_INAS | CAN_CTL0_PNS | CAN_CTL0_LPS);
457457

458458
if((CAN_CTL0_NRDY | CAN_CTL0_LPS) == reg) {
459-
state = CAN_DISABLE_MODE;
459+
state = GD32_CAN_DISABLE_MODE;
460460
} else if((CAN_CTL0_NRDY | CAN_CTL0_INAS) == reg) {
461-
state = CAN_INACTIVE_MODE;
461+
state = GD32_CAN_INACTIVE_MODE;
462462
} else if(0U == reg) {
463463
if(CAN_CTL1(can_periph)&CAN_CTL1_MMOD) {
464-
state = CAN_MONITOR_MODE;
464+
state = GD32_CAN_MONITOR_MODE;
465465
} else if(CAN_CTL1(can_periph)&CAN_CTL1_LSCMOD) {
466-
state = CAN_LOOPBACK_SILENT_MODE;
466+
state = GD32_CAN_LOOPBACK_SILENT_MODE;
467467
} else {
468-
state = CAN_NORMAL_MODE;
468+
state = GD32_CAN_NORMAL_MODE;
469469
}
470470
} else if(CAN_CTL0_PNS == reg) {
471-
state = CAN_PN_MODE;
471+
state = GD32_CAN_PN_MODE;
472472
} else {
473473
/* should not get here */
474474
}

gd32a50x/standard_peripheral/source/gd32a50x_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void timer_struct_para_init(timer_parameter_struct *initpara)
118118
\param[out] none
119119
\retval none
120120
*/
121-
void timer_init(uint32_t timer_periph, timer_parameter_struct *initpara)
121+
void gd32_timer_init(uint32_t timer_periph, timer_parameter_struct *initpara)
122122
{
123123
/* configure the counter prescaler value */
124124
TIMER_PSC(timer_periph) = (uint16_t)initpara->prescaler;

0 commit comments

Comments
 (0)