mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-13 06:55:31 +08:00
Merge pull request #4766 from iysheng/master
[bsp][gd32450] Fix the wrong judgment with CAN_STAT_IWS flag
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -100,7 +100,7 @@
|
||||
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
|
||||
#define __STATIC_INLINE static inline
|
||||
|
||||
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||
#define __packed
|
||||
#define __ASM _asm /*!< asm keyword for COSMIC Compiler */
|
||||
#define __INLINE inline /*use -pc99 on compile line !< inline keyword for COSMIC Compiler */
|
||||
@@ -170,8 +170,8 @@
|
||||
#define __FPU_USED 0
|
||||
#endif
|
||||
|
||||
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||
#if ( __CSMC__ & 0x400) // FPU present for parser
|
||||
#elif defined ( __CSMC__ ) /* Cosmic */
|
||||
#if ( __CSMC__ & 0x400) // FPU present for parser
|
||||
#if (__FPU_PRESENT == 1)
|
||||
#define __FPU_USED 1
|
||||
#else
|
||||
|
||||
@@ -552,7 +552,7 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t v
|
||||
/** \brief Set Base Priority with condition
|
||||
|
||||
This function assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
|
||||
or the new value increases the BASEPRI priority level.
|
||||
or the new value increases the BASEPRI priority level.
|
||||
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_crc.h
|
||||
\brief definitions for the CRC
|
||||
\file gd32f4xx_crc.h
|
||||
\brief definitions for the CRC
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_CRC_H
|
||||
@@ -37,19 +62,19 @@
|
||||
/* deinit CRC calculation unit */
|
||||
void crc_deinit(void);
|
||||
|
||||
/* reset data register to the value of initializaiton data register */
|
||||
/* reset data register(CRC_DATA) to the value of 0xFFFFFFFF */
|
||||
void crc_data_register_reset(void);
|
||||
/* read the data register */
|
||||
/* read the value of the data register */
|
||||
uint32_t crc_data_register_read(void);
|
||||
|
||||
/* read the free data register */
|
||||
/* read the value of the free data register */
|
||||
uint8_t crc_free_data_register_read(void);
|
||||
/* write the free data register */
|
||||
/* write data to the free data register */
|
||||
void crc_free_data_register_write(uint8_t free_data);
|
||||
|
||||
/* CRC calculate a 32-bit data */
|
||||
/* calculate the CRC value of a 32-bit data */
|
||||
uint32_t crc_single_data_calculate(uint32_t sdata);
|
||||
/* CRC calculate a 32-bit data array */
|
||||
/* calculate the CRC value of an array of 32-bit values */
|
||||
uint32_t crc_block_data_calculate(uint32_t array[], uint32_t size);
|
||||
|
||||
#endif /* GD32F4XX_CRC_H */
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_ctc.h
|
||||
\brief definitions for the CTC
|
||||
\file gd32f4xx_ctc.h
|
||||
\brief definitions for the CTC
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_CTC_H
|
||||
@@ -25,7 +50,7 @@
|
||||
|
||||
/* bits definitions */
|
||||
/* CTC_CTL0 */
|
||||
#define CTC_CTL0_CKOKIE BIT(0) /*!< clock trim OK(CKOKIF) interrupt enable */
|
||||
#define CTC_CTL0_CKOKIE BIT(0) /*!< clock trim OK(CKOKIF) interrupt enable */
|
||||
#define CTC_CTL0_CKWARNIE BIT(1) /*!< clock trim warning(CKWARNIF) interrupt enable */
|
||||
#define CTC_CTL0_ERRIE BIT(2) /*!< error(ERRIF) interrupt enable */
|
||||
#define CTC_CTL0_EREFIE BIT(3) /*!< EREFIF interrupt enable */
|
||||
@@ -90,19 +115,19 @@
|
||||
#define CTC_REFSOURCE_PSC_DIV128 CTL1_REFPSC(7) /*!< reference signal divided by 128 */
|
||||
|
||||
/* CTC interrupt enable definitions */
|
||||
#define CTC_INT_CKOKIE CTC_CTL0_CKOKIE /*!< clock trim OK interrupt enable */
|
||||
#define CTC_INT_CKWARNIE CTC_CTL0_CKWARNIE /*!< clock trim warning interrupt enable */
|
||||
#define CTC_INT_ERRIE CTC_CTL0_ERRIE /*!< error interrupt enable */
|
||||
#define CTC_INT_EREFIE CTC_CTL0_EREFIE /*!< expect reference interrupt enable */
|
||||
#define CTC_INT_CKOK CTC_CTL0_CKOKIE /*!< clock trim OK interrupt enable */
|
||||
#define CTC_INT_CKWARN CTC_CTL0_CKWARNIE /*!< clock trim warning interrupt enable */
|
||||
#define CTC_INT_ERR CTC_CTL0_ERRIE /*!< error interrupt enable */
|
||||
#define CTC_INT_EREF CTC_CTL0_EREFIE /*!< expect reference interrupt enable */
|
||||
|
||||
/* CTC interrupt source definitions */
|
||||
#define CTC_INT_CKOK CTC_STAT_CKOKIF /*!< clock trim OK interrupt flag */
|
||||
#define CTC_INT_CKWARN CTC_STAT_CKWARNIF /*!< clock trim warning interrupt flag */
|
||||
#define CTC_INT_ERR CTC_STAT_ERRIF /*!< error interrupt flag */
|
||||
#define CTC_INT_EREF CTC_STAT_EREFIF /*!< expect reference interrupt flag */
|
||||
#define CTC_INT_CKERR CTC_STAT_CKERR /*!< clock trim error bit */
|
||||
#define CTC_INT_REFMISS CTC_STAT_REFMISS /*!< reference sync pulse miss */
|
||||
#define CTC_INT_TRIMERR CTC_STAT_TRIMERR /*!< trim value error */
|
||||
#define CTC_INT_FLAG_CKOK CTC_STAT_CKOKIF /*!< clock trim OK interrupt flag */
|
||||
#define CTC_INT_FLAG_CKWARN CTC_STAT_CKWARNIF /*!< clock trim warning interrupt flag */
|
||||
#define CTC_INT_FLAG_ERR CTC_STAT_ERRIF /*!< error interrupt flag */
|
||||
#define CTC_INT_FLAG_EREF CTC_STAT_EREFIF /*!< expect reference interrupt flag */
|
||||
#define CTC_INT_FLAG_CKERR CTC_STAT_CKERR /*!< clock trim error bit */
|
||||
#define CTC_INT_FLAG_REFMISS CTC_STAT_REFMISS /*!< reference sync pulse miss */
|
||||
#define CTC_INT_FLAG_TRIMERR CTC_STAT_TRIMERR /*!< trim value error */
|
||||
|
||||
/* CTC flag definitions */
|
||||
#define CTC_FLAG_CKOK CTC_STAT_CKOKIF /*!< clock trim OK flag */
|
||||
@@ -116,45 +141,30 @@
|
||||
/* function declarations */
|
||||
/* reset ctc clock trim controller */
|
||||
void ctc_deinit(void);
|
||||
|
||||
/* enable the CTC interrupt */
|
||||
void ctc_interrupt_enable(uint32_t ctc_interrupt);
|
||||
/* disable the CTC interrupt */
|
||||
void ctc_interrupt_disable(uint32_t ctc_interrupt);
|
||||
/* get CTC interrupt flag */
|
||||
FlagStatus ctc_interrupt_flag_get(uint32_t ctc_interrupt);
|
||||
/* clear CTC interrupt flag */
|
||||
void ctc_interrupt_flag_clear(uint32_t ctc_interrupt);
|
||||
|
||||
/* get CTC flag */
|
||||
FlagStatus ctc_flag_get(uint32_t ctc_flag);
|
||||
/* clear CTC flag */
|
||||
void ctc_flag_clear(uint32_t ctc_flag);
|
||||
/* enable CTC trim counter */
|
||||
void ctc_counter_enable(void);
|
||||
/* disable CTC trim counter */
|
||||
void ctc_counter_disable(void);
|
||||
|
||||
/* configure the IRC48M trim value */
|
||||
void ctc_irc48m_trim_value_config(uint8_t ctc_trim_value);
|
||||
void ctc_irc48m_trim_value_config(uint8_t trim_value);
|
||||
/* generate software reference source sync pulse */
|
||||
void ctc_software_refsource_pulse_generate(void);
|
||||
/* configure hardware automatically trim mode */
|
||||
void ctc_hardware_trim_mode_config(uint32_t ctc_hardmode);
|
||||
|
||||
/* enable CTC counter */
|
||||
void ctc_counter_enable(void);
|
||||
/* disable CTC counter */
|
||||
void ctc_counter_disable(void);
|
||||
void ctc_hardware_trim_mode_config(uint32_t hardmode);
|
||||
|
||||
/* configure reference signal source polarity */
|
||||
void ctc_refsource_polarity_config(uint32_t ctc_polarity);
|
||||
void ctc_refsource_polarity_config(uint32_t polarity);
|
||||
/* select USBFS or USBHS SOF signal */
|
||||
void ctc_usbsof_signal_select(uint32_t ctc_usbsof);
|
||||
void ctc_usbsof_signal_select(uint32_t usbsof);
|
||||
/* select reference signal source */
|
||||
void ctc_refsource_signal_select(uint32_t ctc_refs);
|
||||
void ctc_refsource_signal_select(uint32_t refs);
|
||||
/* configure reference signal source prescaler */
|
||||
void ctc_refsource_prescaler_config(uint32_t ctc_prescaler);
|
||||
void ctc_refsource_prescaler_config(uint32_t prescaler);
|
||||
/* configure clock trim base limit value */
|
||||
void ctc_clock_limit_value_config(uint8_t ctc_limit_value);
|
||||
void ctc_clock_limit_value_config(uint8_t limit_value);
|
||||
/* configure CTC counter reload value */
|
||||
void ctc_counter_reload_value_config(uint16_t ctc_reload_value);
|
||||
void ctc_counter_reload_value_config(uint16_t reload_value);
|
||||
|
||||
/* read CTC counter capture value when reference sync pulse occurred */
|
||||
uint16_t ctc_counter_capture_value_read(void);
|
||||
@@ -165,4 +175,18 @@ uint16_t ctc_counter_reload_value_read(void);
|
||||
/* read the IRC48M trim value */
|
||||
uint8_t ctc_irc48m_trim_value_read(void);
|
||||
|
||||
/* interrupt & flag functions */
|
||||
/* enable the CTC interrupt */
|
||||
void ctc_interrupt_enable(uint32_t interrupt);
|
||||
/* disable the CTC interrupt */
|
||||
void ctc_interrupt_disable(uint32_t interrupt);
|
||||
/* get CTC interrupt flag */
|
||||
FlagStatus ctc_interrupt_flag_get(uint32_t int_flag);
|
||||
/* clear CTC interrupt flag */
|
||||
void ctc_interrupt_flag_clear(uint32_t int_flag);
|
||||
/* get CTC flag */
|
||||
FlagStatus ctc_flag_get(uint32_t flag);
|
||||
/* clear CTC flag */
|
||||
void ctc_flag_clear(uint32_t flag);
|
||||
|
||||
#endif /* GD32F4XX_CTC_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_dbg.h
|
||||
\brief definitions for the DBG
|
||||
\file gd32f4xx_dbg.h
|
||||
\brief definitions for the DBG
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_DBG_H
|
||||
@@ -65,30 +90,43 @@
|
||||
#define DBG_LOW_POWER_DEEPSLEEP DBG_CTL0_DSLP_HOLD /*!< keep debugger connection during deepsleep mode */
|
||||
#define DBG_LOW_POWER_STANDBY DBG_CTL0_STB_HOLD /*!< keep debugger connection during standby mode */
|
||||
|
||||
/* define the peripheral debug hold bit position and its register index offset */
|
||||
#define DBG_REGIDX_BIT(regidx, bitpos) (((regidx) << 6) | (bitpos))
|
||||
#define DBG_REG_VAL(periph) (REG32(DBG + ((uint32_t)(periph) >> 6)))
|
||||
#define DBG_BIT_POS(val) ((uint32_t)(val) & 0x1FU)
|
||||
|
||||
/* register index */
|
||||
enum dbg_reg_idx
|
||||
{
|
||||
DBG_IDX_CTL0 = 0x04U,
|
||||
DBG_IDX_CTL1 = 0x08U,
|
||||
DBG_IDX_CTL2 = 0x0CU
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DBG_TIMER1_HOLD = BIT(0), /*!< hold TIMER1 counter when core is halted */
|
||||
DBG_TIMER2_HOLD = BIT(1), /*!< hold TIMER2 counter when core is halted */
|
||||
DBG_TIMER3_HOLD = BIT(2), /*!< hold TIMER3 counter when core is halted */
|
||||
DBG_TIMER4_HOLD = BIT(3), /*!< hold TIMER4 counter when core is halted */
|
||||
DBG_TIMER5_HOLD = BIT(4), /*!< hold TIMER5 counter when core is halted */
|
||||
DBG_TIMER6_HOLD = BIT(5), /*!< hold TIMER6 counter when core is halted */
|
||||
DBG_TIMER11_HOLD = BIT(6), /*!< hold TIMER11 counter when core is halted */
|
||||
DBG_TIMER12_HOLD = BIT(7), /*!< hold TIMER12 counter when core is halted */
|
||||
DBG_TIMER13_HOLD = BIT(8), /*!< hold TIMER13 counter when core is halted */
|
||||
DBG_RTC_HOLD = BIT(10), /*!< hold RTC calendar and wakeup counter when core is halted */
|
||||
DBG_WWDGT_HOLD = BIT(11), /*!< debug WWDGT kept when core is halted */
|
||||
DBG_FWDGT_HOLD = BIT(12), /*!< debug FWDGT kept when core is halted */
|
||||
DBG_I2C0_HOLD = BIT(21), /*!< hold I2C0 smbus when core is halted */
|
||||
DBG_I2C1_HOLD = BIT(22), /*!< hold I2C1 smbus when core is halted */
|
||||
DBG_I2C2_HOLD = BIT(23), /*!< hold I2C2 smbus when core is halted */
|
||||
DBG_CAN0_HOLD = BIT(25), /*!< debug CAN0 kept when core is halted */
|
||||
DBG_CAN1_HOLD = BIT(26), /*!< debug CAN1 kept when core is halted */
|
||||
DBG_TIMER0_HOLD = (BIT(0) | BIT(30)), /*!< hold TIMER0 counter when core is halted */
|
||||
DBG_TIMER7_HOLD = (BIT(1) | BIT(30)), /*!< hold TIMER7 counter when core is halted */
|
||||
DBG_TIMER8_HOLD = (BIT(16) | BIT(30)), /*!< hold TIMER8 counter when core is halted */
|
||||
DBG_TIMER9_HOLD = (BIT(17) | BIT(30)), /*!< hold TIMER9 counter when core is halted */
|
||||
DBG_TIMER10_HOLD = (BIT(18) | BIT(30)), /*!< hold TIMER10 counter when core is halted */
|
||||
DBG_TIMER1_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 0U), /*!< hold TIMER1 counter when core is halted */
|
||||
DBG_TIMER2_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 1U), /*!< hold TIMER2 counter when core is halted */
|
||||
DBG_TIMER3_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 2U), /*!< hold TIMER3 counter when core is halted */
|
||||
DBG_TIMER4_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 3U), /*!< hold TIMER4 counter when core is halted */
|
||||
DBG_TIMER5_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 4U), /*!< hold TIMER5 counter when core is halted */
|
||||
DBG_TIMER6_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 5U), /*!< hold TIMER6 counter when core is halted */
|
||||
DBG_TIMER11_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 6U), /*!< hold TIMER11 counter when core is halted */
|
||||
DBG_TIMER12_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 7U), /*!< hold TIMER12 counter when core is halted */
|
||||
DBG_TIMER13_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 8U), /*!< hold TIMER13 counter when core is halted */
|
||||
DBG_RTC_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 10U), /*!< hold RTC calendar and wakeup counter when core is halted */
|
||||
DBG_WWDGT_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 11U), /*!< debug WWDGT kept when core is halted */
|
||||
DBG_FWDGT_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 12U), /*!< debug FWDGT kept when core is halted */
|
||||
DBG_I2C0_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 21U), /*!< hold I2C0 smbus when core is halted */
|
||||
DBG_I2C1_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 22U), /*!< hold I2C1 smbus when core is halted */
|
||||
DBG_I2C2_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 23U), /*!< hold I2C2 smbus when core is halted */
|
||||
DBG_CAN0_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 25U), /*!< debug CAN0 kept when core is halted */
|
||||
DBG_CAN1_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL1, 26U), /*!< debug CAN1 kept when core is halted */
|
||||
DBG_TIMER0_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 0U), /*!< hold TIMER0 counter when core is halted */
|
||||
DBG_TIMER7_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 1U), /*!< hold TIMER7 counter when core is halted */
|
||||
DBG_TIMER8_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 16U), /*!< hold TIMER8 counter when core is halted */
|
||||
DBG_TIMER9_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 17U), /*!< hold TIMER9 counter when core is halted */
|
||||
DBG_TIMER10_HOLD = DBG_REGIDX_BIT(DBG_IDX_CTL2, 18U) /*!< hold TIMER10 counter when core is halted */
|
||||
}dbg_periph_enum;
|
||||
|
||||
#define CTL0_TRACE_MODE(regval) (BITS(6,7)&((uint32_t)(regval)<<6))
|
||||
@@ -98,6 +136,8 @@ typedef enum
|
||||
#define TRACE_MODE_SYNC_DATASIZE_4 CTL0_TRACE_MODE(3) /*!< trace pin used for sync mode and data size is 4 */
|
||||
|
||||
/* function declarations */
|
||||
/* deinitialize the DBG */
|
||||
void dbg_deinit(void);
|
||||
/* read DBG_ID code register */
|
||||
uint32_t dbg_id_get(void);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+244
-228
File diff suppressed because it is too large
Load Diff
+512
-484
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_exti.h
|
||||
\brief definitions for the EXTI
|
||||
\file gd32f4xx_exti.h
|
||||
\brief definitions for the EXTI
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.1, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_EXTI_H
|
||||
@@ -97,6 +122,7 @@
|
||||
#define EXTI_RTEN_RTEN17 BIT(17) /*!< rising edge from line 17 */
|
||||
#define EXTI_RTEN_RTEN18 BIT(18) /*!< rising edge from line 18 */
|
||||
#define EXTI_RTEN_RTEN19 BIT(19) /*!< rising edge from line 19 */
|
||||
#define EXTI_RTEN_RTEN20 BIT(20) /*!< rising edge from line 20 */
|
||||
#define EXTI_RTEN_RTEN21 BIT(21) /*!< rising edge from line 21 */
|
||||
#define EXTI_RTEN_RTEN22 BIT(22) /*!< rising edge from line 22 */
|
||||
|
||||
@@ -121,6 +147,7 @@
|
||||
#define EXTI_FTEN_FTEN17 BIT(17) /*!< falling edge from line 17 */
|
||||
#define EXTI_FTEN_FTEN18 BIT(18) /*!< falling edge from line 18 */
|
||||
#define EXTI_FTEN_FTEN19 BIT(19) /*!< falling edge from line 19 */
|
||||
#define EXTI_FTEN_FTEN20 BIT(20) /*!< falling edge from line 20 */
|
||||
#define EXTI_FTEN_FTEN21 BIT(21) /*!< falling edge from line 21 */
|
||||
#define EXTI_FTEN_FTEN22 BIT(22) /*!< falling edge from line 22 */
|
||||
|
||||
@@ -145,6 +172,7 @@
|
||||
#define EXTI_SWIEV_SWIEV17 BIT(17) /*!< software interrupt/event request from line 17 */
|
||||
#define EXTI_SWIEV_SWIEV18 BIT(18) /*!< software interrupt/event request from line 18 */
|
||||
#define EXTI_SWIEV_SWIEV19 BIT(19) /*!< software interrupt/event request from line 19 */
|
||||
#define EXTI_SWIEV_SWIEV20 BIT(20) /*!< software interrupt/event request from line 20 */
|
||||
#define EXTI_SWIEV_SWIEV21 BIT(21) /*!< software interrupt/event request from line 21 */
|
||||
#define EXTI_SWIEV_SWIEV22 BIT(22) /*!< software interrupt/event request from line 22 */
|
||||
|
||||
@@ -169,13 +197,14 @@
|
||||
#define EXTI_PD_PD17 BIT(17) /*!< interrupt/event pending status from line 17 */
|
||||
#define EXTI_PD_PD18 BIT(18) /*!< interrupt/event pending status from line 18 */
|
||||
#define EXTI_PD_PD19 BIT(19) /*!< interrupt/event pending status from line 19 */
|
||||
#define EXTI_PD_PD20 BIT(20) /*!< interrupt/event pending status from line 20 */
|
||||
#define EXTI_PD_PD21 BIT(21) /*!< interrupt/event pending status from line 21 */
|
||||
#define EXTI_PD_PD22 BIT(22) /*!< interrupt/event pending status from line 22 */
|
||||
|
||||
/* constants definitions */
|
||||
/* EXTI line number */
|
||||
typedef enum
|
||||
{
|
||||
{
|
||||
EXTI_0 = BIT(0), /*!< EXTI line 0 */
|
||||
EXTI_1 = BIT(1), /*!< EXTI line 1 */
|
||||
EXTI_2 = BIT(2), /*!< EXTI line 2 */
|
||||
@@ -196,7 +225,7 @@ typedef enum
|
||||
EXTI_17 = BIT(17), /*!< EXTI line 17 */
|
||||
EXTI_18 = BIT(18), /*!< EXTI line 18 */
|
||||
EXTI_19 = BIT(19), /*!< EXTI line 19 */
|
||||
EXTI_20 = BIT(20), /*!< EXTI line 20 */
|
||||
EXTI_20 = BIT(20), /*!< EXTI line 20 */
|
||||
EXTI_21 = BIT(21), /*!< EXTI line 21 */
|
||||
EXTI_22 = BIT(22), /*!< EXTI line 22 */
|
||||
}exti_line_enum;
|
||||
@@ -210,10 +239,11 @@ typedef enum
|
||||
|
||||
/* interrupt trigger mode */
|
||||
typedef enum
|
||||
{
|
||||
{
|
||||
EXTI_TRIG_RISING = 0, /*!< EXTI rising edge trigger */
|
||||
EXTI_TRIG_FALLING, /*!< EXTI falling edge trigger */
|
||||
EXTI_TRIG_BOTH /*!< EXTI rising and falling edge trigger */
|
||||
EXTI_TRIG_BOTH, /*!< EXTI rising and falling edge trigger */
|
||||
EXTI_TRIG_NONE /*!< none EXTI edge trigger */
|
||||
}exti_trig_type_enum;
|
||||
|
||||
/* function declarations */
|
||||
@@ -223,13 +253,18 @@ void exti_deinit(void);
|
||||
void exti_init(exti_line_enum linex, exti_mode_enum mode, exti_trig_type_enum trig_type);
|
||||
/* enable the interrupts from EXTI line x */
|
||||
void exti_interrupt_enable(exti_line_enum linex);
|
||||
/* enable the events from EXTI line x */
|
||||
void exti_event_enable(exti_line_enum linex);
|
||||
/* disable the interrupts from EXTI line x */
|
||||
void exti_interrupt_disable(exti_line_enum linex);
|
||||
/* enable the events from EXTI line x */
|
||||
void exti_event_enable(exti_line_enum linex);
|
||||
/* disable the events from EXTI line x */
|
||||
void exti_event_disable(exti_line_enum linex);
|
||||
/* EXTI software interrupt event enable */
|
||||
void exti_software_interrupt_enable(exti_line_enum linex);
|
||||
/* EXTI software interrupt event disable */
|
||||
void exti_software_interrupt_disable(exti_line_enum linex);
|
||||
|
||||
/* interrupt & flag functions */
|
||||
/* get EXTI lines pending flag */
|
||||
FlagStatus exti_flag_get(exti_line_enum linex);
|
||||
/* clear EXTI lines pending flag */
|
||||
@@ -238,9 +273,5 @@ void exti_flag_clear(exti_line_enum linex);
|
||||
FlagStatus exti_interrupt_flag_get(exti_line_enum linex);
|
||||
/* clear EXTI lines pending flag */
|
||||
void exti_interrupt_flag_clear(exti_line_enum linex);
|
||||
/* EXTI software interrupt event enable */
|
||||
void exti_software_interrupt_enable(exti_line_enum linex);
|
||||
/* EXTI software interrupt event disable */
|
||||
void exti_software_interrupt_disable(exti_line_enum linex);
|
||||
|
||||
#endif /* GD32F4XX_EXTI_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_fwdgt.h
|
||||
\brief definitions for the FWDGT
|
||||
\file gd32f4xx_fwdgt.h
|
||||
\brief definitions for the FWDGT
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_FWDGT_H
|
||||
@@ -58,7 +83,13 @@
|
||||
#define FWDGT_PSC_TIMEOUT ((uint32_t)0x000FFFFFU) /*!< FWDGT_PSC register write operation state flag timeout */
|
||||
#define FWDGT_RLD_TIMEOUT ((uint32_t)0x000FFFFFU) /*!< FWDGT_RLD register write operation state flag timeout */
|
||||
|
||||
/* FWDGT flag definitions */
|
||||
#define FWDGT_FLAG_PUD FWDGT_STAT_PUD /*!< FWDGT prescaler divider value update flag */
|
||||
#define FWDGT_FLAG_RUD FWDGT_STAT_RUD /*!< FWDGT counter reload value update flag */
|
||||
|
||||
/* function declarations */
|
||||
/* enable write access to FWDGT_PSC and FWDGT_RLD */
|
||||
void fwdgt_write_enable(void);
|
||||
/* disable write access to FWDGT_PSC and FWDGT_RLD */
|
||||
void fwdgt_write_disable(void);
|
||||
/* start the free watchdog timer counter */
|
||||
|
||||
+310
-285
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_iref.h
|
||||
\brief definitions for the IREF
|
||||
\file gd32f4xx_iref.h
|
||||
\brief definitions for the IREF
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_IREF_H
|
||||
@@ -25,7 +50,7 @@
|
||||
#define IREF_CTL_CSDT BITS(0,5) /*!< current step data */
|
||||
#define IREF_CTL_SCMOD BIT(7) /*!< sink current mode */
|
||||
#define IREF_CTL_CPT BITS(8,12) /*!< current precision trim */
|
||||
#define IREF_CTL_SSEL BIT(14) /*!< step selection */
|
||||
#define IREF_CTL_SSEL BIT(14) /*!< step selection */
|
||||
#define IREF_CTL_CREN BIT(15) /*!< current reference enable */
|
||||
|
||||
/* constants definitions */
|
||||
@@ -130,13 +155,13 @@
|
||||
#define IREF_CUR_STEP_DATA_61 CTL_CSDT(61) /*!< IREF current step data 61 */
|
||||
#define IREF_CUR_STEP_DATA_62 CTL_CSDT(62) /*!< IREF current step data 62 */
|
||||
#define IREF_CUR_STEP_DATA_63 CTL_CSDT(63) /*!< IREF current step data 63 */
|
||||
|
||||
|
||||
/* IREF mode selection */
|
||||
#define IREF_STEP(regval) (BIT(14) & ((uint32_t)(regval) << 14))
|
||||
#define IREF_MODE_LOW_POWER IREF_STEP(0) /*!< low power, 1uA step */
|
||||
#define IREF_MODE_HIGH_CURRENT IREF_STEP(1) /*!< high current, 8uA step */
|
||||
|
||||
/* IREF sink current mode*/
|
||||
|
||||
/* IREF sink current mode*/
|
||||
#define IREF_CURRENT(regval) (BIT(7) & ((uint32_t)(regval) << 7))
|
||||
#define IREF_SOURCE_CURRENT IREF_CURRENT(0) /*!< IREF source current */
|
||||
#define IREF_SINK_CURRENT IREF_CURRENT(1) /*!< IREF sink current */
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_misc.h
|
||||
\brief definitions for the MISC
|
||||
\file gd32f4xx_misc.h
|
||||
\brief definitions for the MISC
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_MISC_H
|
||||
|
||||
@@ -1,14 +1,40 @@
|
||||
/*!
|
||||
\file gd32f4xx_pmu.h
|
||||
\brief definitions for the PMU
|
||||
\file gd32f4xx_pmu.h
|
||||
\brief definitions for the PMU
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GD32F4XX_PMU_H
|
||||
#define GD32F4XX_PMU_H
|
||||
|
||||
@@ -52,14 +78,14 @@
|
||||
/* constants definitions */
|
||||
/* PMU low voltage detector threshold definitions */
|
||||
#define CTL_LVDT(regval) (BITS(5,7)&((uint32_t)(regval)<<5))
|
||||
#define PMU_LVDT_0 CTL_LVDT(0) /*!< voltage threshold is 2.2V */
|
||||
#define PMU_LVDT_0 CTL_LVDT(0) /*!< voltage threshold is 2.1V */
|
||||
#define PMU_LVDT_1 CTL_LVDT(1) /*!< voltage threshold is 2.3V */
|
||||
#define PMU_LVDT_2 CTL_LVDT(2) /*!< voltage threshold is 2.4V */
|
||||
#define PMU_LVDT_3 CTL_LVDT(3) /*!< voltage threshold is 2.5V */
|
||||
#define PMU_LVDT_4 CTL_LVDT(4) /*!< voltage threshold is 2.6V */
|
||||
#define PMU_LVDT_5 CTL_LVDT(5) /*!< voltage threshold is 2.7V */
|
||||
#define PMU_LVDT_6 CTL_LVDT(6) /*!< voltage threshold is 2.8V */
|
||||
#define PMU_LVDT_7 CTL_LVDT(7) /*!< voltage threshold is 2.9V */
|
||||
#define PMU_LVDT_3 CTL_LVDT(3) /*!< voltage threshold is 2.6V */
|
||||
#define PMU_LVDT_4 CTL_LVDT(4) /*!< voltage threshold is 2.7V */
|
||||
#define PMU_LVDT_5 CTL_LVDT(5) /*!< voltage threshold is 2.9V */
|
||||
#define PMU_LVDT_6 CTL_LVDT(6) /*!< voltage threshold is 3.0V */
|
||||
#define PMU_LVDT_7 CTL_LVDT(7) /*!< voltage threshold is 3.1V */
|
||||
|
||||
/* PMU LDO output voltage select definitions */
|
||||
#define CTL_LDOVS(regval) (BITS(14,15)&((uint32_t)(regval)<<14))
|
||||
@@ -124,7 +150,7 @@
|
||||
void pmu_deinit(void);
|
||||
|
||||
/* select low voltage detector threshold */
|
||||
void pmu_lvd_select(uint32_t pmu_lvdt_n);
|
||||
void pmu_lvd_select(uint32_t lvdt_n);
|
||||
/* LDO output voltage select */
|
||||
void pmu_ldo_output_select(uint32_t ldo_output);
|
||||
/* PMU lvd disable */
|
||||
@@ -148,7 +174,7 @@ void pmu_lowdriver_normalpower_config(uint32_t mode);
|
||||
/* PMU work at sleep mode */
|
||||
void pmu_to_sleepmode(uint8_t sleepmodecmd);
|
||||
/* PMU work at deepsleep mode */
|
||||
void pmu_to_deepsleepmode(uint32_t pmu_ldo, uint8_t deepsleepmodecmd);
|
||||
void pmu_to_deepsleepmode(uint32_t ldo, uint8_t deepsleepmodecmd);
|
||||
/* PMU work at standby mode */
|
||||
void pmu_to_standbymode(uint8_t standbymodecmd);
|
||||
/* PMU wakeup pin enable */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,40 @@
|
||||
/*!
|
||||
\file gd32f4xx_rtc.h
|
||||
\brief definitions for the RTC
|
||||
\file gd32f4xx_rtc.c
|
||||
\brief definitions for the RTC
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GD32F4XX_RTC_H
|
||||
#define GD32F4XX_RTC_H
|
||||
|
||||
@@ -254,7 +280,7 @@ typedef struct
|
||||
ControlStatus tamper_precharge_enable; /*!< RTC tamper precharge feature during a voltage level detection */
|
||||
uint32_t tamper_precharge_time; /*!< RTC tamper precharge duration if precharge feature is enabled */
|
||||
ControlStatus tamper_with_timestamp; /*!< RTC tamper time-stamp feature */
|
||||
}rtc_tamper_struct;
|
||||
}rtc_tamper_struct;
|
||||
|
||||
/* time register value */
|
||||
#define TIME_SC(regval) (BITS(0,6) & ((uint32_t)(regval) << 0)) /*!< write value to RTC_TIME_SC bit field */
|
||||
@@ -380,7 +406,7 @@ typedef struct
|
||||
#define GET_DTS_DAY(regval) GET_BITS((regval),0,5) /*!< get value of RTC_DTS_DAY bit field */
|
||||
|
||||
#define DTS_MON(regval) (BITS(8,12) & ((uint32_t)(regval) << 8)) /*!< write value to RTC_DTS_MON bit field */
|
||||
#define GET_DTS_MON(regval) GET_BITS((regval),8,11) /*!< get value of RTC_DTS_MON bit field */
|
||||
#define GET_DTS_MON(regval) GET_BITS((regval),8,12) /*!< get value of RTC_DTS_MON bit field */
|
||||
|
||||
#define DTS_DOW(regval) (BITS(13,15) & ((uint32_t)(regval) << 13)) /*!< write value to RTC_DTS_DOW bit field */
|
||||
#define GET_DTS_DOW(regval) GET_BITS((regval),13,15) /*!< get value of RTC_DTS_DOW bit field */
|
||||
@@ -399,7 +425,7 @@ typedef struct
|
||||
#define RTC_CALIBRATION_PLUS_RESET ((uint32_t)0x00000000U) /*!< no effect */
|
||||
|
||||
/* tamp register value */
|
||||
#define TAMP_FREQ(regval) (BITS(8,10) & ((uint32_t)(regval) << 10)) /*!< write value to RTC_TAMP_FREQ bit field */
|
||||
#define TAMP_FREQ(regval) (BITS(8,10) & ((uint32_t)(regval) << 8)) /*!< write value to RTC_TAMP_FREQ bit field */
|
||||
#define RTC_FREQ_DIV32768 TAMP_FREQ(0) /*!< sample once every 32768 RTCCLK(1Hz if RTCCLK=32.768KHz) */
|
||||
#define RTC_FREQ_DIV16384 TAMP_FREQ(1) /*!< sample once every 16384 RTCCLK(2Hz if RTCCLK=32.768KHz) */
|
||||
#define RTC_FREQ_DIV8192 TAMP_FREQ(2) /*!< sample once every 8192 RTCCLK(4Hz if RTCCLK=32.768KHz) */
|
||||
@@ -475,12 +501,12 @@ typedef struct
|
||||
#define RTC_WUT_RESET ((uint32_t)0x0000FFFFU) /*!< RTC_WUT register reset value */
|
||||
|
||||
/* RTC alarm */
|
||||
#define RTC_ALARM0 ((uint8_t)0x01U) /*!< RTC alarm 0 */
|
||||
#define RTC_ALARM1 ((uint8_t)0x02U) /*!< RTC alarm 1 */
|
||||
#define RTC_ALARM0 ((uint8_t)0x01U) /*!< RTC alarm 0 */
|
||||
#define RTC_ALARM1 ((uint8_t)0x02U) /*!< RTC alarm 1 */
|
||||
|
||||
/* RTC coarse calibration direction */
|
||||
#define CALIB_INCREASE ((uint8_t)0x01U) /*!< RTC coarse calibration increase */
|
||||
#define CALIB_DECREASE ((uint8_t)0x02U) /*!< RTC coarse calibration decrease */
|
||||
#define CALIB_INCREASE ((uint8_t)0x01U) /*!< RTC coarse calibration increase */
|
||||
#define CALIB_DECREASE ((uint8_t)0x02U) /*!< RTC coarse calibration decrease */
|
||||
|
||||
/* RTC wakeup timer clock */
|
||||
#define CTL_WTCS(regval) (BITS(0,2) & ((regval)<< 0))
|
||||
@@ -490,13 +516,30 @@ typedef struct
|
||||
#define WAKEUP_RTCCK_DIV2 CTL_WTCS(3) /*!< wakeup timer clock is RTC clock divided by 2 */
|
||||
#define WAKEUP_CKSPRE CTL_WTCS(4) /*!< wakeup timer clock is ckapre */
|
||||
#define WAKEUP_CKSPRE_2EXP16 CTL_WTCS(6) /*!< wakeup timer clock is ckapre and wakeup timer add 2exp16 */
|
||||
|
||||
|
||||
/* RTC_AF pin */
|
||||
#define RTC_AF0_TIMESTAMP ((uint32_t)0x00000000) /*!< RTC_AF0 use for timestamp */
|
||||
#define RTC_AF1_TIMESTAMP RTC_TAMP_TSSEL /*!< RTC_AF1 use for timestamp */
|
||||
#define RTC_AF0_TAMPER0 ((uint32_t)0x00000000) /*!< RTC_AF0 use for tamper0 */
|
||||
#define RTC_AF1_TAMPER0 RTC_TAMP_TP0SEL /*!< RTC_AF1 use for tamper0 */
|
||||
|
||||
/* RTC flags */
|
||||
#define RTC_FLAG_ALRM0W RTC_STAT_ALRM0WF /*!< alarm0 configuration can be write flag */
|
||||
#define RTC_FLAG_ALRM1W RTC_STAT_ALRM1WF /*!< alarm1 configuration can be write flag */
|
||||
#define RTC_FLAG_WTW RTC_STAT_WTWF /*!< wakeup timer can be write flag */
|
||||
#define RTC_FLAG_SOP RTC_STAT_SOPF /*!< shift function operation pending flag */
|
||||
#define RTC_FLAG_YCM RTC_STAT_YCM /*!< year configuration mark status flag */
|
||||
#define RTC_FLAG_RSYN RTC_STAT_RSYNF /*!< register synchronization flag */
|
||||
#define RTC_FLAG_INIT RTC_STAT_INITF /*!< initialization state flag */
|
||||
#define RTC_FLAG_ALRM0 RTC_STAT_ALRM0F /*!< alarm0 occurs flag */
|
||||
#define RTC_FLAG_ALRM1 RTC_STAT_ALRM1F /*!< alarm1 occurs flag */
|
||||
#define RTC_FLAG_WT RTC_STAT_WTF /*!< wakeup timer occurs flag */
|
||||
#define RTC_FLAG_TS RTC_STAT_TSF /*!< time-stamp flag */
|
||||
#define RTC_FLAG_TSOVR RTC_STAT_TSOVRF /*!< time-stamp overflow flag */
|
||||
#define RTC_FLAG_TP0 RTC_STAT_TP0F /*!< RTC tamper 0 detected flag */
|
||||
#define RTC_FLAG_TP1 RTC_STAT_TP1F /*!< RTC tamper 1 detected flag */
|
||||
#define RTC_STAT_SCP RTC_STAT_SCPF /*!< smooth calibration pending flag */
|
||||
|
||||
/* function declarations */
|
||||
/* reset most of the RTC registers */
|
||||
ErrStatus rtc_deinit(void);
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_sdio.h
|
||||
\brief definitions for the SDIO
|
||||
\file gd32f4xx_sdio.h
|
||||
\brief definitions for the SDIO
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_SDIO_H
|
||||
@@ -179,7 +204,7 @@
|
||||
#define SDIO_FLAG_SDIOINT BIT(22) /*!< SD I/O interrupt received flag */
|
||||
#define SDIO_FLAG_ATAEND BIT(23) /*!< CE-ATA command completion signal received (only for CMD61) flag */
|
||||
|
||||
/* SDIO interrupt flags */
|
||||
/* SDIO interrupt enable or disable */
|
||||
#define SDIO_INT_CCRCERR BIT(0) /*!< SDIO CCRCERR interrupt */
|
||||
#define SDIO_INT_DTCRCERR BIT(1) /*!< SDIO DTCRCERR interrupt */
|
||||
#define SDIO_INT_CMDTMOUT BIT(2) /*!< SDIO CMDTMOUT interrupt */
|
||||
@@ -205,6 +230,32 @@
|
||||
#define SDIO_INT_SDIOINT BIT(22) /*!< SDIO SDIOINT interrupt */
|
||||
#define SDIO_INT_ATAEND BIT(23) /*!< SDIO ATAEND interrupt */
|
||||
|
||||
/* SDIO interrupt flags */
|
||||
#define SDIO_INT_FLAG_CCRCERR BIT(0) /*!< SDIO CCRCERR interrupt flag */
|
||||
#define SDIO_INT_FLAG_DTCRCERR BIT(1) /*!< SDIO DTCRCERR interrupt flag */
|
||||
#define SDIO_INT_FLAG_CMDTMOUT BIT(2) /*!< SDIO CMDTMOUT interrupt flag */
|
||||
#define SDIO_INT_FLAG_DTTMOUT BIT(3) /*!< SDIO DTTMOUT interrupt flag */
|
||||
#define SDIO_INT_FLAG_TXURE BIT(4) /*!< SDIO TXURE interrupt flag */
|
||||
#define SDIO_INT_FLAG_RXORE BIT(5) /*!< SDIO RXORE interrupt flag */
|
||||
#define SDIO_INT_FLAG_CMDRECV BIT(6) /*!< SDIO CMDRECV interrupt flag */
|
||||
#define SDIO_INT_FLAG_CMDSEND BIT(7) /*!< SDIO CMDSEND interrupt flag */
|
||||
#define SDIO_INT_FLAG_DTEND BIT(8) /*!< SDIO DTEND interrupt flag */
|
||||
#define SDIO_INT_FLAG_STBITE BIT(9) /*!< SDIO STBITE interrupt flag */
|
||||
#define SDIO_INT_FLAG_DTBLKEND BIT(10) /*!< SDIO DTBLKEND interrupt flag */
|
||||
#define SDIO_INT_FLAG_CMDRUN BIT(11) /*!< SDIO CMDRUN interrupt flag */
|
||||
#define SDIO_INT_FLAG_TXRUN BIT(12) /*!< SDIO TXRUN interrupt flag */
|
||||
#define SDIO_INT_FLAG_RXRUN BIT(13) /*!< SDIO RXRUN interrupt flag */
|
||||
#define SDIO_INT_FLAG_TFH BIT(14) /*!< SDIO TFH interrupt flag */
|
||||
#define SDIO_INT_FLAG_RFH BIT(15) /*!< SDIO RFH interrupt flag */
|
||||
#define SDIO_INT_FLAG_TFF BIT(16) /*!< SDIO TFF interrupt flag */
|
||||
#define SDIO_INT_FLAG_RFF BIT(17) /*!< SDIO RFF interrupt flag */
|
||||
#define SDIO_INT_FLAG_TFE BIT(18) /*!< SDIO TFE interrupt flag */
|
||||
#define SDIO_INT_FLAG_RFE BIT(19) /*!< SDIO RFE interrupt flag */
|
||||
#define SDIO_INT_FLAG_TXDTVAL BIT(20) /*!< SDIO TXDTVAL interrupt flag */
|
||||
#define SDIO_INT_FLAG_RXDTVAL BIT(21) /*!< SDIO RXDTVAL interrupt flag */
|
||||
#define SDIO_INT_FLAG_SDIOINT BIT(22) /*!< SDIO SDIOINT interrupt flag */
|
||||
#define SDIO_INT_FLAG_ATAEND BIT(23) /*!< SDIO ATAEND interrupt flag */
|
||||
|
||||
/* SDIO power control */
|
||||
#define PWRCTL_PWRCTL(regval) (BITS(0,1) & ((uint32_t)(regval) << 0))
|
||||
#define SDIO_POWER_OFF PWRCTL_PWRCTL(0) /*!< SDIO power off */
|
||||
@@ -275,6 +326,7 @@
|
||||
#define SDIO_READWAITTYPE_CLK SDIO_DATACTL_RWTYPE /*!< read wait control by stopping SDIO_CLK */
|
||||
|
||||
/* function declarations */
|
||||
/* de/initialization functions, hardware clock, bus mode, power_state and SDIO clock configuration */
|
||||
/* deinitialize the SDIO */
|
||||
void sdio_deinit(void);
|
||||
/* configure the SDIO clock */
|
||||
@@ -294,7 +346,7 @@ void sdio_clock_enable(void);
|
||||
/* disable SDIO_CLK clock output */
|
||||
void sdio_clock_disable(void);
|
||||
|
||||
/* configure the command index, argument, response type, wait type and CSM to send command */
|
||||
/* configure the command index, argument, response type, wait type and CSM to send command functions */
|
||||
/* configure the command and response */
|
||||
void sdio_command_response_config(uint32_t cmd_index, uint32_t cmd_argument, uint32_t response_type);
|
||||
/* set the command state machine wait type */
|
||||
@@ -308,7 +360,7 @@ uint8_t sdio_command_index_get(void);
|
||||
/* get the response for the last received command */
|
||||
uint32_t sdio_response_get(uint32_t sdio_responsex);
|
||||
|
||||
/* configure the data timeout, length, block size, transfer mode, direction and DSM for data transfer */
|
||||
/* configure the data timeout, length, block size, transfer mode, direction and DSM for data transfer functions */
|
||||
/* configure the data timeout, data length and data block size */
|
||||
void sdio_data_config(uint32_t data_timeout, uint32_t data_length, uint32_t data_blocksize);
|
||||
/* configure the data transfer mode and direction */
|
||||
@@ -330,6 +382,7 @@ void sdio_dma_enable(void);
|
||||
/* disable the DMA request for SDIO */
|
||||
void sdio_dma_disable(void);
|
||||
|
||||
/* flag and interrupt functions */
|
||||
/* get the flags state of SDIO */
|
||||
FlagStatus sdio_flag_get(uint32_t flag);
|
||||
/* clear the pending flags of SDIO */
|
||||
@@ -343,6 +396,7 @@ FlagStatus sdio_interrupt_flag_get(uint32_t int_flag);
|
||||
/* clear the interrupt pending flags of SDIO */
|
||||
void sdio_interrupt_flag_clear(uint32_t int_flag);
|
||||
|
||||
/* SD I/O card functions */
|
||||
/* enable the read wait mode(SD I/O only) */
|
||||
void sdio_readwait_enable(void);
|
||||
/* disable the read wait mode(SD I/O only) */
|
||||
@@ -362,6 +416,7 @@ void sdio_suspend_enable(void);
|
||||
/* disable the SD I/O suspend operation(SD I/O only) */
|
||||
void sdio_suspend_disable(void);
|
||||
|
||||
/* CE-ATA functions */
|
||||
/* enable the CE-ATA command(CE-ATA only) */
|
||||
void sdio_ceata_command_enable(void);
|
||||
/* disable the CE-ATA command(CE-ATA only) */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+42
-19
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_syscfg.h
|
||||
\brief definitions for the SYSCFG
|
||||
\file gd32f4xx_syscfg.h
|
||||
\brief definitions for the SYSCFG
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_SYSCFG_H
|
||||
@@ -85,13 +110,13 @@
|
||||
#define EXTISS3 ((uint8_t)0x03U) /*!< EXTI source select GPIOx pin 12~15 */
|
||||
|
||||
/* EXTI source select mask bits definition */
|
||||
#define EXTI_SS_MASK BITS(0,3)
|
||||
#define EXTI_SS_MASK BITS(0,3) /*!< EXTI source select mask */
|
||||
|
||||
/* EXTI source select jumping step definition */
|
||||
#define EXTI_SS_JSTEP ((uint8_t)(0x04U))
|
||||
#define EXTI_SS_JSTEP ((uint8_t)(0x04U)) /*!< EXTI source select jumping step */
|
||||
|
||||
/* EXTI source select moving step definition */
|
||||
#define EXTI_SS_MSTEP(pin) (EXTI_SS_JSTEP*((pin)%EXTI_SS_JSTEP))
|
||||
#define EXTI_SS_MSTEP(pin) (EXTI_SS_JSTEP*((pin)%EXTI_SS_JSTEP)) /*!< EXTI source select moving step */
|
||||
|
||||
/* EXTI source port definitions */
|
||||
#define EXTI_SOURCE_GPIOA ((uint8_t)0x00U) /*!< EXTI GPIOA configuration */
|
||||
@@ -123,35 +148,33 @@
|
||||
#define EXTI_SOURCE_PIN15 ((uint8_t)0x0FU) /*!< EXTI GPIO pin15 configuration */
|
||||
|
||||
/* ethernet PHY selection */
|
||||
#define SYSCFG_ENET_PHY_MII ((uint32_t)0x00000000U)
|
||||
#define SYSCFG_ENET_PHY_RMII ((uint32_t)0x00800000U)
|
||||
#define SYSCFG_ENET_PHY_MII ((uint32_t)0x00000000U) /*!< MII is selected for the Ethernet MAC */
|
||||
#define SYSCFG_ENET_PHY_RMII ((uint32_t)0x00800000U) /*!< RMII is selected for the Ethernet MAC */
|
||||
|
||||
/* I/O compensation cell enable/disable */
|
||||
#define SYSCFG_COMPENSATION_ENABLE ((uint32_t)0x00000001U)
|
||||
#define SYSCFG_COMPENSATION_DISABLE ((uint32_t)0x00000000U)
|
||||
#define SYSCFG_COMPENSATION_ENABLE ((uint32_t)0x00000001U) /*!< I/O compensation cell enable */
|
||||
#define SYSCFG_COMPENSATION_DISABLE ((uint32_t)0x00000000U) /*!< I/O compensation cell disable */
|
||||
|
||||
/* function declarations */
|
||||
/* initialization functions */
|
||||
/* deinit syscfg module */
|
||||
void syscfg_deinit(void);
|
||||
|
||||
/* function configuration */
|
||||
/* configure the boot mode */
|
||||
void syscfg_bootmode_config(uint8_t syscfg_bootmode);
|
||||
|
||||
/* FMC memory mapping swap */
|
||||
/* configure FMC memory mapping swap */
|
||||
void syscfg_fmc_swap_config(uint32_t syscfg_fmc_swap);
|
||||
|
||||
/* configure the EXMC swap */
|
||||
void syscfg_exmc_swap_config(uint32_t syscfg_exmc_swap);
|
||||
|
||||
void syscfg_exmc_swap_config(uint32_t syscfg_exmc_swap);
|
||||
/* configure the GPIO pin as EXTI Line */
|
||||
void syscfg_exti_line_config(uint8_t exti_port, uint8_t exti_pin);
|
||||
|
||||
/* configure the PHY interface for the ethernet MAC */
|
||||
void syscfg_enet_phy_interface_config(uint32_t syscfg_enet_phy_interface);
|
||||
|
||||
/* configure the I/O compensation cell */
|
||||
void syscfg_compensation_config(uint32_t syscfg_compensation);
|
||||
void syscfg_compensation_config(uint32_t syscfg_compensation);
|
||||
|
||||
/* interrupt & flag functions */
|
||||
/* check the I/O compensation cell is ready or not */
|
||||
FlagStatus syscfg_flag_get(void);
|
||||
|
||||
|
||||
+217
-171
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_trng.h
|
||||
\brief definitions for the TRNG
|
||||
\file gd32f4xx_trng.h
|
||||
\brief definitions for the TRNG
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_TRNG_H
|
||||
@@ -14,13 +39,13 @@
|
||||
|
||||
#include "gd32f4xx.h"
|
||||
|
||||
/* EXTI definitions */
|
||||
/* TRNG definitions */
|
||||
#define TRNG TRNG_BASE
|
||||
|
||||
/* registers definitions */
|
||||
#define TRNG_CTL REG32(TRNG + 0x00U) /*!< interrupt enable register */
|
||||
#define TRNG_STAT REG32(TRNG + 0x04U) /*!< event enable register */
|
||||
#define TRNG_DATA REG32(TRNG + 0x08U) /*!< rising edge trigger enable register */
|
||||
#define TRNG_CTL REG32(TRNG + 0x00U) /*!< control register */
|
||||
#define TRNG_STAT REG32(TRNG + 0x04U) /*!< status register */
|
||||
#define TRNG_DATA REG32(TRNG + 0x08U) /*!< data register */
|
||||
|
||||
/* bits definitions */
|
||||
/* TRNG_CTL */
|
||||
@@ -40,7 +65,7 @@
|
||||
/* constants definitions */
|
||||
/* trng status flag */
|
||||
typedef enum
|
||||
{
|
||||
{
|
||||
TRNG_FLAG_DRDY = TRNG_STAT_DRDY, /*!< random Data ready status */
|
||||
TRNG_FLAG_CECS = TRNG_STAT_CECS, /*!< clock error current status */
|
||||
TRNG_FLAG_SECS = TRNG_STAT_SECS /*!< seed error current status */
|
||||
@@ -54,6 +79,7 @@ typedef enum
|
||||
}trng_int_flag_enum;
|
||||
|
||||
/* function declarations */
|
||||
/* initialization functions */
|
||||
/* deinitialize the TRNG */
|
||||
void trng_deinit(void);
|
||||
/* enable the TRNG interface */
|
||||
@@ -62,14 +88,14 @@ void trng_enable(void);
|
||||
void trng_disable(void);
|
||||
/* get the true random data */
|
||||
uint32_t trng_get_true_random_data(void);
|
||||
|
||||
/* flag & interrupt functions */
|
||||
/* trng interrupt enable */
|
||||
void trng_interrupt_enable(void);
|
||||
/* trng interrupt disable */
|
||||
void trng_interrupt_disable(void);
|
||||
/* get the trng status flags */
|
||||
FlagStatus trng_flag_get(trng_flag_enum flag);
|
||||
/* clear the trng status flags */
|
||||
void trng_flag_clear(trng_flag_enum flag);
|
||||
/* the trng interrupt enable */
|
||||
void trng_interrupt_enable(void);
|
||||
/* the trng interrupt disable */
|
||||
void trng_interrupt_disable(void);
|
||||
/* get the trng interrupt flags */
|
||||
FlagStatus trng_interrupt_flag_get(trng_int_flag_enum int_flag);
|
||||
/* clear the trng interrupt flags */
|
||||
|
||||
+121
-93
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_wwdgt.h
|
||||
\brief definitions for the WWDGT
|
||||
\file gd32f4xx_wwdgt.h
|
||||
\brief definitions for the WWDGT
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GD32F4XX_WWDGT_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,43 @@
|
||||
/*!
|
||||
\file gd32f4xx_crc.c
|
||||
\brief CRC driver
|
||||
\file gd32f4xx_crc.c
|
||||
\brief CRC driver
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_crc.h"
|
||||
|
||||
#define CRC_DATA_RESET_VALUE ((uint32_t)0xFFFFFFFFU)
|
||||
#define CRC_FDATA_RESET_VALUE ((uint32_t)0x00000000U)
|
||||
/*!
|
||||
\brief deinit CRC calculation unit
|
||||
\param[in] none
|
||||
@@ -19,13 +46,13 @@
|
||||
*/
|
||||
void crc_deinit(void)
|
||||
{
|
||||
CRC_DATA = (uint32_t)0xFFFFFFFFU;
|
||||
CRC_FDATA = (uint32_t)0x00000000U;
|
||||
CRC_CTL = CRC_CTL_RST;
|
||||
CRC_DATA = CRC_DATA_RESET_VALUE;
|
||||
CRC_FDATA = CRC_FDATA_RESET_VALUE;
|
||||
CRC_CTL = (uint32_t)CRC_CTL_RST;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief reset data register to the value of initializaiton data register
|
||||
\brief reset data register(CRC_DATA) to the value of 0xFFFFFFFF
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -36,7 +63,7 @@ void crc_data_register_reset(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief read the data register
|
||||
\brief read the value of the data register
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval 32-bit value of the data register
|
||||
@@ -49,7 +76,7 @@ uint32_t crc_data_register_read(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief read the free data register
|
||||
\brief read the value of the free data register
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval 8-bit value of the free data register
|
||||
@@ -62,8 +89,8 @@ uint8_t crc_free_data_register_read(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief write the free data register
|
||||
\param[in] free_data: specify 8-bit data
|
||||
\brief write data to the free data register
|
||||
\param[in] free_data: specified 8-bit data
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
@@ -73,10 +100,10 @@ void crc_free_data_register_write(uint8_t free_data)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief CRC calculate a 32-bit data
|
||||
\param[in] sdata: specify 32-bit data
|
||||
\brief calculate the CRC value of a 32-bit data
|
||||
\param[in] sdata: specified 32-bit data
|
||||
\param[out] none
|
||||
\retval 32-bit CRC calculate value
|
||||
\retval 32-bit value calculated by CRC
|
||||
*/
|
||||
uint32_t crc_single_data_calculate(uint32_t sdata)
|
||||
{
|
||||
@@ -85,11 +112,11 @@ uint32_t crc_single_data_calculate(uint32_t sdata)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief CRC calculate a 32-bit data array
|
||||
\param[in] array: pointer to an array of 32 bit data words
|
||||
\brief calculate the CRC value of an array of 32-bit values
|
||||
\param[in] array: pointer to an array of 32-bit values
|
||||
\param[in] size: size of the array
|
||||
\param[out] none
|
||||
\retval 32-bit CRC calculate value
|
||||
\retval 32-bit value calculated by CRC
|
||||
*/
|
||||
uint32_t crc_block_data_calculate(uint32_t array[], uint32_t size)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,55 @@
|
||||
/*!
|
||||
\file gd32f4xx_dbg.c
|
||||
\brief DBG driver
|
||||
\file gd32f4xx_dbg.c
|
||||
\brief DBG driver
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_dbg.h"
|
||||
|
||||
#define DBG_RESET_VAL 0x00000000U
|
||||
|
||||
/*!
|
||||
\brief deinitialize the DBG
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void dbg_deinit(void)
|
||||
{
|
||||
DBG_CTL0 = DBG_RESET_VAL;
|
||||
DBG_CTL1 = DBG_RESET_VAL;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief read DBG_ID code register
|
||||
\param[in] none
|
||||
@@ -55,32 +94,69 @@ void dbg_low_power_disable(uint32_t dbg_low_power)
|
||||
/*!
|
||||
\brief enable peripheral behavior when the mcu is in debug mode
|
||||
\param[in] dbg_periph: dbg_periph_enum
|
||||
\param[out] none
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg DBG_TIMER1_HOLD: hold TIMER1 counter when core is halted
|
||||
\arg DBG_TIMER2_HOLD: hold TIMER2 counter when core is halted
|
||||
\arg DBG_TIMER3_HOLD: hold TIMER3 counter when core is halted
|
||||
\arg DBG_TIMER4_HOLD: hold TIMER4 counter when core is halted
|
||||
\arg DBG_TIMER5_HOLD: hold TIMER5 counter when core is halted
|
||||
\arg DBG_TIMER6_HOLD: hold TIMER6 counter when core is halted
|
||||
\arg DBG_TIMER11_HOLD: hold TIMER11 counter when core is halted
|
||||
\arg DBG_TIMER12_HOLD: hold TIMER12 counter when core is halted
|
||||
\arg DBG_TIMER13_HOLD: hold TIMER13 counter when core is halted
|
||||
\arg DBG_RTC_HOLD: hold RTC calendar and wakeup counter when core is halted
|
||||
\arg DBG_WWDGT_HOLD: debug WWDGT kept when core is halted
|
||||
\arg DBG_FWDGT_HOLD: debug FWDGT kept when core is halted
|
||||
\arg DBG_I2C0_HOLD: hold I2C0 smbus when core is halted
|
||||
\arg DBG_I2C1_HOLD: hold I2C1 smbus when core is halted
|
||||
\arg DBG_I2C2_HOLD: hold I2C2 smbus when core is halted
|
||||
\arg DBG_CAN0_HOLD: debug CAN0 kept when core is halted
|
||||
\arg DBG_CAN1_HOLD: debug CAN1 kept when core is halted
|
||||
\arg DBG_TIMER0_HOLD: hold TIMER0 counter when core is halted
|
||||
\arg DBG_TIMER7_HOLD: hold TIMER7 counter when core is halted
|
||||
\arg DBG_TIMER8_HOLD: hold TIMER8 counter when core is halted
|
||||
\arg DBG_TIMER9_HOLD: hold TIMER9 counter when core is halted
|
||||
\arg DBG_TIMER10_HOLD: hold TIMER10 counter when core is halted
|
||||
\arg \param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void dbg_periph_enable(dbg_periph_enum dbg_periph)
|
||||
{
|
||||
if(RESET == ((uint32_t)dbg_periph & BIT(30))){
|
||||
DBG_CTL1 |= (uint32_t)dbg_periph;
|
||||
}else{
|
||||
DBG_CTL2 |= ((uint32_t)dbg_periph & (~BIT(30)));
|
||||
}
|
||||
|
||||
DBG_REG_VAL(dbg_periph) |= BIT(DBG_BIT_POS(dbg_periph));
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable peripheral behavior when the mcu is in debug mode
|
||||
\param[in] dbg_periph: dbg_periph_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg DBG_TIMER1_HOLD: hold TIMER1 counter when core is halted
|
||||
\arg DBG_TIMER2_HOLD: hold TIMER2 counter when core is halted
|
||||
\arg DBG_TIMER3_HOLD: hold TIMER3 counter when core is halted
|
||||
\arg DBG_TIMER4_HOLD: hold TIMER4 counter when core is halted
|
||||
\arg DBG_TIMER5_HOLD: hold TIMER5 counter when core is halted
|
||||
\arg DBG_TIMER6_HOLD: hold TIMER6 counter when core is halted
|
||||
\arg DBG_TIMER11_HOLD: hold TIMER11 counter when core is halted
|
||||
\arg DBG_TIMER12_HOLD: hold TIMER12 counter when core is halted
|
||||
\arg DBG_TIMER13_HOLD: hold TIMER13 counter when core is halted
|
||||
\arg DBG_RTC_HOLD: hold RTC calendar and wakeup counter when core is halted
|
||||
\arg DBG_WWDGT_HOLD: debug WWDGT kept when core is halted
|
||||
\arg DBG_FWDGT_HOLD: debug FWDGT kept when core is halted
|
||||
\arg DBG_I2C0_HOLD: hold I2C0 smbus when core is halted
|
||||
\arg DBG_I2C1_HOLD: hold I2C1 smbus when core is halted
|
||||
\arg DBG_I2C2_HOLD: hold I2C2 smbus when core is halted
|
||||
\arg DBG_CAN0_HOLD: debug CAN0 kept when core is halted
|
||||
\arg DBG_CAN1_HOLD: debug CAN1 kept when core is halted
|
||||
\arg DBG_TIMER0_HOLD: hold TIMER0 counter when core is halted
|
||||
\arg DBG_TIMER7_HOLD: hold TIMER7 counter when core is halted
|
||||
\arg DBG_TIMER8_HOLD: hold TIMER8 counter when core is halted
|
||||
\arg DBG_TIMER9_HOLD: hold TIMER9 counter when core is halted
|
||||
\arg DBG_TIMER10_HOLD: hold TIMER10 counter when core is halted
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void dbg_periph_disable(dbg_periph_enum dbg_periph)
|
||||
{
|
||||
if(RESET == ((uint32_t)dbg_periph & BIT(30))){
|
||||
DBG_CTL1 &= ~(uint32_t)dbg_periph;
|
||||
}else{
|
||||
DBG_CTL2 &= ~((uint32_t)dbg_periph & (~BIT(30)));
|
||||
}
|
||||
DBG_REG_VAL(dbg_periph) &= ~BIT(DBG_BIT_POS(dbg_periph));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -106,9 +182,9 @@ void dbg_trace_pin_disable(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief trace pin mode selection
|
||||
\brief trace pin mode selection
|
||||
\param[in] trace_mode:
|
||||
\arg TRACE_MODE_ASYNC: trace pin used for async mode
|
||||
\arg TRACE_MODE_ASYNC: trace pin used for async mode
|
||||
\arg TRACE_MODE_SYNC_DATASIZE_1: trace pin used for sync mode and data size is 1
|
||||
\arg TRACE_MODE_SYNC_DATASIZE_2: trace pin used for sync mode and data size is 2
|
||||
\arg TRACE_MODE_SYNC_DATASIZE_4: trace pin used for sync mode and data size is 4
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_fwdgt.c
|
||||
\brief FWDGT driver
|
||||
\file gd32f4xx_fwdgt.c
|
||||
\brief FWDGT driver
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_fwdgt.h"
|
||||
@@ -16,6 +41,17 @@
|
||||
/* write value to FWDGT_RLD_RLD bit field */
|
||||
#define RLD_RLD(regval) (BITS(0,11) & ((uint32_t)(regval) << 0))
|
||||
|
||||
/*!
|
||||
\brief enable write access to FWDGT_PSC and FWDGT_RLD
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void fwdgt_write_enable(void)
|
||||
{
|
||||
FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable write access to FWDGT_PSC and FWDGT_RLD
|
||||
\param[in] none
|
||||
@@ -27,6 +63,17 @@ void fwdgt_write_disable(void)
|
||||
FWDGT_CTL = FWDGT_WRITEACCESS_DISABLE;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief start the free watchdog timer counter
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void fwdgt_enable(void)
|
||||
{
|
||||
FWDGT_CTL = FWDGT_KEY_ENABLE;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief reload the counter of FWDGT
|
||||
\param[in] none
|
||||
@@ -38,22 +85,11 @@ void fwdgt_counter_reload(void)
|
||||
FWDGT_CTL = FWDGT_KEY_RELOAD;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief start the free watchdog timer counter
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void fwdgt_enable(void)
|
||||
{
|
||||
FWDGT_CTL = FWDGT_KEY_ENABLE;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief configure counter reload value, and prescaler divider value
|
||||
\param[in] reload_value: specify reload value(0x0000 - 0x0FFF)
|
||||
\param[in] prescaler_div: FWDGT prescaler value
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg FWDGT_PSC_DIV4: FWDGT prescaler set to 4
|
||||
\arg FWDGT_PSC_DIV8: FWDGT prescaler set to 8
|
||||
\arg FWDGT_PSC_DIV16: FWDGT prescaler set to 16
|
||||
@@ -68,15 +104,15 @@ ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
|
||||
{
|
||||
uint32_t timeout = FWDGT_PSC_TIMEOUT;
|
||||
uint32_t flag_status = RESET;
|
||||
|
||||
|
||||
/* enable write access to FWDGT_PSC,and FWDGT_RLD */
|
||||
FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE;
|
||||
|
||||
|
||||
/* wait until the PUD flag to be reset */
|
||||
do{
|
||||
flag_status = FWDGT_STAT & FWDGT_STAT_PUD;
|
||||
}while((--timeout > 0U) && ((uint32_t)RESET != flag_status));
|
||||
|
||||
|
||||
if ((uint32_t)RESET != flag_status){
|
||||
return ERROR;
|
||||
}
|
||||
@@ -89,13 +125,13 @@ ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
|
||||
do{
|
||||
flag_status = FWDGT_STAT & FWDGT_STAT_RUD;
|
||||
}while((--timeout > 0U) && ((uint32_t)RESET != flag_status));
|
||||
|
||||
|
||||
if ((uint32_t)RESET != flag_status){
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
FWDGT_RLD = RLD_RLD(reload_value);
|
||||
|
||||
|
||||
/* reload the counter */
|
||||
FWDGT_CTL = FWDGT_KEY_RELOAD;
|
||||
|
||||
@@ -104,7 +140,8 @@ ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
|
||||
|
||||
/*!
|
||||
\brief get flag state of FWDGT
|
||||
\param[in] flag: flag to get
|
||||
\param[in] flag: flag to get
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg FWDGT_STAT_PUD: a write operation to FWDGT_PSC register is on going
|
||||
\arg FWDGT_STAT_RUD: a write operation to FWDGT_RLD register is on going
|
||||
\param[out] none
|
||||
@@ -112,7 +149,7 @@ ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
|
||||
*/
|
||||
FlagStatus fwdgt_flag_get(uint16_t flag)
|
||||
{
|
||||
if(FWDGT_STAT & flag){
|
||||
if(RESET != (FWDGT_STAT & flag)){
|
||||
return SET;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_iref.c
|
||||
\brief IREF driver
|
||||
\file gd32f4xx_iref.c
|
||||
\brief IREF driver
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_iref.h"
|
||||
@@ -87,7 +112,7 @@ void iref_sink_set(uint32_t sinkmode)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief set IREF step data
|
||||
\brief set IREF step data
|
||||
\param[in] stepdata
|
||||
\arg IREF_CUR_STEP_DATA_X:(x=0..63): step*x
|
||||
\param[out] none
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_misc.c
|
||||
\brief MISC driver
|
||||
\file gd32f4xx_misc.c
|
||||
\brief MISC driver
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_misc.h"
|
||||
@@ -36,7 +61,7 @@ void nvic_priority_group_set(uint32_t nvic_prigroup)
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void nvic_irq_enable(uint8_t nvic_irq, uint8_t nvic_irq_pre_priority,
|
||||
void nvic_irq_enable(uint8_t nvic_irq, uint8_t nvic_irq_pre_priority,
|
||||
uint8_t nvic_irq_sub_priority)
|
||||
{
|
||||
uint32_t temp_priority = 0x00U, temp_pre = 0x00U, temp_sub = 0x00U;
|
||||
@@ -57,6 +82,9 @@ void nvic_irq_enable(uint8_t nvic_irq, uint8_t nvic_irq_pre_priority,
|
||||
temp_pre=4U;
|
||||
temp_sub=0x0U;
|
||||
}else{
|
||||
nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2);
|
||||
temp_pre=2U;
|
||||
temp_sub=0x2U;
|
||||
}
|
||||
/* get the temp_priority to fill the NVIC->IP register */
|
||||
temp_priority = (uint32_t)nvic_irq_pre_priority << (0x4U - temp_pre);
|
||||
@@ -96,10 +124,10 @@ void nvic_vector_table_set(uint32_t nvic_vict_tab, uint32_t offset)
|
||||
/*!
|
||||
\brief set the state of the low power mode
|
||||
\param[in] lowpower_mode: the low power mode state
|
||||
\arg SCB_LPM_SLEEP_EXIT_ISR: if chose this para, the system always enter low power
|
||||
\arg SCB_LPM_SLEEP_EXIT_ISR: if chose this para, the system always enter low power
|
||||
mode by exiting from ISR
|
||||
\arg SCB_LPM_DEEPSLEEP: if chose this para, the system will enter the DEEPSLEEP mode
|
||||
\arg SCB_LPM_WAKE_BY_ALL_INT: if chose this para, the lowpower mode can be woke up
|
||||
\arg SCB_LPM_WAKE_BY_ALL_INT: if chose this para, the lowpower mode can be woke up
|
||||
by all the enable and disable interrupts
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -112,10 +140,10 @@ void system_lowpower_set(uint8_t lowpower_mode)
|
||||
/*!
|
||||
\brief reset the state of the low power mode
|
||||
\param[in] lowpower_mode: the low power mode state
|
||||
\arg SCB_LPM_SLEEP_EXIT_ISR: if chose this para, the system will exit low power
|
||||
\arg SCB_LPM_SLEEP_EXIT_ISR: if chose this para, the system will exit low power
|
||||
mode by exiting from ISR
|
||||
\arg SCB_LPM_DEEPSLEEP: if chose this para, the system will enter the SLEEP mode
|
||||
\arg SCB_LPM_WAKE_BY_ALL_INT: if chose this para, the lowpower mode only can be
|
||||
\arg SCB_LPM_WAKE_BY_ALL_INT: if chose this para, the lowpower mode only can be
|
||||
woke up by the enable interrupts
|
||||
\param[out] none
|
||||
\retval none
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_syscfg.c
|
||||
\brief SYSCFG driver
|
||||
\file gd32f4xx_syscfg.c
|
||||
\brief SYSCFG driver
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_syscfg.h"
|
||||
@@ -24,8 +49,9 @@ void syscfg_deinit(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure the boot mode
|
||||
\brief configure the boot mode
|
||||
\param[in] syscfg_bootmode: selects the memory remapping
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg SYSCFG_BOOTMODE_FLASH: main flash memory (0x08000000~0x083BFFFF) is mapped at address 0x00000000
|
||||
\arg SYSCFG_BOOTMODE_BOOTLOADER: boot loader (0x1FFF0000 - 0x1FFF77FF) is mapped at address 0x00000000
|
||||
\arg SYSCFG_BOOTMODE_EXMC_SRAM: SRAM/NOR 0 and 1 of EXMC (0x60000000~0x67FFFFFF) is mapped at address 0x00000000
|
||||
@@ -44,6 +70,7 @@ void syscfg_bootmode_config(uint8_t syscfg_bootmode)
|
||||
/*!
|
||||
\brief FMC memory mapping swap
|
||||
\param[in] syscfg_fmc_swap: selects the interal flash bank swapping
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg SYSCFG_FMC_SWP_BANK0: bank 0 is mapped at address 0x08000000 and bank 1 is mapped at address 0x08100000
|
||||
\arg SYSCFG_FMC_SWP_BANK1: bank 1 is mapped at address 0x08000000 and bank 0 is mapped at address 0x08100000
|
||||
\param[out] none
|
||||
@@ -61,6 +88,7 @@ void syscfg_fmc_swap_config(uint32_t syscfg_fmc_swap)
|
||||
/*!
|
||||
\brief EXMC memory mapping swap
|
||||
\param[in] syscfg_exmc_swap: selects the memories in EXMC swapping
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg SYSCFG_EXMC_SWP_ENABLE: SDRAM bank 0 and bank 1 are swapped with NAND bank 1 and PC card
|
||||
\arg SYSCFG_EXMC_SWP_DISABLE: no memory mapping swap
|
||||
\param[out] none
|
||||
@@ -79,8 +107,10 @@ void syscfg_exmc_swap_config(uint32_t syscfg_exmc_swap)
|
||||
/*!
|
||||
\brief configure the GPIO pin as EXTI Line
|
||||
\param[in] exti_port: specify the GPIO port used in EXTI
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_SOURCE_GPIOx(x = A,B,C,D,E,F,G,H,I): EXTI GPIO port
|
||||
\param[in] exti_pin: specify the EXTI line
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_SOURCE_PINx(x = 0..15): EXTI GPIO pin
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -123,15 +153,16 @@ void syscfg_exti_line_config(uint8_t exti_port, uint8_t exti_pin)
|
||||
/*!
|
||||
\brief configure the PHY interface for the ethernet MAC
|
||||
\param[in] syscfg_enet_phy_interface: specifies the media interface mode.
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg SYSCFG_ENET_PHY_MII: MII mode is selected
|
||||
\arg SYSCFG_ENET_PHY_RMII: RMII mode is selected
|
||||
\arg SYSCFG_ENET_PHY_RMII: RMII mode is selected
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void syscfg_enet_phy_interface_config(uint32_t syscfg_enet_phy_interface)
|
||||
{
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
|
||||
reg = SYSCFG_CFG1;
|
||||
/* reset the ENET_PHY_SEL bit and set according to syscfg_enet_phy_interface */
|
||||
reg &= ~SYSCFG_CFG1_ENET_PHY_SEL;
|
||||
@@ -141,12 +172,13 @@ void syscfg_enet_phy_interface_config(uint32_t syscfg_enet_phy_interface)
|
||||
/*!
|
||||
\brief configure the I/O compensation cell
|
||||
\param[in] syscfg_compensation: specifies the I/O compensation cell mode
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg SYSCFG_COMPENSATION_ENABLE: I/O compensation cell is enabled
|
||||
\arg SYSCFG_COMPENSATION_DISABLE: I/O compensation cell is disabled
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void syscfg_compensation_config(uint32_t syscfg_compensation)
|
||||
void syscfg_compensation_config(uint32_t syscfg_compensation)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
|
||||
+581
-410
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_trng.c
|
||||
\brief TRNG driver
|
||||
\file gd32f4xx_trng.c
|
||||
\brief TRNG driver
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_trng.h"
|
||||
@@ -56,6 +81,28 @@ uint32_t trng_get_true_random_data(void)
|
||||
return (TRNG_DATA);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable the TRNG interrupt
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void trng_interrupt_enable(void)
|
||||
{
|
||||
TRNG_CTL |= TRNG_CTL_IE;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable the TRNG interrupt
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void trng_interrupt_disable(void)
|
||||
{
|
||||
TRNG_CTL &= ~TRNG_CTL_IE;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get the trng status flags
|
||||
\param[in] flag: trng status flag, refer to trng_flag_enum
|
||||
@@ -75,42 +122,6 @@ FlagStatus trng_flag_get(trng_flag_enum flag)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief clear the trng status flags
|
||||
\param[in] flag: the special status flag
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg TRNG_FLAG_CECS: Clock error current status
|
||||
\arg TRNG_FLAG_SECS: Seed error current status
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void trng_flag_clear(trng_flag_enum flag)
|
||||
{
|
||||
TRNG_STAT &= ~(uint32_t)flag;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable the TRNG interrupt
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void trng_interrupt_enable(void)
|
||||
{
|
||||
TRNG_CTL |= TRNG_CTL_IE;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable the TRNG interrupt
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void trng_interrupt_disable(void)
|
||||
{
|
||||
TRNG_CTL &= ~TRNG_CTL_IE;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get the trng interrupt flags
|
||||
\param[in] int_flag: trng interrupt flag, refer to trng_int_flag_enum
|
||||
|
||||
+209
-152
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_wwdgt.c
|
||||
\brief WWDGT driver
|
||||
\file gd32f4xx_wwdgt.c
|
||||
\brief WWDGT driver
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2020-09-30, V2.1.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
Copyright (c) 2020, GigaDevice Semiconductor Inc.
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_wwdgt.h"
|
||||
@@ -28,22 +53,6 @@ void wwdgt_deinit(void)
|
||||
rcu_periph_reset_disable(RCU_WWDGTRST);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure the window watchdog timer counter value
|
||||
\param[in] counter_value: 0x00 - 0x7F
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void wwdgt_counter_update(uint16_t counter_value)
|
||||
{
|
||||
uint32_t reg = 0U;
|
||||
|
||||
reg = (WWDGT_CTL & (~WWDGT_CTL_CNT));
|
||||
reg |= CTL_CNT(counter_value);
|
||||
|
||||
WWDGT_CTL = reg;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief start the window watchdog timer counter
|
||||
\param[in] none
|
||||
@@ -56,10 +65,27 @@ void wwdgt_enable(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure counter value, window value, and prescaler divider value
|
||||
\param[in] counter: 0x00 - 0x7F
|
||||
\brief configure the window watchdog timer counter value
|
||||
\param[in] counter_value: 0x00 - 0x7F
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void wwdgt_counter_update(uint16_t counter_value)
|
||||
{
|
||||
uint32_t reg = 0U;
|
||||
|
||||
reg = (WWDGT_CTL & (~WWDGT_CTL_CNT));
|
||||
reg |= CTL_CNT(counter_value);
|
||||
|
||||
WWDGT_CTL = reg;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure counter value, window value, and prescaler divider value
|
||||
\param[in] counter: 0x00 - 0x7F
|
||||
\param[in] window: 0x00 - 0x7F
|
||||
\param[in] prescaler: wwdgt prescaler value
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg WWDGT_CFG_PSC_DIV1: the time base of window watchdog counter = (PCLK1/4096)/1
|
||||
\arg WWDGT_CFG_PSC_DIV2: the time base of window watchdog counter = (PCLK1/4096)/2
|
||||
\arg WWDGT_CFG_PSC_DIV4: the time base of window watchdog counter = (PCLK1/4096)/4
|
||||
@@ -74,12 +100,12 @@ void wwdgt_config(uint16_t counter, uint16_t window, uint32_t prescaler)
|
||||
/* clear WIN and PSC bits, clear CNT bit */
|
||||
reg_cfg = (WWDGT_CFG &(~(WWDGT_CFG_WIN|WWDGT_CFG_PSC)));
|
||||
reg_ctl = (WWDGT_CTL &(~WWDGT_CTL_CNT));
|
||||
|
||||
|
||||
/* configure WIN and PSC bits, configure CNT bit */
|
||||
reg_cfg |= CFG_WIN(window);
|
||||
reg_cfg |= prescaler;
|
||||
reg_ctl |= CTL_CNT(counter);
|
||||
|
||||
|
||||
WWDGT_CTL = reg_ctl;
|
||||
WWDGT_CFG = reg_cfg;
|
||||
}
|
||||
@@ -103,7 +129,7 @@ void wwdgt_interrupt_enable(void)
|
||||
*/
|
||||
FlagStatus wwdgt_flag_get(void)
|
||||
{
|
||||
if(WWDGT_STAT & WWDGT_STAT_EWIF){
|
||||
if(RESET != (WWDGT_STAT & WWDGT_STAT_EWIF)){
|
||||
return SET;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,100 +0,0 @@
|
||||
/*!
|
||||
\file usb_defines.h
|
||||
\brief USB core defines
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#ifndef USB_DEFINES_H
|
||||
#define USB_DEFINES_H
|
||||
|
||||
#include "usb_conf.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0 /*!< USB null marco value*/
|
||||
#endif /* NULL */
|
||||
|
||||
#define USB_CORE_SPEED_HIGH 0U /* USB core speed is high-speed */
|
||||
#define USB_CORE_SPEED_FULL 1U /* USB core speed is full-speed */
|
||||
|
||||
#define USBFS_MAX_PACKET_SIZE 64U /* USBFS max packet size */
|
||||
#define USBFS_MAX_HOST_CHANNELCOUNT 8U /* USBFS host channel count */
|
||||
#define USBFS_MAX_DEV_EPCOUNT 4U /* USBFS device endpoint count */
|
||||
#define USBFS_MAX_FIFO_WORDLEN 320U /* USBFS max fifo size in words */
|
||||
|
||||
#define USBHS_MAX_PACKET_SIZE 512U /* USBHS max packet size */
|
||||
#define USBHS_MAX_HOST_CHANNELCOUNT 12U /* USBHS host channel count */
|
||||
#define USBHS_MAX_DEV_EPCOUNT 6U /* USBHS device endpoint count */
|
||||
#define USBHS_MAX_FIFO_WORDLEN 1280U /* USBHS max fifo size in words */
|
||||
|
||||
#define USB_CORE_ULPI_PHY 1U /* USB core use external ULPI PHY */
|
||||
#define USB_CORE_EMBEDDED_PHY 2U /* USB core use embedded PHY */
|
||||
|
||||
#define DSTAT_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ 0U /* USB enumerate speed use high-speed PHY clock in 30MHz or 60MHz */
|
||||
#define DSTAT_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ 1U /* USB enumerate speed use full-speed PHY clock in 30MHz or 60MHz */
|
||||
#define DSTAT_ENUMSPD_LS_PHY_6MHZ 2U /* USB enumerate speed use low-speed PHY clock in 6MHz */
|
||||
#define DSTAT_ENUMSPD_FS_PHY_48MHZ 3U /* USB enumerate speed use full-speed PHY clock in 48MHz */
|
||||
|
||||
#define GRSTATR_RPCKST_IN 2U /* IN data packet received */
|
||||
#define GRSTATR_RPCKST_IN_XFER_COMP 3U /* IN transfer completed (generates an interrupt if poped) */
|
||||
#define GRSTATR_RPCKST_DATA_TOGGLE_ERR 5U /* Data toggle error (generates an interrupt if poped) */
|
||||
#define GRSTATR_RPCKST_CH_HALTED 7U /* Channel halted (generates an interrupt if poped) */
|
||||
|
||||
#define DEVICE_MODE 0U /* USB core in device mode */
|
||||
#define HOST_MODE 1U /* USB core in host mode */
|
||||
#define OTG_MODE 2U /* USB core in OTG mode */
|
||||
|
||||
#define USB_EPTYPE_CTRL 0U /* USB control endpoint type */
|
||||
#define USB_EPTYPE_ISOC 1U /* USB synchronous endpoint type */
|
||||
#define USB_EPTYPE_BULK 2U /* USB bulk endpoint type */
|
||||
#define USB_EPTYPE_INTR 3U /* USB interrupt endpoint type */
|
||||
#define USB_EPTYPE_MASK 3U /* USB endpoint type mask */
|
||||
|
||||
#define RXSTAT_GOUT_NAK 1U /* global OUT NAK (triggers an interrupt) */
|
||||
#define RXSTAT_DATA_UPDT 2U /* OUT data packet received */
|
||||
#define RXSTAT_XFER_COMP 3U /* OUT transfer completed (triggers an interrupt) */
|
||||
#define RXSTAT_SETUP_COMP 4U /* SETUP transaction completed (triggers an interrupt) */
|
||||
#define RXSTAT_SETUP_UPDT 6U /* SETUP data packet received */
|
||||
|
||||
#define DPID_DATA0 0U /* device endpoint data PID is DATA0 */
|
||||
#define DPID_DATA1 2U /* device endpoint data PID is DATA1 */
|
||||
#define DPID_DATA2 1U /* device endpoint data PID is DATA2 */
|
||||
#define DPID_MDATA 3U /* device endpoint data PID is MDATA */
|
||||
|
||||
#define HC_PID_DATA0 0U /* host channel data PID is DATA0 */
|
||||
#define HC_PID_DATA2 1U /* host channel data PID is DATA2 */
|
||||
#define HC_PID_DATA1 2U /* host channel data PID is DATA1 */
|
||||
#define HC_PID_SETUP 3U /* host channel data PID is SETUP */
|
||||
|
||||
#define HPRT_PRTSPD_HIGH_SPEED 0U /* host port speed use high speed */
|
||||
#define HPRT_PRTSPD_FULL_SPEED 1U /* host port speed use full speed */
|
||||
#define HPRT_PRTSPD_LOW_SPEED 2U /* host port speed use low speed */
|
||||
|
||||
#define HCTLR_30_60_MHZ 0U /* USB PHY(ULPI) clock is 60MHz */
|
||||
#define HCTLR_48_MHZ 1U /* USB PHY(embedded full-speed) clock is 48MHz */
|
||||
#define HCTLR_6_MHZ 2U /* USB PHY(embedded low-speed) clock is 6MHz */
|
||||
|
||||
#define HCCHAR_CTRL 0U /* control channel type */
|
||||
#define HCCHAR_ISOC 1U /* synchronous channel type */
|
||||
#define HCCHAR_BULK 2U /* bulk channel type */
|
||||
#define HCCHAR_INTR 3U /* interrupt channel type */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
USB_HS_CORE_ID = 0,
|
||||
USB_FS_CORE_ID = 1
|
||||
}usb_core_id_enum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
USB_SPEED_UNKNOWN = 0,
|
||||
USB_SPEED_LOW,
|
||||
USB_SPEED_FULL,
|
||||
USB_SPEED_HIGH
|
||||
}usb_speed_enum;
|
||||
|
||||
#endif /* USB_DEFINES_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,188 +0,0 @@
|
||||
/*!
|
||||
\file usb_std.h
|
||||
\brief USB 2.0 standard defines
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#ifndef USB_STD_H
|
||||
#define USB_STD_H
|
||||
|
||||
#include "usb_conf.h"
|
||||
|
||||
#define USB_DEV_QUALIFIER_DESC_LEN 0x0AU /*!< USB device qualifier descriptor length */
|
||||
#define USB_DEV_DESC_LEN 0x12U /*!< USB device descriptor length */
|
||||
#define USB_CFG_DESC_LEN 0x09U /*!< USB device configuration descriptor length */
|
||||
#define USB_IF_DESC_LEN 0x09U /*!< USB device interface descriptor length */
|
||||
#define USB_EP_DESC_LEN 0x07U /*!< USB device endpoint descriptor length */
|
||||
#define USB_OTG_DESC_LEN 0x03U /*!< USB device OTG descriptor length */
|
||||
|
||||
/* bit 7 of bmRequestType: data phase transfer direction */
|
||||
#define USB_DIR_MASK 0x80U /*!< USB transfer direction mask */
|
||||
#define USB_DIR_OUT 0x00U /*!< USB transfer OUT direction */
|
||||
#define USB_DIR_IN 0x80U /*!< USB transfer IN direction */
|
||||
|
||||
/* bit 6..5 of bmRequestType: request type */
|
||||
#define USB_STANDARD_REQ 0x00U /*!< USB standard request */
|
||||
#define USB_CLASS_REQ 0x20U /*!< USB class request */
|
||||
#define USB_VENDOR_REQ 0x40U /*!< USB vebdor request */
|
||||
#define USB_REQ_MASK 0x60U /*!< USB request mask */
|
||||
|
||||
/* bit 4..0 of bmRequestType: recipient type */
|
||||
#define USB_REQTYPE_DEVICE 0x00U /*!< USB device request type */
|
||||
#define USB_REQTYPE_INTERFACE 0x01U /*!< USB interface request type*/
|
||||
#define USB_REQTYPE_ENDPOINT 0x02U /*!< USB endpoint request type*/
|
||||
#define USB_REQTYPE_MASK 0x03U /*!< USB request type mask*/
|
||||
|
||||
/* bRequest value */
|
||||
#define USBREQ_GET_STATUS 0x00U /*!< USB get status request*/
|
||||
#define USBREQ_CLEAR_FEATURE 0x01U /*!< USB clear feature request*/
|
||||
#define USBREQ_SET_FEATURE 0x03U /*!< USB set feature request*/
|
||||
#define USBREQ_SET_ADDRESS 0x05U /*!< USB set address request*/
|
||||
#define USBREQ_GET_DESCRIPTOR 0x06U /*!< USB get descriptor request*/
|
||||
#define USBREQ_SET_DESCRIPTOR 0x07U /*!< USB set descriptor request*/
|
||||
#define USBREQ_GET_CONFIGURATION 0x08U /*!< USB get configuration request*/
|
||||
#define USBREQ_SET_CONFIGURATION 0x09U /*!< USB set configuration request*/
|
||||
#define USBREQ_GET_INTERFACE 0x0AU /*!< USB get interface request*/
|
||||
#define USBREQ_SET_INTERFACE 0x0BU /*!< USB set interface request*/
|
||||
#define USBREQ_SYNCH_FRAME 0x0CU /*!< USB synchronize frame request*/
|
||||
|
||||
/* descriptor types of usb specifications */
|
||||
#define USB_DESCTYPE_DEVICE 0x01U /*!< USB device descriptor type*/
|
||||
#define USB_DESCTYPE_CONFIGURATION 0x02U /*!< USB configuration descriptor type*/
|
||||
#define USB_DESCTYPE_STRING 0x03U /*!< USB string descriptor type*/
|
||||
#define USB_DESCTYPE_INTERFACE 0x04U /*!< USB interface descriptor type*/
|
||||
#define USB_DESCTYPE_ENDPOINT 0x05U /*!< USB endpoint descriptor type*/
|
||||
#define USB_DESCTYPE_DEVICE_QUALIFIER 0x06U /*!< USB device qualtfier descriptor type*/
|
||||
#define USB_DESCTYPE_OTHER_SPEED_CONFIGURATION 0x07U /*!< USB other speed configuration descriptor type*/
|
||||
#define USB_DESCTYPE_INTERFACE_POWER 0x08U /*!< USB interface power descriptor type*/
|
||||
|
||||
#define USB_DESCTYPE_HID 0x21U /*!< USB HID descriptor type*/
|
||||
#define USB_DESCTYPE_HID_REPORT 0x22U /*!< USB HID report descriptor type*/
|
||||
|
||||
#define USB_DEVDESC_SIZE 18U /*!< USB device descriptor size*/
|
||||
#define USB_CFGDESC_SIZE 9U /*!< USB configure descriptor size*/
|
||||
#define USB_INTDESC_SIZE 9U /*!< USB interface descriptor size*/
|
||||
#define USB_EPDESC_SIZE 7U /*!< USB endpoint descriptor size*/
|
||||
|
||||
/* descriptor type and descriptor index */
|
||||
/* use the following values when USB host need to get descriptor */
|
||||
#define USB_DEVDESC ((USB_DESCTYPE_DEVICE << 8U) & 0xFF00U) /*!< USB device operation marco */
|
||||
#define USB_CFGDESC ((USB_DESCTYPE_CONFIGURATION << 8U) & 0xFF00U) /*!< USB configuration operation marco */
|
||||
#define USB_STRDESC ((USB_DESCTYPE_STRING << 8U) & 0xFF00U) /*!< USB string operation marco */
|
||||
#define USB_INTDESC ((USB_DESCTYPE_INTERFACE << 8U) & 0xFF00U) /*!< USB interface operation marco */
|
||||
#define USB_EPDESC ((USB_DESCTYPE_INTERFACE << 8U) & 0xFF00U) /*!< USB endpoint operation marco */
|
||||
#define USB_DEVQUADESC ((USB_DESCTYPE_DEVICE_QUALIFIER << 8U) & 0xFF00U) /*!< USB device qualifier operation marco */
|
||||
#define USB_OSPCFGDESC ((USB_DESCTYPE_OTHER_SPEED_CONFIGURATION << 8U) & 0xFF00U) /*!< USB other speed configuration operation marco */
|
||||
#define USB_INTPWRDESC ((USB_DESCTYPE_INTERFACE_POWER << 8U) & 0xFF00U) /*!< USB interface power operation marco */
|
||||
#define USB_HIDREPDESC ((USB_DESCTYPE_HID_REPORT << 8U) & 0xFF00U) /*!< USB HID report operation marco */
|
||||
#define USB_HIDDESC ((USB_DESCTYPE_HID << 8U) & 0xFF00U) /*!< USB HID operation marco */
|
||||
|
||||
#define SWAPBYTE(addr) (((uint16_t)(*((uint8_t *)(addr)))) + \
|
||||
(uint16_t)(((uint16_t)(*(((uint8_t *)(addr)) + 1U))) << 8U))
|
||||
|
||||
/* supported classes */
|
||||
#define USB_MSC_CLASS 0x08U /*!< USB MSC class*/
|
||||
#define USB_HID_CLASS 0x03U /*!< USB HID class*/
|
||||
|
||||
/* interface descriptor field values for hid boot protocol */
|
||||
#define HID_BOOT_CODE 0x01U /*!< USB HID boot code*/
|
||||
#define HID_KEYBRD_BOOT_CODE 0x01U /*!< USB HID keyboard boot code*/
|
||||
#define HID_MOUSE_BOOT_CODE 0x02U /*!< USB HID mouse boot code*/
|
||||
|
||||
/* as per usb specs 9.2.6.4 :standard request with data request timeout: 5sec
|
||||
standard request with no data stage timeout : 50ms */
|
||||
#define DATA_STAGE_TIMEOUT 5000U /*!< USB data stage timeout*/
|
||||
#define NODATA_STAGE_TIMEOUT 50U /*!< USB no data stage timeout*/
|
||||
|
||||
#define USBH_CFG_DESC_SET_SIZE (USB_CFGDESC_SIZE + USB_INTDESC_SIZE \
|
||||
+ (USBH_MAX_EP_NUM * USB_EPDESC_SIZE)) /*!< USB host set configuration descriptor size */
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t data[8];
|
||||
|
||||
struct _setup_packet_struct
|
||||
{
|
||||
uint8_t bmRequestType; /*!< type of request */
|
||||
uint8_t bRequest; /*!< request of setup packet */
|
||||
uint16_t wValue; /*!< value of setup packet */
|
||||
uint16_t wIndex; /*!< index of setup packet */
|
||||
uint16_t wLength; /*!< length of setup packet */
|
||||
} b;
|
||||
}usb_setup_union;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength; /*!< size of the descriptor */
|
||||
uint8_t bDescriptorType; /*!< type of the descriptor */
|
||||
} usb_descriptor_header_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_descriptor_header_struct Header; /*!< descriptor header, including type and size */
|
||||
|
||||
uint16_t bcdUSB; /*!< BCD of the supported USB specification */
|
||||
uint8_t bDeviceClass; /*!< USB device class */
|
||||
uint8_t bDeviceSubClass; /*!< USB device subclass */
|
||||
uint8_t bDeviceProtocol; /*!< USB device protocol */
|
||||
uint8_t bMaxPacketSize0; /*!< size of the control (address 0) endpoint's bank in bytes */
|
||||
uint16_t idVendor; /*!< vendor ID for the USB product */
|
||||
uint16_t idProduct; /*!< unique product ID for the USB product */
|
||||
uint16_t bcdDevice; /*!< product release (version) number */
|
||||
uint8_t iManufacturer; /*!< string index for the manufacturer's name */
|
||||
uint8_t iProduct; /*!< string index for the product name/details */
|
||||
uint8_t iSerialNumber; /*!< string index for the product's globally unique hexadecimal serial number */
|
||||
uint8_t bNumberConfigurations; /*!< total number of configurations supported by the device */
|
||||
} usb_descriptor_device_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_descriptor_header_struct Header; /*!< descriptor header, including type and size */
|
||||
|
||||
uint16_t wTotalLength; /*!< size of the configuration descriptor header,and all sub descriptors inside the configuration */
|
||||
uint8_t bNumInterfaces; /*!< total number of interfaces in the configuration */
|
||||
uint8_t bConfigurationValue; /*!< configuration index of the current configuration */
|
||||
uint8_t iConfiguration; /*!< index of a string descriptor describing the configuration */
|
||||
uint8_t bmAttributes; /*!< configuration attributes */
|
||||
uint8_t bMaxPower; /*!< maximum power consumption of the device while in the current configuration */
|
||||
} usb_descriptor_configuration_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_descriptor_header_struct Header; /*!< descriptor header, including type and size */
|
||||
|
||||
uint8_t bInterfaceNumber; /*!< index of the interface in the current configuration */
|
||||
uint8_t bAlternateSetting; /*!< alternate setting for the interface number */
|
||||
uint8_t bNumEndpoints; /*!< total number of endpoints in the interface */
|
||||
uint8_t bInterfaceClass; /*!< interface class ID */
|
||||
uint8_t bInterfaceSubClass; /*!< interface subclass ID */
|
||||
uint8_t bInterfaceProtocol; /*!< interface protocol ID */
|
||||
uint8_t iInterface; /*!< index of the string descriptor describing the interface */
|
||||
} usb_descriptor_interface_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_descriptor_header_struct Header; /*!< descriptor header, including type and size. */
|
||||
|
||||
uint8_t bEndpointAddress; /*!< logical address of the endpoint */
|
||||
uint8_t bmAttributes; /*!< endpoint attributes */
|
||||
uint16_t wMaxPacketSize; /*!< size of the endpoint bank, in bytes */
|
||||
uint8_t bInterval; /*!< polling interval in milliseconds for the endpoint if it is an INTERRUPT or ISOCHRONOUS type */
|
||||
} usb_descriptor_endpoint_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
usb_descriptor_header_struct Header; /*!< descriptor header, including type and size. */
|
||||
uint16_t wLANGID; /*!< LANGID code */
|
||||
}usb_descriptor_language_id_struct;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif /* USB_STD_H */
|
||||
@@ -1,54 +0,0 @@
|
||||
/*!
|
||||
\file usbd_core.h
|
||||
\brief USB device-mode core driver header file
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
|
||||
#ifndef USBD_CORE_H
|
||||
#define USBD_CORE_H
|
||||
|
||||
#include "usbd_conf.h"
|
||||
#include "usb_core.h"
|
||||
#include "usbd_std.h"
|
||||
|
||||
/* device status */
|
||||
#define USB_STATUS_DEFAULT 1U /* default status */
|
||||
#define USB_STATUS_ADDRESSED 2U /* addressed status */
|
||||
#define USB_STATUS_CONFIGURED 3U /* configured status */
|
||||
#define USB_STATUS_SUSPENDED 4U /* suspended status */
|
||||
|
||||
/* function declarations */
|
||||
/* initailizes the USB device-mode handler stack */
|
||||
void usbd_init (usb_core_handle_struct *pudev, usb_core_id_enum core_id);
|
||||
/* endpoint initialization */
|
||||
void usbd_ep_init (usb_core_handle_struct *pudev, const usb_descriptor_endpoint_struct *pep_desc);
|
||||
/* endpoint deinitialize */
|
||||
void usbd_ep_deinit (usb_core_handle_struct *pudev, uint8_t ep_addr);
|
||||
/* endpoint prepare to receive data */
|
||||
void usbd_ep_rx (usb_core_handle_struct *pudev, uint8_t ep_addr, uint8_t *pbuf, uint16_t buf_len);
|
||||
/* endpoint prepare to transmit data */
|
||||
void usbd_ep_tx (usb_core_handle_struct *pudev, uint8_t ep_addr, uint8_t *pbuf, uint32_t buf_len);
|
||||
/* transmit data on the control channel */
|
||||
usbd_status_enum usbd_ctltx (usb_core_handle_struct *pudev, uint8_t *pbuf, uint16_t len);
|
||||
/* receive data on the control channel */
|
||||
usbd_status_enum usbd_ctlrx (usb_core_handle_struct *pudev, uint8_t *pbuf, uint16_t len);
|
||||
/* transmit status on the control channel */
|
||||
usbd_status_enum usbd_ctlstatus_tx (usb_core_handle_struct *pudev);
|
||||
/* receive status on the control channel */
|
||||
usbd_status_enum usbd_ctlstatus_rx (usb_core_handle_struct *pudev);
|
||||
/* set an endpoint to STALL status */
|
||||
void usbd_ep_stall (usb_core_handle_struct *pudev, uint8_t ep_addr);
|
||||
/* clear endpoint stalled status */
|
||||
void usbd_ep_clear_stall (usb_core_handle_struct *pudev, uint8_t ep_addr);
|
||||
/* flushes the FIFOs */
|
||||
void usbd_ep_fifo_flush (usb_core_handle_struct *pudev, uint8_t ep_addr);
|
||||
/* get the received data length */
|
||||
uint16_t usbd_rxcount_get (usb_core_handle_struct *pudev, uint8_t ep_id);
|
||||
|
||||
#endif /* USBD_CORE_H */
|
||||
@@ -1,31 +0,0 @@
|
||||
/*!
|
||||
\file usbd_int.h
|
||||
\brief USB device-mode interrupt handler header file
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#ifndef USBD_INT_H
|
||||
#define USBD_INT_H
|
||||
|
||||
#include "usbd_core.h"
|
||||
|
||||
/* function declarations */
|
||||
/* USB device-mode interrupts global service routine handler */
|
||||
uint32_t usbd_isr (usb_core_handle_struct *pudev);
|
||||
|
||||
#ifdef USBHS_DEDICATED_EP1_ENABLED
|
||||
|
||||
/* USB dedicated OUT endpoint 1 interrupt service routine handler */
|
||||
uint32_t USBD_EP1OUT_ISR_Handler (usb_core_handle_struct *pudev);
|
||||
/* USB dedicated IN endpoint 1 interrupt service routine handler */
|
||||
uint32_t USBD_EP1IN_ISR_Handler (usb_core_handle_struct *pudev);
|
||||
|
||||
#endif /* USBHS_DEDICATED_EP1_ENABLED */
|
||||
|
||||
#endif /* USBD_INT_H */
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*!
|
||||
\file usbd_std.h
|
||||
\brief USB 2.0 standard driver
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-06-30, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#ifndef USBD_STD_H
|
||||
#define USBD_STD_H
|
||||
|
||||
#include "usb_std.h"
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_conf.h"
|
||||
#include <wchar.h>
|
||||
|
||||
#define USBD_LANGID_STR_IDX 0x00U /*!< USB language ID string index*/
|
||||
#define USBD_MFC_STR_IDX 0x01U /*!< USB manufacturer string index*/
|
||||
#define USBD_PRODUCT_STR_IDX 0x02U /*!< USB product string index*/
|
||||
#define USBD_SERIAL_STR_IDX 0x03U /*!< USB serial string index*/
|
||||
#define USBD_CONFIG_STR_IDX 0x04U /*!< USB configuration string index*/
|
||||
#define USBD_INTERFACE_STR_IDX 0x05U /*!< USB interface string index*/
|
||||
|
||||
#define USB_STATUS_REMOTE_WAKEUP 0x02U /*!< USB remote wakeup status*/
|
||||
#define USB_STATUS_SELF_POWERED 0x01U /*!< USB self power status*/
|
||||
|
||||
#define USB_FEATURE_ENDP_HALT 0x00U /*!< USB halt endpoint feature*/
|
||||
#define USB_FEATURE_REMOTE_WAKEUP 0x01U /*!< USB remote wakeup feature*/
|
||||
#define USB_FEATURE_TEST_MODE 0x02U /*!< USB test mode feature*/
|
||||
|
||||
#define ENG_LANGID 0x0409U /*!< USB english language id*/
|
||||
#define CHN_LANGID 0x0804U /*!< USB chinese language id*/
|
||||
|
||||
#define USB_DEVICE_DESC_SIZE 0x12U /*!< USB device descriptor size*/
|
||||
|
||||
#define LOWBYTE(x) ((uint8_t)((x) & 0x00FFU)) /*!< USB lowbyte operation marco*/
|
||||
#define HIGHBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U)) /*!< USB highbyte operation marco*/
|
||||
|
||||
#define USB_MIN(a, b) (((a) < (b)) ? (a) : (b)) /*!< USB minimum operation marco*/
|
||||
|
||||
#define WIDE_STRING(string) _WIDE_STRING(string)
|
||||
#define _WIDE_STRING(string) L##string
|
||||
|
||||
#define USBD_STRING_DESC(string) \
|
||||
(uint8_t *)&(struct { \
|
||||
uint8_t _len; \
|
||||
uint8_t _type; \
|
||||
wchar_t _data[sizeof(string)]; \
|
||||
}) { \
|
||||
sizeof(WIDE_STRING(string)) + 2U - 2U, \
|
||||
USB_DESCTYPE_STRING, \
|
||||
WIDE_STRING(string) \
|
||||
}
|
||||
|
||||
#define IS_NOT_EP0(ep_addr) (((ep_addr) != 0x00U) && ((ep_addr) != 0x80U))
|
||||
|
||||
/* function declarations */
|
||||
/* USB device setup transaction*/
|
||||
usbd_status_enum usbd_setup_transaction (usb_core_handle_struct *pudev);
|
||||
/* USB device out transaction*/
|
||||
usbd_status_enum usbd_out_transaction (usb_core_handle_struct *pudev, uint8_t endp_num);
|
||||
/* USB device in transaction*/
|
||||
usbd_status_enum usbd_in_transaction (usb_core_handle_struct *pudev, uint8_t endp_num);
|
||||
/* USB device enum error handle*/
|
||||
void usbd_enum_error (usb_core_handle_struct *pudev, usb_device_req_struct *req);
|
||||
|
||||
#endif /* USBD_STD_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,45 +0,0 @@
|
||||
/*!
|
||||
\file usbh_ctrl.h
|
||||
\brief header file for usbh_ctrl.c
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#ifndef USBH_CTRL_H
|
||||
#define USBH_CTRL_H
|
||||
|
||||
#include "usbh_core.h"
|
||||
#include "usbh_usr.h"
|
||||
|
||||
#define CTRL_HANDLE_TABLE_SIZE 13U /*!< the ctrl handle table size define */
|
||||
|
||||
extern state_table_struct ctrl_handle_table[CTRL_HANDLE_TABLE_SIZE];
|
||||
extern uint8_t ctrl_polling_handle_flag;
|
||||
|
||||
/* the enum of CTRL event */
|
||||
typedef enum
|
||||
{
|
||||
CTRL_EVENT_IDLE = 0, /* the ctrl idle event */
|
||||
CTRL_EVENT_SETUP, /* the ctrl setup event */
|
||||
CTRL_EVENT_DATA, /* the ctrl data event */
|
||||
CTRL_EVENT_STATUS, /* the ctrl status event */
|
||||
CTRL_EVENT_COMPLETE, /* the ctrl complete event */
|
||||
CTRL_EVENT_ERROR, /* the ctrl error event */
|
||||
CTRL_EVENT_STALLED, /* the ctrl stalled event */
|
||||
}ctrl_event_enum;
|
||||
|
||||
/* function declarations */
|
||||
/* the polling function of control transfer state handle */
|
||||
usbh_status_enum ctrl_state_polling_fun (usb_core_handle_struct *pudev, usbh_host_struct *puhost, void *pustate);
|
||||
/* send datas from the host channel */
|
||||
usbh_status_enum usbh_xfer (usb_core_handle_struct *pudev, uint8_t *buf, uint8_t hc_num, uint16_t len);
|
||||
/* send the setup packet to the device */
|
||||
usbh_status_enum usbh_ctltx_setup (usb_core_handle_struct *pudev, uint8_t *buf, uint8_t hc_num);
|
||||
/* this function prepare a hc and start a transfer */
|
||||
uint32_t hcd_submit_request (usb_core_handle_struct *pudev, uint8_t channel_num);
|
||||
|
||||
#endif /* USBH_CTRL_H */
|
||||
@@ -1,46 +0,0 @@
|
||||
/*!
|
||||
\file usbh_hcs.h
|
||||
\brief header file for usbh_hcs.c
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#ifndef USBH_HCS_H
|
||||
#define USBH_HCS_H
|
||||
|
||||
#include "usbh_core.h"
|
||||
|
||||
#define HC_MAX 8U
|
||||
|
||||
#define HC_OK 0x0000U
|
||||
#define HC_USED 0x8000U
|
||||
#define HC_ERROR 0xFFFFU
|
||||
#define HC_USED_MASK 0x7FFFU
|
||||
|
||||
/* function declarations */
|
||||
/* allocate a new channel for the pipe */
|
||||
uint8_t usbh_channel_alloc (usb_core_handle_struct *pudev, uint8_t ep_addr);
|
||||
/* free all usb host channel */
|
||||
uint8_t usbh_allchannel_dealloc (usb_core_handle_struct *pudev);
|
||||
/* free the usb host channel */
|
||||
uint8_t usbh_channel_free (usb_core_handle_struct *pudev, uint8_t index);
|
||||
/* open a channel */
|
||||
uint8_t usbh_channel_open (usb_core_handle_struct *pudev,
|
||||
uint8_t channel_num,
|
||||
uint8_t dev_addr,
|
||||
uint8_t dev_speed,
|
||||
uint8_t ep_type,
|
||||
uint16_t ep_mps);
|
||||
/* modify a channel */
|
||||
uint8_t usbh_channel_modify (usb_core_handle_struct *pudev,
|
||||
uint8_t channel_num,
|
||||
uint8_t dev_addr,
|
||||
uint8_t dev_speed,
|
||||
uint8_t ep_type,
|
||||
uint16_t ep_mps);
|
||||
|
||||
#endif /* USBH_HCS_H */
|
||||
@@ -1,30 +0,0 @@
|
||||
/*!
|
||||
\file usbh_int.h
|
||||
\brief USB host mode interrupt handler header file
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.1, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#ifndef USBH_INT_H
|
||||
#define USBH_INT_H
|
||||
|
||||
#include "usb_core.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t (*sof) (usb_core_handle_struct *pudev);
|
||||
uint8_t (*device_connected) (usb_core_handle_struct *pudev);
|
||||
uint8_t (*device_disconnected) (usb_core_handle_struct *pudev);
|
||||
}usbh_hcd_int_cb_struct;
|
||||
|
||||
extern usbh_hcd_int_cb_struct *usbh_hcd_int_fops;
|
||||
|
||||
/* function declarations */
|
||||
/* handle global host interrupt */
|
||||
uint32_t usbh_isr (usb_core_handle_struct *pudev);
|
||||
|
||||
#endif /* USBH_INT_H */
|
||||
@@ -1,74 +0,0 @@
|
||||
/*!
|
||||
\file usbh_std.h
|
||||
\brief header file for usbh_std.c
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#ifndef USBH_STD_H
|
||||
#define USBH_STD_H
|
||||
|
||||
#include "usbh_core.h"
|
||||
#include "usbh_usr.h"
|
||||
|
||||
/* standard feature selector for clear feature command */
|
||||
#define FEATURE_SELECTOR_ENDPOINT 0x00U
|
||||
#define FEATURE_SELECTOR_DEVICE 0x01U
|
||||
|
||||
#define USBH_SETUP_PACKET_SIZE 8U /* setup packet size */
|
||||
#define ENUM_HANDLE_TABLE_SIZE 10U /* enumerate handle table size */
|
||||
|
||||
extern uint8_t usbh_cfg_desc[512];
|
||||
extern uint8_t enum_polling_handle_flag;
|
||||
extern state_table_struct enum_handle_table[ENUM_HANDLE_TABLE_SIZE];
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ENUN_EVENT_IDLE = 0, /* the enum idle event */
|
||||
ENUM_EVENT_SET_ADDR, /* the enum set address event */
|
||||
ENUN_EVENT_GET_FULL_DEV_DESC, /* the enum get full device descripter event */
|
||||
ENUN_EVENT_GET_CFG_DESC, /* the enum get congiguration descripter event */
|
||||
ENUN_EVENT_GET_FULL_CFG_DESC, /* the enum get full configuration descripter event */
|
||||
ENUN_EVENT_GET_MFC_STRING_DESC, /* the enum get MFC string descripter event */
|
||||
ENUN_EVENT_GET_PRODUCT_STRING_DESC, /* the enum get product string event */
|
||||
ENUN_EVENT_GET_SERIALNUM_STRING_DESC, /* the enum get serialnum string event */
|
||||
ENUN_EVENT_SET_CONFIGURATION, /* the enum set configuration event */
|
||||
ENUN_EVENT_DEV_CONFIGURED /* the enum device configured event */
|
||||
}enum_event_enum;
|
||||
|
||||
/* function declarations */
|
||||
/* the polling function of enumeration state */
|
||||
usbh_status_enum enum_state_polling_fun (usb_core_handle_struct *pudev, usbh_host_struct *puhost, void *pustate);
|
||||
/* get descriptor in usb host enumeration stage */
|
||||
void usbh_enum_desc_get (usb_core_handle_struct *pudev,
|
||||
usbh_host_struct *puhost,
|
||||
uint8_t *buf,
|
||||
uint8_t req_type,
|
||||
uint16_t value_idx,
|
||||
uint16_t len);
|
||||
/* set address in usb host enumeration stage */
|
||||
void usbh_enum_addr_set (usb_core_handle_struct *pudev, usbh_host_struct *puhost, uint8_t device_address);
|
||||
/* set configuration in usb host enumeration stage */
|
||||
void usbh_enum_cfg_set (usb_core_handle_struct *pudev, usbh_host_struct *puhost, uint16_t cfg_idx);
|
||||
/* parse the device descriptor */
|
||||
void usbh_device_desc_parse (usb_descriptor_device_struct *dev_desc, uint8_t *buf, uint16_t len);
|
||||
/* parse the configuration descriptor */
|
||||
void usbh_cfg_desc_parse (usb_descriptor_configuration_struct *cfg_desc,
|
||||
usb_descriptor_interface_struct *itf_desc,
|
||||
usb_descriptor_endpoint_struct ep_desc[][USBH_MAX_EP_NUM],
|
||||
uint8_t *buf,
|
||||
uint16_t len);
|
||||
/* parse the interface descriptor */
|
||||
void usbh_interface_desc_parse (usb_descriptor_interface_struct *itf_desc, uint8_t *buf);
|
||||
/* parse the endpoint descriptor */
|
||||
void usbh_endpoint_desc_parse (usb_descriptor_endpoint_struct *ep_desc, uint8_t *buf);
|
||||
/* parse the string descriptor */
|
||||
void usbh_string_desc_parse (uint8_t *psrc, uint8_t *pdest, uint16_t len);
|
||||
/* get the next descriptor header */
|
||||
usb_descriptor_header_struct *usbh_next_desc_get (uint8_t *pbuf, uint16_t *ptr);
|
||||
|
||||
#endif /* USBH_STD_H */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,162 +0,0 @@
|
||||
/*!
|
||||
\file usbh_hcs.c
|
||||
\brief this file implements functions for opening and closing host channels
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 GigaDevice
|
||||
|
||||
2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
#include "usbh_hcs.h"
|
||||
|
||||
static uint16_t usbh_freechannel_get (usb_core_handle_struct *pudev);
|
||||
|
||||
/*!
|
||||
\brief open a channel
|
||||
\param[in] pudev: pointer to usb device
|
||||
\param[in] channel_num: host channel number which is in (0..7)
|
||||
\param[in] dev_addr: USB device address allocated to attached device
|
||||
\param[in] dev_speed: USB device speed (Full speed/Low speed)
|
||||
\param[in] ep_type: endpoint type (bulk/int/ctl)
|
||||
\param[in] ep_mps: max packet size
|
||||
\param[out] none
|
||||
\retval operation status
|
||||
*/
|
||||
uint8_t usbh_channel_open (usb_core_handle_struct *pudev,
|
||||
uint8_t channel_num,
|
||||
uint8_t dev_addr,
|
||||
uint8_t dev_speed,
|
||||
uint8_t ep_type,
|
||||
uint16_t ep_mps)
|
||||
{
|
||||
usb_hostchannel_struct *puhc = &pudev->host.host_channel[channel_num];
|
||||
uint16_t channel_info = puhc->info;
|
||||
|
||||
puhc->endp_id = (uint8_t)channel_info & 0x7FU;
|
||||
puhc->endp_in = (uint8_t)(channel_info & 0x80U) >> 7;
|
||||
puhc->endp_type = ep_type;
|
||||
puhc->endp_mps = ep_mps;
|
||||
puhc->dev_addr = dev_addr;
|
||||
puhc->dev_speed = dev_speed;
|
||||
|
||||
puhc->data_tg_in = 0U;
|
||||
puhc->data_tg_out = 0U;
|
||||
|
||||
if (HPRT_PRTSPD_HIGH_SPEED == dev_speed) {
|
||||
puhc->do_ping = 1U;
|
||||
}
|
||||
|
||||
usb_hostchannel_init(pudev, channel_num);
|
||||
|
||||
return (uint8_t)HC_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief modify a channel
|
||||
\param[in] pudev: pointer to usb device
|
||||
\param[in] channel_num: host channel number which is in (0..7)
|
||||
\param[in] dev_addr: USB Device address allocated to attached device
|
||||
\param[in] dev_speed: USB device speed (Full speed/Low speed)
|
||||
\param[in] ep_type: endpoint type (bulk/int/ctl)
|
||||
\param[in] ep_mps: max packet size
|
||||
\param[out] none
|
||||
\retval operation status
|
||||
*/
|
||||
uint8_t usbh_channel_modify (usb_core_handle_struct *pudev,
|
||||
uint8_t channel_num,
|
||||
uint8_t dev_addr,
|
||||
uint8_t dev_speed,
|
||||
uint8_t ep_type,
|
||||
uint16_t ep_mps)
|
||||
{
|
||||
usb_hostchannel_struct *puhc = &pudev->host.host_channel[channel_num];
|
||||
|
||||
if (0U != dev_addr) {
|
||||
puhc->dev_addr = dev_addr;
|
||||
}
|
||||
|
||||
if ((puhc->endp_mps != ep_mps) && (0U != ep_mps)) {
|
||||
puhc->endp_mps = ep_mps;
|
||||
}
|
||||
|
||||
if ((puhc->dev_speed != dev_speed) && (0U != dev_speed)) {
|
||||
puhc->dev_speed = dev_speed;
|
||||
}
|
||||
|
||||
usb_hostchannel_init(pudev, channel_num);
|
||||
|
||||
return (uint8_t)HC_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief allocate a new channel for the pipe
|
||||
\param[in] pudev: pointer to usb device
|
||||
\param[in] ep_addr: endpoint for which the channel to be allocated
|
||||
\param[out] none
|
||||
\retval host channel number
|
||||
*/
|
||||
uint8_t usbh_channel_alloc (usb_core_handle_struct *pudev, uint8_t ep_addr)
|
||||
{
|
||||
uint16_t hc_num = usbh_freechannel_get(pudev);
|
||||
|
||||
if ((uint16_t)HC_ERROR != hc_num) {
|
||||
pudev->host.host_channel[hc_num].info = HC_USED | ep_addr;
|
||||
}
|
||||
|
||||
return (uint8_t)hc_num;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief free the usb host channel
|
||||
\param[in] pudev: pointer to usb device
|
||||
\param[in] index: channel number to be freed which is in (0..7)
|
||||
\param[out] none
|
||||
\retval host operation status
|
||||
*/
|
||||
uint8_t usbh_channel_free (usb_core_handle_struct *pudev, uint8_t index)
|
||||
{
|
||||
if (index < HC_MAX) {
|
||||
pudev->host.host_channel[index].info &= HC_USED_MASK;
|
||||
}
|
||||
|
||||
return USBH_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief free all usb host channel
|
||||
\param[in] pudev: pointer to usb device
|
||||
\param[out] none
|
||||
\retval host operation status
|
||||
*/
|
||||
uint8_t usbh_allchannel_dealloc (usb_core_handle_struct *pudev)
|
||||
{
|
||||
uint8_t index;
|
||||
|
||||
for (index = 2U; index < HC_MAX; index ++) {
|
||||
pudev->host.host_channel[index].info = 0U;
|
||||
}
|
||||
|
||||
return USBH_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get a free channel number for allocation to a device endpoint
|
||||
\param[in] pudev: pointer to usb device
|
||||
\param[out] none
|
||||
\retval free channel number
|
||||
*/
|
||||
static uint16_t usbh_freechannel_get (usb_core_handle_struct *pudev)
|
||||
{
|
||||
uint8_t index = 0U;
|
||||
|
||||
for (index = 0U; index < HC_MAX; index++) {
|
||||
if (0U == (pudev->host.host_channel[index].info & HC_USED)) {
|
||||
return (uint16_t)index;
|
||||
}
|
||||
}
|
||||
|
||||
return HC_ERROR;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -21,12 +21,12 @@ path = [
|
||||
cwd + '/CMSIS/GD/GD32F4xx/Include',
|
||||
cwd + '/CMSIS',
|
||||
cwd + '/GD32F4xx_standard_peripheral/Include',]
|
||||
|
||||
|
||||
if GetDepend(['RT_USING_BSP_USB']):
|
||||
path += [cwd + '/GD32F4xx_usb_driver/Include']
|
||||
src += [cwd + '/GD32F4xx_usb_driver/Source']
|
||||
|
||||
CPPDEFINES = ['USE_STDPERIPH_DRIVER', 'GD32F4XX']
|
||||
CPPDEFINES = ['USE_STDPERIPH_DRIVER']
|
||||
|
||||
group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
|
||||
|
||||
|
||||
@@ -377,14 +377,14 @@ static rt_err_t gd32_control(struct rt_serial_device *serial, int cmd, void *arg
|
||||
/* disable rx irq */
|
||||
NVIC_DisableIRQ(uart->irqn);
|
||||
/* disable interrupt */
|
||||
usart_interrupt_disable(uart->uart_periph, USART_INTEN_RBNEIE);
|
||||
usart_interrupt_disable(uart->uart_periph, USART_INT_RBNE);
|
||||
|
||||
break;
|
||||
case RT_DEVICE_CTRL_SET_INT:
|
||||
/* enable rx irq */
|
||||
NVIC_EnableIRQ(uart->irqn);
|
||||
/* enable interrupt */
|
||||
usart_interrupt_enable(uart->uart_periph, USART_INTEN_RBNEIE);
|
||||
usart_interrupt_enable(uart->uart_periph, USART_INT_RBNE);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ static void uart_isr(struct rt_serial_device *serial)
|
||||
RT_ASSERT(uart != RT_NULL);
|
||||
|
||||
/* UART in mode Receiver -------------------------------------------------*/
|
||||
if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_RBNEIE) != RESET) &&
|
||||
if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_FLAG_RBNE) != RESET) &&
|
||||
(usart_flag_get(uart->uart_periph, USART_FLAG_RBNE) != RESET))
|
||||
{
|
||||
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
|
||||
|
||||
@@ -38,7 +38,7 @@ if PLATFORM == 'gcc':
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections'
|
||||
DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -DGD32F450'
|
||||
CFLAGS = DEVICE + ' -Dgcc' # -D' + PART_TYPE
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
|
||||
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-gd32.map,-cref,-u,Reset_Handler -T gd32_rom.ld'
|
||||
|
||||
Reference in New Issue
Block a user