Skip to content

Commit

Permalink
gd32e10x: apply patches for hal
Browse files Browse the repository at this point in the history
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

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
  • Loading branch information
feilongfl authored and nandojve committed Aug 28, 2022
1 parent 74ad25d commit dd0e032
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions gd32e10x/cmsis/gd/gd32e10x/include/gd32e10x.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
#define REG32(addr) (*(volatile uint32_t *)(uint32_t)(addr))
#define REG16(addr) (*(volatile uint16_t *)(uint32_t)(addr))
#define REG8(addr) (*(volatile uint8_t *)(uint32_t)(addr))
#ifndef BIT
#define BIT(x) ((uint32_t)((uint32_t)0x01U<<(x)))
#endif /* BIT */

#define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
#define GET_BITS(regval, start, end) (((regval) & BITS((start),(end))) >> (start))

Expand Down
5 changes: 0 additions & 5 deletions gd32e10x/cmsis/gd/gd32e10x/source/system_gd32e10x.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ void SystemInit (void)
/* configure the system clock source, PLL Multiplier, AHB/APBx prescalers and Flash settings */
system_clock_config();

#ifdef VECT_TAB_SRAM
nvic_vector_table_set(NVIC_VECTTAB_RAM,VECT_TAB_OFFSET);
#else
nvic_vector_table_set(NVIC_VECTTAB_FLASH,VECT_TAB_OFFSET);
#endif

}

Expand Down
5 changes: 5 additions & 0 deletions gd32e10x/standard_peripheral/include/gd32e10x_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ typedef enum {
#define I2C_ADDFORMAT_7BITS ((uint32_t)0x00000000U) /*!< address format is 7 bits */
#define I2C_ADDFORMAT_10BITS I2C_SADDR0_ADDFORMAT /*!< address format is 10 bits */

#define I2CCLK_MAX ((uint32_t)0x0000003FU)/*!< i2cclk maximum value */
#define I2CCLK_MIN ((uint32_t)0x00000002U)/*!< i2cclk minimum value for standard mode */
#define I2CCLK_FM_MIN ((uint32_t)0x00000008U)/*!< i2cclk minimum value for fast mode */
#define I2CCLK_FM_PLUS_MIN ((uint32_t)0x00000018U)/*!< i2cclk minimum value for fast mode plus */

/* function declarations */
/* reset I2C */
void i2c_deinit(uint32_t i2c_periph);
Expand Down
2 changes: 1 addition & 1 deletion gd32e10x/standard_peripheral/include/gd32e10x_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ void timer_deinit(uint32_t timer_periph);
/* initialize TIMER init parameter struct */
void timer_struct_para_init(timer_parameter_struct* initpara);
/* initialize TIMER counter */
void timer_init(uint32_t timer_periph, timer_parameter_struct* initpara);
void gd32_timer_init(uint32_t timer_periph, timer_parameter_struct* initpara);
/* enable a timer */
void timer_enable(uint32_t timer_periph);
/* disable a timer */
Expand Down
2 changes: 0 additions & 2 deletions gd32e10x/standard_peripheral/source/gd32e10x_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ OF SUCH DAMAGE.
#include "gd32e10x_i2c.h"

/* I2C register bit mask */
#define I2CCLK_MAX ((uint32_t)0x0000003FU) /*!< i2cclk maximum value */
#define I2CCLK_MIN ((uint32_t)0x00000002U) /*!< i2cclk minimum value */
#define I2C_FLAG_MASK ((uint32_t)0x0000FFFFU) /*!< i2c flag mask */
#define I2C_ADDRESS_MASK ((uint32_t)0x000003FFU) /*!< i2c address mask */
#define I2C_ADDRESS2_MASK ((uint32_t)0x000000FEU) /*!< the second i2c address mask */
Expand Down
2 changes: 1 addition & 1 deletion gd32e10x/standard_peripheral/source/gd32e10x_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void timer_struct_para_init(timer_parameter_struct* initpara)
\param[out] none
\retval none
*/
void timer_init(uint32_t timer_periph, timer_parameter_struct* initpara)
void gd32_timer_init(uint32_t timer_periph, timer_parameter_struct* initpara)
{
/* configure the counter prescaler value */
TIMER_PSC(timer_periph) = (uint16_t)initpara->prescaler;
Expand Down

0 comments on commit dd0e032

Please sign in to comment.