mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-06-15 02:09:22 +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:
@@ -1,27 +1,55 @@
|
||||
/*!
|
||||
\file gd32f4xx.h
|
||||
\brief general definitions for GD32F4xx
|
||||
\file gd32f4xx.h
|
||||
\brief general definitions for GD32F4xx
|
||||
|
||||
\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 update 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_H
|
||||
#define GD32F4XX_H
|
||||
|
||||
#ifdef cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* define GD32F4xx */
|
||||
#if !defined (GD32F4xx)
|
||||
#define GD32F4xx
|
||||
#if !defined (GD32F450) && !defined (GD32F405) && !defined (GD32F407)
|
||||
/* #define GD32F450 */
|
||||
/* #define GD32F405 */
|
||||
/* #define GD32F407 */
|
||||
#endif /* define GD32F4xx */
|
||||
#if !defined (GD32F4xx)
|
||||
#error "Please select the target GD32F4xx device used in your application (in gd32f4xx.h file)"
|
||||
|
||||
#if !defined (GD32F450) && !defined (GD32F405) && !defined (GD32F407)
|
||||
#error "Please select the target GD32F4xx device in gd32f4xx.h file"
|
||||
#endif /* undefine GD32F4xx tip */
|
||||
|
||||
/* define value of high speed crystal oscillator (HXTAL) in Hz */
|
||||
@@ -31,11 +59,11 @@
|
||||
|
||||
/* define startup timeout value of high speed crystal oscillator (HXTAL) */
|
||||
#if !defined (HXTAL_STARTUP_TIMEOUT)
|
||||
#define HXTAL_STARTUP_TIMEOUT ((uint16_t)0x0800)
|
||||
#define HXTAL_STARTUP_TIMEOUT ((uint16_t)0xFFFF)
|
||||
#endif /* high speed crystal oscillator startup timeout */
|
||||
|
||||
/* define value of internal 16MHz RC oscillator (IRC16M) in Hz */
|
||||
#if !defined (IRC16M_VALUE)
|
||||
#if !defined (IRC16M_VALUE)
|
||||
#define IRC16M_VALUE ((uint32_t)16000000)
|
||||
#endif /* internal 16MHz RC oscillator value */
|
||||
|
||||
@@ -45,12 +73,12 @@
|
||||
#endif /* internal 16MHz RC oscillator startup timeout */
|
||||
|
||||
/* define value of internal 32KHz RC oscillator(IRC32K) in Hz */
|
||||
#if !defined (IRC32K_VALUE)
|
||||
#if !defined (IRC32K_VALUE)
|
||||
#define IRC32K_VALUE ((uint32_t)32000)
|
||||
#endif /* internal 32KHz RC oscillator value */
|
||||
|
||||
/* define value of low speed crystal oscillator (LXTAL)in Hz */
|
||||
#if !defined (LXTAL_VALUE)
|
||||
#if !defined (LXTAL_VALUE)
|
||||
#define LXTAL_VALUE ((uint32_t)32768)
|
||||
#endif /* low speed crystal oscillator value */
|
||||
|
||||
@@ -61,35 +89,35 @@
|
||||
#define __GD32F4xx_STDPERIPH_VERSION_MAIN (0x03) /*!< [31:24] main version */
|
||||
#define __GD32F4xx_STDPERIPH_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
|
||||
#define __GD32F4xx_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
|
||||
#define __GD32F4xx_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||
#define __GD32F4xx_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||
#define __GD32F4xx_STDPERIPH_VERSION ((__GD32F4xx_STDPERIPH_VERSION_MAIN << 24)\
|
||||
|(__GD32F4xx_STDPERIPH_VERSION_SUB1 << 16)\
|
||||
|(__GD32F4xx_STDPERIPH_VERSION_SUB2 << 8)\
|
||||
|(__GD32F4xx_STDPERIPH_VERSION_RC))
|
||||
|
||||
/* configuration of the Cortex-M4 processor and core peripherals */
|
||||
#define __CM4_REV 0x0001 /*!< Core revision r0p1 */
|
||||
#define __MPU_PRESENT 1 /*!< GD32F4xx do not provide MPU */
|
||||
/* configuration of the cortex-M4 processor and core peripherals */
|
||||
#define __CM4_REV 0x0001 /*!< core revision r0p1 */
|
||||
#define __MPU_PRESENT 1 /*!< GD32F4xx provide MPU */
|
||||
#define __NVIC_PRIO_BITS 4 /*!< GD32F4xx uses 4 bits for the priority levels */
|
||||
#define __VENDOR_SYSTICKCONFIG 0 /*!< set to 1 if different sysTick config is used */
|
||||
#define __Vendor_SysTickConfig 0 /*!< set to 1 if different sysTick config is used */
|
||||
#define __FPU_PRESENT 1 /*!< FPU present */
|
||||
/* define interrupt number */
|
||||
typedef enum IRQn
|
||||
{
|
||||
/* Cortex-M4 processor exceptions numbers */
|
||||
/* cortex-M4 processor exceptions numbers */
|
||||
NonMaskableInt_IRQn = -14, /*!< 2 non maskable interrupt */
|
||||
MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 memory management interrupt */
|
||||
BusFault_IRQn = -11, /*!< 5 Cortex-M4 bus fault interrupt */
|
||||
UsageFault_IRQn = -10, /*!< 6 Cortex-M4 usage fault interrupt */
|
||||
SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV call interrupt */
|
||||
DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 debug monitor interrupt */
|
||||
PendSV_IRQn = -2, /*!< 14 Cortex-M4 pend SV interrupt */
|
||||
SysTick_IRQn = -1, /*!< 15 Cortex-M4 system tick interrupt */
|
||||
MemoryManagement_IRQn = -12, /*!< 4 cortex-M4 memory management interrupt */
|
||||
BusFault_IRQn = -11, /*!< 5 cortex-M4 bus fault interrupt */
|
||||
UsageFault_IRQn = -10, /*!< 6 cortex-M4 usage fault interrupt */
|
||||
SVCall_IRQn = -5, /*!< 11 cortex-M4 SV call interrupt */
|
||||
DebugMonitor_IRQn = -4, /*!< 12 cortex-M4 debug monitor interrupt */
|
||||
PendSV_IRQn = -2, /*!< 14 cortex-M4 pend SV interrupt */
|
||||
SysTick_IRQn = -1, /*!< 15 cortex-M4 system tick interrupt */
|
||||
/* interruput numbers */
|
||||
WWDGT_IRQn = 0, /*!< window watchDog timer interrupt */
|
||||
WWDGT_IRQn = 0, /*!< window watchdog timer interrupt */
|
||||
LVD_IRQn = 1, /*!< LVD through EXTI line detect interrupt */
|
||||
TAMPER_STAMP_IRQn = 2, /*!< Tamper and TimeStamp through EXTI Line detect */
|
||||
RTC_WKUP_IRQn = 3, /*!< RTC Wakeup through EXTI line interrupt */
|
||||
TAMPER_STAMP_IRQn = 2, /*!< tamper and timestamp through EXTI line detect */
|
||||
RTC_WKUP_IRQn = 3, /*!< RTC wakeup through EXTI line interrupt */
|
||||
FMC_IRQn = 4, /*!< FMC interrupt */
|
||||
RCU_CTC_IRQn = 5, /*!< RCU and CTC interrupt */
|
||||
EXTI0_IRQn = 6, /*!< EXTI line 0 interrupts */
|
||||
@@ -97,23 +125,23 @@ typedef enum IRQn
|
||||
EXTI2_IRQn = 8, /*!< EXTI line 2 interrupts */
|
||||
EXTI3_IRQn = 9, /*!< EXTI line 3 interrupts */
|
||||
EXTI4_IRQn = 10, /*!< EXTI line 4 interrupts */
|
||||
DMA0_Channel0_IRQn = 11, /*!< DMA0 Channel0 Interrupt */
|
||||
DMA0_Channel1_IRQn = 12, /*!< DMA0 Channel1 Interrupt */
|
||||
DMA0_Channel2_IRQn = 13, /*!< DMA0 Channel2 Interrupt */
|
||||
DMA0_Channel3_IRQn = 14, /*!< DMA0 Channel3 Interrupt */
|
||||
DMA0_Channel4_IRQn = 15, /*!< DMA0 Channel4 Interrupt */
|
||||
DMA0_Channel5_IRQn = 16, /*!< DMA0 Channel5 Interrupt */
|
||||
DMA0_Channel6_IRQn = 17, /*!< DMA0 Channel6 Interrupt */
|
||||
DMA0_Channel0_IRQn = 11, /*!< DMA0 channel0 Interrupt */
|
||||
DMA0_Channel1_IRQn = 12, /*!< DMA0 channel1 Interrupt */
|
||||
DMA0_Channel2_IRQn = 13, /*!< DMA0 channel2 interrupt */
|
||||
DMA0_Channel3_IRQn = 14, /*!< DMA0 channel3 interrupt */
|
||||
DMA0_Channel4_IRQn = 15, /*!< DMA0 channel4 interrupt */
|
||||
DMA0_Channel5_IRQn = 16, /*!< DMA0 channel5 interrupt */
|
||||
DMA0_Channel6_IRQn = 17, /*!< DMA0 channel6 interrupt */
|
||||
ADC_IRQn = 18, /*!< ADC interrupt */
|
||||
CAN0_TX_IRQn = 19, /*!< CAN0 TX interrupts */
|
||||
CAN0_RX0_IRQn = 20, /*!< CAN0 RX0 interrupts */
|
||||
CAN0_RX1_IRQn = 21, /*!< CAN0 RX1 interrupts */
|
||||
CAN0_EWMC_IRQn = 22, /*!< CAN0 EWMC interrupts */
|
||||
CAN0_TX_IRQn = 19, /*!< CAN0 TX interrupt */
|
||||
CAN0_RX0_IRQn = 20, /*!< CAN0 RX0 interrupt */
|
||||
CAN0_RX1_IRQn = 21, /*!< CAN0 RX1 interrupt */
|
||||
CAN0_EWMC_IRQn = 22, /*!< CAN0 EWMC interrupt */
|
||||
EXTI5_9_IRQn = 23, /*!< EXTI[9:5] interrupts */
|
||||
TIMER0_BRK_TIMER8_IRQn = 24, /*!< TIMER0 Break and TIMER8 interrupts */
|
||||
TIMER0_UP_TIMER9_IRQn = 25, /*!< TIMER0 Update and TIMER9 interrupts */
|
||||
TIMER0_TRG_CMT_TIMER10_IRQn = 26, /*!< TIMER0 Trigger and Commutation and TIMER10 interrupts */
|
||||
TIMER0_CC_IRQn = 27, /*!< TIMER0 Capture Compare interrupts */
|
||||
TIMER0_BRK_TIMER8_IRQn = 24, /*!< TIMER0 break and TIMER8 interrupts */
|
||||
TIMER0_UP_TIMER9_IRQn = 25, /*!< TIMER0 update and TIMER9 interrupts */
|
||||
TIMER0_TRG_CMT_TIMER10_IRQn = 26, /*!< TIMER0 trigger and commutation and TIMER10 interrupts */
|
||||
TIMER0_Channel_IRQn = 27, /*!< TIMER0 channel capture compare interrupt */
|
||||
TIMER1_IRQn = 28, /*!< TIMER1 interrupt */
|
||||
TIMER2_IRQn = 29, /*!< TIMER2 interrupt */
|
||||
TIMER3_IRQn = 30, /*!< TIMER3 interrupts */
|
||||
@@ -127,54 +155,127 @@ typedef enum IRQn
|
||||
USART1_IRQn = 38, /*!< USART1 interrupt */
|
||||
USART2_IRQn = 39, /*!< USART2 interrupt */
|
||||
EXTI10_15_IRQn = 40, /*!< EXTI[15:10] interrupts */
|
||||
RTC_Alarm_IRQn = 41, /*!< RTC Alarm interrupt */
|
||||
USBFS_WKUP_IRQn = 42, /*!< USBFS Wakeup interrupt */
|
||||
TIMER7_BRK_TIMER11_IRQn = 43, /*!< TIMER7 Break and TIMER11 interrupts */
|
||||
TIMER7_UP_TIMER12_IRQn = 44, /*!< TIMER7 Update and TIMER12 interrupts */
|
||||
TIMER7_TRG_CMT_TIMER13_IRQn = 45, /*!< TIMER7 Trigger and Commutation and TIMER13 interrupts */
|
||||
TIMER7_CC_IRQn = 46, /*!< TIMER7 Capture Compare interrupts */
|
||||
DMA0_Channel7_IRQn = 47, /*!< DMA0 Channel7 Interrupt */
|
||||
EXMC_IRQn = 48, /*!< EXMC Interrupt */
|
||||
SDIO_IRQn = 49, /*!< SDIO Interrupt */
|
||||
TIMER4_IRQn = 50, /*!< TIMER4 Interrupt */
|
||||
SPI2_IRQn = 51, /*!< SPI2 Interrupt */
|
||||
UART3_IRQn = 52, /*!< UART3 Interrupt */
|
||||
UART4_IRQn = 53, /*!< UART4 Interrupt */
|
||||
TIMER5_DAC_IRQn = 54, /*!< TIMER5 and DAC0 DAC1 Underrun error Interrupt */
|
||||
TIMER6_IRQn = 55, /*!< TIMER6 Interrupt */
|
||||
DMA1_Channel0_IRQn = 56, /*!< DMA1 Channel0 Interrupt */
|
||||
DMA1_Channel1_IRQn = 57, /*!< DMA1 Channel1 Interrupt */
|
||||
DMA1_Channel2_IRQn = 58, /*!< DMA1 Channel2 Interrupt */
|
||||
DMA1_Channel3_IRQn = 59, /*!< DMA1 Channel3 Interrupt */
|
||||
DMA1_Channel4_IRQn = 60, /*!< DMA1 Channel4 Interrupt */
|
||||
ENET_IRQn = 61, /*!< Ethernet Interrupt */
|
||||
ENET_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI Line Interrupt */
|
||||
CAN1_TX_IRQn = 63, /*!< CAN1 TX Interrupt */
|
||||
CAN1_RX0_IRQn = 64, /*!< CAN1 RX0 Interrupt */
|
||||
CAN1_RX1_IRQn = 65, /*!< CAN1 RX1 Interrupt */
|
||||
CAN1_EWMC_IRQn = 66, /*!< CAN1 EWMC Interrupt */
|
||||
USBFS_IRQn = 67, /*!< USBFS Interrupt */
|
||||
DMA1_Channel5_IRQn = 68, /*!< DMA1 Channel5 Interrupt */
|
||||
DMA1_Channel6_IRQn = 69, /*!< DMA1 Channel6 Interrupt */
|
||||
DMA1_Channel7_IRQn = 70, /*!< DMA1 Channel7 Interrupt */
|
||||
USART5_IRQn = 71, /*!< USART5 Interrupt */
|
||||
I2C2_EV_IRQn = 72, /*!< I2C2 Event Interrupt */
|
||||
I2C2_ER_IRQn = 73, /*!< I2C2 Error Interrupt */
|
||||
USBHS_EP1_Out_IRQn = 74, /*!< USBHS Endpoint 1 Out Interrupt */
|
||||
USBHS_EP1_In_IRQn = 75, /*!< USBHS Endpoint 1 in Interrupt */
|
||||
USBHS_WKUP_IRQn = 76, /*!< USBHS Wakeup through EXTI Line Interrupt */
|
||||
USBHS_IRQn = 77, /*!< USBHS Interrupt */
|
||||
DCI_IRQn = 78, /*!< DCI Interrupt */
|
||||
TRNG_IRQn = 80, /*!< TRNG Interrupt */
|
||||
FPU_IRQn = 81, /*!< FPU Interrupt */
|
||||
UART6_IRQn = 82, /*!< UART6 Interrupt */
|
||||
UART7_IRQn = 83, /*!< UART7 Interrupt */
|
||||
SPI3_IRQn = 84, /*!< SPI3 Interrupt */
|
||||
SPI4_IRQn = 85, /*!< SPI4 Interrupt */
|
||||
SPI5_IRQn = 86, /*!< SPI5 Interrupt */
|
||||
TLI_IRQn = 88, /*!< TLI Interrupt */
|
||||
TLI_ER_IRQn = 89, /*!< TLI Error Interrupt */
|
||||
IPA_IRQn = 90, /*!< IPA Interrupt */
|
||||
RTC_Alarm_IRQn = 41, /*!< RTC alarm interrupt */
|
||||
USBFS_WKUP_IRQn = 42, /*!< USBFS wakeup interrupt */
|
||||
TIMER7_BRK_TIMER11_IRQn = 43, /*!< TIMER7 break and TIMER11 interrupts */
|
||||
TIMER7_UP_TIMER12_IRQn = 44, /*!< TIMER7 update and TIMER12 interrupts */
|
||||
TIMER7_TRG_CMT_TIMER13_IRQn = 45, /*!< TIMER7 trigger and commutation and TIMER13 interrupts */
|
||||
TIMER7_Channel_IRQn = 46, /*!< TIMER7 channel capture compare interrupt */
|
||||
DMA0_Channel7_IRQn = 47, /*!< DMA0 channel7 interrupt */
|
||||
|
||||
#if defined (GD32F450)
|
||||
EXMC_IRQn = 48, /*!< EXMC interrupt */
|
||||
SDIO_IRQn = 49, /*!< SDIO interrupt */
|
||||
TIMER4_IRQn = 50, /*!< TIMER4 interrupt */
|
||||
SPI2_IRQn = 51, /*!< SPI2 interrupt */
|
||||
UART3_IRQn = 52, /*!< UART3 interrupt */
|
||||
UART4_IRQn = 53, /*!< UART4 interrupt */
|
||||
TIMER5_DAC_IRQn = 54, /*!< TIMER5 and DAC0 DAC1 underrun error interrupts */
|
||||
TIMER6_IRQn = 55, /*!< TIMER6 interrupt */
|
||||
DMA1_Channel0_IRQn = 56, /*!< DMA1 channel0 interrupt */
|
||||
DMA1_Channel1_IRQn = 57, /*!< DMA1 channel1 interrupt */
|
||||
DMA1_Channel2_IRQn = 58, /*!< DMA1 channel2 interrupt */
|
||||
DMA1_Channel3_IRQn = 59, /*!< DMA1 channel3 interrupt */
|
||||
DMA1_Channel4_IRQn = 60, /*!< DMA1 channel4 interrupt */
|
||||
ENET_IRQn = 61, /*!< ENET interrupt */
|
||||
ENET_WKUP_IRQn = 62, /*!< ENET wakeup through EXTI line interrupt */
|
||||
CAN1_TX_IRQn = 63, /*!< CAN1 TX interrupt */
|
||||
CAN1_RX0_IRQn = 64, /*!< CAN1 RX0 interrupt */
|
||||
CAN1_RX1_IRQn = 65, /*!< CAN1 RX1 interrupt */
|
||||
CAN1_EWMC_IRQn = 66, /*!< CAN1 EWMC interrupt */
|
||||
USBFS_IRQn = 67, /*!< USBFS interrupt */
|
||||
DMA1_Channel5_IRQn = 68, /*!< DMA1 channel5 interrupt */
|
||||
DMA1_Channel6_IRQn = 69, /*!< DMA1 channel6 interrupt */
|
||||
DMA1_Channel7_IRQn = 70, /*!< DMA1 channel7 interrupt */
|
||||
USART5_IRQn = 71, /*!< USART5 interrupt */
|
||||
I2C2_EV_IRQn = 72, /*!< I2C2 event interrupt */
|
||||
I2C2_ER_IRQn = 73, /*!< I2C2 error interrupt */
|
||||
USBHS_EP1_Out_IRQn = 74, /*!< USBHS endpoint 1 out interrupt */
|
||||
USBHS_EP1_In_IRQn = 75, /*!< USBHS endpoint 1 in interrupt */
|
||||
USBHS_WKUP_IRQn = 76, /*!< USBHS wakeup through EXTI line interrupt */
|
||||
USBHS_IRQn = 77, /*!< USBHS interrupt */
|
||||
DCI_IRQn = 78, /*!< DCI interrupt */
|
||||
TRNG_IRQn = 80, /*!< TRNG interrupt */
|
||||
FPU_IRQn = 81, /*!< FPU interrupt */
|
||||
UART6_IRQn = 82, /*!< UART6 interrupt */
|
||||
UART7_IRQn = 83, /*!< UART7 interrupt */
|
||||
SPI3_IRQn = 84, /*!< SPI3 interrupt */
|
||||
SPI4_IRQn = 85, /*!< SPI4 interrupt */
|
||||
SPI5_IRQn = 86, /*!< SPI5 interrupt */
|
||||
TLI_IRQn = 88, /*!< TLI interrupt */
|
||||
TLI_ER_IRQn = 89, /*!< TLI error interrupt */
|
||||
IPA_IRQn = 90, /*!< IPA interrupt */
|
||||
#endif /* GD32F450 */
|
||||
|
||||
#if defined (GD32F405)
|
||||
SDIO_IRQn = 49, /*!< SDIO interrupt */
|
||||
TIMER4_IRQn = 50, /*!< TIMER4 interrupt */
|
||||
SPI2_IRQn = 51, /*!< SPI2 interrupt */
|
||||
UART3_IRQn = 52, /*!< UART3 interrupt */
|
||||
UART4_IRQn = 53, /*!< UART4 interrupt */
|
||||
TIMER5_DAC_IRQn = 54, /*!< TIMER5 and DAC0 DAC1 underrun error interrupts */
|
||||
TIMER6_IRQn = 55, /*!< TIMER6 interrupt */
|
||||
DMA1_Channel0_IRQn = 56, /*!< DMA1 channel0 interrupt */
|
||||
DMA1_Channel1_IRQn = 57, /*!< DMA1 channel1 interrupt */
|
||||
DMA1_Channel2_IRQn = 58, /*!< DMA1 channel2 interrupt */
|
||||
DMA1_Channel3_IRQn = 59, /*!< DMA1 channel3 interrupt */
|
||||
DMA1_Channel4_IRQn = 60, /*!< DMA1 channel4 interrupt */
|
||||
CAN1_TX_IRQn = 63, /*!< CAN1 TX interrupt */
|
||||
CAN1_RX0_IRQn = 64, /*!< CAN1 RX0 interrupt */
|
||||
CAN1_RX1_IRQn = 65, /*!< CAN1 RX1 interrupt */
|
||||
CAN1_EWMC_IRQn = 66, /*!< CAN1 EWMC interrupt */
|
||||
USBFS_IRQn = 67, /*!< USBFS interrupt */
|
||||
DMA1_Channel5_IRQn = 68, /*!< DMA1 channel5 interrupt */
|
||||
DMA1_Channel6_IRQn = 69, /*!< DMA1 channel6 interrupt */
|
||||
DMA1_Channel7_IRQn = 70, /*!< DMA1 channel7 interrupt */
|
||||
USART5_IRQn = 71, /*!< USART5 interrupt */
|
||||
I2C2_EV_IRQn = 72, /*!< I2C2 event interrupt */
|
||||
I2C2_ER_IRQn = 73, /*!< I2C2 error interrupt */
|
||||
USBHS_EP1_Out_IRQn = 74, /*!< USBHS endpoint 1 Out interrupt */
|
||||
USBHS_EP1_In_IRQn = 75, /*!< USBHS endpoint 1 in interrupt */
|
||||
USBHS_WKUP_IRQn = 76, /*!< USBHS wakeup through EXTI line interrupt */
|
||||
USBHS_IRQn = 77, /*!< USBHS interrupt */
|
||||
DCI_IRQn = 78, /*!< DCI interrupt */
|
||||
TRNG_IRQn = 80, /*!< TRNG interrupt */
|
||||
FPU_IRQn = 81, /*!< FPU interrupt */
|
||||
#endif /* GD32F405 */
|
||||
|
||||
#if defined (GD32F407)
|
||||
EXMC_IRQn = 48, /*!< EXMC interrupt */
|
||||
SDIO_IRQn = 49, /*!< SDIO interrupt */
|
||||
TIMER4_IRQn = 50, /*!< TIMER4 interrupt */
|
||||
SPI2_IRQn = 51, /*!< SPI2 interrupt */
|
||||
UART3_IRQn = 52, /*!< UART3 interrupt */
|
||||
UART4_IRQn = 53, /*!< UART4 interrupt */
|
||||
TIMER5_DAC_IRQn = 54, /*!< TIMER5 and DAC0 DAC1 underrun error interrupts */
|
||||
TIMER6_IRQn = 55, /*!< TIMER6 interrupt */
|
||||
DMA1_Channel0_IRQn = 56, /*!< DMA1 channel0 interrupt */
|
||||
DMA1_Channel1_IRQn = 57, /*!< DMA1 channel1 interrupt */
|
||||
DMA1_Channel2_IRQn = 58, /*!< DMA1 channel2 interrupt */
|
||||
DMA1_Channel3_IRQn = 59, /*!< DMA1 channel3 interrupt */
|
||||
DMA1_Channel4_IRQn = 60, /*!< DMA1 channel4 interrupt */
|
||||
ENET_IRQn = 61, /*!< ENET interrupt */
|
||||
ENET_WKUP_IRQn = 62, /*!< ENET wakeup through EXTI line interrupt */
|
||||
CAN1_TX_IRQn = 63, /*!< CAN1 TX interrupt */
|
||||
CAN1_RX0_IRQn = 64, /*!< CAN1 RX0 interrupt */
|
||||
CAN1_RX1_IRQn = 65, /*!< CAN1 RX1 interrupt */
|
||||
CAN1_EWMC_IRQn = 66, /*!< CAN1 EWMC interrupt */
|
||||
USBFS_IRQn = 67, /*!< USBFS interrupt */
|
||||
DMA1_Channel5_IRQn = 68, /*!< DMA1 channel5 interrupt */
|
||||
DMA1_Channel6_IRQn = 69, /*!< DMA1 channel6 interrupt */
|
||||
DMA1_Channel7_IRQn = 70, /*!< DMA1 channel7 interrupt */
|
||||
USART5_IRQn = 71, /*!< USART5 interrupt */
|
||||
I2C2_EV_IRQn = 72, /*!< I2C2 event interrupt */
|
||||
I2C2_ER_IRQn = 73, /*!< I2C2 error interrupt */
|
||||
USBHS_EP1_Out_IRQn = 74, /*!< USBHS endpoint 1 out interrupt */
|
||||
USBHS_EP1_In_IRQn = 75, /*!< USBHS endpoint 1 in interrupt */
|
||||
USBHS_WKUP_IRQn = 76, /*!< USBHS wakeup through EXTI line interrupt */
|
||||
USBHS_IRQn = 77, /*!< USBHS interrupt */
|
||||
DCI_IRQn = 78, /*!< DCI interrupt */
|
||||
TRNG_IRQn = 80, /*!< TRNG interrupt */
|
||||
FPU_IRQn = 81, /*!< FPU interrupt */
|
||||
#endif /* GD32F407 */
|
||||
|
||||
} IRQn_Type;
|
||||
|
||||
/* includes */
|
||||
@@ -193,7 +294,7 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
|
||||
#define REG16(addr) (*(volatile uint16_t *)(uint32_t)(addr))
|
||||
#define REG8(addr) (*(volatile uint8_t *)(uint32_t)(addr))
|
||||
#define BIT(x) ((uint32_t)((uint32_t)0x01U<<(x)))
|
||||
#define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
|
||||
#define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
|
||||
#define GET_BITS(regval, start, end) (((regval) & BITS((start),(end))) >> (start))
|
||||
|
||||
/* main flash and SRAM memory map */
|
||||
@@ -254,7 +355,7 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
|
||||
/* define marco USE_STDPERIPH_DRIVER */
|
||||
#if !defined USE_STDPERIPH_DRIVER
|
||||
#define USE_STDPERIPH_DRIVER
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_STDPERIPH_DRIVER
|
||||
#include "gd32f4xx_libopt.h"
|
||||
#endif /* USE_STDPERIPH_DRIVER */
|
||||
@@ -262,4 +363,4 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrStatus;
|
||||
#ifdef cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
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
@@ -1,12 +1,38 @@
|
||||
/*!
|
||||
\file gd32f4xx_can.h
|
||||
\brief definitions for the CAN
|
||||
\file gd32f4xx_can.h
|
||||
\brief definitions for the CAN
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2019-11-27, 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_CAN_H
|
||||
@@ -42,7 +68,7 @@
|
||||
#define CAN_RFIFOMI0(canx) REG32((canx) + 0x1B0U) /*!< CAN receive FIFO0 mailbox identifier register */
|
||||
#define CAN_RFIFOMP0(canx) REG32((canx) + 0x1B4U) /*!< CAN receive FIFO0 mailbox property register */
|
||||
#define CAN_RFIFOMDATA00(canx) REG32((canx) + 0x1B8U) /*!< CAN receive FIFO0 mailbox data0 register */
|
||||
#define CAN_RFIFOMDATA10(canx) REG32((canx) + 0x1CCU) /*!< CAN receive FIFO0 mailbox data1 register */
|
||||
#define CAN_RFIFOMDATA10(canx) REG32((canx) + 0x1BCU) /*!< CAN receive FIFO0 mailbox data1 register */
|
||||
#define CAN_RFIFOMI1(canx) REG32((canx) + 0x1C0U) /*!< CAN receive FIFO1 mailbox identifier register */
|
||||
#define CAN_RFIFOMP1(canx) REG32((canx) + 0x1C4U) /*!< CAN receive FIFO1 mailbox property register */
|
||||
#define CAN_RFIFOMDATA01(canx) REG32((canx) + 0x1C8U) /*!< CAN receive FIFO1 mailbox data0 register */
|
||||
@@ -110,20 +136,20 @@
|
||||
#define CAN_F27DATA1(canx) REG32((canx) + 0x31CU) /*!< CAN filter 27 data 1 register */
|
||||
|
||||
/* CAN transmit mailbox bank */
|
||||
#define CAN_TMI(canx, bank) REG32((canx) + 0x180U + ((bank) * 0x10U)) /*!< CAN transmit mailbox identifier register */
|
||||
#define CAN_TMP(canx, bank) REG32((canx) + 0x184U + ((bank) * 0x10U)) /*!< CAN transmit mailbox property register */
|
||||
#define CAN_TMDATA0(canx, bank) REG32((canx) + 0x188U + ((bank) * 0x10U)) /*!< CAN transmit mailbox data0 register */
|
||||
#define CAN_TMDATA1(canx, bank) REG32((canx) + 0x18CU + ((bank) * 0x10U)) /*!< CAN transmit mailbox data1 register */
|
||||
#define CAN_TMI(canx, bank) REG32((canx) + 0x180U + ((bank) * 0x10U)) /*!< CAN transmit mailbox identifier register */
|
||||
#define CAN_TMP(canx, bank) REG32((canx) + 0x184U + ((bank) * 0x10U)) /*!< CAN transmit mailbox property register */
|
||||
#define CAN_TMDATA0(canx, bank) REG32((canx) + 0x188U + ((bank) * 0x10U)) /*!< CAN transmit mailbox data0 register */
|
||||
#define CAN_TMDATA1(canx, bank) REG32((canx) + 0x18CU + ((bank) * 0x10U)) /*!< CAN transmit mailbox data1 register */
|
||||
|
||||
/* CAN filter bank */
|
||||
#define CAN_FDATA0(canx, bank) REG32((canx) + 0x240U + ((bank) * 0x8U) + 0x0U) /*!< CAN filter data 0 register */
|
||||
#define CAN_FDATA1(canx, bank) REG32((canx) + 0x240U + ((bank) * 0x8U) + 0x4U) /*!< CAN filter data 1 register */
|
||||
#define CAN_FDATA0(canx, bank) REG32((canx) + 0x240U + ((bank) * 0x8U) + 0x0U) /*!< CAN filter data 0 register */
|
||||
#define CAN_FDATA1(canx, bank) REG32((canx) + 0x240U + ((bank) * 0x8U) + 0x4U) /*!< CAN filter data 1 register */
|
||||
|
||||
/* CAN receive fifo mailbox bank */
|
||||
#define CAN_RFIFOMI(canx, bank) REG32((canx) + 0x1B0U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox identifier register */
|
||||
#define CAN_RFIFOMP(canx, bank) REG32((canx) + 0x1B4U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox property register */
|
||||
#define CAN_RFIFOMDATA0(canx, bank) REG32((canx) + 0x1B8U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox data0 register */
|
||||
#define CAN_RFIFOMDATA1(canx, bank) REG32((canx) + 0x1BCU + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox data1 register */
|
||||
#define CAN_RFIFOMI(canx, bank) REG32((canx) + 0x1B0U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox identifier register */
|
||||
#define CAN_RFIFOMP(canx, bank) REG32((canx) + 0x1B4U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox property register */
|
||||
#define CAN_RFIFOMDATA0(canx, bank) REG32((canx) + 0x1B8U + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox data0 register */
|
||||
#define CAN_RFIFOMDATA1(canx, bank) REG32((canx) + 0x1BCU + ((bank) * 0x10U)) /*!< CAN receive FIFO mailbox data1 register */
|
||||
|
||||
/* bits definitions */
|
||||
/* CAN_CTL */
|
||||
@@ -198,7 +224,7 @@
|
||||
#define CAN_INTEN_BOIE BIT(10) /*!< bus-off interrupt enable */
|
||||
#define CAN_INTEN_ERRNIE BIT(11) /*!< error number interrupt enable */
|
||||
#define CAN_INTEN_ERRIE BIT(15) /*!< error interrupt enable */
|
||||
#define CAN_INTEN_WUIE BIT(16) /*!< wakeup interrupt enable */
|
||||
#define CAN_INTEN_WIE BIT(16) /*!< wakeup interrupt enable */
|
||||
#define CAN_INTEN_SLPWIE BIT(17) /*!< sleep working interrupt enable */
|
||||
|
||||
/* CAN_ERR */
|
||||
@@ -280,11 +306,19 @@
|
||||
/* CAN_FW */
|
||||
#define CAN_FW_FW(regval) BIT(regval) /*!< filter working */
|
||||
|
||||
/* CAN_FxDATAy */
|
||||
#define CAN_FDATA_FD(regval) BIT(regval) /*!< filter data */
|
||||
|
||||
/* consts definitions */
|
||||
/* define the CAN bit position and its register index offset */
|
||||
#define CAN_REGIDX_BIT(regidx, bitpos) (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos))
|
||||
#define CAN_REG_VAL(canx, offset) (REG32((canx) + ((uint32_t)(offset) >> 6)))
|
||||
#define CAN_BIT_POS(val) ((uint32_t)(val) & 0x1FU)
|
||||
#define CAN_REGIDX_BIT(regidx, bitpos) (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos))
|
||||
#define CAN_REG_VAL(canx, offset) (REG32((canx) + ((uint32_t)(offset) >> 6)))
|
||||
#define CAN_BIT_POS(val) ((uint32_t)(val) & 0x1FU)
|
||||
|
||||
#define CAN_REGIDX_BITS(regidx, bitpos0, bitpos1) (((uint32_t)(regidx) << 12) | ((uint32_t)(bitpos0) << 6) | (uint32_t)(bitpos1))
|
||||
#define CAN_REG_VALS(canx, offset) (REG32((canx) + ((uint32_t)(offset) >> 12)))
|
||||
#define CAN_BIT_POS0(val) (((uint32_t)(val) >> 6) & 0x1FU)
|
||||
#define CAN_BIT_POS1(val) ((uint32_t)(val) & 0x1FU)
|
||||
|
||||
/* register offset */
|
||||
#define STAT_REG_OFFSET ((uint8_t)0x04U) /*!< STAT register offset */
|
||||
@@ -296,45 +330,84 @@
|
||||
/* CAN flags */
|
||||
typedef enum
|
||||
{
|
||||
/* flags in STAT register */
|
||||
CAN_FLAG_RXL = CAN_REGIDX_BIT(STAT_REG_OFFSET, 11U), /*!< RX level */
|
||||
CAN_FLAG_LASTRX = CAN_REGIDX_BIT(STAT_REG_OFFSET, 10U), /*!< last sample value of RX pin */
|
||||
CAN_FLAG_RS = CAN_REGIDX_BIT(STAT_REG_OFFSET, 9U), /*!< receiving state */
|
||||
CAN_FLAG_TS = CAN_REGIDX_BIT(STAT_REG_OFFSET, 8U), /*!< transmitting state */
|
||||
CAN_FLAG_SLPIF = CAN_REGIDX_BIT(STAT_REG_OFFSET, 4U), /*!< status change flag of entering sleep working mode */
|
||||
CAN_FLAG_WUIF = CAN_REGIDX_BIT(STAT_REG_OFFSET, 3U), /*!< status change flag of wakeup from sleep working mode */
|
||||
CAN_FLAG_ERRIF = CAN_REGIDX_BIT(STAT_REG_OFFSET, 2U), /*!< error flag */
|
||||
CAN_FLAG_SLPWS = CAN_REGIDX_BIT(STAT_REG_OFFSET, 1U), /*!< sleep working state */
|
||||
CAN_FLAG_IWS = CAN_REGIDX_BIT(STAT_REG_OFFSET, 0U), /*!< initial working state */
|
||||
/* flags in TSTAT register */
|
||||
CAN_FLAG_MTE2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 19U), /*!< mailbox 2 transmit error */
|
||||
CAN_FLAG_MTE1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 11U), /*!< mailbox 1 transmit error */
|
||||
CAN_FLAG_MTE0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 3U), /*!< mailbox 0 transmit error */
|
||||
CAN_FLAG_MTF2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 16U), /*!< mailbox 2 transmit finished */
|
||||
CAN_FLAG_MTF1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 8U), /*!< mailbox 1 transmit finished */
|
||||
CAN_FLAG_MTF0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 0U), /*!< mailbox 0 transmit finished */
|
||||
CAN_FLAG_TMLS2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 31U), /*!< transmit mailbox 2 last sending in Tx FIFO */
|
||||
CAN_FLAG_TMLS1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 30U), /*!< transmit mailbox 1 last sending in Tx FIFO */
|
||||
CAN_FLAG_TMLS0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 29U), /*!< transmit mailbox 0 last sending in Tx FIFO */
|
||||
CAN_FLAG_TME2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 28U), /*!< transmit mailbox 2 empty */
|
||||
CAN_FLAG_TME1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 27U), /*!< transmit mailbox 1 empty */
|
||||
CAN_FLAG_TME0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 26U), /*!< transmit mailbox 0 empty */
|
||||
CAN_FLAG_MTE2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 19U), /*!< mailbox 2 transmit error */
|
||||
CAN_FLAG_MTE1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 11U), /*!< mailbox 1 transmit error */
|
||||
CAN_FLAG_MTE0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 3U), /*!< mailbox 0 transmit error */
|
||||
CAN_FLAG_MAL2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 18U), /*!< mailbox 2 arbitration lost */
|
||||
CAN_FLAG_MAL1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 10U), /*!< mailbox 1 arbitration lost */
|
||||
CAN_FLAG_MAL0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 2U), /*!< mailbox 0 arbitration lost */
|
||||
CAN_FLAG_MTFNERR2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 17U), /*!< mailbox 2 transmit finished with no error */
|
||||
CAN_FLAG_MTFNERR1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 9U), /*!< mailbox 1 transmit finished with no error */
|
||||
CAN_FLAG_MTFNERR0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 1U), /*!< mailbox 0 transmit finished with no error */
|
||||
CAN_FLAG_MTF2 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 16U), /*!< mailbox 2 transmit finished */
|
||||
CAN_FLAG_MTF1 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 8U), /*!< mailbox 1 transmit finished */
|
||||
CAN_FLAG_MTF0 = CAN_REGIDX_BIT(TSTAT_REG_OFFSET, 0U), /*!< mailbox 0 transmit finished */
|
||||
/* flags in RFIFO0 register */
|
||||
CAN_FLAG_RFO0 = CAN_REGIDX_BIT(RFIFO0_REG_OFFSET, 4U), /*!< receive FIFO0 overfull */
|
||||
CAN_FLAG_RFF0 = CAN_REGIDX_BIT(RFIFO0_REG_OFFSET, 3U), /*!< receive FIFO0 full */
|
||||
CAN_FLAG_RFO0 = CAN_REGIDX_BIT(RFIFO0_REG_OFFSET, 4U), /*!< receive FIFO0 overfull */
|
||||
CAN_FLAG_RFF0 = CAN_REGIDX_BIT(RFIFO0_REG_OFFSET, 3U), /*!< receive FIFO0 full */
|
||||
/* flags in RFIFO1 register */
|
||||
CAN_FLAG_RFO1 = CAN_REGIDX_BIT(RFIFO1_REG_OFFSET, 4U), /*!< receive FIFO1 overfull */
|
||||
CAN_FLAG_RFF1 = CAN_REGIDX_BIT(RFIFO1_REG_OFFSET, 3U), /*!< receive FIFO1 full */
|
||||
CAN_FLAG_RFO1 = CAN_REGIDX_BIT(RFIFO1_REG_OFFSET, 4U), /*!< receive FIFO1 overfull */
|
||||
CAN_FLAG_RFF1 = CAN_REGIDX_BIT(RFIFO1_REG_OFFSET, 3U), /*!< receive FIFO1 full */
|
||||
/* flags in ERR register */
|
||||
CAN_FLAG_BOERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 2U), /*!< bus-off error */
|
||||
CAN_FLAG_PERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 1U), /*!< passive error */
|
||||
CAN_FLAG_WERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 0U), /*!< warning error */
|
||||
CAN_FLAG_BOERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 2U), /*!< bus-off error */
|
||||
CAN_FLAG_PERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 1U), /*!< passive error */
|
||||
CAN_FLAG_WERR = CAN_REGIDX_BIT(ERR_REG_OFFSET, 0U), /*!< warning error */
|
||||
}can_flag_enum;
|
||||
|
||||
/* CAN interrupt flags */
|
||||
typedef enum
|
||||
{
|
||||
/* interrupt flags in STAT register */
|
||||
CAN_INT_SLPIF = CAN_REGIDX_BIT(STAT_REG_OFFSET, 4U), /*!< status change interrupt flag of sleep working mode entering */
|
||||
CAN_INT_WUIF = CAN_REGIDX_BIT(STAT_REG_OFFSET, 3U), /*!< status change interrupt flag of wakeup from sleep working mode */
|
||||
CAN_INT_ERRIF = CAN_REGIDX_BIT(STAT_REG_OFFSET, 2U), /*!< error interrupt flag */
|
||||
CAN_INT_FLAG_SLPIF = CAN_REGIDX_BITS(STAT_REG_OFFSET, 4U, 17U), /*!< status change interrupt flag of sleep working mode entering */
|
||||
CAN_INT_FLAG_WUIF = CAN_REGIDX_BITS(STAT_REG_OFFSET, 3U, 16), /*!< status change interrupt flag of wakeup from sleep working mode */
|
||||
CAN_INT_FLAG_ERRIF = CAN_REGIDX_BITS(STAT_REG_OFFSET, 2U, 15), /*!< error interrupt flag */
|
||||
/* interrupt flags in TSTAT register */
|
||||
CAN_INT_FLAG_MTF2 = CAN_REGIDX_BITS(TSTAT_REG_OFFSET, 16U, 0U), /*!< mailbox 2 transmit finished interrupt flag */
|
||||
CAN_INT_FLAG_MTF1 = CAN_REGIDX_BITS(TSTAT_REG_OFFSET, 8U, 0U), /*!< mailbox 1 transmit finished interrupt flag */
|
||||
CAN_INT_FLAG_MTF0 = CAN_REGIDX_BITS(TSTAT_REG_OFFSET, 0U, 0U), /*!< mailbox 0 transmit finished interrupt flag */
|
||||
/* interrupt flags in RFIFO0 register */
|
||||
CAN_INT_FLAG_RFO0 = CAN_REGIDX_BITS(RFIFO0_REG_OFFSET, 4U, 3U), /*!< receive FIFO0 overfull interrupt flag */
|
||||
CAN_INT_FLAG_RFF0 = CAN_REGIDX_BITS(RFIFO0_REG_OFFSET, 3U, 2U), /*!< receive FIFO0 full interrupt flag */
|
||||
CAN_INT_FLAG_RFL0 = CAN_REGIDX_BITS(RFIFO0_REG_OFFSET, 2U, 1U), /*!< receive FIFO0 not empty interrupt flag */
|
||||
/* interrupt flags in RFIFO0 register */
|
||||
CAN_INT_FLAG_RFO1 = CAN_REGIDX_BITS(RFIFO1_REG_OFFSET, 4U, 6U), /*!< receive FIFO1 overfull interrupt flag */
|
||||
CAN_INT_FLAG_RFF1 = CAN_REGIDX_BITS(RFIFO1_REG_OFFSET, 3U, 5U), /*!< receive FIFO1 full interrupt flag */
|
||||
CAN_INT_FLAG_RFL1 = CAN_REGIDX_BITS(RFIFO1_REG_OFFSET, 2U, 4U), /*!< receive FIFO0 not empty interrupt flag */
|
||||
/* interrupt flags in ERR register */
|
||||
CAN_INT_FLAG_ERRN = CAN_REGIDX_BITS(ERR_REG_OFFSET, 3U, 11U), /*!< error number interrupt flag */
|
||||
CAN_INT_FLAG_BOERR = CAN_REGIDX_BITS(ERR_REG_OFFSET, 2U, 10U), /*!< bus-off error interrupt flag */
|
||||
CAN_INT_FLAG_PERR = CAN_REGIDX_BITS(ERR_REG_OFFSET, 1U, 9U), /*!< passive error interrupt flag */
|
||||
CAN_INT_FLAG_WERR = CAN_REGIDX_BITS(ERR_REG_OFFSET, 0U, 8U), /*!< warning error interrupt flag */
|
||||
}can_interrupt_flag_enum;
|
||||
|
||||
/* CAN initiliaze parameters struct */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t working_mode; /*!< CAN working mode */
|
||||
uint8_t working_mode; /*!< CAN working mode */
|
||||
uint8_t resync_jump_width; /*!< CAN resynchronization jump width */
|
||||
uint8_t time_segment_1; /*!< time segment 1 */
|
||||
uint8_t time_segment_2; /*!< time segment 2 */
|
||||
ControlStatus time_triggered; /*!< time triggered communication mode */
|
||||
ControlStatus auto_bus_off_recovery; /*!< automatic bus-off recovery */
|
||||
ControlStatus auto_wake_up; /*!< automatic wake-up mode */
|
||||
ControlStatus auto_retrans; /*!< automatic retransmission mode */
|
||||
ControlStatus no_auto_retrans; /*!< automatic retransmission mode disable */
|
||||
ControlStatus rec_fifo_overwrite; /*!< receive FIFO overwrite mode */
|
||||
ControlStatus trans_fifo_order; /*!< transmit FIFO order */
|
||||
uint16_t prescaler; /*!< baudrate prescaler */
|
||||
@@ -387,18 +460,26 @@ typedef enum
|
||||
CAN_ERROR_BITRECESSIVE, /*!< bit recessive error */
|
||||
CAN_ERROR_BITDOMINANTER, /*!< bit dominant error */
|
||||
CAN_ERROR_CRC, /*!< CRC error */
|
||||
CAN_ERROR_SOFTWARECFG /*!< software configure */
|
||||
CAN_ERROR_SOFTWARECFG, /*!< software configure */
|
||||
}can_error_enum;
|
||||
|
||||
/* transmit states */
|
||||
typedef enum
|
||||
{
|
||||
CAN_TRANSMIT_FAILED = 0, /*!< CAN transmitted failure */
|
||||
CAN_TRANSMIT_OK = 1, /*!< CAN transmitted success */
|
||||
CAN_TRANSMIT_PENDING = 2, /*!< CAN transmitted pending */
|
||||
CAN_TRANSMIT_NOMAILBOX = 4, /*!< no empty mailbox to be used for CAN */
|
||||
CAN_TRANSMIT_FAILED = 0U, /*!< CAN transmitted failure */
|
||||
CAN_TRANSMIT_OK = 1U, /*!< CAN transmitted success */
|
||||
CAN_TRANSMIT_PENDING = 2U, /*!< CAN transmitted pending */
|
||||
CAN_TRANSMIT_NOMAILBOX = 4U, /*!< no empty mailbox to be used for CAN */
|
||||
}can_transmit_state_enum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CAN_INIT_STRUCT = 0, /* CAN initiliaze parameters struct */
|
||||
CAN_FILTER_STRUCT, /* CAN filter parameters struct */
|
||||
CAN_TX_MESSAGE_STRUCT, /* CAN transmit message struct */
|
||||
CAN_RX_MESSAGE_STRUCT, /* CAN receive message struct */
|
||||
}can_struct_type_enum;
|
||||
|
||||
/* CAN baudrate prescaler*/
|
||||
#define BT_BAUDPSC(regval) (BITS(0,9) & ((uint32_t)(regval) << 0))
|
||||
|
||||
@@ -438,66 +519,76 @@ typedef enum
|
||||
/* transmit data byte 2 */
|
||||
#define TMDATA0_DB2(regval) (BITS(16,23) & ((uint32_t)(regval) << 16))
|
||||
|
||||
/* transmit data byte 3 */
|
||||
/* transmit data byte 3 */
|
||||
#define TMDATA0_DB3(regval) (BITS(24,31) & ((uint32_t)(regval) << 24))
|
||||
|
||||
/* transmit data byte 4 */
|
||||
/* transmit data byte 4 */
|
||||
#define TMDATA1_DB4(regval) (BITS(0,7) & ((uint32_t)(regval) << 0))
|
||||
|
||||
/* transmit data byte 5 */
|
||||
/* transmit data byte 5 */
|
||||
#define TMDATA1_DB5(regval) (BITS(8,15) & ((uint32_t)(regval) << 8))
|
||||
|
||||
/* transmit data byte 6 */
|
||||
/* transmit data byte 6 */
|
||||
#define TMDATA1_DB6(regval) (BITS(16,23) & ((uint32_t)(regval) << 16))
|
||||
|
||||
/* transmit data byte 7 */
|
||||
/* transmit data byte 7 */
|
||||
#define TMDATA1_DB7(regval) (BITS(24,31) & ((uint32_t)(regval) << 24))
|
||||
|
||||
/* receive mailbox extended identifier*/
|
||||
#define RFIFOMI_EFID(regval) GET_BITS((uint32_t)(regval), 3, 31)
|
||||
#define GET_RFIFOMI_EFID(regval) GET_BITS((uint32_t)(regval), 3U, 31U)
|
||||
|
||||
/* receive mailbox standrad identifier*/
|
||||
#define RFIFOMI_SFID(regval) GET_BITS((uint32_t)(regval), 21, 31)
|
||||
#define GET_RFIFOMI_SFID(regval) GET_BITS((uint32_t)(regval), 21U, 31U)
|
||||
|
||||
/* receive data length */
|
||||
#define RFIFOMP_DLENC(regval) GET_BITS((uint32_t)(regval), 0, 3)
|
||||
#define GET_RFIFOMP_DLENC(regval) GET_BITS((uint32_t)(regval), 0U, 3U)
|
||||
|
||||
#define RFIFOMP_FI(regval) GET_BITS((uint32_t)(regval), 8, 15)
|
||||
/* the index of the filter by which the frame is passed */
|
||||
#define GET_RFIFOMP_FI(regval) GET_BITS((uint32_t)(regval), 8U, 15U)
|
||||
|
||||
/* receive data byte 0 */
|
||||
#define RFIFOMDATA0_DB0(regval) GET_BITS((uint32_t)(regval), 0, 7)
|
||||
#define GET_RFIFOMDATA0_DB0(regval) GET_BITS((uint32_t)(regval), 0U, 7U)
|
||||
|
||||
/* receive data byte 1 */
|
||||
#define RFIFOMDATA0_DB1(regval) GET_BITS((uint32_t)(regval), 8, 15)
|
||||
#define GET_RFIFOMDATA0_DB1(regval) GET_BITS((uint32_t)(regval), 8U, 15U)
|
||||
|
||||
/* receive data byte 2 */
|
||||
#define RFIFOMDATA0_DB2(regval) GET_BITS((uint32_t)(regval), 16, 23)
|
||||
#define GET_RFIFOMDATA0_DB2(regval) GET_BITS((uint32_t)(regval), 16U, 23U)
|
||||
|
||||
/* receive data byte 3 */
|
||||
#define RFIFOMDATA0_DB3(regval) GET_BITS((uint32_t)(regval), 24, 31)
|
||||
#define GET_RFIFOMDATA0_DB3(regval) GET_BITS((uint32_t)(regval), 24U, 31U)
|
||||
|
||||
/* receive data byte 4 */
|
||||
#define RFIFOMDATA1_DB4(regval) GET_BITS((uint32_t)(regval), 0, 7)
|
||||
#define GET_RFIFOMDATA1_DB4(regval) GET_BITS((uint32_t)(regval), 0U, 7U)
|
||||
|
||||
/* receive data byte 5 */
|
||||
#define RFIFOMDATA1_DB5(regval) GET_BITS((uint32_t)(regval), 8, 15)
|
||||
#define GET_RFIFOMDATA1_DB5(regval) GET_BITS((uint32_t)(regval), 8U, 15U)
|
||||
|
||||
/* receive data byte 6 */
|
||||
#define RFIFOMDATA1_DB6(regval) GET_BITS((uint32_t)(regval), 16, 23)
|
||||
#define GET_RFIFOMDATA1_DB6(regval) GET_BITS((uint32_t)(regval), 16U, 23U)
|
||||
|
||||
/* receive data byte 7 */
|
||||
#define RFIFOMDATA1_DB7(regval) GET_BITS((uint32_t)(regval), 24, 31)
|
||||
#define GET_RFIFOMDATA1_DB7(regval) GET_BITS((uint32_t)(regval), 24U, 31U)
|
||||
|
||||
/* error number */
|
||||
#define GET_ERR_ERRN(regval) GET_BITS((uint32_t)(regval), 4U, 6U)
|
||||
|
||||
/* transmit error count */
|
||||
#define GET_ERR_TECNT(regval) GET_BITS((uint32_t)(regval), 16U, 23U)
|
||||
|
||||
/* receive error count */
|
||||
#define GET_ERR_RECNT(regval) GET_BITS((uint32_t)(regval), 24U, 31U)
|
||||
|
||||
/* CAN errors */
|
||||
#define ERR_ERRN(regval) (BITS(4,6) & ((uint32_t)(regval) << 4))
|
||||
#define CAN_ERRN_0 ERR_ERRN(0) /* no error */
|
||||
#define CAN_ERRN_1 ERR_ERRN(1) /*!< fill error */
|
||||
#define CAN_ERRN_2 ERR_ERRN(2) /*!< format error */
|
||||
#define CAN_ERRN_3 ERR_ERRN(3) /*!< ACK error */
|
||||
#define CAN_ERRN_4 ERR_ERRN(4) /*!< bit recessive error */
|
||||
#define CAN_ERRN_5 ERR_ERRN(5) /*!< bit dominant error */
|
||||
#define CAN_ERRN_6 ERR_ERRN(6) /*!< CRC error */
|
||||
#define CAN_ERRN_7 ERR_ERRN(7) /*!< software error */
|
||||
#define CAN_ERRN_0 ERR_ERRN(0U) /* no error */
|
||||
#define CAN_ERRN_1 ERR_ERRN(1U) /*!< fill error */
|
||||
#define CAN_ERRN_2 ERR_ERRN(2U) /*!< format error */
|
||||
#define CAN_ERRN_3 ERR_ERRN(3U) /*!< ACK error */
|
||||
#define CAN_ERRN_4 ERR_ERRN(4U) /*!< bit recessive error */
|
||||
#define CAN_ERRN_5 ERR_ERRN(5U) /*!< bit dominant error */
|
||||
#define CAN_ERRN_6 ERR_ERRN(6U) /*!< CRC error */
|
||||
#define CAN_ERRN_7 ERR_ERRN(7U) /*!< software error */
|
||||
|
||||
#define CAN_STATE_PENDING ((uint32_t)0x00000000U) /*!< CAN pending */
|
||||
|
||||
@@ -556,7 +647,7 @@ typedef enum
|
||||
#define CAN_FIFO1 ((uint8_t)0x01U) /*!< receive FIFO1 */
|
||||
|
||||
/* frame number of receive fifo */
|
||||
#define CAN_RFIFO_RFL0_MASK ((uint32_t)0x00000003U) /*!< mask for frame number in receive FIFO0 */
|
||||
#define CAN_RFIF_RFL_MASK ((uint32_t)0x00000003U) /*!< mask for frame number in receive FIFOx */
|
||||
|
||||
#define CAN_SFID_MASK ((uint32_t)0x000007FFU) /*!< mask of standard identifier */
|
||||
#define CAN_EFID_MASK ((uint32_t)0x1FFFFFFFU) /*!< mask of extended identifier */
|
||||
@@ -575,7 +666,7 @@ typedef enum
|
||||
#define CAN_FILTERMODE_LIST ((uint8_t)0x01U) /*!< list mode */
|
||||
|
||||
/* filter 16 bits mask */
|
||||
#define CAN_FILTER_MASK_16BITS ((uint32_t)0x0000FFFFU)
|
||||
#define CAN_FILTER_MASK_16BITS ((uint32_t)0x0000FFFFU) /*!< can filter 16 bits mask */
|
||||
|
||||
/* frame type */
|
||||
#define CAN_FT_DATA ((uint32_t)0x00000000U) /*!< data frame */
|
||||
@@ -584,62 +675,72 @@ typedef enum
|
||||
/* CAN timeout */
|
||||
#define CAN_TIMEOUT ((uint32_t)0x0000FFFFU) /*!< timeout value */
|
||||
|
||||
/* interrupt enable bits */
|
||||
#define CAN_INT_TME CAN_INTEN_TMEIE /*!< transmit mailbox empty interrupt enable */
|
||||
#define CAN_INT_RFNE0 CAN_INTEN_RFNEIE0 /*!< receive FIFO0 not empty interrupt enable */
|
||||
#define CAN_INT_RFF0 CAN_INTEN_RFFIE0 /*!< receive FIFO0 full interrupt enable */
|
||||
#define CAN_INT_RFO0 CAN_INTEN_RFOIE0 /*!< receive FIFO0 overfull interrupt enable */
|
||||
#define CAN_INT_RFNE1 CAN_INTEN_RFNEIE1 /*!< receive FIFO1 not empty interrupt enable */
|
||||
#define CAN_INT_RFF1 CAN_INTEN_RFFIE1 /*!< receive FIFO1 full interrupt enable */
|
||||
#define CAN_INT_RFO1 CAN_INTEN_RFOIE1 /*!< receive FIFO1 overfull interrupt enable */
|
||||
#define CAN_INT_WERR CAN_INTEN_WERRIE /*!< warning error interrupt enable */
|
||||
#define CAN_INT_PERR CAN_INTEN_PERRIE /*!< passive error interrupt enable */
|
||||
#define CAN_INT_BO CAN_INTEN_BOIE /*!< bus-off interrupt enable */
|
||||
#define CAN_INT_ERRN CAN_INTEN_ERRNIE /*!< error number interrupt enable */
|
||||
#define CAN_INT_ERR CAN_INTEN_ERRIE /*!< error interrupt enable */
|
||||
#define CAN_INT_WAKEUP CAN_INTEN_WIE /*!< wakeup interrupt enable */
|
||||
#define CAN_INT_SLPW CAN_INTEN_SLPWIE /*!< sleep working interrupt enable */
|
||||
|
||||
/* function declarations */
|
||||
/* initialization functions */
|
||||
/* CAN deinit */
|
||||
/* deinitialize CAN */
|
||||
void can_deinit(uint32_t can_periph);
|
||||
/* CAN init */
|
||||
/* initialize CAN struct */
|
||||
void can_struct_para_init(can_struct_type_enum type, void* p_struct);
|
||||
/* initialize CAN */
|
||||
ErrStatus can_init(uint32_t can_periph, can_parameter_struct* can_parameter_init);
|
||||
|
||||
/* transmit functions */
|
||||
/* CAN transmit message */
|
||||
uint8_t can_message_transmit(uint32_t can_periph, can_trasnmit_message_struct* transmit_message);
|
||||
/* CAN transmit state */
|
||||
can_transmit_state_enum can_transmit_states(uint32_t can_periph, uint8_t mailbox_number);
|
||||
/* CAN stop transmission */
|
||||
void can_transmission_stop(uint32_t can_periph, uint8_t mailbox_number);
|
||||
/* CAN transmit error number */
|
||||
uint8_t can_transmit_error_number(uint32_t can_periph);
|
||||
|
||||
/* filter functions */
|
||||
/* CAN filter init */
|
||||
void can_filter_init(can_filter_parameter_struct* can_filter_parameter_init);
|
||||
/* set can1 fliter start bank number */
|
||||
void can1_filter_start_bank(uint8_t start_bank);
|
||||
|
||||
/* enable functions */
|
||||
/* CAN debug freeze enable */
|
||||
void can_debug_freeze_enable(uint32_t can_periph);
|
||||
/* CAN debug freeze disable */
|
||||
void can_debug_freeze_disable(uint32_t can_periph);
|
||||
/* CAN time triggle mode enable */
|
||||
/* CAN time trigger mode enable */
|
||||
void can_time_trigger_mode_enable(uint32_t can_periph);
|
||||
/* CAN time triggle mode disable */
|
||||
/* CAN time trigger mode disable */
|
||||
void can_time_trigger_mode_disable(uint32_t can_periph);
|
||||
/* CAN interrupt enable */
|
||||
void can_interrupt_enable(uint32_t can_periph, uint32_t interrupt);
|
||||
/* CAN interrupt disable */
|
||||
void can_interrupt_disable(uint32_t can_periph, uint32_t interrupt);
|
||||
|
||||
/* receive functions */
|
||||
/* transmit functions */
|
||||
/* transmit CAN message */
|
||||
uint8_t can_message_transmit(uint32_t can_periph, can_trasnmit_message_struct* transmit_message);
|
||||
/* get CAN transmit state */
|
||||
can_transmit_state_enum can_transmit_states(uint32_t can_periph, uint8_t mailbox_number);
|
||||
/* stop CAN transmission */
|
||||
void can_transmission_stop(uint32_t can_periph, uint8_t mailbox_number);
|
||||
/* CAN receive message */
|
||||
void can_message_receive(uint32_t can_periph, uint8_t fifo_number, can_receive_message_struct* receive_message);
|
||||
/* CAN release fifo */
|
||||
void can_fifo_release(uint32_t can_periph, uint8_t fifo_number);
|
||||
/* CAN receive message length */
|
||||
uint8_t can_receive_message_length(uint32_t can_periph, uint8_t fifo_number);
|
||||
/* CAN receive error number */
|
||||
uint8_t can_receive_error_number(uint32_t can_periph);
|
||||
|
||||
/* mode functions */
|
||||
uint8_t can_receive_message_length_get(uint32_t can_periph, uint8_t fifo_number);
|
||||
/* CAN working mode */
|
||||
ErrStatus can_working_mode_set(uint32_t can_periph, uint8_t working_mode);
|
||||
/* CAN wakeup from sleep mode */
|
||||
ErrStatus can_wakeup(uint32_t can_periph);
|
||||
|
||||
/* flag functions */
|
||||
/* CAN get error */
|
||||
can_error_enum can_error_get(uint32_t can_periph);
|
||||
/* get CAN receive error number */
|
||||
uint8_t can_receive_error_number_get(uint32_t can_periph);
|
||||
/* get CAN transmit error number */
|
||||
uint8_t can_transmit_error_number_get(uint32_t can_periph);
|
||||
|
||||
/* CAN interrupt enable */
|
||||
void can_interrupt_enable(uint32_t can_periph, uint32_t interrupt);
|
||||
/* CAN interrupt disable */
|
||||
void can_interrupt_disable(uint32_t can_periph, uint32_t interrupt);
|
||||
/* CAN get flag state */
|
||||
FlagStatus can_flag_get(uint32_t can_periph, can_flag_enum flag);
|
||||
/* CAN clear flag state */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_dac.h
|
||||
\brief definitions for the DAC
|
||||
\file gd32f4xx_dac.h
|
||||
\brief definitions for the DAC
|
||||
|
||||
\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_DAC_H
|
||||
@@ -20,152 +45,153 @@
|
||||
#define DAC1 1U
|
||||
|
||||
/* registers definitions */
|
||||
#define DAC_CTL REG32(DAC + 0x00U) /*!< DAC control register */
|
||||
#define DAC_SWT REG32(DAC + 0x04U) /*!< DAC software trigger register */
|
||||
#define DAC0_R12DH REG32(DAC + 0x08U) /*!< DAC0 12-bit right-aligned data holding register */
|
||||
#define DAC0_L12DH REG32(DAC + 0x0CU) /*!< DAC0 12-bit left-aligned data holding register */
|
||||
#define DAC0_R8DH REG32(DAC + 0x10U) /*!< DAC0 8-bit right-aligned data holding register */
|
||||
#define DAC1_R12DH REG32(DAC + 0x14U) /*!< DAC1 12-bit right-aligned data holding register */
|
||||
#define DAC1_L12DH REG32(DAC + 0x18U) /*!< DAC1 12-bit left-aligned data holding register */
|
||||
#define DAC1_R8DH REG32(DAC + 0x1CU) /*!< DAC1 8-bit right-aligned data holding register */
|
||||
#define DACC_R12DH REG32(DAC + 0x20U) /*!< DAC concurrent mode 12-bit right-aligned data holding register */
|
||||
#define DACC_L12DH REG32(DAC + 0x24U) /*!< DAC concurrent mode 12-bit left-aligned data holding register */
|
||||
#define DACC_R8DH REG32(DAC + 0x28U) /*!< DAC concurrent mode 8-bit right-aligned data holding register */
|
||||
#define DAC0_DO REG32(DAC + 0x2CU) /*!< DAC0 data output register */
|
||||
#define DAC1_DO REG32(DAC + 0x30U) /*!< DAC1 data output register */
|
||||
#define DAC_STAT REG32(DAC + 0x34U) /*!< DAC status register */
|
||||
#define DAC_CTL REG32(DAC + 0x00U) /*!< DAC control register */
|
||||
#define DAC_SWT REG32(DAC + 0x04U) /*!< DAC software trigger register */
|
||||
#define DAC0_R12DH REG32(DAC + 0x08U) /*!< DAC0 12-bit right-aligned data holding register */
|
||||
#define DAC0_L12DH REG32(DAC + 0x0CU) /*!< DAC0 12-bit left-aligned data holding register */
|
||||
#define DAC0_R8DH REG32(DAC + 0x10U) /*!< DAC0 8-bit right-aligned data holding register */
|
||||
#define DAC1_R12DH REG32(DAC + 0x14U) /*!< DAC1 12-bit right-aligned data holding register */
|
||||
#define DAC1_L12DH REG32(DAC + 0x18U) /*!< DAC1 12-bit left-aligned data holding register */
|
||||
#define DAC1_R8DH REG32(DAC + 0x1CU) /*!< DAC1 8-bit right-aligned data holding register */
|
||||
#define DACC_R12DH REG32(DAC + 0x20U) /*!< DAC concurrent mode 12-bit right-aligned data holding register */
|
||||
#define DACC_L12DH REG32(DAC + 0x24U) /*!< DAC concurrent mode 12-bit left-aligned data holding register */
|
||||
#define DACC_R8DH REG32(DAC + 0x28U) /*!< DAC concurrent mode 8-bit right-aligned data holding register */
|
||||
#define DAC0_DO REG32(DAC + 0x2CU) /*!< DAC0 data output register */
|
||||
#define DAC1_DO REG32(DAC + 0x30U) /*!< DAC1 data output register */
|
||||
#define DAC_STAT REG32(DAC + 0x34U) /*!< DAC status register */
|
||||
|
||||
/* bits definitions */
|
||||
/* DAC_CLT */
|
||||
#define DAC_CTL_DEN0 BIT(0) /*!< DAC0 enable/disable bit */
|
||||
#define DAC_CTL_DBOFF0 BIT(1) /*!< DAC0 output buffer turn on/turn off bit */
|
||||
#define DAC_CTL_DTEN0 BIT(2) /*!< DAC0 trigger enable/disable bit */
|
||||
#define DAC_CTL_DTSEL0 BITS(3,5) /*!< DAC0 trigger source selection enable/disable bits */
|
||||
#define DAC_CTL_DWM0 BITS(6,7) /*!< DAC0 noise wave mode */
|
||||
#define DAC_CTL_DWBW0 BITS(8,11) /*!< DAC0 noise wave bit width */
|
||||
#define DAC_CTL_DDMAEN0 BIT(12) /*!< DAC0 DMA enable/disanle bit */
|
||||
#define DAC_CTL_DDUDRIE0 BIT(13) /*!< DAC0 DMA underrun interrupt enable/disable bit */
|
||||
#define DAC_CTL_DEN1 BIT(16) /*!< DAC1 enable/disable bit */
|
||||
#define DAC_CTL_DBOFF1 BIT(17) /*!< DAC1 output buffer turn on/turn off bit */
|
||||
#define DAC_CTL_DTEN1 BIT(18) /*!< DAC1 trigger enable/disable bit */
|
||||
#define DAC_CTL_DTSEL1 BITS(19,21) /*!< DAC1 trigger source selection enable/disable bits */
|
||||
#define DAC_CTL_DWM1 BITS(22,23) /*!< DAC1 noise wave mode */
|
||||
#define DAC_CTL_DWBW1 BITS(24,27) /*!< DAC1 noise wave bit width */
|
||||
#define DAC_CTL_DDMAEN1 BIT(28) /*!< DAC1 DMA enable/disanle bit */
|
||||
#define DAC_CTL_DDUDRIE1 BIT(29) /*!< DAC1 DMA underrun interrupt enable/disable bit */
|
||||
/* DAC_CTL */
|
||||
#define DAC_CTL_DEN0 BIT(0) /*!< DAC0 enable/disable bit */
|
||||
#define DAC_CTL_DBOFF0 BIT(1) /*!< DAC0 output buffer turn on/turn off bit */
|
||||
#define DAC_CTL_DTEN0 BIT(2) /*!< DAC0 trigger enable/disable bit */
|
||||
#define DAC_CTL_DTSEL0 BITS(3,5) /*!< DAC0 trigger source selection enable/disable bits */
|
||||
#define DAC_CTL_DWM0 BITS(6,7) /*!< DAC0 noise wave mode */
|
||||
#define DAC_CTL_DWBW0 BITS(8,11) /*!< DAC0 noise wave bit width */
|
||||
#define DAC_CTL_DDMAEN0 BIT(12) /*!< DAC0 DMA enable/disable bit */
|
||||
#define DAC_CTL_DDUDRIE0 BIT(13) /*!< DAC0 DMA underrun interrupt enable/disable bit */
|
||||
#define DAC_CTL_DEN1 BIT(16) /*!< DAC1 enable/disable bit */
|
||||
#define DAC_CTL_DBOFF1 BIT(17) /*!< DAC1 output buffer turn on/turn off bit */
|
||||
#define DAC_CTL_DTEN1 BIT(18) /*!< DAC1 trigger enable/disable bit */
|
||||
#define DAC_CTL_DTSEL1 BITS(19,21) /*!< DAC1 trigger source selection enable/disable bits */
|
||||
#define DAC_CTL_DWM1 BITS(22,23) /*!< DAC1 noise wave mode */
|
||||
#define DAC_CTL_DWBW1 BITS(24,27) /*!< DAC1 noise wave bit width */
|
||||
#define DAC_CTL_DDMAEN1 BIT(28) /*!< DAC1 DMA enable/disable bit */
|
||||
#define DAC_CTL_DDUDRIE1 BIT(29) /*!< DAC1 DMA underrun interrupt enable/disable bit */
|
||||
|
||||
/* DAC_SWT */
|
||||
#define DAC_SWT_SWTR0 BIT(0) /*!< DAC0 software trigger bit, cleared by hardware */
|
||||
#define DAC_SWT_SWTR1 BIT(1) /*!< DAC1 software trigger bit, cleared by hardware */
|
||||
#define DAC_SWT_SWTR0 BIT(0) /*!< DAC0 software trigger bit, cleared by hardware */
|
||||
#define DAC_SWT_SWTR1 BIT(1) /*!< DAC1 software trigger bit, cleared by hardware */
|
||||
|
||||
/* DAC0_R12DH */
|
||||
#define DAC0_R12DH_DAC0_DH BITS(0,11) /*!< DAC0 12-bit right-aligned data bits */
|
||||
#define DAC0_R12DH_DAC0_DH BITS(0,11) /*!< DAC0 12-bit right-aligned data bits */
|
||||
|
||||
/* DAC0_L12DH */
|
||||
#define DAC0_L12DH_DAC0_DH BITS(4,15) /*!< DAC0 12-bit left-aligned data bits */
|
||||
#define DAC0_L12DH_DAC0_DH BITS(4,15) /*!< DAC0 12-bit left-aligned data bits */
|
||||
|
||||
/* DAC0_R8DH */
|
||||
#define DAC0_R8DH_DAC0_DH BITS(0,7) /*!< DAC0 8-bit right-aligned data bits */
|
||||
#define DAC0_R8DH_DAC0_DH BITS(0,7) /*!< DAC0 8-bit right-aligned data bits */
|
||||
|
||||
/* DAC1_R12DH */
|
||||
#define DAC1_R12DH_DAC1_DH BITS(0,11) /*!< DAC1 12-bit right-aligned data bits */
|
||||
#define DAC1_R12DH_DAC1_DH BITS(0,11) /*!< DAC1 12-bit right-aligned data bits */
|
||||
|
||||
/* DAC1_L12DH */
|
||||
#define DAC1_L12DH_DAC1_DH BITS(4,15) /*!< DAC1 12-bit left-aligned data bits */
|
||||
#define DAC1_L12DH_DAC1_DH BITS(4,15) /*!< DAC1 12-bit left-aligned data bits */
|
||||
|
||||
/* DAC1_R8DH */
|
||||
#define DAC1_R8DH_DAC1_DH BITS(0,7) /*!< DAC1 8-bit right-aligned data bits */
|
||||
#define DAC1_R8DH_DAC1_DH BITS(0,7) /*!< DAC1 8-bit right-aligned data bits */
|
||||
|
||||
/* DACC_R12DH */
|
||||
#define DACC_R12DH_DAC0_DH BITS(0,11) /*!< DAC concurrent mode DAC0 12-bit right-aligned data bits */
|
||||
#define DACC_R12DH_DAC1_DH BITS(16,27) /*!< DAC concurrent mode DAC1 12-bit right-aligned data bits */
|
||||
#define DACC_R12DH_DAC0_DH BITS(0,11) /*!< DAC concurrent mode DAC0 12-bit right-aligned data bits */
|
||||
#define DACC_R12DH_DAC1_DH BITS(16,27) /*!< DAC concurrent mode DAC1 12-bit right-aligned data bits */
|
||||
|
||||
/* DACC_L12DH */
|
||||
#define DACC_L12DH_DAC0_DH BITS(4,15) /*!< DAC concurrent mode DAC0 12-bit left-aligned data bits */
|
||||
#define DACC_L12DH_DAC1_DH BITS(20,31) /*!< DAC concurrent mode DAC1 12-bit left-aligned data bits */
|
||||
#define DACC_L12DH_DAC0_DH BITS(4,15) /*!< DAC concurrent mode DAC0 12-bit left-aligned data bits */
|
||||
#define DACC_L12DH_DAC1_DH BITS(20,31) /*!< DAC concurrent mode DAC1 12-bit left-aligned data bits */
|
||||
|
||||
/* DACC_R8DH */
|
||||
#define DACC_R8DH_DAC0_DH BITS(0,7) /*!< DAC concurrent mode DAC0 8-bit right-aligned data bits */
|
||||
#define DACC_R8DH_DAC1_DH BITS(16,23) /*!< DAC concurrent mode DAC1 8-bit right-aligned data bits */
|
||||
#define DACC_R8DH_DAC0_DH BITS(0,7) /*!< DAC concurrent mode DAC0 8-bit right-aligned data bits */
|
||||
#define DACC_R8DH_DAC1_DH BITS(8,15) /*!< DAC concurrent mode DAC1 8-bit right-aligned data bits */
|
||||
|
||||
/* DAC0_DO */
|
||||
#define DAC0_DO_DAC0_DO BITS(0,11) /*!< DAC0 12-bit output data bits */
|
||||
#define DAC0_DO_DAC0_DO BITS(0,11) /*!< DAC0 12-bit output data bits */
|
||||
|
||||
/* DAC1_DO */
|
||||
#define DAC1_DO_DAC1_DO BITS(0,11) /*!< DAC1 12-bit output data bits */
|
||||
#define DAC1_DO_DAC1_DO BITS(0,11) /*!< DAC1 12-bit output data bits */
|
||||
|
||||
/* DAC_STAT */
|
||||
#define DAC_STAT_DDUDR0 BIT(13) /*!< DAC0 DMA underrun flag */
|
||||
#define DAC_STAT_DDUDR1 BIT(29) /*!< DAC1 DMA underrun flag */
|
||||
#define DAC_STAT_DDUDR0 BIT(13) /*!< DAC0 DMA underrun flag */
|
||||
#define DAC_STAT_DDUDR1 BIT(29) /*!< DAC1 DMA underrun flag */
|
||||
|
||||
/* constants definitions */
|
||||
/* DAC trigger source */
|
||||
#define CTL_DTSEL(regval) (BITS(3,5) & ((uint32_t)(regval) << 3))
|
||||
#define DAC_TRIGGER_T5_TRGO CTL_DTSEL(0) /*!< TIMER5 TRGO */
|
||||
#define DAC_TRIGGER_T7_TRGO CTL_DTSEL(1) /*!< TIMER7 TRGO */
|
||||
#define DAC_TRIGGER_T6_TRGO CTL_DTSEL(2) /*!< TIMER6 TRGO */
|
||||
#define DAC_TRIGGER_T4_TRGO CTL_DTSEL(3) /*!< TIMER4 TRGO */
|
||||
#define DAC_TRIGGER_T1_TRGO CTL_DTSEL(4) /*!< TIMER1 TRGO */
|
||||
#define DAC_TRIGGER_T3_TRGO CTL_DTSEL(5) /*!< TIMER3 TRGO */
|
||||
#define DAC_TRIGGER_EXTI_9 CTL_DTSEL(6) /*!< EXTI interrupt line9 event */
|
||||
#define DAC_TRIGGER_SOFTWARE CTL_DTSEL(7) /*!< software trigger */
|
||||
#define DAC_TRIGGER_T5_TRGO CTL_DTSEL(0) /*!< TIMER5 TRGO */
|
||||
#define DAC_TRIGGER_T7_TRGO CTL_DTSEL(1) /*!< TIMER7 TRGO */
|
||||
#define DAC_TRIGGER_T6_TRGO CTL_DTSEL(2) /*!< TIMER6 TRGO */
|
||||
#define DAC_TRIGGER_T4_TRGO CTL_DTSEL(3) /*!< TIMER4 TRGO */
|
||||
#define DAC_TRIGGER_T1_TRGO CTL_DTSEL(4) /*!< TIMER1 TRGO */
|
||||
#define DAC_TRIGGER_T3_TRGO CTL_DTSEL(5) /*!< TIMER3 TRGO */
|
||||
#define DAC_TRIGGER_EXTI_9 CTL_DTSEL(6) /*!< EXTI interrupt line9 event */
|
||||
#define DAC_TRIGGER_SOFTWARE CTL_DTSEL(7) /*!< software trigger */
|
||||
|
||||
/* DAC noise wave mode */
|
||||
#define CTL_DWM(regval) (BITS(6,7) & ((uint32_t)(regval) << 6))
|
||||
#define DAC_WAVE_DISABLE CTL_DWM(0) /*!< wave disable */
|
||||
#define DAC_WAVE_MODE_LFSR CTL_DWM(1) /*!< LFSR noise mode */
|
||||
#define DAC_WAVE_MODE_TRIANGLE CTL_DWM(2) /*!< triangle noise mode */
|
||||
#define DAC_WAVE_DISABLE CTL_DWM(0) /*!< wave disable */
|
||||
#define DAC_WAVE_MODE_LFSR CTL_DWM(1) /*!< LFSR noise mode */
|
||||
#define DAC_WAVE_MODE_TRIANGLE CTL_DWM(2) /*!< triangle noise mode */
|
||||
|
||||
/* DAC noise wave bit width */
|
||||
#define DWBW(regval) (BITS(8,11) & ((uint32_t)(regval) << 8))
|
||||
#define DAC_WAVE_BIT_WIDTH_1 DWBW(0) /*!< bit width of the wave signal is 1 */
|
||||
#define DAC_WAVE_BIT_WIDTH_2 DWBW(1) /*!< bit width of the wave signal is 2 */
|
||||
#define DAC_WAVE_BIT_WIDTH_3 DWBW(2) /*!< bit width of the wave signal is 3 */
|
||||
#define DAC_WAVE_BIT_WIDTH_4 DWBW(3) /*!< bit width of the wave signal is 4 */
|
||||
#define DAC_WAVE_BIT_WIDTH_5 DWBW(4) /*!< bit width of the wave signal is 5 */
|
||||
#define DAC_WAVE_BIT_WIDTH_6 DWBW(5) /*!< bit width of the wave signal is 6 */
|
||||
#define DAC_WAVE_BIT_WIDTH_7 DWBW(6) /*!< bit width of the wave signal is 7 */
|
||||
#define DAC_WAVE_BIT_WIDTH_8 DWBW(7) /*!< bit width of the wave signal is 8 */
|
||||
#define DAC_WAVE_BIT_WIDTH_9 DWBW(8) /*!< bit width of the wave signal is 9 */
|
||||
#define DAC_WAVE_BIT_WIDTH_10 DWBW(9) /*!< bit width of the wave signal is 10 */
|
||||
#define DAC_WAVE_BIT_WIDTH_11 DWBW(10) /*!< bit width of the wave signal is 11 */
|
||||
#define DAC_WAVE_BIT_WIDTH_12 DWBW(11) /*!< bit width of the wave signal is 12 */
|
||||
#define DAC_WAVE_BIT_WIDTH_1 DWBW(0) /*!< bit width of the wave signal is 1 */
|
||||
#define DAC_WAVE_BIT_WIDTH_2 DWBW(1) /*!< bit width of the wave signal is 2 */
|
||||
#define DAC_WAVE_BIT_WIDTH_3 DWBW(2) /*!< bit width of the wave signal is 3 */
|
||||
#define DAC_WAVE_BIT_WIDTH_4 DWBW(3) /*!< bit width of the wave signal is 4 */
|
||||
#define DAC_WAVE_BIT_WIDTH_5 DWBW(4) /*!< bit width of the wave signal is 5 */
|
||||
#define DAC_WAVE_BIT_WIDTH_6 DWBW(5) /*!< bit width of the wave signal is 6 */
|
||||
#define DAC_WAVE_BIT_WIDTH_7 DWBW(6) /*!< bit width of the wave signal is 7 */
|
||||
#define DAC_WAVE_BIT_WIDTH_8 DWBW(7) /*!< bit width of the wave signal is 8 */
|
||||
#define DAC_WAVE_BIT_WIDTH_9 DWBW(8) /*!< bit width of the wave signal is 9 */
|
||||
#define DAC_WAVE_BIT_WIDTH_10 DWBW(9) /*!< bit width of the wave signal is 10 */
|
||||
#define DAC_WAVE_BIT_WIDTH_11 DWBW(10) /*!< bit width of the wave signal is 11 */
|
||||
#define DAC_WAVE_BIT_WIDTH_12 DWBW(11) /*!< bit width of the wave signal is 12 */
|
||||
|
||||
/* unmask LFSR bits in DAC LFSR noise mode */
|
||||
#define DAC_LFSR_BIT0 DAC_WAVE_BIT_WIDTH_1 /*!< unmask the LFSR bit0 */
|
||||
#define DAC_LFSR_BITS1_0 DAC_WAVE_BIT_WIDTH_2 /*!< unmask the LFSR bits[1:0] */
|
||||
#define DAC_LFSR_BITS2_0 DAC_WAVE_BIT_WIDTH_3 /*!< unmask the LFSR bits[2:0] */
|
||||
#define DAC_LFSR_BITS3_0 DAC_WAVE_BIT_WIDTH_4 /*!< unmask the LFSR bits[3:0] */
|
||||
#define DAC_LFSR_BITS4_0 DAC_WAVE_BIT_WIDTH_5 /*!< unmask the LFSR bits[4:0] */
|
||||
#define DAC_LFSR_BITS5_0 DAC_WAVE_BIT_WIDTH_6 /*!< unmask the LFSR bits[5:0] */
|
||||
#define DAC_LFSR_BITS6_0 DAC_WAVE_BIT_WIDTH_7 /*!< unmask the LFSR bits[6:0] */
|
||||
#define DAC_LFSR_BITS7_0 DAC_WAVE_BIT_WIDTH_8 /*!< unmask the LFSR bits[7:0] */
|
||||
#define DAC_LFSR_BITS8_0 DAC_WAVE_BIT_WIDTH_9 /*!< unmask the LFSR bits[8:0] */
|
||||
#define DAC_LFSR_BITS9_0 DAC_WAVE_BIT_WIDTH_10 /*!< unmask the LFSR bits[9:0] */
|
||||
#define DAC_LFSR_BITS10_0 DAC_WAVE_BIT_WIDTH_11 /*!< unmask the LFSR bits[10:0] */
|
||||
#define DAC_LFSR_BITS11_0 DAC_WAVE_BIT_WIDTH_12 /*!< unmask the LFSR bits[11:0] */
|
||||
|
||||
/* triangle amplitude in DAC triangle noise mode */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_1 DAC_WAVE_BIT_WIDTH_1 /*!< triangle amplitude is 1 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_3 DAC_WAVE_BIT_WIDTH_2 /*!< triangle amplitude is 3 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_7 DAC_WAVE_BIT_WIDTH_3 /*!< triangle amplitude is 7 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_15 DAC_WAVE_BIT_WIDTH_4 /*!< triangle amplitude is 15 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_31 DAC_WAVE_BIT_WIDTH_5 /*!< triangle amplitude is 31 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_63 DAC_WAVE_BIT_WIDTH_6 /*!< triangle amplitude is 63 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_127 DAC_WAVE_BIT_WIDTH_7 /*!< triangle amplitude is 127 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_255 DAC_WAVE_BIT_WIDTH_8 /*!< triangle amplitude is 255 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_511 DAC_WAVE_BIT_WIDTH_9 /*!< triangle amplitude is 511 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_1023 DAC_WAVE_BIT_WIDTH_10 /*!< triangle amplitude is 1023 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_2047 DAC_WAVE_BIT_WIDTH_11 /*!< triangle amplitude is 2047 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_4095 DAC_WAVE_BIT_WIDTH_12 /*!< triangle amplitude is 4095 */
|
||||
#define DAC_LFSR_BIT0 DAC_WAVE_BIT_WIDTH_1 /*!< unmask the LFSR bit0 */
|
||||
#define DAC_LFSR_BITS1_0 DAC_WAVE_BIT_WIDTH_2 /*!< unmask the LFSR bits[1:0] */
|
||||
#define DAC_LFSR_BITS2_0 DAC_WAVE_BIT_WIDTH_3 /*!< unmask the LFSR bits[2:0] */
|
||||
#define DAC_LFSR_BITS3_0 DAC_WAVE_BIT_WIDTH_4 /*!< unmask the LFSR bits[3:0] */
|
||||
#define DAC_LFSR_BITS4_0 DAC_WAVE_BIT_WIDTH_5 /*!< unmask the LFSR bits[4:0] */
|
||||
#define DAC_LFSR_BITS5_0 DAC_WAVE_BIT_WIDTH_6 /*!< unmask the LFSR bits[5:0] */
|
||||
#define DAC_LFSR_BITS6_0 DAC_WAVE_BIT_WIDTH_7 /*!< unmask the LFSR bits[6:0] */
|
||||
#define DAC_LFSR_BITS7_0 DAC_WAVE_BIT_WIDTH_8 /*!< unmask the LFSR bits[7:0] */
|
||||
#define DAC_LFSR_BITS8_0 DAC_WAVE_BIT_WIDTH_9 /*!< unmask the LFSR bits[8:0] */
|
||||
#define DAC_LFSR_BITS9_0 DAC_WAVE_BIT_WIDTH_10 /*!< unmask the LFSR bits[9:0] */
|
||||
#define DAC_LFSR_BITS10_0 DAC_WAVE_BIT_WIDTH_11 /*!< unmask the LFSR bits[10:0] */
|
||||
#define DAC_LFSR_BITS11_0 DAC_WAVE_BIT_WIDTH_12 /*!< unmask the LFSR bits[11:0] */
|
||||
|
||||
/* DAC data alignment */
|
||||
#define DATA_ALIGN(regval) (BITS(0,1) & ((uint32_t)(regval) << 0))
|
||||
#define DAC_ALIGN_12B_R DATA_ALIGN(0) /*!< data right 12b alignment */
|
||||
#define DAC_ALIGN_12B_L DATA_ALIGN(1) /*!< data left 12b alignment */
|
||||
#define DAC_ALIGN_8B_R DATA_ALIGN(2) /*!< data right 8b alignment */
|
||||
#define DAC_ALIGN_12B_R DATA_ALIGN(0) /*!< data right 12 bit alignment */
|
||||
#define DAC_ALIGN_12B_L DATA_ALIGN(1) /*!< data left 12 bit alignment */
|
||||
#define DAC_ALIGN_8B_R DATA_ALIGN(2) /*!< data right 8 bit alignment */
|
||||
|
||||
/* triangle amplitude in DAC triangle noise mode */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_1 DAC_WAVE_BIT_WIDTH_1 /*!< triangle amplitude is 1 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_3 DAC_WAVE_BIT_WIDTH_2 /*!< triangle amplitude is 3 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_7 DAC_WAVE_BIT_WIDTH_3 /*!< triangle amplitude is 7 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_15 DAC_WAVE_BIT_WIDTH_4 /*!< triangle amplitude is 15 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_31 DAC_WAVE_BIT_WIDTH_5 /*!< triangle amplitude is 31 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_63 DAC_WAVE_BIT_WIDTH_6 /*!< triangle amplitude is 63 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_127 DAC_WAVE_BIT_WIDTH_7 /*!< triangle amplitude is 127 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_255 DAC_WAVE_BIT_WIDTH_8 /*!< triangle amplitude is 255 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_511 DAC_WAVE_BIT_WIDTH_9 /*!< triangle amplitude is 511 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_1023 DAC_WAVE_BIT_WIDTH_10 /*!< triangle amplitude is 1023 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_2047 DAC_WAVE_BIT_WIDTH_11 /*!< triangle amplitude is 2047 */
|
||||
#define DAC_TRIANGLE_AMPLITUDE_4095 DAC_WAVE_BIT_WIDTH_12 /*!< triangle amplitude is 4095 */
|
||||
|
||||
/* function declarations */
|
||||
/* initialization functions */
|
||||
/* deinitialize DAC */
|
||||
void dac_deinit(void);
|
||||
/* enable DAC */
|
||||
@@ -175,26 +201,29 @@ void dac_disable(uint32_t dac_periph);
|
||||
/* enable DAC DMA */
|
||||
void dac_dma_enable(uint32_t dac_periph);
|
||||
/* disable DAC DMA */
|
||||
void dac_dma_disable(uint32_t dac_periph);
|
||||
void dac_dma_disable(uint32_t dac_periph);
|
||||
/* enable DAC output buffer */
|
||||
void dac_output_buffer_enable(uint32_t dac_periph);
|
||||
/* disable DAC output buffer */
|
||||
void dac_output_buffer_disable(uint32_t dac_periph);
|
||||
/* get the last data output value */
|
||||
uint16_t dac_output_value_get(uint32_t dac_periph);
|
||||
/* set DAC data holding register value */
|
||||
void dac_data_set(uint32_t dac_periph, uint32_t dac_align, uint16_t data);
|
||||
|
||||
/* DAC trigger configuration */
|
||||
/* enable DAC trigger */
|
||||
void dac_trigger_enable(uint32_t dac_periph);
|
||||
/* disable DAC trigger */
|
||||
void dac_trigger_disable(uint32_t dac_periph);
|
||||
/* configure DAC trigger source */
|
||||
void dac_trigger_source_config(uint32_t dac_periph, uint32_t triggersource);
|
||||
/* enable DAC software trigger */
|
||||
void dac_software_trigger_enable(uint32_t dac_periph);
|
||||
/* disable DAC software trigger */
|
||||
void dac_software_trigger_disable(uint32_t dac_periph);
|
||||
/* enable DAC interrupt(DAC0 DMA underrun interrupt) */
|
||||
void dac_interrupt_enable(uint32_t dac_periph);
|
||||
/* disable DAC interrupt(DAC0 DMA underrun interrupt) */
|
||||
void dac_interrupt_disable(uint32_t dac_periph);
|
||||
|
||||
/* configure DAC trigger source */
|
||||
void dac_trigger_source_config(uint32_t dac_periph, uint32_t triggersource);
|
||||
/* DAC wave mode configuration */
|
||||
/* configure DAC wave mode */
|
||||
void dac_wave_mode_config(uint32_t dac_periph, uint32_t wave_mode);
|
||||
/* configure DAC wave bit width */
|
||||
@@ -203,14 +232,8 @@ void dac_wave_bit_width_config(uint32_t dac_periph, uint32_t bit_width);
|
||||
void dac_lfsr_noise_config(uint32_t dac_periph, uint32_t unmask_bits);
|
||||
/* configure DAC triangle noise mode */
|
||||
void dac_triangle_noise_config(uint32_t dac_periph, uint32_t amplitude);
|
||||
/* get the last data output value */
|
||||
uint16_t dac_output_value_get(uint32_t dac_periph);
|
||||
|
||||
/* set DAC data holding register value */
|
||||
void dac_data_set(uint32_t dac_periph, uint32_t dac_align, uint16_t data);
|
||||
/* set DAC concurrent mode data holding register value */
|
||||
void dac_concurrent_data_set(uint32_t dac_align, uint16_t data0, uint16_t data1);
|
||||
|
||||
/* DAC concurrent mode configuration */
|
||||
/* enable DAC concurrent mode */
|
||||
void dac_concurrent_enable(void);
|
||||
/* disable DAC concurrent mode */
|
||||
@@ -223,11 +246,18 @@ void dac_concurrent_software_trigger_disable(void);
|
||||
void dac_concurrent_output_buffer_enable(void);
|
||||
/* disable DAC concurrent buffer function */
|
||||
void dac_concurrent_output_buffer_disable(void);
|
||||
/* set DAC concurrent mode data holding register value */
|
||||
void dac_concurrent_data_set(uint32_t dac_align, uint16_t data0, uint16_t data1);
|
||||
/* enable DAC concurrent interrupt */
|
||||
void dac_concurrent_interrupt_enable(void);
|
||||
/* disable DAC concurrent interrupt */
|
||||
void dac_concurrent_interrupt_disable(void);
|
||||
|
||||
/* DAC interrupt configuration */
|
||||
/* enable DAC interrupt(DAC DMA underrun interrupt) */
|
||||
void dac_interrupt_enable(uint32_t dac_periph);
|
||||
/* disable DAC interrupt(DAC DMA underrun interrupt) */
|
||||
void dac_interrupt_disable(uint32_t dac_periph);
|
||||
/* get the specified DAC flag(DAC DMA underrun flag) */
|
||||
FlagStatus dac_flag_get(uint32_t dac_periph);
|
||||
/* clear the specified DAC flag(DAC DMA underrun flag) */
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_dci.h
|
||||
\brief definitions for the DCI
|
||||
\file gd32f4xx_dci.h
|
||||
\brief definitions for the DCI
|
||||
|
||||
\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_DCI_H
|
||||
@@ -32,17 +57,17 @@
|
||||
|
||||
/* bits definitions */
|
||||
/* DCI_CTL */
|
||||
#define DCI_CTL_CAP BIT(0) /*!< capture enable */
|
||||
#define DCI_CTL_SNAP BIT(1) /*!< snapshot mode */
|
||||
#define DCI_CTL_WDEN BIT(2) /*!< window enable */
|
||||
#define DCI_CTL_JM BIT(3) /*!< jpeg mode */
|
||||
#define DCI_CTL_ESM BIT(4) /*!< embedded synchronous mode */
|
||||
#define DCI_CTL_CKS BIT(5) /*!< clock polarity selection */
|
||||
#define DCI_CTL_HPS BIT(6) /*!< horizontal polarity selection */
|
||||
#define DCI_CTL_VPS BIT(7) /*!< vertical polarity selection */
|
||||
#define DCI_CTL_FR BITS(8,9) /*!< frame rate */
|
||||
#define DCI_CTL_DCIF BITS(10,11) /*!< digital camera interface format */
|
||||
#define DCI_CTL_DCIEN BIT(14) /*!< dci enable */
|
||||
#define DCI_CTL_CAP BIT(0) /*!< capture enable */
|
||||
#define DCI_CTL_SNAP BIT(1) /*!< snapshot mode */
|
||||
#define DCI_CTL_WDEN BIT(2) /*!< window enable */
|
||||
#define DCI_CTL_JM BIT(3) /*!< JPEG mode */
|
||||
#define DCI_CTL_ESM BIT(4) /*!< embedded synchronous mode */
|
||||
#define DCI_CTL_CKS BIT(5) /*!< clock polarity selection */
|
||||
#define DCI_CTL_HPS BIT(6) /*!< horizontal polarity selection */
|
||||
#define DCI_CTL_VPS BIT(7) /*!< vertical polarity selection */
|
||||
#define DCI_CTL_FR BITS(8,9) /*!< frame rate */
|
||||
#define DCI_CTL_DCIF BITS(10,11) /*!< digital camera interface format */
|
||||
#define DCI_CTL_DCIEN BIT(14) /*!< DCI enable */
|
||||
|
||||
/* DCI_STAT0 */
|
||||
#define DCI_STAT0_HS BIT(0) /*!< HS line status */
|
||||
@@ -98,16 +123,16 @@
|
||||
#define DCI_CWSZ_WVSZ BITS(16,29) /*!< window vertical size */
|
||||
|
||||
/* constants definitions */
|
||||
/* DCI parameter struct definitions */
|
||||
/* DCI parameter structure definitions */
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
uint32_t capture_mode; /*!< DCI capture mode: continuous or snapshot */
|
||||
uint32_t clock_polarity; /*!< clock polarity selection */
|
||||
uint32_t hsync_polarity; /*!< horizontal polarity selection */
|
||||
uint32_t vsync_polarity; /*!< vertical polarity selection */
|
||||
uint32_t frame_rate; /*!< frame capture rate */
|
||||
uint32_t interface_format; /*!< digital camera interface format */
|
||||
}dci_parameter_struct;
|
||||
}dci_parameter_struct;
|
||||
|
||||
#define DCI_CAPTURE_MODE_CONTINUOUS ((uint32_t)0x00000000U) /*!< continuous capture mode */
|
||||
#define DCI_CAPTURE_MODE_SNAPSHOT DCI_CTL_SNAP /*!< snapshot capture mode */
|
||||
@@ -120,36 +145,44 @@ typedef struct
|
||||
|
||||
#define DCI_VSYNC_POLARITY_LOW ((uint32_t)0x00000000U) /*!< low level during blanking period */
|
||||
#define DCI_VSYNC_POLARITY_HIGH DCI_CTL_VPS /*!< high level during blanking period*/
|
||||
|
||||
#define CTL_FR(regval) (BITS(8,9)&((uint32_t)(regval) << 8U))
|
||||
|
||||
#define CTL_FR(regval) (BITS(8,9)&((uint32_t)(regval) << 8U))
|
||||
#define DCI_FRAME_RATE_ALL CTL_FR(0) /*!< capture all frames */
|
||||
#define DCI_FRAME_RATE_1_2 CTL_FR(1) /*!< capture one in 2 frames */
|
||||
#define DCI_FRAME_RATE_1_4 CTL_FR(2) /*!< capture one in 4 frames */
|
||||
|
||||
#define CTL_DCIF(regval) (BITS(10,11)&((uint32_t)(regval) << 10U))
|
||||
#define CTL_DCIF(regval) (BITS(10,11)&((uint32_t)(regval) << 10U))
|
||||
#define DCI_INTERFACE_FORMAT_8BITS CTL_DCIF(0) /*!< 8-bit data on every pixel clock */
|
||||
#define DCI_INTERFACE_FORMAT_10BITS CTL_DCIF(1) /*!< 10-bit data on every pixel clock */
|
||||
#define DCI_INTERFACE_FORMAT_12BITS CTL_DCIF(2) /*!< 12-bit data on every pixel clock */
|
||||
#define DCI_INTERFACE_FORMAT_14BITS CTL_DCIF(3) /*!< 14-bit data on every pixel clock */
|
||||
|
||||
/* DCI interrupt constants definitions */
|
||||
#define DCI_INT_EF ((uint32_t)0x00000001U) /*!< end of frame interrupt */
|
||||
#define DCI_INT_OVR ((uint32_t)0x00000002U) /*!< FIFO overrun interrupt */
|
||||
#define DCI_INT_ESE ((uint32_t)0x00000004U) /*!< embedded synchronous error interrupt */
|
||||
#define DCI_INT_VS ((uint32_t)0x00000008U) /*!< vsync interrupt */
|
||||
#define DCI_INT_EL ((uint32_t)0x00000010U) /*!< end of line interrupt */
|
||||
#define DCI_INT_EF BIT(0) /*!< end of frame interrupt */
|
||||
#define DCI_INT_OVR BIT(1) /*!< FIFO overrun interrupt */
|
||||
#define DCI_INT_ESE BIT(2) /*!< embedded synchronous error interrupt */
|
||||
#define DCI_INT_VSYNC BIT(3) /*!< vsync interrupt */
|
||||
#define DCI_INT_EL BIT(4) /*!< end of line interrupt */
|
||||
|
||||
/* DCI flag definitions */
|
||||
#define DCI_FLAG_HS ((uint8_t)0x01U) /*!< HS line status */
|
||||
#define DCI_FLAG_VS ((uint8_t)0x02U) /*!< VS line status */
|
||||
#define DCI_FLAG_FV ((uint8_t)0x03U) /*!< FIFO valid */
|
||||
#define DCI_FLAG_EFF ((uint8_t)0x04U) /*!< end of frame flag */
|
||||
#define DCI_FLAG_OVRF ((uint8_t)0x05U) /*!< FIFO overrun flag */
|
||||
#define DCI_FLAG_ESEF ((uint8_t)0x06U) /*!< embedded synchronous error flag */
|
||||
#define DCI_FLAG_VSF ((uint8_t)0x07U) /*!< vsync flag */
|
||||
#define DCI_FLAG_ELF ((uint8_t)0x08U) /*!< end of line flag */
|
||||
/* DCI interrupt flag definitions */
|
||||
#define DCI_INT_FLAG_EF BIT(0) /*!< end of frame interrupt flag */
|
||||
#define DCI_INT_FLAG_OVR BIT(1) /*!< FIFO overrun interrupt flag */
|
||||
#define DCI_INT_FLAG_ESE BIT(2) /*!< embedded synchronous error interrupt flag */
|
||||
#define DCI_INT_FLAG_VSYNC BIT(3) /*!< vsync interrupt flag */
|
||||
#define DCI_INT_FLAG_EL BIT(4) /*!< end of line interrupt flag */
|
||||
|
||||
/* DCI flag definitions */
|
||||
#define DCI_FLAG_HS DCI_STAT0_HS /*!< HS line status */
|
||||
#define DCI_FLAG_VS DCI_STAT0_VS /*!< VS line status */
|
||||
#define DCI_FLAG_FV DCI_STAT0_FV /*!< FIFO valid */
|
||||
#define DCI_FLAG_EF (DCI_STAT1_EFF | BIT(31)) /*!< end of frame flag */
|
||||
#define DCI_FLAG_OVR (DCI_STAT1_OVRF | BIT(31)) /*!< FIFO overrun flag */
|
||||
#define DCI_FLAG_ESE (DCI_STAT1_ESEF | BIT(31)) /*!< embedded synchronous error flag */
|
||||
#define DCI_FLAG_VSYNC (DCI_STAT1_VSF | BIT(31)) /*!< vsync flag */
|
||||
#define DCI_FLAG_EL (DCI_STAT1_ELF | BIT(31)) /*!< end of line flag */
|
||||
|
||||
/* function declarations */
|
||||
/* initialization functions */
|
||||
/* DCI deinit */
|
||||
void dci_deinit(void);
|
||||
/* initialize DCI registers */
|
||||
@@ -157,44 +190,49 @@ void dci_init(dci_parameter_struct* dci_struct);
|
||||
|
||||
/* enable DCI function */
|
||||
void dci_enable(void);
|
||||
/* disble DCI function */
|
||||
/* disable DCI function */
|
||||
void dci_disable(void);
|
||||
/* enable DCI capture */
|
||||
void dci_capture_enable(void);
|
||||
/* disble DCI capture */
|
||||
/* disable DCI capture */
|
||||
void dci_capture_disable(void);
|
||||
/* enable DCI jpeg mode */
|
||||
void dci_jpeg_enable(void);
|
||||
/* disble DCI jpeg mode */
|
||||
/* disable DCI jpeg mode */
|
||||
void dci_jpeg_disable(void);
|
||||
|
||||
/* function configuration */
|
||||
/* enable cropping window function */
|
||||
void dci_crop_window_enable(void);
|
||||
/* disble cropping window function */
|
||||
/* disable cropping window function */
|
||||
void dci_crop_window_disable(void);
|
||||
/* config DCI cropping window */
|
||||
/* configure DCI cropping window */
|
||||
void dci_crop_window_config(uint16_t start_x, uint16_t start_y, uint16_t size_width, uint16_t size_height);
|
||||
|
||||
/* enable sync codes function */
|
||||
void dci_sync_codes_enable(void);
|
||||
/* disble sync codes function */
|
||||
void dci_sync_codes_disable(void);
|
||||
/* config sync codes */
|
||||
/* enable embedded synchronous mode */
|
||||
void dci_embedded_sync_enable(void);
|
||||
/* disable embedded synchronous mode */
|
||||
void dci_embedded_sync_disable(void);
|
||||
/* configure synchronous codes in embedded synchronous mode */
|
||||
void dci_sync_codes_config(uint8_t frame_start, uint8_t line_start, uint8_t line_end, uint8_t frame_end);
|
||||
/* config sync codes unmask */
|
||||
/* configure synchronous codes unmask in embedded synchronous mode */
|
||||
void dci_sync_codes_unmask_config(uint8_t frame_start, uint8_t line_start, uint8_t line_end, uint8_t frame_end);
|
||||
|
||||
/* read DCI data register */
|
||||
uint32_t dci_data_read(void);
|
||||
|
||||
/* enable specified DCI interrupt */
|
||||
void dci_interrupt_enable(uint32_t interrupt);
|
||||
/* disble specified DCI interrupt */
|
||||
void dci_interrupt_disable(uint32_t interrupt);
|
||||
/* clear specified interrupt */
|
||||
void dci_interrupt_clear(uint32_t interrupt);
|
||||
/* interrupt & flag functions */
|
||||
/* get specified flag */
|
||||
FlagStatus dci_flag_get(uint32_t flag);
|
||||
/* enable specified DCI interrupt */
|
||||
void dci_interrupt_enable(uint32_t interrupt);
|
||||
/* disable specified DCI interrupt */
|
||||
void dci_interrupt_disable(uint32_t interrupt);
|
||||
|
||||
|
||||
/* get specified interrupt flag */
|
||||
FlagStatus dci_interrupt_flag_get(uint32_t interrupt);
|
||||
FlagStatus dci_interrupt_flag_get(uint32_t int_flag);
|
||||
/* clear specified interrupt flag */
|
||||
void dci_interrupt_flag_clear(uint32_t int_flag);
|
||||
|
||||
#endif /* GD32F4XX_DCI_H */
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_dma.h
|
||||
\brief definitions for the DMA
|
||||
\file gd32f4xx_dma.c
|
||||
\brief definitions for the DMA
|
||||
|
||||
\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_DMA_H
|
||||
@@ -123,10 +148,10 @@
|
||||
#define DMA_CHXPADDR_PADDR BITS(0,31) /*!< peripheral base address */
|
||||
|
||||
/* DMA_CHxM0ADDR,x=0..7 */
|
||||
#define DMA_CHXM0ADDR_PADDR BITS(0,31) /*!< memory 0 base address */
|
||||
#define DMA_CHXM0ADDR_M0ADDR BITS(0,31) /*!< memory 0 base address */
|
||||
|
||||
/* DMA_CHxM1ADDR,x=0..7 */
|
||||
#define DMA_CHXM1ADDR_PADDR BITS(0,31) /*!< memory 1 base address */
|
||||
#define DMA_CHXM1ADDR_M0ADDR BITS(0,31) /*!< memory 1 base address */
|
||||
|
||||
/* DMA_CHxFCTL,x=0..7 */
|
||||
#define DMA_CHXFCTL_FCCV BITS(0,1) /*!< FIFO counter critical value */
|
||||
@@ -136,7 +161,7 @@
|
||||
|
||||
/* constants definitions */
|
||||
/* DMA channel select */
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
DMA_CH0 = 0, /*!< DMA Channel 0 */
|
||||
DMA_CH1, /*!< DMA Channel 1 */
|
||||
@@ -149,7 +174,7 @@ typedef enum
|
||||
} dma_channel_enum;
|
||||
|
||||
/* DMA peripheral select */
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
DMA_SUBPERI0 = 0, /*!< DMA Peripheral 0 */
|
||||
DMA_SUBPERI1, /*!< DMA Peripheral 1 */
|
||||
@@ -166,7 +191,7 @@ typedef struct
|
||||
{
|
||||
uint32_t periph_addr; /*!< peripheral base address */
|
||||
uint32_t periph_width; /*!< transfer data size of peripheral */
|
||||
uint32_t periph_inc; /*!< peripheral increasing mode */
|
||||
uint32_t periph_inc; /*!< peripheral increasing mode */
|
||||
|
||||
uint32_t memory0_addr; /*!< memory 0 base address */
|
||||
uint32_t memory_width; /*!< transfer data size of memory */
|
||||
@@ -176,7 +201,7 @@ typedef struct
|
||||
uint32_t periph_burst_width; /*!< multi data mode enable */
|
||||
uint32_t critical_value; /*!< FIFO critical */
|
||||
|
||||
uint32_t circular_mode;
|
||||
uint32_t circular_mode; /*!< DMA circular mode */
|
||||
uint32_t direction; /*!< channel data transfer direction */
|
||||
uint32_t number; /*!< channel transfer number */
|
||||
uint32_t priority; /*!< channel priority level */
|
||||
@@ -186,7 +211,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
uint32_t periph_addr; /*!< peripheral base address */
|
||||
uint32_t periph_inc; /*!< peripheral increasing mode */
|
||||
uint32_t periph_inc; /*!< peripheral increasing mode */
|
||||
|
||||
uint32_t memory0_addr; /*!< memory 0 base address */
|
||||
uint32_t memory_inc; /*!< memory increasing mode */
|
||||
@@ -296,85 +321,108 @@ typedef struct
|
||||
#define DMA_FIFO_STATUS_FULL ((uint32_t)0x00000005U) /*!< the data in the FIFO is full */
|
||||
|
||||
/* DMA reset value */
|
||||
#define DMA_CHCTL_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXCTL register */
|
||||
#define DMA_CHCNT_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXCNT register */
|
||||
#define DMA_CHPADDR_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXPADDR register */
|
||||
#define DMA_CHMADDR_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXMADDR register */
|
||||
#define DMA_CHINTF_RESET_VALUE ((uint32_t)0x0000003DU) /*!< clear DMA channel CHXINTFS register */
|
||||
#define DMA_CHFCTL_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXFCTL register */
|
||||
#define DMA_CHCTL_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXCTL register */
|
||||
#define DMA_CHCNT_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXCNT register */
|
||||
#define DMA_CHPADDR_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXPADDR register */
|
||||
#define DMA_CHMADDR_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXMADDR register */
|
||||
#define DMA_CHINTF_RESET_VALUE ((uint32_t)0x0000003DU) /*!< clear DMA channel CHXINTFS register */
|
||||
#define DMA_CHFCTL_RESET_VALUE ((uint32_t)0x00000000U) /*!< the reset value of DMA channel CHXFCTL register */
|
||||
|
||||
/* DMA_INTF register */
|
||||
/* interrupt flag bits */
|
||||
#define DMA_INT_FLAG_FEE DMA_INTF_FEEIF /*!< FIFO error and exception flag */
|
||||
#define DMA_INT_FLAG_SDE DMA_INTF_SDEIF /*!< single data mode exception flag */
|
||||
#define DMA_INT_FLAG_TAE DMA_INTF_TAEIF /*!< transfer access error flag */
|
||||
#define DMA_INT_FLAG_HTF DMA_INTF_HTFIF /*!< half transfer finish flag */
|
||||
#define DMA_INT_FLAG_FTF DMA_INTF_FTFIF /*!< full transfer finish flag */
|
||||
|
||||
/* flag bits */
|
||||
#define DMA_FLAG_FEE DMA_INTF_FEEIF /*!< FIFO error and exception flag */
|
||||
#define DMA_FLAG_SDE DMA_INTF_SDEIF /*!< single data mode exception flag */
|
||||
#define DMA_FLAG_TAE DMA_INTF_TAEIF /*!< transfer access error flag */
|
||||
#define DMA_FLAG_HTF DMA_INTF_HTFIF /*!< half transfer finish flag */
|
||||
#define DMA_FLAG_FTF DMA_INTF_FTFIF /*!< full transfer finish flag */
|
||||
|
||||
|
||||
/* function declarations */
|
||||
/* DMA deinitialization and initialization functions */
|
||||
/* deinitialize DMA a channel registers */
|
||||
void dma_deinit(uint32_t dma_periph,dma_channel_enum channelx);
|
||||
void dma_deinit(uint32_t dma_periph, dma_channel_enum channelx);
|
||||
/* initialize the DMA single data mode parameters struct with the default values */
|
||||
void dma_single_data_para_struct_init(dma_single_data_parameter_struct* init_struct);
|
||||
/* initialize the DMA multi data mode parameters struct with the default values */
|
||||
void dma_multi_data_para_struct_init(dma_multi_data_parameter_struct* init_struct);
|
||||
/* DMA single data mode initialize */
|
||||
void dma_single_data_mode_init(uint32_t dma_periph,dma_channel_enum channelx,dma_single_data_parameter_struct init_struct);
|
||||
void dma_single_data_mode_init(uint32_t dma_periph, dma_channel_enum channelx, dma_single_data_parameter_struct* init_struct);
|
||||
/* DMA multi data mode initialize */
|
||||
void dma_multi_data_mode_init(uint32_t dma_periph,dma_channel_enum channelx,dma_multi_data_parameter_struct init_struct);
|
||||
void dma_multi_data_mode_init(uint32_t dma_periph, dma_channel_enum channelx, dma_multi_data_parameter_struct* init_struct);
|
||||
|
||||
/* DMA configuration functions */
|
||||
/* set DMA peripheral base address */
|
||||
void dma_periph_address_config(uint32_t dma_periph,dma_channel_enum channelx,uint32_t address);
|
||||
void dma_periph_address_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t address);
|
||||
/* set DMA Memory base address */
|
||||
void dma_memory_address_config(uint32_t dma_periph,dma_channel_enum channelx,uint8_t memory_flag,uint32_t address);
|
||||
void dma_memory_address_config(uint32_t dma_periph, dma_channel_enum channelx, uint8_t memory_flag, uint32_t address);
|
||||
|
||||
/* set the number of remaining data to be transferred by the DMA */
|
||||
void dma_transfer_number_config(uint32_t dma_periph,dma_channel_enum channelx,uint32_t number);
|
||||
void dma_transfer_number_config(uint32_t dma_periph,dma_channel_enum channelx, uint32_t number);
|
||||
/* get the number of remaining data to be transferred by the DMA */
|
||||
uint32_t dma_transfer_number_get(uint32_t dma_periph,dma_channel_enum channelx);
|
||||
uint32_t dma_transfer_number_get(uint32_t dma_periph, dma_channel_enum channelx);
|
||||
|
||||
/* configure priority level of DMA channel */
|
||||
void dma_priority_config(uint32_t dma_periph,dma_channel_enum channelx,uint32_t priority);
|
||||
void dma_priority_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t priority);
|
||||
|
||||
/* configure transfer burst beats of memory */
|
||||
void dma_memory_burst_beats_config (uint32_t dma_periph,dma_channel_enum channelx,uint32_t mbeat);
|
||||
void dma_memory_burst_beats_config (uint32_t dma_periph, dma_channel_enum channelx, uint32_t mbeat);
|
||||
/* configure transfer burst beats of peripheral */
|
||||
void dma_periph_burst_beats_config (uint32_t dma_periph,dma_channel_enum channelx,uint32_t pbeat);
|
||||
void dma_periph_burst_beats_config (uint32_t dma_periph, dma_channel_enum channelx, uint32_t pbeat);
|
||||
/* configure transfer data size of memory */
|
||||
void dma_memory_width_config (uint32_t dma_periph,dma_channel_enum channelx,uint32_t msize);
|
||||
void dma_memory_width_config (uint32_t dma_periph, dma_channel_enum channelx, uint32_t msize);
|
||||
/* configure transfer data size of peripheral */
|
||||
void dma_periph_width_config (uint32_t dma_periph,dma_channel_enum channelx,uint32_t psize);
|
||||
void dma_periph_width_config (uint32_t dma_periph, dma_channel_enum channelx, uint32_t psize);
|
||||
|
||||
/* configure next address increasement algorithm of memory */
|
||||
void dma_memory_address_generation_config(uint32_t dma_periph,dma_channel_enum channelx,uint8_t generation_algorithm);
|
||||
void dma_memory_address_generation_config(uint32_t dma_periph, dma_channel_enum channelx, uint8_t generation_algorithm);
|
||||
/* configure next address increasement algorithm of peripheral */
|
||||
void dma_peripheral_address_generation_config(uint32_t dma_periph,dma_channel_enum channelx,uint8_t generation_algorithm);
|
||||
void dma_peripheral_address_generation_config(uint32_t dma_periph, dma_channel_enum channelx, uint8_t generation_algorithm);
|
||||
|
||||
/* enable DMA circulation mode */
|
||||
void dma_circulation_enable(uint32_t dma_periph,dma_channel_enum channelx);
|
||||
void dma_circulation_enable(uint32_t dma_periph, dma_channel_enum channelx);
|
||||
/* disable DMA circulation mode */
|
||||
void dma_circulation_disable(uint32_t dma_periph,dma_channel_enum channelx);
|
||||
void dma_circulation_disable(uint32_t dma_periph, dma_channel_enum channelx);
|
||||
/* enable DMA channel */
|
||||
void dma_channel_enable(uint32_t dma_periph,dma_channel_enum channelx);
|
||||
void dma_channel_enable(uint32_t dma_periph, dma_channel_enum channelx);
|
||||
/* disable DMA channel */
|
||||
void dma_channel_disable(uint32_t dma_periph,dma_channel_enum channelx);
|
||||
void dma_channel_disable(uint32_t dma_periph, dma_channel_enum channelx);
|
||||
|
||||
/* configure the direction of data transfer on the channel */
|
||||
void dma_transfer_direction_config(uint32_t dma_periph,dma_channel_enum channelx,uint8_t direction);
|
||||
void dma_transfer_direction_config(uint32_t dma_periph, dma_channel_enum channelx, uint8_t direction);
|
||||
|
||||
/* DMA switch buffer mode config */
|
||||
void dma_switch_buffer_mode_config(uint32_t dma_periph,dma_channel_enum channelx,uint32_t memory1_addr,uint32_t memory_select);
|
||||
void dma_switch_buffer_mode_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t memory1_addr, uint32_t memory_select);
|
||||
/* DMA using memory get */
|
||||
uint32_t dma_using_memory_get(uint32_t dma_periph,dma_channel_enum channelx);
|
||||
uint32_t dma_using_memory_get(uint32_t dma_periph, dma_channel_enum channelx);
|
||||
|
||||
/* DMA channel peripheral select */
|
||||
void dma_channel_subperipheral_select(uint32_t dma_periph,dma_channel_enum channelx,dma_subperipheral_enum sub_periph);
|
||||
void dma_channel_subperipheral_select(uint32_t dma_periph, dma_channel_enum channelx, dma_subperipheral_enum sub_periph);
|
||||
/* DMA flow controller configure */
|
||||
void dma_flow_controller_config(uint32_t dma_periph,dma_channel_enum channelx,uint32_t controller);
|
||||
void dma_flow_controller_config(uint32_t dma_periph, dma_channel_enum channelx, uint32_t controller);
|
||||
/* DMA flow controller enable */
|
||||
void dma_switch_buffer_mode_enable(uint32_t dma_periph,dma_channel_enum channelx,ControlStatus newvalue);
|
||||
void dma_switch_buffer_mode_enable(uint32_t dma_periph, dma_channel_enum channelx, ControlStatus newvalue);
|
||||
/* DMA FIFO status get */
|
||||
uint32_t dma_fifo_status_get(uint32_t dma_periph,dma_channel_enum channelx);
|
||||
uint32_t dma_fifo_status_get(uint32_t dma_periph, dma_channel_enum channelx);
|
||||
|
||||
/* flag and interrupt functions */
|
||||
/* check DMA flag is set or not */
|
||||
FlagStatus dma_flag_get(uint32_t dma_periph,dma_channel_enum channelx,uint32_t flag);
|
||||
FlagStatus dma_flag_get(uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag);
|
||||
/* clear DMA a channel flag */
|
||||
void dma_flag_clear(uint32_t dma_periph,dma_channel_enum channelx,uint32_t flag);
|
||||
void dma_flag_clear(uint32_t dma_periph, dma_channel_enum channelx, uint32_t flag);
|
||||
/* check DMA flag is set or not */
|
||||
FlagStatus dma_interrupt_flag_get(uint32_t dma_periph,dma_channel_enum channelx,uint32_t interrupt);
|
||||
FlagStatus dma_interrupt_flag_get(uint32_t dma_periph, dma_channel_enum channelx, uint32_t interrupt);
|
||||
/* clear DMA a channel flag */
|
||||
void dma_interrupt_flag_clear(uint32_t dma_periph,dma_channel_enum channelx,uint32_t interrupt);
|
||||
void dma_interrupt_flag_clear(uint32_t dma_periph, dma_channel_enum channelx, uint32_t interrupt);
|
||||
/* enable DMA interrupt */
|
||||
void dma_interrupt_enable(uint32_t dma_periph,dma_channel_enum channelx,uint32_t source);
|
||||
void dma_interrupt_enable(uint32_t dma_periph, dma_channel_enum channelx, uint32_t source);
|
||||
/* disable DMA interrupt */
|
||||
void dma_interrupt_disable(uint32_t dma_periph,dma_channel_enum channelx,uint32_t source);
|
||||
void dma_interrupt_disable(uint32_t dma_periph, dma_channel_enum channelx, uint32_t source);
|
||||
|
||||
#endif /* GD32F4XX_DMA_H */
|
||||
|
||||
+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 */
|
||||
|
||||
@@ -1,13 +1,40 @@
|
||||
/*!
|
||||
\file gd32f4xx_fmc.h
|
||||
\brief definitions for the FMC
|
||||
\file gd32f4xx_fmc.h
|
||||
\brief definitions for the FMC
|
||||
|
||||
\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_FMC_H
|
||||
#define GD32F4XX_FMC_H
|
||||
|
||||
@@ -18,15 +45,15 @@
|
||||
#define OB OB_BASE /*!< option byte base address */
|
||||
|
||||
/* registers definitions */
|
||||
#define FMC_WS REG32((FMC) + 0x00U) /*!< FMC wait state register */
|
||||
#define FMC_KEY REG32((FMC) + 0x04U) /*!< FMC unlock key register */
|
||||
#define FMC_OBKEY REG32((FMC) + 0x08U) /*!< FMC option byte unlock key register */
|
||||
#define FMC_STAT REG32((FMC) + 0x0CU) /*!< FMC status register */
|
||||
#define FMC_CTL REG32((FMC) + 0x10U) /*!< FMC control register */
|
||||
#define FMC_OBCTL0 REG32((FMC) + 0x14U) /*!< FMC option byte control register 0 */
|
||||
#define FMC_OBCTL1 REG32((FMC) + 0x18U) /*!< FMC option byte control register 1 */
|
||||
#define FMC_WSEN REG32((FMC) + 0xFCU) /*!< FMC wait state enable register */
|
||||
#define FMC_PID REG32((FMC) + 0x100U) /*!< FMC product ID register */
|
||||
#define FMC_WS REG32((FMC) + 0x0000U) /*!< FMC wait state register */
|
||||
#define FMC_KEY REG32((FMC) + 0x0004U) /*!< FMC unlock key register */
|
||||
#define FMC_OBKEY REG32((FMC) + 0x0008U) /*!< FMC option byte unlock key register */
|
||||
#define FMC_STAT REG32((FMC) + 0x000CU) /*!< FMC status register */
|
||||
#define FMC_CTL REG32((FMC) + 0x0010U) /*!< FMC control register */
|
||||
#define FMC_OBCTL0 REG32((FMC) + 0x0014U) /*!< FMC option byte control register 0 */
|
||||
#define FMC_OBCTL1 REG32((FMC) + 0x0018U) /*!< FMC option byte control register 1 */
|
||||
#define FMC_WSEN REG32((FMC) + 0x00FCU) /*!< FMC wait state enable register */
|
||||
#define FMC_PID REG32((FMC) + 0x0100U) /*!< FMC product ID register */
|
||||
|
||||
#define OB_WP1 REG32((OB) + 0x00000008U) /*!< option byte write protection 1 */
|
||||
#define OB_USER REG32((OB) + 0x00010000U) /*!< option byte user value*/
|
||||
@@ -98,7 +125,6 @@ typedef enum
|
||||
FMC_WPERR, /*!< erase/program protection error */
|
||||
FMC_OPERR, /*!< operation error */
|
||||
FMC_PGERR, /*!< program error */
|
||||
FMC_TOERR /*!< timeout error */
|
||||
}fmc_state_enum;
|
||||
|
||||
/* unlock key */
|
||||
@@ -108,9 +134,6 @@ typedef enum
|
||||
#define OB_UNLOCK_KEY0 ((uint32_t)0x08192A3BU) /*!< ob unlock key 0 */
|
||||
#define OB_UNLOCK_KEY1 ((uint32_t)0x4C5D6E7FU) /*!< ob unlock key 1 */
|
||||
|
||||
/* FMC time out */
|
||||
#define FMC_TIMEOUT_COUNT ((uint32_t)0x000F0000) /*!< enable FMC error timeout */
|
||||
|
||||
/* option byte write protection */
|
||||
#define OB_LWP ((uint32_t)0x000000FFU) /*!< write protection low bits */
|
||||
#define OB_HWP ((uint32_t)0x0000FF00U) /*!< write protection high bits */
|
||||
@@ -146,7 +169,7 @@ typedef enum
|
||||
#define OB_BB_DISABLE OBCTL0_BB(0) /*!< boot from bank0 */
|
||||
#define OB_BB_ENABLE OBCTL0_BB(1) /*!< boot from bank1 or bank0 if bank1 is void */
|
||||
|
||||
/* option byte software/hardware free watch dog timer */
|
||||
/* option byte software/hardware free watch dog timer */
|
||||
#define OBCTL0_NWDG_HW(regval) (BIT(5) & ((uint32_t)(regval))<< 5)
|
||||
#define OB_FWDGT_SW OBCTL0_NWDG_HW(1) /*!< software free watchdog */
|
||||
#define OB_FWDGT_HW OBCTL0_NWDG_HW(0) /*!< hardware free watchdog */
|
||||
@@ -179,19 +202,19 @@ typedef enum
|
||||
#define OB_WP_9 ((uint32_t)0x00000200U) /*!< erase/program protection of sector 9 */
|
||||
#define OB_WP_10 ((uint32_t)0x00000400U) /*!< erase/program protection of sector 10 */
|
||||
#define OB_WP_11 ((uint32_t)0x00000800U) /*!< erase/program protection of sector 11 */
|
||||
#define OB_WP_12 ((uint32_t)0x00000001U) /*!< erase/program protection of sector 12 */
|
||||
#define OB_WP_13 ((uint32_t)0x00000002U) /*!< erase/program protection of sector 13 */
|
||||
#define OB_WP_14 ((uint32_t)0x00000004U) /*!< erase/program protection of sector 14 */
|
||||
#define OB_WP_15 ((uint32_t)0x00000008U) /*!< erase/program protection of sector 15 */
|
||||
#define OB_WP_16 ((uint32_t)0x00000010U) /*!< erase/program protection of sector 16 */
|
||||
#define OB_WP_17 ((uint32_t)0x00000020U) /*!< erase/program protection of sector 17 */
|
||||
#define OB_WP_18 ((uint32_t)0x00000040U) /*!< erase/program protection of sector 18 */
|
||||
#define OB_WP_19 ((uint32_t)0x00000080U) /*!< erase/program protection of sector 19 */
|
||||
#define OB_WP_20 ((uint32_t)0x00000100U) /*!< erase/program protection of sector 20 */
|
||||
#define OB_WP_21 ((uint32_t)0x00000200U) /*!< erase/program protection of sector 21 */
|
||||
#define OB_WP_22 ((uint32_t)0x00000400U) /*!< erase/program protection of sector 22 */
|
||||
#define OB_WP_23_30 ((uint32_t)0x00000800U) /*!< erase/program protection of sector 23~30 */
|
||||
#define OB_WP_ALL ((uint32_t)0x00000FFFU) /*!< erase/program protection of all sectors */
|
||||
#define OB_WP_12 ((uint32_t)0x00010000U) /*!< erase/program protection of sector 12 */
|
||||
#define OB_WP_13 ((uint32_t)0x00020000U) /*!< erase/program protection of sector 13 */
|
||||
#define OB_WP_14 ((uint32_t)0x00040000U) /*!< erase/program protection of sector 14 */
|
||||
#define OB_WP_15 ((uint32_t)0x00080000U) /*!< erase/program protection of sector 15 */
|
||||
#define OB_WP_16 ((uint32_t)0x00100000U) /*!< erase/program protection of sector 16 */
|
||||
#define OB_WP_17 ((uint32_t)0x00200000U) /*!< erase/program protection of sector 17 */
|
||||
#define OB_WP_18 ((uint32_t)0x00400000U) /*!< erase/program protection of sector 18 */
|
||||
#define OB_WP_19 ((uint32_t)0x00800000U) /*!< erase/program protection of sector 19 */
|
||||
#define OB_WP_20 ((uint32_t)0x01000000U) /*!< erase/program protection of sector 20 */
|
||||
#define OB_WP_21 ((uint32_t)0x02000000U) /*!< erase/program protection of sector 21 */
|
||||
#define OB_WP_22 ((uint32_t)0x04000000U) /*!< erase/program protection of sector 22 */
|
||||
#define OB_WP_23_27 ((uint32_t)0x08000000U) /*!< erase/program protection of sector 23~27 */
|
||||
#define OB_WP_ALL ((uint32_t)0x0FFF0FFFU) /*!< erase/program protection of all sectors */
|
||||
|
||||
/* option bytes D-bus read protection */
|
||||
#define OB_DRP_0 ((uint32_t)0x00000001U) /*!< D-bus read protection protection of sector 0 */
|
||||
@@ -206,26 +229,25 @@ typedef enum
|
||||
#define OB_DRP_9 ((uint32_t)0x00000200U) /*!< D-bus read protection protection of sector 9 */
|
||||
#define OB_DRP_10 ((uint32_t)0x00000400U) /*!< D-bus read protection protection of sector 10 */
|
||||
#define OB_DRP_11 ((uint32_t)0x00000800U) /*!< D-bus read protection protection of sector 11 */
|
||||
#define OB_DRP_12 ((uint32_t)0x00000001U) /*!< D-bus read protection protection of sector 12 */
|
||||
#define OB_DRP_13 ((uint32_t)0x00000002U) /*!< D-bus read protection protection of sector 13 */
|
||||
#define OB_DRP_14 ((uint32_t)0x00000004U) /*!< D-bus read protection protection of sector 14 */
|
||||
#define OB_DRP_15 ((uint32_t)0x00000008U) /*!< D-bus read protection protection of sector 15 */
|
||||
#define OB_DRP_16 ((uint32_t)0x00000010U) /*!< D-bus read protection protection of sector 16 */
|
||||
#define OB_DRP_17 ((uint32_t)0x00000020U) /*!< D-bus read protection protection of sector 17 */
|
||||
#define OB_DRP_18 ((uint32_t)0x00000040U) /*!< D-bus read protection protection of sector 18 */
|
||||
#define OB_DRP_19 ((uint32_t)0x00000080U) /*!< D-bus read protection protection of sector 19 */
|
||||
#define OB_DRP_20 ((uint32_t)0x00000100U) /*!< D-bus read protection protection of sector 20 */
|
||||
#define OB_DRP_21 ((uint32_t)0x00000200U) /*!< D-bus read protection protection of sector 21 */
|
||||
#define OB_DRP_22 ((uint32_t)0x00000400U) /*!< D-bus read protection protection of sector 22 */
|
||||
#define OB_DRP_23_30 ((uint32_t)0x00000800U) /*!< D-bus read protection protection of sector 23~30 */
|
||||
#define OB_DRP_ALL ((uint32_t)0x00000FFFU) /*!< D-bus read protection protection of all sectors */
|
||||
#define OB_DRP_12 ((uint32_t)0x00010000U) /*!< D-bus read protection protection of sector 12 */
|
||||
#define OB_DRP_13 ((uint32_t)0x00020000U) /*!< D-bus read protection protection of sector 13 */
|
||||
#define OB_DRP_14 ((uint32_t)0x00040000U) /*!< D-bus read protection protection of sector 14 */
|
||||
#define OB_DRP_15 ((uint32_t)0x00080000U) /*!< D-bus read protection protection of sector 15 */
|
||||
#define OB_DRP_16 ((uint32_t)0x00100000U) /*!< D-bus read protection protection of sector 16 */
|
||||
#define OB_DRP_17 ((uint32_t)0x00200000U) /*!< D-bus read protection protection of sector 17 */
|
||||
#define OB_DRP_18 ((uint32_t)0x00400000U) /*!< D-bus read protection protection of sector 18 */
|
||||
#define OB_DRP_19 ((uint32_t)0x00800000U) /*!< D-bus read protection protection of sector 19 */
|
||||
#define OB_DRP_20 ((uint32_t)0x01000000U) /*!< D-bus read protection protection of sector 20 */
|
||||
#define OB_DRP_21 ((uint32_t)0x02000000U) /*!< D-bus read protection protection of sector 21 */
|
||||
#define OB_DRP_22 ((uint32_t)0x04000000U) /*!< D-bus read protection protection of sector 22 */
|
||||
#define OB_DRP_23_27 ((uint32_t)0x08000000U) /*!< D-bus read protection protection of sector 23~27 */
|
||||
|
||||
/* double banks or single bank selection when flash size is 1M bytes */
|
||||
/* double banks or single bank selection when flash size is 1M bytes */
|
||||
#define OBCTL0_DBS(regval) (BIT(30) & ((uint32_t)(regval)<<30))
|
||||
#define OB_DBS_DISABLE OBCTL0_DBS(0) /*!< single bank when flash size is 1M bytes */
|
||||
#define OB_DBS_ENABLE OBCTL0_DBS(1) /*!< double bank when flash size is 1M bytes */
|
||||
|
||||
/* option bytes D-bus read protection mode */
|
||||
/* option bytes D-bus read protection mode */
|
||||
#define OBCTL0_DRP(regval) (BIT(31) & ((uint32_t)(regval)<<31))
|
||||
#define OB_DRP_DISABLE OBCTL0_DRP(0) /*!< the WPx bits used as erase/program protection of each sector */
|
||||
#define OB_DRP_ENABLE OBCTL0_DRP(1) /*!< the WPx bits used as erase/program protection and D-bus read protection of each sector */
|
||||
@@ -260,19 +282,17 @@ typedef enum
|
||||
#define CTL_SECTOR_NUMBER_21 CTL_SN(25) /*!< sector 21 */
|
||||
#define CTL_SECTOR_NUMBER_22 CTL_SN(26) /*!< sector 22 */
|
||||
#define CTL_SECTOR_NUMBER_23 CTL_SN(27) /*!< sector 23 */
|
||||
#define CTL_SECTOR_NUMBER_28 CTL_SN(28) /*!< sector 28 */
|
||||
#define CTL_SECTOR_NUMBER_29 CTL_SN(29) /*!< sector 29 */
|
||||
#define CTL_SECTOR_NUMBER_30 CTL_SN(30) /*!< sector 30 */
|
||||
|
||||
/* FMC program size */
|
||||
|
||||
/* FMC program size */
|
||||
#define CTL_PSZ(regval) (BITS(8,9) & ((uint32_t)(regval))<< 8)
|
||||
#define CTL_PSZ_BYTE CTL_PSZ(0) /*!< FMC program by byte access */
|
||||
#define CTL_PSZ_HALF_WORD CTL_PSZ(1) /*!< FMC program by half-word access */
|
||||
#define CTL_PSZ_WORD CTL_PSZ(2) /*!< FMC program by word access */
|
||||
|
||||
/* FMC interrupt enable */
|
||||
#define FMC_INTEN_END ((uint32_t)0x01000000U) /*!< enable FMC end of program interrupt */
|
||||
#define FMC_INTEN_ERR ((uint32_t)0x02000000U) /*!< enable FMC error interrupt */
|
||||
#define FMC_INT_END ((uint32_t)0x01000000U) /*!< enable FMC end of program interrupt */
|
||||
#define FMC_INT_ERR ((uint32_t)0x02000000U) /*!< enable FMC error interrupt */
|
||||
|
||||
/* FMC flags */
|
||||
#define FMC_FLAG_END ((uint32_t)0x00000001U) /*!< FMC end of operation flag bit */
|
||||
@@ -281,7 +301,7 @@ typedef enum
|
||||
#define FMC_FLAG_PGMERR ((uint32_t)0x00000040U) /*!< FMC program size not match error flag bit */
|
||||
#define FMC_FLAG_PGSERR ((uint32_t)0x00000080U) /*!< FMC program sequence error flag bit */
|
||||
#define FMC_FLAG_RDDERR ((uint32_t)0x00000100U) /*!< FMC read D-bus protection error flag bit */
|
||||
#define FMC_FLAG_BUSY ((uint32_t)0x00010000U) /*!< FMC busy flag */
|
||||
#define FMC_FLAG_BUSY ((uint32_t)0x00010000U) /*!< FMC busy flag */
|
||||
|
||||
/* function declarations */
|
||||
/* FMC main memory programming functions */
|
||||
@@ -313,25 +333,17 @@ void ob_unlock(void);
|
||||
void ob_lock(void);
|
||||
/* send option byte change command */
|
||||
void ob_start(void);
|
||||
/* erase option byte */
|
||||
void ob_erase(void);
|
||||
/* enable write protect */
|
||||
void ob_write_protection0_enable(uint32_t ob_wp);
|
||||
void ob_write_protection_enable(uint32_t ob_wp);
|
||||
/* disable write protect */
|
||||
void ob_write_protection0_disable(uint32_t ob_wp);
|
||||
/* enable write protect */
|
||||
void ob_write_protection1_enable(uint32_t ob_wp);
|
||||
/* disable write protect */
|
||||
void ob_write_protection1_disable(uint32_t ob_wp);
|
||||
/* configure the erase/program protection mode */
|
||||
void ob_drp_config(uint32_t ob_drp);
|
||||
/* enable the erase/program protection mode */
|
||||
void ob_drp0_enable(uint32_t ob_drp);
|
||||
/* disable the erase/program protection mode */
|
||||
void ob_drp0_disable(uint32_t ob_drp);
|
||||
/* enable the erase/program protection mode */
|
||||
void ob_drp1_enable(uint32_t ob_drp);
|
||||
/* disable the erase/program protection mode */
|
||||
void ob_drp1_disable(uint32_t ob_drp);
|
||||
/* set the option byte security protection level */
|
||||
void ob_write_protection_disable(uint32_t ob_wp);
|
||||
/* enable erase/program protection and D-bus read protection */
|
||||
void ob_drp_enable(uint32_t ob_drp);
|
||||
/* disable erase/program protection and D-bus read protection */
|
||||
void ob_drp_disable(uint32_t ob_drp);
|
||||
/* set the option byte security protection level */
|
||||
void ob_security_protection_config(uint8_t ob_spc);
|
||||
/* write the FMC option byte user */
|
||||
void ob_user_write(uint32_t ob_fwdgt, uint32_t ob_deepsleep, uint32_t ob_stdby);
|
||||
@@ -366,6 +378,6 @@ void fmc_flag_clear(uint32_t fmc_flag);
|
||||
/* return the FMC state */
|
||||
fmc_state_enum fmc_state_get(void);
|
||||
/* check FMC ready or not */
|
||||
fmc_state_enum fmc_ready_wait(uint32_t count);
|
||||
fmc_state_enum fmc_ready_wait(void);
|
||||
|
||||
#endif /* GD32F4XX_FMC_H */
|
||||
|
||||
@@ -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
@@ -1,29 +1,56 @@
|
||||
/*!
|
||||
\file gd32f4xx_i2c.h
|
||||
\brief definitions for the I2C
|
||||
\file gd32f4xx_i2c.h
|
||||
\brief definitions for the I2C
|
||||
|
||||
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
|
||||
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
|
||||
\version 2019-04-16, 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_I2C_H
|
||||
#define GD32F4XX_I2C_H
|
||||
|
||||
#include "gd32f4xx.h"
|
||||
|
||||
/* I2Cx(x=0,1,2) definitions */
|
||||
#define I2C0 I2C_BASE
|
||||
#define I2C1 (I2C_BASE+0x400U)
|
||||
#define I2C2 (I2C_BASE+0x800U)
|
||||
#define I2C0 I2C_BASE /*!< I2C0 base address */
|
||||
#define I2C1 (I2C_BASE+0x400U) /*!< I2C1 base address */
|
||||
#define I2C2 (I2C_BASE+0x800U) /*!< I2C2 base address */
|
||||
|
||||
/* registers definitions */
|
||||
#define I2C_CTL0(i2cx) REG32((i2cx) + 0x00U) /*!< I2C control register 0 */
|
||||
#define I2C_CTL1(i2cx) REG32((i2cx) + 0x04U) /*!< I2C control register 1 */
|
||||
#define I2C_SADDR0(i2cx) REG32((i2cx) + 0x08U) /*!< I2C slave address register 0*/
|
||||
#define I2C_SADDR1(i2cx) REG32((i2cx) + 0x0CU) /*!< I2C slave address register */
|
||||
#define I2C_SADDR0(i2cx) REG32((i2cx) + 0x08U) /*!< I2C slave address register 0 */
|
||||
#define I2C_SADDR1(i2cx) REG32((i2cx) + 0x0CU) /*!< I2C slave address register 1 */
|
||||
#define I2C_DATA(i2cx) REG32((i2cx) + 0x10U) /*!< I2C transfer buffer register */
|
||||
#define I2C_STAT0(i2cx) REG32((i2cx) + 0x14U) /*!< I2C transfer status register 0 */
|
||||
#define I2C_STAT1(i2cx) REG32((i2cx) + 0x18U) /*!< I2C transfer status register */
|
||||
@@ -32,7 +59,6 @@
|
||||
#define I2C_FCTL(i2cx) REG32((i2cx) + 0x24U) /*!< I2C filter control register */
|
||||
#define I2C_SAMCS(i2cx) REG32((i2cx) + 0x80U) /*!< I2C SAM control and status register */
|
||||
|
||||
|
||||
/* bits definitions */
|
||||
/* I2Cx_CTL0 */
|
||||
#define I2C_CTL0_I2CEN BIT(0) /*!< peripheral enable */
|
||||
@@ -41,7 +67,7 @@
|
||||
#define I2C_CTL0_ARPEN BIT(4) /*!< ARP enable */
|
||||
#define I2C_CTL0_PECEN BIT(5) /*!< PEC enable */
|
||||
#define I2C_CTL0_GCEN BIT(6) /*!< general call enable */
|
||||
#define I2C_CTL0_DISSTRC BIT(7) /*!< clock stretching disable (slave mode) */
|
||||
#define I2C_CTL0_SS BIT(7) /*!< clock stretching disable (slave mode) */
|
||||
#define I2C_CTL0_START BIT(8) /*!< start generation */
|
||||
#define I2C_CTL0_STOP BIT(9) /*!< stop generation */
|
||||
#define I2C_CTL0_ACKEN BIT(10) /*!< acknowledge enable */
|
||||
@@ -52,7 +78,7 @@
|
||||
|
||||
/* I2Cx_CTL1 */
|
||||
#define I2C_CTL1_I2CCLK BITS(0,5) /*!< I2CCLK[5:0] bits (peripheral clock frequency) */
|
||||
#define I2C_CTL1_ERRIE BIT(8) /*!< error interrupt inable */
|
||||
#define I2C_CTL1_ERRIE BIT(8) /*!< error interrupt enable */
|
||||
#define I2C_CTL1_EVIE BIT(9) /*!< event interrupt enable */
|
||||
#define I2C_CTL1_BUFIE BIT(10) /*!< buffer interrupt enable */
|
||||
#define I2C_CTL1_DMAON BIT(11) /*!< DMA requests enable */
|
||||
@@ -90,12 +116,12 @@
|
||||
/* I2Cx_STAT1 */
|
||||
#define I2C_STAT1_MASTER BIT(0) /*!< master/slave */
|
||||
#define I2C_STAT1_I2CBSY BIT(1) /*!< bus busy */
|
||||
#define I2C_STAT1_TRS BIT(2) /*!< transmitter/receiver */
|
||||
#define I2C_STAT1_TR BIT(2) /*!< transmitter/receiver */
|
||||
#define I2C_STAT1_RXGC BIT(4) /*!< general call address (slave mode) */
|
||||
#define I2C_STAT1_DEFSMB BIT(5) /*!< SMBus device default address (slave mode) */
|
||||
#define I2C_STAT1_HSTSMB BIT(6) /*!< SMBus host header (slave mode) */
|
||||
#define I2C_STAT1_DUMODF BIT(7) /*!< dual flag (slave mode) */
|
||||
#define I2C_STAT1_ECV BITS(8,15) /*!< packet error checking register */
|
||||
#define I2C_STAT1_PECV BITS(8,15) /*!< packet error checking value */
|
||||
|
||||
/* I2Cx_CKCFG */
|
||||
#define I2C_CKCFG_CLKC BITS(0,11) /*!< clock control register in fast/standard mode (master mode) */
|
||||
@@ -123,7 +149,6 @@
|
||||
#define I2C_SAMCS_RFF BIT(14) /*!< rxframe fall flag, cleared by software write 0 */
|
||||
#define I2C_SAMCS_RFR BIT(15) /*!< rxframe rise flag, cleared by software write 0 */
|
||||
|
||||
|
||||
/* constants definitions */
|
||||
|
||||
/* the digital noise filter can filter spikes's length */
|
||||
@@ -146,6 +171,94 @@ typedef enum {
|
||||
I2C_DF_15PCLKS /*!< enable digital noise filter and the maximum filtered spiker's length 15 PCLK1 */
|
||||
}i2c_digital_filter_enum;
|
||||
|
||||
/* constants definitions */
|
||||
/* define the I2C bit position and its register index offset */
|
||||
#define I2C_REGIDX_BIT(regidx, bitpos) (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos))
|
||||
#define I2C_REG_VAL(i2cx, offset) (REG32((i2cx) + (((uint32_t)(offset) & 0xFFFFU) >> 6)))
|
||||
#define I2C_BIT_POS(val) ((uint32_t)(val) & 0x1FU)
|
||||
#define I2C_REGIDX_BIT2(regidx, bitpos, regidx2, bitpos2) (((uint32_t)(regidx2) << 22) | (uint32_t)((bitpos2) << 16)\
|
||||
| (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos)))
|
||||
#define I2C_REG_VAL2(i2cx, offset) (REG32((i2cx) + ((uint32_t)(offset) >> 22)))
|
||||
#define I2C_BIT_POS2(val) (((uint32_t)(val) & 0x1F0000U) >> 16)
|
||||
|
||||
/* register offset */
|
||||
#define I2C_CTL1_REG_OFFSET 0x04U /*!< CTL1 register offset */
|
||||
#define I2C_STAT0_REG_OFFSET 0x14U /*!< STAT0 register offset */
|
||||
#define I2C_STAT1_REG_OFFSET 0x18U /*!< STAT1 register offset */
|
||||
#define I2C_SAMCS_REG_OFFSET 0x80U /*!< SAMCS register offset */
|
||||
|
||||
/* I2C flags */
|
||||
typedef enum
|
||||
{
|
||||
/* flags in STAT0 register */
|
||||
I2C_FLAG_SBSEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 0U), /*!< start condition sent out in master mode */
|
||||
I2C_FLAG_ADDSEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 1U), /*!< address is sent in master mode or received and matches in slave mode */
|
||||
I2C_FLAG_BTC = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 2U), /*!< byte transmission finishes */
|
||||
I2C_FLAG_ADD10SEND = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 3U), /*!< header of 10-bit address is sent in master mode */
|
||||
I2C_FLAG_STPDET = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 4U), /*!< stop condition detected in slave mode */
|
||||
I2C_FLAG_RBNE = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 6U), /*!< I2C_DATA is not Empty during receiving */
|
||||
I2C_FLAG_TBE = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 7U), /*!< I2C_DATA is empty during transmitting */
|
||||
I2C_FLAG_BERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 8U), /*!< a bus error occurs indication a unexpected start or stop condition on I2C bus */
|
||||
I2C_FLAG_LOSTARB = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 9U), /*!< arbitration lost in master mode */
|
||||
I2C_FLAG_AERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 10U), /*!< acknowledge error */
|
||||
I2C_FLAG_OUERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 11U), /*!< over-run or under-run situation occurs in slave mode */
|
||||
I2C_FLAG_PECERR = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 12U), /*!< PEC error when receiving data */
|
||||
I2C_FLAG_SMBTO = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 14U), /*!< timeout signal in SMBus mode */
|
||||
I2C_FLAG_SMBALT = I2C_REGIDX_BIT(I2C_STAT0_REG_OFFSET, 15U), /*!< SMBus alert status */
|
||||
/* flags in STAT1 register */
|
||||
I2C_FLAG_MASTER = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 0U), /*!< a flag indicating whether I2C block is in master or slave mode */
|
||||
I2C_FLAG_I2CBSY = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 1U), /*!< busy flag */
|
||||
I2C_FLAG_TRS = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 2U), /*!< whether the I2C is a transmitter or a receiver */
|
||||
I2C_FLAG_RXGC = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 4U), /*!< general call address (00h) received */
|
||||
I2C_FLAG_DEFSMB = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 5U), /*!< default address of SMBus device */
|
||||
I2C_FLAG_HSTSMB = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 6U), /*!< SMBus host header detected in slave mode */
|
||||
I2C_FLAG_DUMOD = I2C_REGIDX_BIT(I2C_STAT1_REG_OFFSET, 7U), /*!< dual flag in slave mode indicating which address is matched in dual-address mode */
|
||||
/* flags in SAMCS register */
|
||||
I2C_FLAG_TFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 12U), /*!< txframe fall flag */
|
||||
I2C_FLAG_TFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 13U), /*!< txframe rise flag */
|
||||
I2C_FLAG_RFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 14U), /*!< rxframe fall flag */
|
||||
I2C_FLAG_RFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 15U) /*!< rxframe rise flag */
|
||||
}i2c_flag_enum;
|
||||
|
||||
/* I2C interrupt flags */
|
||||
typedef enum
|
||||
{
|
||||
/* interrupt flags in CTL1 register */
|
||||
I2C_INT_FLAG_SBSEND = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 0U), /*!< start condition sent out in master mode interrupt flag */
|
||||
I2C_INT_FLAG_ADDSEND = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 1U), /*!< address is sent in master mode or received and matches in slave mode interrupt flag */
|
||||
I2C_INT_FLAG_BTC = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 2U), /*!< byte transmission finishes */
|
||||
I2C_INT_FLAG_ADD10SEND = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 3U), /*!< header of 10-bit address is sent in master mode interrupt flag */
|
||||
I2C_INT_FLAG_STPDET = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 4U), /*!< stop condition detected in slave mode interrupt flag */
|
||||
I2C_INT_FLAG_RBNE = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 6U), /*!< I2C_DATA is not Empty during receiving interrupt flag */
|
||||
I2C_INT_FLAG_TBE = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 9U, I2C_STAT0_REG_OFFSET, 7U), /*!< I2C_DATA is empty during transmitting interrupt flag */
|
||||
I2C_INT_FLAG_BERR = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 8U), /*!< a bus error occurs indication a unexpected start or stop condition on I2C bus interrupt flag */
|
||||
I2C_INT_FLAG_LOSTARB = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 9U), /*!< arbitration lost in master mode interrupt flag */
|
||||
I2C_INT_FLAG_AERR = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 10U), /*!< acknowledge error interrupt flag */
|
||||
I2C_INT_FLAG_OUERR = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 11U), /*!< over-run or under-run situation occurs in slave mode interrupt flag */
|
||||
I2C_INT_FLAG_PECERR = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 12U), /*!< PEC error when receiving data interrupt flag */
|
||||
I2C_INT_FLAG_SMBTO = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 14U), /*!< timeout signal in SMBus mode interrupt flag */
|
||||
I2C_INT_FLAG_SMBALT = I2C_REGIDX_BIT2(I2C_CTL1_REG_OFFSET, 8U, I2C_STAT0_REG_OFFSET, 15U), /*!< SMBus Alert status interrupt flag */
|
||||
/* interrupt flags in SAMCS register */
|
||||
I2C_INT_FLAG_TFF = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 4U, I2C_SAMCS_REG_OFFSET, 12U), /*!< txframe fall interrupt flag */
|
||||
I2C_INT_FLAG_TFR = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 5U, I2C_SAMCS_REG_OFFSET, 13U), /*!< txframe rise interrupt flag */
|
||||
I2C_INT_FLAG_RFF = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 6U, I2C_SAMCS_REG_OFFSET, 14U), /*!< rxframe fall interrupt flag */
|
||||
I2C_INT_FLAG_RFR = I2C_REGIDX_BIT2(I2C_SAMCS_REG_OFFSET, 7U, I2C_SAMCS_REG_OFFSET, 15U) /*!< rxframe rise interrupt flag */
|
||||
}i2c_interrupt_flag_enum;
|
||||
|
||||
/* I2C interrupt enable or disable */
|
||||
typedef enum
|
||||
{
|
||||
/* interrupt in CTL1 register */
|
||||
I2C_INT_ERR = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 8U), /*!< error interrupt enable */
|
||||
I2C_INT_EV = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 9U), /*!< event interrupt enable */
|
||||
I2C_INT_BUF = I2C_REGIDX_BIT(I2C_CTL1_REG_OFFSET, 10U), /*!< buffer interrupt enable */
|
||||
/* interrupt in SAMCS register */
|
||||
I2C_INT_TFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 4U), /*!< txframe fall interrupt enable */
|
||||
I2C_INT_TFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 5U), /*!< txframe rise interrupt enable */
|
||||
I2C_INT_RFF = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 6U), /*!< rxframe fall interrupt enable */
|
||||
I2C_INT_RFR = I2C_REGIDX_BIT(I2C_SAMCS_REG_OFFSET, 7U) /*!< rxframe rise interrupt enable */
|
||||
}i2c_interrupt_enum;
|
||||
|
||||
/* SMBus/I2C mode switch and SMBus type selection */
|
||||
#define I2C_I2CMODE_ENABLE ((uint32_t)0x00000000U) /*!< I2C mode */
|
||||
#define I2C_SMBUSMODE_ENABLE I2C_CTL0_SMBEN /*!< SMBus mode */
|
||||
@@ -153,27 +266,28 @@ typedef enum {
|
||||
/* SMBus/I2C mode switch and SMBus type selection */
|
||||
#define I2C_SMBUS_DEVICE ((uint32_t)0x00000000U) /*!< SMBus mode device type */
|
||||
#define I2C_SMBUS_HOST I2C_CTL0_SMBSEL /*!< SMBus mode host type */
|
||||
|
||||
/* I2C transfer direction */
|
||||
#define I2C_TRANSMITTER (~BIT(0)) /*!< transmitter */
|
||||
#define I2C_RECEIVER BIT(0) /*!< receiver */
|
||||
#define I2C_RECEIVER ((uint32_t)0x00000001U) /*!< receiver */
|
||||
#define I2C_TRANSMITTER ((uint32_t)0xFFFFFFFEU) /*!< transmitter */
|
||||
|
||||
/* whether or not to send an ACK */
|
||||
#define I2C_ACK_ENABLE ((uint8_t)0x01U) /*!< ACK will be sent */
|
||||
#define I2C_ACK_DISABLE ((uint8_t)0x00U) /*!< ACK will be not sent */
|
||||
#define I2C_ACK_DISABLE ((uint32_t)0x00000000U) /*!< ACK will be not sent */
|
||||
#define I2C_ACK_ENABLE ((uint32_t)0x00000001U) /*!< ACK will be sent */
|
||||
|
||||
/* I2C POAP position*/
|
||||
#define I2C_ACKPOS_CURRENT ((uint8_t)0x01U) /*!< ACKEN bit decides whether to send ACK or not for the current */
|
||||
#define I2C_ACKPOS_NEXT ((uint8_t)0x00U) /*!< ACKEN bit decides whether to send ACK or not for the next byte */
|
||||
#define I2C_ACKPOS_NEXT ((uint32_t)0x00000000U) /*!< ACKEN bit decides whether or not to send ACK for the next byte */
|
||||
#define I2C_ACKPOS_CURRENT ((uint32_t)0x00000001U) /*!< ACKEN bit decides whether or not to send ACK or not for the current byte */
|
||||
|
||||
/* I2C dual-address mode switch */
|
||||
#define I2C_DUADEN_DISABLE ((uint8_t)0x00U) /*!< dual-address mode disabled */
|
||||
#define I2C_DUADEN_ENABLE ((uint8_t)0x01U) /*!< dual-address mode enabled */
|
||||
#define I2C_DUADEN_DISABLE ((uint32_t)0x00000000U) /*!< dual-address mode disabled */
|
||||
#define I2C_DUADEN_ENABLE ((uint32_t)0x00000001U) /*!< dual-address mode enabled */
|
||||
|
||||
/* whether or not to stretch SCL low */
|
||||
#define I2C_SCLSTRETCH_ENABLE ((uint32_t)0x00000000U) /*!< SCL stretching is enabled */
|
||||
#define I2C_SCLSTRETCH_DISABLE I2C_CTL0_DISSTRC /*!< SCL stretching is disabled */
|
||||
#define I2C_SCLSTRETCH_DISABLE I2C_CTL0_SS /*!< SCL stretching is disabled */
|
||||
|
||||
/* whether or not to response to a General Call */
|
||||
/* whether or not to response to a general call */
|
||||
#define I2C_GCEN_ENABLE I2C_CTL0_GCEN /*!< slave will response to a general call */
|
||||
#define I2C_GCEN_DISABLE ((uint32_t)0x00000000U) /*!< slave will not response to a general call */
|
||||
|
||||
@@ -185,11 +299,11 @@ typedef enum {
|
||||
/* DMA mode switch */
|
||||
#define I2C_DMA_ON I2C_CTL1_DMAON /*!< DMA mode enabled */
|
||||
#define I2C_DMA_OFF ((uint32_t)0x00000000U) /*!< DMA mode disabled */
|
||||
|
||||
/* flag indicating DMA last transfer */
|
||||
#define I2C_DMALST_ON I2C_CTL1_DMALST /*!< next DMA EOT is the last transfer */
|
||||
#define I2C_DMALST_OFF ((uint32_t)0x00000000U) /*!< next DMA EOT is not the last transfer */
|
||||
|
||||
|
||||
/* I2C PEC configure */
|
||||
/* PEC enable */
|
||||
#define I2C_PEC_ENABLE I2C_CTL0_PECEN /*!< PEC calculation on */
|
||||
@@ -203,105 +317,78 @@ typedef enum {
|
||||
/* issue or not alert through SMBA pin */
|
||||
#define I2C_SALTSEND_ENABLE I2C_CTL0_SALT /*!< issue alert through SMBA pin */
|
||||
#define I2C_SALTSEND_DISABLE ((uint32_t)0x00000000U) /*!< not issue alert through SMBA */
|
||||
|
||||
/* ARP protocol in SMBus switch */
|
||||
#define I2C_ARP_ENABLE I2C_CTL0_ARPEN /*!< ARP is enabled */
|
||||
#define I2C_ARP_DISABLE ((uint32_t)0x00000000U) /*!< ARP is disabled */
|
||||
|
||||
/* I2C state */
|
||||
/* I2C bit state */
|
||||
#define I2C_SBSEND BIT(0) /*!< start condition sent out in master mode */
|
||||
#define I2C_ADDSEND BIT(1) /*!< address is sent in master mode or received and matches in slave mode */
|
||||
#define I2C_BTC BIT(2) /*!< byte transmission finishes */
|
||||
#define I2C_ADD10SEND BIT(3) /*!< header of 10-bit address is sent in master mode */
|
||||
#define I2C_STPDET BIT(4) /*!< etop condition detected in slave mode */
|
||||
#define I2C_RBNE BIT(6) /*!< I2C_DATA is not Empty during receiving */
|
||||
#define I2C_TBE BIT(7) /*!< I2C_DATA is empty during transmitting */
|
||||
#define I2C_BERR BIT(8) /*!< a bus error occurs indication a unexpected start or stop condition on I2C bus */
|
||||
#define I2C_LOSTARB BIT(9) /*!< arbitration lost in master mode */
|
||||
#define I2C_AERR BIT(10) /*!< acknowledge error */
|
||||
#define I2C_OUERR BIT(11) /*!< over-run or under-run situation occurs in slave mode */
|
||||
#define I2C_PECERR BIT(12) /*!< PEC error when receiving data */
|
||||
#define I2C_SMBTO BIT(14) /*!< timeout signal in SMBus mode */
|
||||
#define I2C_SMBALT BIT(15) /*!< SMBus alert status */
|
||||
#define I2C_MASTER (BIT(0)|BIT(31)) /*!< a flag indicating whether I2C block is in master or slave mode */
|
||||
#define I2C_I2CBSY (BIT(1)|BIT(31)) /*!< busy flag */
|
||||
#define I2C_TRS (BIT(2)|BIT(31)) /*!< whether the I2C is a transmitter or a receiver */
|
||||
#define I2C_RXGC (BIT(4)|BIT(31)) /*!< general call address (00h) received */
|
||||
#define I2C_DEFSMB (BIT(5)|BIT(31)) /*!< default address of SMBus device */
|
||||
#define I2C_HSTSMB (BIT(6)|BIT(31)) /*!< SMBus host header detected in slave mode */
|
||||
#define I2C_DUMODF (BIT(7)|BIT(31)) /*!< dual flag in slave mode indicating which address is matched in dual-address mode */
|
||||
/* transmit I2C data */
|
||||
#define DATA_TRANS(regval) (BITS(0,7) & ((uint32_t)(regval) << 0))
|
||||
|
||||
/* receive I2C data */
|
||||
#define DATA_RECV(regval) GET_BITS((uint32_t)(regval), 0, 7)
|
||||
|
||||
/* I2C duty cycle in fast mode */
|
||||
#define CKCFG_DTCY(regval) (BIT(14) & ((uint32_t)(regval) << 14))
|
||||
#define I2C_DTCY_2 CKCFG_DTCY(0) /*!< I2C fast mode Tlow/Thigh = 2 */
|
||||
#define I2C_DTCY_16_9 CKCFG_DTCY(1) /*!< I2C fast mode Tlow/Thigh = 16/9 */
|
||||
#define I2C_DTCY_2 ((uint32_t)0x00000000U) /*!< I2C fast mode Tlow/Thigh = 2 */
|
||||
#define I2C_DTCY_16_9 I2C_CKCFG_DTCY /*!< I2C fast mode Tlow/Thigh = 16/9 */
|
||||
|
||||
/* address mode for the I2C slave */
|
||||
#define SADDR0_ADDFORMAT(regval) (BIT(15) & ((regval) << 15))
|
||||
#define I2C_ADDFORMAT_7BITS SADDR0_ADDFORMAT(0) /*!< address:7 bits */
|
||||
#define I2C_ADDFORMAT_10BITS SADDR0_ADDFORMAT(1) /*!< address:10 bits */
|
||||
#define I2C_ADDFORMAT_7BITS ((uint32_t)0x00000000U) /*!< address:7 bits */
|
||||
#define I2C_ADDFORMAT_10BITS I2C_SADDR0_ADDFORMAT /*!< address:10 bits */
|
||||
|
||||
/* function declarations */
|
||||
/* reset I2C */
|
||||
void i2c_deinit(uint32_t i2c_periph);
|
||||
/* I2C clock configure */
|
||||
void i2c_clock_config(uint32_t i2c_periph,uint32_t clkspeed,uint32_t dutycyc);
|
||||
/* I2C address configure */
|
||||
void i2c_mode_addr_config(uint32_t i2c_periph,uint32_t i2cmod,uint32_t addformat,uint32_t addr);
|
||||
/* configure I2C clock */
|
||||
void i2c_clock_config(uint32_t i2c_periph, uint32_t clkspeed, uint32_t dutycyc);
|
||||
/* configure I2C address */
|
||||
void i2c_mode_addr_config(uint32_t i2c_periph, uint32_t mode, uint32_t addformat, uint32_t addr);
|
||||
/* SMBus type selection */
|
||||
void i2c_smbus_type_config(uint32_t i2c_periph,uint32_t type);
|
||||
void i2c_smbus_type_config(uint32_t i2c_periph, uint32_t type);
|
||||
/* whether or not to send an ACK */
|
||||
void i2c_ack_config(uint32_t i2c_periph,uint8_t ack);
|
||||
/* I2C POAP position configure */
|
||||
void i2c_ackpos_config(uint32_t i2c_periph,uint8_t pos);
|
||||
/* master send slave address */
|
||||
void i2c_master_addressing(uint32_t i2c_periph,uint8_t addr,uint32_t trandirection);
|
||||
/* dual-address mode switch */
|
||||
void i2c_dualaddr_enable(uint32_t i2c_periph, uint8_t dualaddr);
|
||||
|
||||
/* enable i2c */
|
||||
void i2c_ack_config(uint32_t i2c_periph, uint32_t ack);
|
||||
/* configure I2C POAP position */
|
||||
void i2c_ackpos_config(uint32_t i2c_periph, uint32_t pos);
|
||||
/* master sends slave address */
|
||||
void i2c_master_addressing(uint32_t i2c_periph, uint32_t addr, uint32_t trandirection);
|
||||
/* enable dual-address mode */
|
||||
void i2c_dualaddr_enable(uint32_t i2c_periph, uint32_t addr);
|
||||
/* disable dual-address mode */
|
||||
void i2c_dualaddr_disable(uint32_t i2c_periph);
|
||||
/* enable I2C */
|
||||
void i2c_enable(uint32_t i2c_periph);
|
||||
/* disable i2c */
|
||||
/* disable I2C */
|
||||
void i2c_disable(uint32_t i2c_periph);
|
||||
|
||||
/* generate a START condition on I2C bus */
|
||||
void i2c_start_on_bus(uint32_t i2c_periph);
|
||||
/* generate a STOP condition on I2C bus */
|
||||
void i2c_stop_on_bus(uint32_t i2c_periph);
|
||||
/* i2c transmit data function */
|
||||
void i2c_transmit_data(uint32_t i2c_periph,uint8_t data);
|
||||
/* i2c receive data function */
|
||||
uint8_t i2c_receive_data(uint32_t i2c_periph);
|
||||
/* I2C DMA mode enable */
|
||||
void i2c_dma_enable(uint32_t i2c_periph,uint32_t dmastste);
|
||||
/* flag indicating DMA last transfer */
|
||||
void i2c_dma_last_transfer_enable(uint32_t i2c_periph,uint32_t dmalast);
|
||||
/* whether to stretch SCL low when data is not ready in slave mode */
|
||||
void i2c_stretch_scl_low_config(uint32_t i2c_periph,uint32_t stretchpara );
|
||||
/* whether or not to response to a general call */
|
||||
void i2c_slave_response_to_gcall_config(uint32_t i2c_periph,uint32_t gcallpara);
|
||||
/* software reset I2C */
|
||||
/* I2C transmit data function */
|
||||
void i2c_data_transmit(uint32_t i2c_periph, uint8_t data);
|
||||
/* I2C receive data function */
|
||||
uint8_t i2c_data_receive(uint32_t i2c_periph);
|
||||
/* enable I2C DMA mode */
|
||||
void i2c_dma_enable(uint32_t i2c_periph, uint32_t dmastate);
|
||||
/* configure whether next DMA EOT is DMA last transfer or not */
|
||||
void i2c_dma_last_transfer_config(uint32_t i2c_periph, uint32_t dmalast);
|
||||
/* whether to stretch SCL low when data is not ready in slave mode */
|
||||
void i2c_stretch_scl_low_config(uint32_t i2c_periph, uint32_t stretchpara);
|
||||
/* whether or not to response to a general call */
|
||||
void i2c_slave_response_to_gcall_config(uint32_t i2c_periph, uint32_t gcallpara);
|
||||
/* software reset I2C */
|
||||
void i2c_software_reset_config(uint32_t i2c_periph, uint32_t sreset);
|
||||
|
||||
/* check i2c state */
|
||||
FlagStatus i2c_flag_get(uint32_t i2c_periph,uint32_t state);
|
||||
/* clear i2c state */
|
||||
void i2c_flag_clear(uint32_t i2c_periph,uint32_t state);
|
||||
/* enable i2c interrupt */
|
||||
void i2c_interrupt_enable(uint32_t i2c_periph,uint32_t inttype);
|
||||
/* disable i2c interrupt */
|
||||
void i2c_interrupt_disable(uint32_t i2c_periph,uint32_t inttype);
|
||||
|
||||
/* I2C PEC calculation on or off */
|
||||
void i2c_pec_enable(uint32_t i2c_periph,uint32_t pecstate);
|
||||
void i2c_pec_enable(uint32_t i2c_periph, uint32_t pecstate);
|
||||
/* I2C whether to transfer PEC value */
|
||||
void i2c_pec_transfer_enable(uint32_t i2c_periph,uint32_t pecpara);
|
||||
/* packet error checking value */
|
||||
uint8_t i2c_pec_value(uint32_t i2c_periph);
|
||||
|
||||
void i2c_pec_transfer_enable(uint32_t i2c_periph, uint32_t pecpara);
|
||||
/* packet error checking value */
|
||||
uint8_t i2c_pec_value_get(uint32_t i2c_periph);
|
||||
/* I2C issue alert through SMBA pin */
|
||||
void i2c_smbus_alert_issue(uint32_t i2c_periph,uint32_t smbuspara);
|
||||
/* I2C ARP protocol in SMBus switch */
|
||||
void i2c_smbus_arp_enable(uint32_t i2c_periph,uint32_t arpstate);
|
||||
void i2c_smbus_issue_alert(uint32_t i2c_periph, uint32_t smbuspara);
|
||||
/* I2C ARP protocol in SMBus switch */
|
||||
void i2c_smbus_arp_enable(uint32_t i2c_periph, uint32_t arpstate);
|
||||
|
||||
/* I2C analog noise filter disable */
|
||||
void i2c_analog_noise_filter_disable(uint32_t i2c_periph);
|
||||
@@ -318,14 +405,18 @@ void i2c_sam_disable(uint32_t i2c_periph);
|
||||
void i2c_sam_timeout_enable(uint32_t i2c_periph);
|
||||
/* disable SAM_V interface timeout detect */
|
||||
void i2c_sam_timeout_disable(uint32_t i2c_periph);
|
||||
/* enable the specified I2C SAM interrupt */
|
||||
void i2c_sam_interrupt_enable(uint32_t i2c_periph,uint32_t inttype);
|
||||
/* disable the specified I2C SAM interrupt */
|
||||
void i2c_sam_interrupt_disable(uint32_t i2c_periph,uint32_t inttype);
|
||||
/* check i2c SAM state */
|
||||
FlagStatus i2c_sam_flag_get(uint32_t i2c_periph,uint32_t samstate);
|
||||
/* clear i2c SAM state */
|
||||
void i2c_sam_flag_clear(uint32_t i2c_periph,uint32_t samstate);
|
||||
|
||||
/* check I2C flag is set or not */
|
||||
FlagStatus i2c_flag_get(uint32_t i2c_periph, i2c_flag_enum flag);
|
||||
/* clear I2C flag */
|
||||
void i2c_flag_clear(uint32_t i2c_periph, i2c_flag_enum flag);
|
||||
/* enable I2C interrupt */
|
||||
void i2c_interrupt_enable(uint32_t i2c_periph, i2c_interrupt_enum interrupt);
|
||||
/* disable I2C interrupt */
|
||||
void i2c_interrupt_disable(uint32_t i2c_periph, i2c_interrupt_enum interrupt);
|
||||
/* check I2C interrupt flag */
|
||||
FlagStatus i2c_interrupt_flag_get(uint32_t i2c_periph, i2c_interrupt_flag_enum int_flag);
|
||||
/* clear I2C interrupt flag */
|
||||
void i2c_interrupt_flag_clear(uint32_t i2c_periph, i2c_interrupt_flag_enum int_flag);
|
||||
|
||||
#endif /* GD32F4XX_I2C_H */
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_ipa.h
|
||||
\brief definitions for the IPA
|
||||
\file gd32f4xx_ipa.h
|
||||
\brief definitions for the IPA
|
||||
|
||||
\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_IPA_H
|
||||
@@ -24,7 +49,7 @@
|
||||
#define IPA_INTC REG32(IPA + 0x08U) /*!< IPA interrupt flag clear register */
|
||||
#define IPA_FMADDR REG32(IPA + 0x0CU) /*!< IPA foreground memory base address register */
|
||||
#define IPA_FLOFF REG32(IPA + 0x10U) /*!< IPA foreground line offset register */
|
||||
#define IPA_BMADDR REG32(IPA + 0x14U) /*!< IPA background memory base address register */
|
||||
#define IPA_BMADDR REG32(IPA + 0x14U) /*!< IPA background memory base address register */
|
||||
#define IPA_BLOFF REG32(IPA + 0x18U) /*!< IPA background line offset register */
|
||||
#define IPA_FPCTL REG32(IPA + 0x1CU) /*!< IPA foreground pixel control register */
|
||||
#define IPA_FPV REG32(IPA + 0x20U) /*!< IPA foreground pixel value register */
|
||||
@@ -33,11 +58,11 @@
|
||||
#define IPA_FLMADDR REG32(IPA + 0x2CU) /*!< IPA foreground LUT memory base address register */
|
||||
#define IPA_BLMADDR REG32(IPA + 0x30U) /*!< IPA background LUT memory base address register */
|
||||
#define IPA_DPCTL REG32(IPA + 0x34U) /*!< IPA destination pixel control register */
|
||||
#define IPA_DPV REG32(IPA + 0x38U) /*!< IPA destination pixel value register */
|
||||
#define IPA_DPV REG32(IPA + 0x38U) /*!< IPA destination pixel value register */
|
||||
#define IPA_DMADDR REG32(IPA + 0x3CU) /*!< IPA destination memory base address register */
|
||||
#define IPA_DLOFF REG32(IPA + 0x40U) /*!< IPA destination line offset register */
|
||||
#define IPA_IMS REG32(IPA + 0x44U) /*!< IPA image size register */
|
||||
#define IPA_LM REG32(IPA + 0x48U) /*!< IPA line mark register */
|
||||
#define IPA_LM REG32(IPA + 0x48U) /*!< IPA line mark register */
|
||||
#define IPA_ITCTL REG32(IPA + 0x4CU) /*!< IPA inter-timer control register */
|
||||
|
||||
/* IPA_CTL */
|
||||
@@ -113,7 +138,7 @@
|
||||
#define IPA_BLMADDR_BLMADDR BITS(0,31) /*!< background LUT memory base address */
|
||||
|
||||
/* IPA_DPCTL */
|
||||
#define IPA_DPCTL_DPF BITS(0,2) /*!< destination pixel control register */
|
||||
#define IPA_DPCTL_DPF BITS(0,2) /*!< destination pixel control register */
|
||||
|
||||
/* IPA_DPV */
|
||||
/* destination pixel format ARGB8888 */
|
||||
@@ -165,7 +190,7 @@
|
||||
/* constants definitions */
|
||||
/* IPA foreground parameter struct definitions */
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
uint32_t foreground_memaddr; /*!< foreground memory base address */
|
||||
uint32_t foreground_lineoff; /*!< foreground line offset */
|
||||
uint32_t foreground_prealpha; /*!< foreground pre-defined alpha value */
|
||||
@@ -174,25 +199,25 @@ typedef struct
|
||||
uint32_t foreground_prered; /*!< foreground pre-defined red value */
|
||||
uint32_t foreground_pregreen; /*!< foreground pre-defined green value */
|
||||
uint32_t foreground_preblue; /*!< foreground pre-defined blue value */
|
||||
}ipa_foreground_parameter_struct;
|
||||
}ipa_foreground_parameter_struct;
|
||||
|
||||
/* IPA background parameter struct definitions */
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
uint32_t background_memaddr; /*!< background memory base address */
|
||||
uint32_t background_lineoff; /*!< background line offset */
|
||||
uint32_t background_prealpha; /*!< background pre-defined alpha value */
|
||||
uint32_t background_alpha_algorithm; /*!< background alpha value calculation algorithm */
|
||||
uint32_t background_alpha_algorithm; /*!< background alpha value calculation algorithm */
|
||||
uint32_t background_pf; /*!< background pixel format */
|
||||
uint32_t background_prered; /*!< background pre-defined red value */
|
||||
uint32_t background_pregreen; /*!< background pre-defined green value */
|
||||
uint32_t background_preblue; /*!< background pre-defined blue value */
|
||||
}ipa_background_parameter_struct;
|
||||
}ipa_background_parameter_struct;
|
||||
|
||||
/* IPA destination parameter struct definitions */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t destination_memaddr; /*!< destination memory base address */
|
||||
uint32_t destination_memaddr; /*!< destination memory base address */
|
||||
uint32_t destination_lineoff; /*!< destination line offset */
|
||||
uint32_t destination_prealpha; /*!< destination pre-defined alpha value */
|
||||
uint32_t destination_pf; /*!< destination pixel format */
|
||||
@@ -200,17 +225,17 @@ typedef struct
|
||||
uint32_t destination_pregreen; /*!< destination pre-defined green value */
|
||||
uint32_t destination_preblue; /*!< destination pre-defined blue value */
|
||||
uint32_t image_width; /*!< width of the image to be processed */
|
||||
uint32_t image_height; /*!< height of the image to be processed */
|
||||
}ipa_destination_parameter_struct;
|
||||
uint32_t image_height; /*!< height of the image to be processed */
|
||||
}ipa_destination_parameter_struct;
|
||||
|
||||
/* destination pixel format */
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
IPA_DPF_ARGB8888, /*!< destination pixel format ARGB8888 */
|
||||
IPA_DPF_RGB888, /*!< destination pixel format RGB888 */
|
||||
IPA_DPF_RGB565, /*!< destination pixel format RGB565 */
|
||||
IPA_DPF_ARGB1555, /*!< destination pixel format ARGB1555 */
|
||||
IPA_DPF_ARGB4444 /*!< destination pixel format ARGB4444 */
|
||||
IPA_DPF_ARGB8888, /*!< destination pixel format ARGB8888 */
|
||||
IPA_DPF_RGB888, /*!< destination pixel format RGB888 */
|
||||
IPA_DPF_RGB565, /*!< destination pixel format RGB565 */
|
||||
IPA_DPF_ARGB1555, /*!< destination pixel format ARGB1555 */
|
||||
IPA_DPF_ARGB4444 /*!< destination pixel format ARGB4444 */
|
||||
} ipa_dpf_enum;
|
||||
|
||||
/* LUT pixel format */
|
||||
@@ -218,30 +243,30 @@ typedef enum
|
||||
#define IPA_LUT_PF_RGB888 ((uint8_t)0x01U) /*!< LUT pixel format RGB888 */
|
||||
|
||||
/* Inter-timer */
|
||||
#define IPA_INTER_TIMER_DISABLE ((uint8_t)0x00U) /*!< Inter-timer disable */
|
||||
#define IPA_INTER_TIMER_ENABLE ((uint8_t)0x01U) /*!< Inter-timer enable */
|
||||
#define IPA_INTER_TIMER_DISABLE ((uint8_t)0x00U) /*!< inter-timer disable */
|
||||
#define IPA_INTER_TIMER_ENABLE ((uint8_t)0x01U) /*!< inter-timer enable */
|
||||
|
||||
/* IPA pixel format convert mode */
|
||||
#define CTL_PFCM(regval) (BITS(16,17) & ((regval) << 16))
|
||||
#define CTL_PFCM(regval) (BITS(16,17) & ((uint32_t)(regval) << 16))
|
||||
#define IPA_FGTODE CTL_PFCM(0) /*!< foreground memory to destination memory without pixel format convert */
|
||||
#define IPA_FGTODE_PF_CONVERT CTL_PFCM(1) /*!< foreground memory to destination memory with pixel format convert */
|
||||
#define IPA_FGBGTODE CTL_PFCM(2) /*!< blending foreground and background memory to destination memory */
|
||||
#define IPA_FILL_UP_DE CTL_PFCM(3) /*!< fill up destination memory with specific color */
|
||||
|
||||
/* foreground alpha value calculation algorithm */
|
||||
#define FPCTL_FAVCA(regval) (BITS(16,17) & ((regval) << 16))
|
||||
#define FPCTL_FAVCA(regval) (BITS(16,17) & ((uint32_t)(regval) << 16))
|
||||
#define IPA_FG_ALPHA_MODE_0 FPCTL_FAVCA(0) /*!< no effect */
|
||||
#define IPA_FG_ALPHA_MODE_1 FPCTL_FAVCA(1) /*!< FPDAV[7:0] is selected as the foreground alpha value */
|
||||
#define IPA_FG_ALPHA_MODE_2 FPCTL_FAVCA(2) /*!< FPDAV[7:0] multiplied by read alpha value */
|
||||
|
||||
/* background alpha value calculation algorithm */
|
||||
#define BPCTL_BAVCA(regval) (BITS(16,17) & ((regval) << 16))
|
||||
#define BPCTL_BAVCA(regval) (BITS(16,17) & ((uint32_t)(regval) << 16))
|
||||
#define IPA_BG_ALPHA_MODE_0 BPCTL_BAVCA(0) /*!< no effect */
|
||||
#define IPA_BG_ALPHA_MODE_1 BPCTL_BAVCA(1) /*!< BPDAV[7:0] is selected as the background alpha value */
|
||||
#define IPA_BG_ALPHA_MODE_2 BPCTL_BAVCA(2) /*!< BPDAV[7:0] multiplied by read alpha value */
|
||||
|
||||
/* foreground pixel format */
|
||||
#define FPCTL_PPF(regval) (BITS(0,3) & ((regval)))
|
||||
#define FPCTL_PPF(regval) (BITS(0,3) & ((uint32_t)(regval)))
|
||||
#define FOREGROUND_PPF_ARGB8888 FPCTL_PPF(0) /*!< foreground pixel format ARGB8888 */
|
||||
#define FOREGROUND_PPF_RGB888 FPCTL_PPF(1) /*!< foreground pixel format RGB888 */
|
||||
#define FOREGROUND_PPF_RGB565 FPCTL_PPF(2) /*!< foreground pixel format RGB565 */
|
||||
@@ -255,7 +280,7 @@ typedef enum
|
||||
#define FOREGROUND_PPF_A4 FPCTL_PPF(10) /*!< foreground pixel format A4 */
|
||||
|
||||
/* background pixel format */
|
||||
#define BPCTL_PPF(regval) (BITS(0,3) & ((regval)))
|
||||
#define BPCTL_PPF(regval) (BITS(0,3) & ((uint32_t)(regval)))
|
||||
#define BACKGROUND_PPF_ARGB8888 BPCTL_PPF(0) /*!< background pixel format ARGB8888 */
|
||||
#define BACKGROUND_PPF_RGB888 BPCTL_PPF(1) /*!< background pixel format RGB888 */
|
||||
#define BACKGROUND_PPF_RGB565 BPCTL_PPF(2) /*!< background pixel format RGB565 */
|
||||
@@ -268,53 +293,92 @@ typedef enum
|
||||
#define BACKGROUND_PPF_A8 BPCTL_PPF(9) /*!< background pixel format A8 */
|
||||
#define BACKGROUND_PPF_A4 BPCTL_PPF(10) /*!< background pixel format A4 */
|
||||
|
||||
/* IPA flags */
|
||||
#define IPA_FLAG_TAE IPA_INTF_TAEIF /*!< transfer access error interrupt flag */
|
||||
#define IPA_FLAG_FTF IPA_INTF_FTFIF /*!< full transfer finish interrupt flag */
|
||||
#define IPA_FLAG_TLM IPA_INTF_TLMIF /*!< transfer line mark interrupt flag */
|
||||
#define IPA_FLAG_LAC IPA_INTF_LACIF /*!< LUT access conflict interrupt flag */
|
||||
#define IPA_FLAG_LLF IPA_INTF_LLFIF /*!< LUT loading finish interrupt flag */
|
||||
#define IPA_FLAG_WCF IPA_INTF_WCFIF /*!< wrong configuration interrupt flag */
|
||||
|
||||
/* IPA interrupt enable or disable */
|
||||
#define IPA_INT_TAE IPA_CTL_TAEIE /*!< transfer access error interrupt */
|
||||
#define IPA_INT_FTF IPA_CTL_FTFIE /*!< full transfer finish interrupt */
|
||||
#define IPA_INT_TLM IPA_CTL_TLMIE /*!< transfer line mark interrupt */
|
||||
#define IPA_INT_LAC IPA_CTL_LACIE /*!< LUT access conflict interrupt */
|
||||
#define IPA_INT_LLF IPA_CTL_LLFIE /*!< LUT loading finish interrupt */
|
||||
#define IPA_INT_WCF IPA_CTL_WCFIE /*!< wrong configuration interrupt */
|
||||
|
||||
/* IPA interrupt flags */
|
||||
#define IPA_INT_FLAG_TAE IPA_INTF_TAEIF /*!< transfer access error interrupt flag */
|
||||
#define IPA_INT_FLAG_FTF IPA_INTF_FTFIF /*!< full transfer finish interrupt flag */
|
||||
#define IPA_INT_FLAG_TLM IPA_INTF_TLMIF /*!< transfer line mark interrupt flag */
|
||||
#define IPA_INT_FLAG_LAC IPA_INTF_LACIF /*!< LUT access conflict interrupt flag */
|
||||
#define IPA_INT_FLAG_LLF IPA_INTF_LLFIF /*!< LUT loading finish interrupt flag */
|
||||
#define IPA_INT_FLAG_WCF IPA_INTF_WCFIF /*!< wrong configuration interrupt flag */
|
||||
|
||||
/* function declarations */
|
||||
|
||||
/* functions enable or disable, pixel format convert mode set */
|
||||
/* deinitialize IPA */
|
||||
void ipa_deinit(void);
|
||||
/* IPA transfer enable */
|
||||
/* enable IPA transfer */
|
||||
void ipa_transfer_enable(void);
|
||||
/* IPA transfer hang up enable */
|
||||
/* enable IPA transfer hang up */
|
||||
void ipa_transfer_hangup_enable(void);
|
||||
/* IPA transfer hang up disable */
|
||||
/* disable IPA transfer hang up */
|
||||
void ipa_transfer_hangup_disable(void);
|
||||
/* IPA transfer stop enable */
|
||||
/* enable IPA transfer stop */
|
||||
void ipa_transfer_stop_enable(void);
|
||||
/* IPA transfer stop disable */
|
||||
/* disable IPA transfer stop */
|
||||
void ipa_transfer_stop_disable(void);
|
||||
/* IPA foreground LUT loading enable */
|
||||
/* enable IPA foreground LUT loading */
|
||||
void ipa_foreground_lut_loading_enable(void);
|
||||
/* IPA background LUT loading enable */
|
||||
/* enable IPA background LUT loading */
|
||||
void ipa_background_lut_loading_enable(void);
|
||||
/* IPA transfer enable */
|
||||
void ipa_pixel_format_convert_mod(uint32_t pfcm);
|
||||
/* set pixel format convert mode, the function is invalid when the IPA transfer is enabled */
|
||||
void ipa_pixel_format_convert_mode_set(uint32_t pfcm);
|
||||
|
||||
/* structure initialization, foreground, background, destination and LUT initialization */
|
||||
/* initialize the structure of IPA foreground parameter struct with the default values, it is
|
||||
suggested that call this function after an ipa_foreground_parameter_struct structure is defined */
|
||||
void ipa_foreground_struct_para_init(ipa_foreground_parameter_struct* foreground_struct);
|
||||
/* initialize foreground parameters */
|
||||
void ipa_foreground_init(ipa_foreground_parameter_struct* foreground_struct);
|
||||
/* initialize the structure of IPA background parameter struct with the default values, it is
|
||||
suggested that call this function after an ipa_background_parameter_struct structure is defined */
|
||||
void ipa_background_struct_para_init(ipa_background_parameter_struct* background_struct);
|
||||
/* initialize background parameters */
|
||||
void ipa_background_init(ipa_background_parameter_struct* background_struct);
|
||||
/* initialize the structure of IPA destination parameter struct with the default values, it is
|
||||
suggested that call this function after an ipa_destination_parameter_struct structure is defined */
|
||||
void ipa_destination_struct_para_init(ipa_destination_parameter_struct* destination_struct);
|
||||
/* initialize destination parameters */
|
||||
void ipa_destination_init(ipa_destination_parameter_struct* destination_struct);
|
||||
/* initialize IPA foreground LUT parameters */
|
||||
void ipa_foreground_lut_init(uint32_t fg_lut_num,uint8_t fg_lut_pf, uint32_t fg_lut_addr);
|
||||
void ipa_foreground_lut_init(uint8_t fg_lut_num, uint8_t fg_lut_pf, uint32_t fg_lut_addr);
|
||||
/* initialize IPA background LUT parameters */
|
||||
void ipa_background_lut_init(uint32_t bg_lut_num,uint8_t bg_lut_pf, uint32_t bg_lut_addr);
|
||||
void ipa_background_lut_init(uint8_t bg_lut_num, uint8_t bg_lut_pf, uint32_t bg_lut_addr);
|
||||
|
||||
/* configure line mark */
|
||||
void ipa_line_mark_config(uint32_t linenum);
|
||||
/* Inter-timer enable or disable */
|
||||
void ipa_inter_timer_config(uint8_t timercfg);
|
||||
/* number of clock cycles interval set */
|
||||
void ipa_interval_clock_num_config(uint32_t clk_num );
|
||||
/* configuration functions */
|
||||
/* configure IPA line mark */
|
||||
void ipa_line_mark_config(uint16_t line_num);
|
||||
/* inter-timer enable or disable */
|
||||
void ipa_inter_timer_config(uint8_t timer_cfg);
|
||||
/* configure the number of clock cycles interval */
|
||||
void ipa_interval_clock_num_config(uint8_t clk_num);
|
||||
|
||||
/* IPA interrupt enable */
|
||||
void ipa_interrupt_enable(uint32_t inttype);
|
||||
/* IPA interrupt disable */
|
||||
void ipa_interrupt_disable(uint32_t inttype);
|
||||
/* flag and interrupt functions */
|
||||
/* get IPA flag status in IPA_INTF register */
|
||||
FlagStatus ipa_flag_get(uint32_t flag);
|
||||
/* clear IPA flag in IPA_INTF register */
|
||||
void ipa_flag_clear(uint32_t flag);
|
||||
/* enable IPA interrupt */
|
||||
void ipa_interrupt_enable(uint32_t int_flag);
|
||||
/* disable IPA interrupt */
|
||||
void ipa_interrupt_disable(uint32_t int_flag);
|
||||
/* get IPA interrupt flag */
|
||||
FlagStatus ipa_interrupt_flag_get(uint32_t intflag);
|
||||
FlagStatus ipa_interrupt_flag_get(uint32_t int_flag);
|
||||
/* clear IPA interrupt flag */
|
||||
void ipa_interrupt_flag_clear(uint32_t intflag);
|
||||
void ipa_interrupt_flag_clear(uint32_t int_flag);
|
||||
|
||||
#endif /* GD32F4XX_IPA_H */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_rcu.h
|
||||
\brief definitions for the RCU
|
||||
\file gd32f4xx_rcu.h
|
||||
\brief definitions for the RCU
|
||||
|
||||
\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_RCU_H
|
||||
@@ -34,14 +59,14 @@
|
||||
#define RCU_APB2EN REG32(RCU + 0x44U) /*!< APB2 enable register */
|
||||
#define RCU_AHB1SPEN REG32(RCU + 0x50U) /*!< AHB1 sleep mode enable register */
|
||||
#define RCU_AHB2SPEN REG32(RCU + 0x54U) /*!< AHB2 sleep mode enable register */
|
||||
#define RCU_AHB3SPEN REG32(RCU + 0x58U) /*!< AHB3 sleep mode enable register */
|
||||
#define RCU_AHB3SPEN REG32(RCU + 0x58U) /*!< AHB3 sleep mode enable register */
|
||||
#define RCU_APB1SPEN REG32(RCU + 0x60U) /*!< APB1 sleep mode enable register */
|
||||
#define RCU_APB2SPEN REG32(RCU + 0x64U) /*!< APB2 sleep mode enable register */
|
||||
#define RCU_BDCTL REG32(RCU + 0x70U) /*!< backup domain control register */
|
||||
#define RCU_RSTSCK REG32(RCU + 0x74U) /*!< reset source / clock register */
|
||||
#define RCU_PLLSSCTL REG32(RCU + 0x80U) /*!< PLL clock spread spectrum control register */
|
||||
#define RCU_PLLI2S REG32(RCU + 0x84U) /*!< PLLI2S register */
|
||||
#define RCU_PLLSAI REG32(RCU + 0x88U) /*!< PLLSAI register */
|
||||
#define RCU_PLLI2S REG32(RCU + 0x84U) /*!< PLLI2S register */
|
||||
#define RCU_PLLSAI REG32(RCU + 0x88U) /*!< PLLSAI register */
|
||||
#define RCU_CFG1 REG32(RCU + 0x8CU) /*!< clock configuration register 1 */
|
||||
#define RCU_ADDCTL REG32(RCU + 0xC0U) /*!< Additional clock control register */
|
||||
#define RCU_ADDINT REG32(RCU + 0xCCU) /*!< Additional clock interrupt register */
|
||||
@@ -54,7 +79,7 @@
|
||||
/* bits definitions */
|
||||
/* RCU_CTL */
|
||||
#define RCU_CTL_IRC16MEN BIT(0) /*!< internal high speed oscillator enable */
|
||||
#define RCU_CTL_IRC16MSTB BIT(1) /*!< IRC8M high speed internal oscillator stabilization flag */
|
||||
#define RCU_CTL_IRC16MSTB BIT(1) /*!< IRC16M high speed internal oscillator stabilization flag */
|
||||
#define RCU_CTL_IRC16MADJ BITS(3,7) /*!< high speed internal oscillator clock trim adjust value */
|
||||
#define RCU_CTL_IRC16MCALIB BITS(8,15) /*!< high speed internal oscillator calibration value register */
|
||||
#define RCU_CTL_HXTALEN BIT(16) /*!< external high speed oscillator enable */
|
||||
@@ -64,7 +89,7 @@
|
||||
#define RCU_CTL_PLLEN BIT(24) /*!< PLL enable */
|
||||
#define RCU_CTL_PLLSTB BIT(25) /*!< PLL Clock Stabilization Flag */
|
||||
#define RCU_CTL_PLLI2SEN BIT(26) /*!< PLLI2S enable */
|
||||
#define RCU_CTL_PLLI2STB BIT(27) /*!< PLLI2S Clock Stabilization Flag */
|
||||
#define RCU_CTL_PLLI2SSTB BIT(27) /*!< PLLI2S Clock Stabilization Flag */
|
||||
#define RCU_CTL_PLLSAIEN BIT(28) /*!< PLLSAI enable */
|
||||
#define RCU_CTL_PLLSAISTB BIT(29) /*!< PLLSAI Clock Stabilization Flag */
|
||||
|
||||
@@ -123,7 +148,7 @@
|
||||
#define RCU_AHB1RST_PGRST BIT(6) /*!< GPIO port G reset */
|
||||
#define RCU_AHB1RST_PHRST BIT(7) /*!< GPIO port H reset */
|
||||
#define RCU_AHB1RST_PIRST BIT(8) /*!< GPIO port I reset */
|
||||
#define RCU_AHB1RST_CRCRST BIT(12) /*!< CRC reset */
|
||||
#define RCU_AHB1RST_CRCRST BIT(12) /*!< CRC reset */
|
||||
#define RCU_AHB1RST_DMA0RST BIT(21) /*!< DMA0 reset */
|
||||
#define RCU_AHB1RST_DMA1RST BIT(22) /*!< DMA1 reset */
|
||||
#define RCU_AHB1RST_IPARST BIT(23) /*!< IPA reset */
|
||||
@@ -134,7 +159,7 @@
|
||||
#define RCU_AHB2RST_DCIRST BIT(0) /*!< DCI reset */
|
||||
#define RCU_AHB2RST_TRNGRST BIT(6) /*!< TRNG reset */
|
||||
#define RCU_AHB2RST_USBFSRST BIT(7) /*!< USBFS reset */
|
||||
|
||||
|
||||
/* RCU_AHB3RST */
|
||||
#define RCU_AHB3RST_EXMCRST BIT(0) /*!< EXMC reset */
|
||||
|
||||
@@ -167,9 +192,9 @@
|
||||
|
||||
/* RCU_APB2RST */
|
||||
#define RCU_APB2RST_TIMER0RST BIT(0) /*!< TIMER0 reset */
|
||||
#define RCU_APB2RST_TIMER7RST BIT(1) /*!< TIMER7 reset */
|
||||
#define RCU_APB2RST_TIMER7RST BIT(1) /*!< TIMER7 reset */
|
||||
#define RCU_APB2RST_USART0RST BIT(4) /*!< USART0 reset */
|
||||
#define RCU_APB2RST_USART5RST BIT(5) /*!< USART5 reset */
|
||||
#define RCU_APB2RST_USART5RST BIT(5) /*!< USART5 reset */
|
||||
#define RCU_APB2RST_ADCRST BIT(8) /*!< ADC reset */
|
||||
#define RCU_APB2RST_SDIORST BIT(11) /*!< SDIO reset */
|
||||
#define RCU_APB2RST_SPI0RST BIT(12) /*!< SPI0 reset */
|
||||
@@ -361,11 +386,11 @@
|
||||
#define RCU_RSTSCK_LPRSTF BIT(31) /*!< low-power reset flag */
|
||||
|
||||
/* RCU_PLLSSCTL */
|
||||
#define RCU_PLLSSCTL_MODCNT BITS(0,12) /*!< these bits configure PLL spread spectrum modulation
|
||||
profile amplitude and frequency. the following criteria
|
||||
#define RCU_PLLSSCTL_MODCNT BITS(0,12) /*!< these bits configure PLL spread spectrum modulation
|
||||
profile amplitude and frequency. the following criteria
|
||||
must be met: MODSTEP*MODCNT=215-1 */
|
||||
#define RCU_PLLSSCTL_MODSTEP BITS(13,27) /*!< these bits configure PLL spread spectrum modulation
|
||||
profile amplitude and frequency. the following criteria
|
||||
#define RCU_PLLSSCTL_MODSTEP BITS(13,27) /*!< these bits configure PLL spread spectrum modulation
|
||||
profile amplitude and frequency. the following criteria
|
||||
must be met: MODSTEP*MODCNT=215-1 */
|
||||
#define RCU_PLLSSCTL_SS_TYPE BIT(30) /*!< PLL spread spectrum modulation type select */
|
||||
#define RCU_PLLSSCTL_SSCGON BIT(31) /*!< PLL spread spectrum modulation enable */
|
||||
@@ -438,7 +463,7 @@
|
||||
#define ADD_APB1EN_REG_OFFSET 0xE4U /*!< APB1 additional enable register offset */
|
||||
#define ADD_APB1SPEN_REG_OFFSET 0xE8U /*!< APB1 additional sleep mode enable register offset */
|
||||
|
||||
/* peripherals reset */
|
||||
/* peripherals reset */
|
||||
#define AHB1RST_REG_OFFSET 0x10U /*!< AHB1 reset register offset */
|
||||
#define AHB2RST_REG_OFFSET 0x14U /*!< AHB2 reset register offset */
|
||||
#define AHB3RST_REG_OFFSET 0x18U /*!< AHB3 reset register offset */
|
||||
@@ -504,7 +529,7 @@ typedef enum
|
||||
RCU_TIMER6 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 5U), /*!< TIMER6 clock */
|
||||
RCU_TIMER11 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 6U), /*!< TIMER11 clock */
|
||||
RCU_TIMER12 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 7U), /*!< TIMER12 clock */
|
||||
RCU_TIMER13 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 8U), /*!< TIMER13 clock */
|
||||
RCU_TIMER13 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 8U), /*!< TIMER13 clock */
|
||||
RCU_WWDGT = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 11U), /*!< WWDGT clock */
|
||||
RCU_SPI1 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 14U), /*!< SPI1 clock */
|
||||
RCU_SPI2 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 15U), /*!< SPI2 clock */
|
||||
@@ -514,7 +539,7 @@ typedef enum
|
||||
RCU_UART4 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 20U), /*!< UART4 clock */
|
||||
RCU_I2C0 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 21U), /*!< I2C0 clock */
|
||||
RCU_I2C1 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 22U), /*!< I2C1 clock */
|
||||
RCU_I2C2 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 23U), /*!< I2C2 clock */
|
||||
RCU_I2C2 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 23U), /*!< I2C2 clock */
|
||||
RCU_CAN0 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 25U), /*!< CAN0 clock */
|
||||
RCU_CAN1 = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 26U), /*!< CAN1 clock */
|
||||
RCU_PMU = RCU_REGIDX_BIT(APB1EN_REG_OFFSET, 28U), /*!< PMU clock */
|
||||
@@ -540,7 +565,7 @@ typedef enum
|
||||
RCU_SPI4 = RCU_REGIDX_BIT(APB2EN_REG_OFFSET, 20U), /*!< SPI4 clock */
|
||||
RCU_SPI5 = RCU_REGIDX_BIT(APB2EN_REG_OFFSET, 21U), /*!< SPI5 clock */
|
||||
RCU_TLI = RCU_REGIDX_BIT(APB2EN_REG_OFFSET, 26U), /*!< TLI clock */
|
||||
/* APB2 additional peripherals */
|
||||
/* APB1 additional peripherals */
|
||||
RCU_CTC = RCU_REGIDX_BIT(ADD_APB1EN_REG_OFFSET, 27U), /*!< CTC clock */
|
||||
RCU_IREF = RCU_REGIDX_BIT(ADD_APB1EN_REG_OFFSET, 31U), /*!< IREF clock */
|
||||
}rcu_periph_enum;
|
||||
@@ -588,7 +613,7 @@ typedef enum
|
||||
RCU_TIMER6_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 5U), /*!< TIMER6 clock */
|
||||
RCU_TIMER11_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 6U), /*!< TIMER11 clock */
|
||||
RCU_TIMER12_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 7U), /*!< TIMER12 clock */
|
||||
RCU_TIMER13_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 8U), /*!< TIMER13 clock */
|
||||
RCU_TIMER13_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 8U), /*!< TIMER13 clock */
|
||||
RCU_WWDGT_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 11U), /*!< WWDGT clock */
|
||||
RCU_SPI1_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 14U), /*!< SPI1 clock */
|
||||
RCU_SPI2_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 15U), /*!< SPI2 clock */
|
||||
@@ -598,7 +623,7 @@ typedef enum
|
||||
RCU_UART4_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 20U), /*!< UART4 clock */
|
||||
RCU_I2C0_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 21U), /*!< I2C0 clock */
|
||||
RCU_I2C1_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 22U), /*!< I2C1 clock */
|
||||
RCU_I2C2_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 23U), /*!< I2C2 clock */
|
||||
RCU_I2C2_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 23U), /*!< I2C2 clock */
|
||||
RCU_CAN0_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 25U), /*!< CAN0 clock */
|
||||
RCU_CAN1_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 26U), /*!< CAN1 clock */
|
||||
RCU_PMU_SLP = RCU_REGIDX_BIT(APB1SPEN_REG_OFFSET, 28U), /*!< PMU clock */
|
||||
@@ -644,8 +669,8 @@ typedef enum
|
||||
RCU_CRCRST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 12U), /*!< CRC clock reset */
|
||||
RCU_DMA0RST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 21U), /*!< DMA0 clock reset */
|
||||
RCU_DMA1RST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 22U), /*!< DMA1 clock reset */
|
||||
RCU_IPAENRST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 23U), /*!< IPA clock reset */
|
||||
RCU_ENETRST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 25U), /*!< ENET clock reset */
|
||||
RCU_IPARST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 23U), /*!< IPA clock reset */
|
||||
RCU_ENETRST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 25U), /*!< ENET clock reset */
|
||||
RCU_USBHSRST = RCU_REGIDX_BIT(AHB1RST_REG_OFFSET, 29U), /*!< USBHS clock reset */
|
||||
/* AHB2 peripherals */
|
||||
RCU_DCIRST = RCU_REGIDX_BIT(AHB2RST_REG_OFFSET, 0U), /*!< DCI clock reset */
|
||||
@@ -662,7 +687,7 @@ typedef enum
|
||||
RCU_TIMER6RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 5U), /*!< TIMER6 clock reset */
|
||||
RCU_TIMER11RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 6U), /*!< TIMER11 clock reset */
|
||||
RCU_TIMER12RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 7U), /*!< TIMER12 clock reset */
|
||||
RCU_TIMER13RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 8U), /*!< TIMER13 clock reset */
|
||||
RCU_TIMER13RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 8U), /*!< TIMER13 clock reset */
|
||||
RCU_WWDGTRST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 11U), /*!< WWDGT clock reset */
|
||||
RCU_SPI1RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 14U), /*!< SPI1 clock reset */
|
||||
RCU_SPI2RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 15U), /*!< SPI2 clock reset */
|
||||
@@ -672,7 +697,7 @@ typedef enum
|
||||
RCU_UART4RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 20U), /*!< UART4 clock reset */
|
||||
RCU_I2C0RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 21U), /*!< I2C0 clock reset */
|
||||
RCU_I2C1RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 22U), /*!< I2C1 clock reset */
|
||||
RCU_I2C2RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 23U), /*!< I2C2 clock reset */
|
||||
RCU_I2C2RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 23U), /*!< I2C2 clock reset */
|
||||
RCU_CAN0RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 25U), /*!< CAN0 clock reset */
|
||||
RCU_CAN1RST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 26U), /*!< CAN1 clock reset */
|
||||
RCU_PMURST = RCU_REGIDX_BIT(APB1RST_REG_OFFSET, 28U), /*!< PMU clock reset */
|
||||
@@ -695,7 +720,7 @@ typedef enum
|
||||
RCU_SPI4RST = RCU_REGIDX_BIT(APB2RST_REG_OFFSET, 20U), /*!< SPI4 clock reset */
|
||||
RCU_SPI5RST = RCU_REGIDX_BIT(APB2RST_REG_OFFSET, 21U), /*!< SPI5 clock reset */
|
||||
RCU_TLIRST = RCU_REGIDX_BIT(APB2RST_REG_OFFSET, 26U), /*!< TLI clock reset */
|
||||
/* APB2 additional peripherals */
|
||||
/* APB1 additional peripherals */
|
||||
RCU_CTCRST = RCU_REGIDX_BIT(ADD_APB1RST_REG_OFFSET, 27U), /*!< CTC clock reset */
|
||||
RCU_IREFRST = RCU_REGIDX_BIT(ADD_APB1RST_REG_OFFSET, 31U) /*!< IREF clock reset */
|
||||
}rcu_periph_reset_enum;
|
||||
@@ -727,7 +752,7 @@ typedef enum
|
||||
{
|
||||
RCU_INT_FLAG_IRC32KSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 0U), /*!< IRC32K stabilization interrupt flag */
|
||||
RCU_INT_FLAG_LXTALSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 1U), /*!< LXTAL stabilization interrupt flag */
|
||||
RCU_INT_FLAG_IRC8MSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 2U), /*!< IRC8M stabilization interrupt flag */
|
||||
RCU_INT_FLAG_IRC16MSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 2U), /*!< IRC16M stabilization interrupt flag */
|
||||
RCU_INT_FLAG_HXTALSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 3U), /*!< HXTAL stabilization interrupt flag */
|
||||
RCU_INT_FLAG_PLLSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 4U), /*!< PLL stabilization interrupt flag */
|
||||
RCU_INT_FLAG_PLLI2SSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 5U), /*!< PLLI2S stabilization interrupt flag */
|
||||
@@ -755,7 +780,7 @@ typedef enum
|
||||
{
|
||||
RCU_INT_IRC32KSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 8U), /*!< IRC32K stabilization interrupt */
|
||||
RCU_INT_LXTALSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 9U), /*!< LXTAL stabilization interrupt */
|
||||
RCU_INT_IRC16MSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 10U), /*!< IRC8M stabilization interrupt */
|
||||
RCU_INT_IRC16MSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 10U), /*!< IRC16M stabilization interrupt */
|
||||
RCU_INT_HXTALSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 11U), /*!< HXTAL stabilization interrupt */
|
||||
RCU_INT_PLLSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 12U), /*!< PLL stabilization interrupt */
|
||||
RCU_INT_PLLI2SSTB = RCU_REGIDX_BIT(INT_REG_OFFSET, 13U), /*!< PLLI2S stabilization interrupt */
|
||||
@@ -890,7 +915,7 @@ typedef enum
|
||||
/* CKOUT1 Clock source selection */
|
||||
#define CFG0_CKOUT1SEL(regval) (BITS(30,31) & ((uint32_t)(regval) << 30))
|
||||
#define RCU_CKOUT1SRC_SYSTEMCLOCK CFG0_CKOUT1SEL(0) /*!< system clock selected */
|
||||
#define RCU_CKOUT1SRC_PLLI2SR CFG0_CKOUT1SEL(1) /*!< low speed crystal oscillator clock (LXTAL) selected */
|
||||
#define RCU_CKOUT1SRC_PLLI2SR CFG0_CKOUT1SEL(1) /*!< CK_PLLI2SR clock selected */
|
||||
#define RCU_CKOUT1SRC_HXTAL CFG0_CKOUT1SEL(2) /*!< high speed crystal oscillator clock (HXTAL) selected */
|
||||
#define RCU_CKOUT1SRC_PLLP CFG0_CKOUT1SEL(3) /*!< CK_PLLP clock selected */
|
||||
|
||||
@@ -938,13 +963,13 @@ typedef enum
|
||||
#define RCU_PLLSAIR_DIV16 CFG1_PLLSAIRDIV(3) /*!< CK_PLLSAIRDIV clock select CK_PLLSAIR/16 */
|
||||
|
||||
/* TIMER clock selection */
|
||||
#define RCU_TIMER_PSC_MUL2 ~RCU_CFG1_TIMERSEL /*!< if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB)
|
||||
#define RCU_TIMER_PSC_MUL2 ~RCU_CFG1_TIMERSEL /*!< if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB)
|
||||
or 0b100(CK_APBx = CK_AHB/2), the TIMER clock is equal to CK_AHB(CK_TIMERx = CK_AHB).
|
||||
or else, the TIMER clock is twice the corresponding APB clock (TIMER in APB1 domain: CK_TIMERx = 2 x CK_APB1;
|
||||
or else, the TIMER clock is twice the corresponding APB clock (TIMER in APB1 domain: CK_TIMERx = 2 x CK_APB1;
|
||||
TIMER in APB2 domain: CK_TIMERx = 2 x CK_APB2) */
|
||||
#define RCU_TIMER_PSC_MUL4 RCU_CFG1_TIMERSEL /*!< if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB),
|
||||
0b100(CK_APBx = CK_AHB/2), or 0b101(CK_APBx = CK_AHB/4), the TIMER clock is equal to CK_AHB(CK_TIMERx = CK_AHB).
|
||||
or else, the TIMER clock is four timers the corresponding APB clock (TIMER in APB1 domain: CK_TIMERx = 4 x CK_APB1;
|
||||
#define RCU_TIMER_PSC_MUL4 RCU_CFG1_TIMERSEL /*!< if APB1PSC/APB2PSC in RCU_CFG0 register is 0b0xx(CK_APBx = CK_AHB),
|
||||
0b100(CK_APBx = CK_AHB/2), or 0b101(CK_APBx = CK_AHB/4), the TIMER clock is equal to CK_AHB(CK_TIMERx = CK_AHB).
|
||||
or else, the TIMER clock is four timers the corresponding APB clock (TIMER in APB1 domain: CK_TIMERx = 4 x CK_APB1;
|
||||
TIMER in APB2 domain: CK_TIMERx = 4 x CK_APB2) */
|
||||
|
||||
/* RCU_PLLSSCTL register bit define */
|
||||
@@ -966,7 +991,7 @@ typedef enum
|
||||
/* The PLLP output frequency division factor from PLL VCO clock */
|
||||
#define RCU_PLLP_DIV_MIN ((uint32_t)2U) /*!< PLLP_DIV min value */
|
||||
#define RCU_PLLP_DIV_MAX ((uint32_t)8U) /*!< PLLP_DIV max value */
|
||||
|
||||
|
||||
/* PLL Clock Source Selection */
|
||||
#define RCU_PLLSRC_IRC16M ((uint32_t)0x00000000U) /*!< IRC16M clock selected as source clock of PLL, PLLSAI, PLLI2S */
|
||||
#define RCU_PLLSRC_HXTAL RCU_PLL_PLLSEL /*!< HXTAL clock selected as source clock of PLL, PLLSAI, PLLI2S */
|
||||
@@ -975,10 +1000,10 @@ typedef enum
|
||||
#define RCU_PLLQ_DIV_MIN ((uint32_t)2U) /*!< PLLQ_DIV min value */
|
||||
#define RCU_PLLQ_DIV_MAX ((uint32_t)15U) /*!< PLLQ_DIV max value */
|
||||
|
||||
#define CHECK_PLL_PSC_VALID(val) (((val) >= RCU_PLLPSC_DIV_MIN)&&((val) <= RCU_PLLPSC_DIV_MAX))
|
||||
#define CHECK_PLL_N_VALID(val, inc) (((val) >= (RCU_PLLN_MUL_MIN + (inc)))&&((val) <= RCU_PLLN_MUL_MAX))
|
||||
#define CHECK_PLL_P_VALID(val) (((val) == 2U) || ((val) == 4U) || ((val) == 6U) || ((val) == 8U))
|
||||
#define CHECK_PLL_Q_VALID(val) (((val) >= RCU_PLLQ_DIV_MIN)&&((val) <= RCU_PLLQ_DIV_MAX))
|
||||
#define CHECK_PLL_PSC_VALID(val) (((val) >= RCU_PLLPSC_DIV_MIN)&&((val) <= RCU_PLLPSC_DIV_MAX))
|
||||
#define CHECK_PLL_N_VALID(val, inc) (((val) >= (RCU_PLLN_MUL_MIN + (inc)))&&((val) <= RCU_PLLN_MUL_MAX))
|
||||
#define CHECK_PLL_P_VALID(val) (((val) == 2U) || ((val) == 4U) || ((val) == 6U) || ((val) == 8U))
|
||||
#define CHECK_PLL_Q_VALID(val) (((val) >= RCU_PLLQ_DIV_MIN)&&((val) <= RCU_PLLQ_DIV_MAX))
|
||||
|
||||
/* RCU_BDCTL register bit define */
|
||||
/* LXTAL drive capability */
|
||||
@@ -1033,7 +1058,7 @@ typedef enum
|
||||
#define CHECK_PLLSAI_R_VALID(val) (((val) >= RCU_PLLSAIR_DIV_MIN)&&((val) <= RCU_PLLSAIR_DIV_MAX))
|
||||
|
||||
/* RCU_ADDCTL register bit define */
|
||||
/* 48MHz clock selection */
|
||||
/* 48MHz clock selection */
|
||||
#define RCU_CK48MSRC_PLL48M ((uint32_t)0x00000000U) /*!< CK48M source clock select PLL48M */
|
||||
#define RCU_CK48MSRC_IRC48M RCU_ADDCTL_CK48MSEL /*!< CK48M source clock select IRC48M */
|
||||
|
||||
@@ -1086,11 +1111,13 @@ void rcu_ckout1_config(uint32_t ckout1_src, uint32_t ckout1_div);
|
||||
/* configure the PLL clock source selection and PLL multiply factor */
|
||||
ErrStatus rcu_pll_config(uint32_t pll_src, uint32_t pll_psc, uint32_t pll_n, uint32_t pll_p, uint32_t pll_q);
|
||||
/* configure the PLLI2S clock */
|
||||
ErrStatus rcu_plli2s_config(uint32_t plli2s_n, uint32_t plli2s_q, uint32_t plli2s_r);
|
||||
ErrStatus rcu_plli2s_config(uint32_t plli2s_n, uint32_t plli2s_r);
|
||||
/* configure the PLLSAI clock */
|
||||
ErrStatus rcu_pllsai_config(uint32_t pllsai_n, uint32_t pllsai_p, uint32_t pllsai_q, uint32_t pllsai_r);
|
||||
ErrStatus rcu_pllsai_config(uint32_t pllsai_n, uint32_t pllsai_p, uint32_t pllsai_r);
|
||||
/* configure the RTC clock source selection */
|
||||
void rcu_rtc_clock_config(uint32_t rtc_clock_source);
|
||||
/* cconfigure the frequency division of RTC clock when HXTAL was selected as its clock source */
|
||||
void rcu_rtc_div_config(uint32_t rtc_div);
|
||||
/* configure the I2S clock source selection */
|
||||
void rcu_i2s_clock_config(uint32_t i2s_clock_source);
|
||||
/* configure the CK48M clock selection */
|
||||
@@ -1098,7 +1125,7 @@ void rcu_ck48m_clock_config(uint32_t ck48m_clock_source);
|
||||
/* configure the PLL48M clock selection */
|
||||
void rcu_pll48m_clock_config(uint32_t pll48m_clock_source);
|
||||
/* configure the TIMER clock prescaler selection */
|
||||
void rcu_timer_clock_prescaler_config(uint32_t timer_clock_prescaler);
|
||||
void rcu_timer_clock_prescaler_config(uint32_t timer_clock_prescaler);
|
||||
/* configure the TLI clock division selection */
|
||||
void rcu_tli_clock_div_config(uint32_t pllsai_r_div);
|
||||
|
||||
@@ -1110,11 +1137,11 @@ void rcu_all_reset_flag_clear(void);
|
||||
/* get the clock stabilization interrupt and ckm flags */
|
||||
FlagStatus rcu_interrupt_flag_get(rcu_int_flag_enum int_flag);
|
||||
/* clear the interrupt flags */
|
||||
void rcu_interrupt_flag_clear(rcu_int_flag_clear_enum int_flag_clear);
|
||||
void rcu_interrupt_flag_clear(rcu_int_flag_clear_enum int_flag);
|
||||
/* enable the stabilization interrupt */
|
||||
void rcu_interrupt_enable(rcu_int_enum stab_int);
|
||||
void rcu_interrupt_enable(rcu_int_enum interrupt);
|
||||
/* disable the stabilization interrupt */
|
||||
void rcu_interrupt_disable(rcu_int_enum stab_int);
|
||||
void rcu_interrupt_disable(rcu_int_enum interrupt);
|
||||
|
||||
/* configure the LXTAL drive capability */
|
||||
void rcu_lxtal_drive_capability_config(uint32_t lxtal_dricap);
|
||||
@@ -1140,7 +1167,7 @@ void rcu_spread_spectrum_config(uint32_t spread_spectrum_type, uint32_t modstep,
|
||||
/* enable the spread spectrum modulation for the main PLL clock */
|
||||
void rcu_spread_spectrum_enable(void);
|
||||
/* disable the spread spectrum modulation for the main PLL clock */
|
||||
void rcu_spread_spectrum_disable(void);
|
||||
void rcu_spread_spectrum_disable(void);
|
||||
/* unlock the voltage key */
|
||||
void rcu_voltage_key_unlock(void);
|
||||
/* set the deep sleep mode voltage */
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -1,14 +1,40 @@
|
||||
/*!
|
||||
\file gd32f4xx_spi.h
|
||||
\brief definitions for the SPI
|
||||
\file gd32f4xx_spi.h
|
||||
\brief definitions for the SPI
|
||||
|
||||
\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_SPI_H
|
||||
#define GD32F4XX_SPI_H
|
||||
|
||||
@@ -50,7 +76,7 @@
|
||||
#define I2S_ADD_I2SPSC(i2sx_add) REG32((i2sx_add) + 0x20U) /*!< I2S_ADD I2S clock prescaler register */
|
||||
|
||||
/* bits definitions */
|
||||
/* SPIx_CTL0 */
|
||||
/* SPI_CTL0 */
|
||||
#define SPI_CTL0_CKPH BIT(0) /*!< clock phase selection*/
|
||||
#define SPI_CTL0_CKPL BIT(1) /*!< clock polarity selection */
|
||||
#define SPI_CTL0_MSTMOD BIT(2) /*!< master mode enable */
|
||||
@@ -66,7 +92,7 @@
|
||||
#define SPI_CTL0_BDOEN BIT(14) /*!< bidirectional transmit output enable*/
|
||||
#define SPI_CTL0_BDEN BIT(15) /*!< bidirectional enable */
|
||||
|
||||
/* SPIx_CTL1 */
|
||||
/* SPI_CTL1 */
|
||||
#define SPI_CTL1_DMAREN BIT(0) /*!< receive buffer dma enable */
|
||||
#define SPI_CTL1_DMATEN BIT(1) /*!< transmit buffer dma enable */
|
||||
#define SPI_CTL1_NSSDRV BIT(2) /*!< drive nss output */
|
||||
@@ -75,16 +101,16 @@
|
||||
#define SPI_CTL1_RBNEIE BIT(6) /*!< receive buffer not empty interrupt enable */
|
||||
#define SPI_CTL1_TBEIE BIT(7) /*!< transmit buffer empty interrupt enable */
|
||||
|
||||
/* SPIx_STAT */
|
||||
/* SPI_STAT */
|
||||
#define SPI_STAT_RBNE BIT(0) /*!< receive buffer not empty */
|
||||
#define SPI_STAT_TBE BIT(1) /*!< transmit buffer empty */
|
||||
#define SPI_STAT_I2SCH BIT(2) /*!< I2S channel side */
|
||||
#define SPI_STAT_TXURERR BIT(3) /*!< I2S transmission underrun error bit */
|
||||
#define SPI_STAT_CRCERR BIT(4) /*!< SPI CRC error bit */
|
||||
#define SPI_STAT_CONFERR BIT(5) /*!< SPI configuration error */
|
||||
#define SPI_STAT_RXORERR BIT(6) /*!< SPI reception overrun error Bit */
|
||||
#define SPI_STAT_TRANS BIT(7) /*!< transmitting on-going Bit */
|
||||
#define SPI_STAT_FERR BIT(8) /*!< format error */
|
||||
#define SPI_STAT_CONFERR BIT(5) /*!< SPI configuration error bit */
|
||||
#define SPI_STAT_RXORERR BIT(6) /*!< SPI reception overrun error bit */
|
||||
#define SPI_STAT_TRANS BIT(7) /*!< transmitting on-going bit */
|
||||
#define SPI_STAT_FERR BIT(8) /*!< format error bit */
|
||||
|
||||
/* SPI_DATA */
|
||||
#define SPI_DATA_DATA BITS(0,15) /*!< data transfer register */
|
||||
@@ -96,9 +122,9 @@
|
||||
#define SPI_RCRC_RCR BITS(0,15) /*!< RX CRC register */
|
||||
|
||||
/* SPI_TCRC */
|
||||
#define SPI_TCRC_TCR BITS(0,15) /*!< RX CRC register */
|
||||
#define SPI_TCRC_TCR BITS(0,15) /*!< TX CRC register */
|
||||
|
||||
/* SPIx_I2SCTL */
|
||||
/* SPI_I2SCTL */
|
||||
#define SPI_I2SCTL_CHLEN BIT(0) /*!< channel length */
|
||||
#define SPI_I2SCTL_DTLEN BITS(1,2) /*!< data length */
|
||||
#define SPI_I2SCTL_CKPL BIT(3) /*!< idle state clock polarity */
|
||||
@@ -108,12 +134,12 @@
|
||||
#define SPI_I2SCTL_I2SEN BIT(10) /*!< I2S enable */
|
||||
#define SPI_I2SCTL_I2SSEL BIT(11) /*!< I2S mode selection */
|
||||
|
||||
/* SPIx_I2S_PSC */
|
||||
/* SPI_I2S_PSC */
|
||||
#define SPI_I2SPSC_DIV BITS(0,7) /*!< dividing factor for the prescaler */
|
||||
#define SPI_I2SPSC_OF BIT(8) /*!< odd factor for the prescaler */
|
||||
#define SPI_I2SPSC_MCKOEN BIT(9) /*!< I2S MCK output enable */
|
||||
|
||||
/* SPIx_SPI_QCTL(only SPI5) */
|
||||
/* SPI_SPI_QCTL(only SPI5) */
|
||||
#define SPI_QCTL_QMOD BIT(0) /*!< quad-SPI mode enable */
|
||||
#define SPI_QCTL_QRD BIT(1) /*!< quad-SPI mode read select */
|
||||
#define SPI_QCTL_IO23_DRV BIT(2) /*!< drive SPI_IO2 and SPI_IO3 enable */
|
||||
@@ -121,7 +147,7 @@
|
||||
/* constants definitions */
|
||||
/* SPI and I2S parameter struct definitions */
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
uint32_t device_mode; /*!< SPI master or slave */
|
||||
uint32_t trans_mode; /*!< SPI transtype */
|
||||
uint32_t frame_size; /*!< SPI frame size */
|
||||
@@ -131,32 +157,39 @@ typedef struct
|
||||
uint32_t prescale; /*!< SPI prescale factor */
|
||||
}spi_parameter_struct;
|
||||
|
||||
/* SPI struct parameter options */
|
||||
/* SPI mode definitions */
|
||||
#define SPI_MASTER (SPI_CTL0_MSTMOD | SPI_CTL0_SWNSS) /*!< SPI as master */
|
||||
#define SPI_SLAVE ((uint32_t)0x00000000U) /*!< SPI as slave */
|
||||
|
||||
#define SPI_BIDIRECTIONAL_TEANSMIT SPI_CTL0_BDOEN /*!< SPI work in transmit-only mode */
|
||||
#define SPI_BIDIRECTIONAL_RECEIVE ~SPI_CTL0_BDOEN /*!< SPI work in receive-only mode */
|
||||
/* SPI bidirectional transfer direction */
|
||||
#define SPI_BIDIRECTIONAL_TRANSMIT SPI_CTL0_BDOEN /*!< SPI work in transmit-only mode */
|
||||
#define SPI_BIDIRECTIONAL_RECEIVE (~SPI_CTL0_BDOEN) /*!< SPI work in receive-only mode */
|
||||
|
||||
/* SPI transmit type */
|
||||
#define SPI_TRANSMODE_FULLDUPLEX ((uint32_t)0x00000000U) /*!< SPI receive and send data at fullduplex communication */
|
||||
#define SPI_TRANSMODE_RECEIVEONLY SPI_CTL0_RO /*!< SPI only receive data */
|
||||
#define SPI_TRANSMODE_BDRECEIVE SPI_CTL0_BDEN /*!< bidirectional receive data */
|
||||
#define SPI_TRANSMODE_BDTRANSMIT (SPI_CTL0_BDEN | SPI_CTL0_BDOEN) /*!< bidirectional transmit data*/
|
||||
|
||||
/* SPI frame size */
|
||||
#define SPI_FRAMESIZE_16BIT SPI_CTL0_FF16 /*!< SPI frame size is 16 bits */
|
||||
#define SPI_FRAMESIZE_8BIT ((uint32_t)0x00000000U) /*!< SPI frame size is 8 bits */
|
||||
|
||||
/* SPI NSS control mode */
|
||||
#define SPI_NSS_SOFT SPI_CTL0_SWNSSEN /*!< SPI nss control by sofrware */
|
||||
#define SPI_NSS_HARD ((uint32_t)0x00000000U) /*!< SPI nss control by hardware */
|
||||
|
||||
#define SPI_ENDIAN_MSB ((uint32_t)0x00000000U) /*!< SPI transmit way is big endian:transmit MSB first */
|
||||
#define SPI_ENDIAN_LSB SPI_CTL0_LF /*!< SPI transmit way is little endian:transmit LSB first */
|
||||
/* SPI transmit way */
|
||||
#define SPI_ENDIAN_MSB ((uint32_t)0x00000000U) /*!< SPI transmit way is big endian: transmit MSB first */
|
||||
#define SPI_ENDIAN_LSB SPI_CTL0_LF /*!< SPI transmit way is little endian: transmit LSB first */
|
||||
|
||||
/* SPI clock polarity and phase */
|
||||
#define SPI_CK_PL_LOW_PH_1EDGE ((uint32_t)0x00000000U) /*!< SPI clock polarity is low level and phase is first edge */
|
||||
#define SPI_CK_PL_HIGH_PH_1EDGE SPI_CTL0_CKPL /*!< SPI clock polarity is high level and phase is first edge */
|
||||
#define SPI_CK_PL_LOW_PH_2EDGE SPI_CTL0_CKPH /*!< SPI clock polarity is low level and phase is second edge */
|
||||
#define SPI_CK_PL_HIGH_PH_2EDGE (SPI_CTL0_CKPL|SPI_CTL0_CKPH) /*!< SPI clock polarity is high level and phase is second edge */
|
||||
|
||||
/* SPI clock prescale factor */
|
||||
#define CTL0_PSC(regval) (BITS(3,5)&((uint32_t)(regval)<<3))
|
||||
#define SPI_PSC_2 CTL0_PSC(0) /*!< SPI clock prescale factor is 2 */
|
||||
#define SPI_PSC_4 CTL0_PSC(1) /*!< SPI clock prescale factor is 4 */
|
||||
@@ -167,118 +200,171 @@ typedef struct
|
||||
#define SPI_PSC_128 CTL0_PSC(6) /*!< SPI clock prescale factor is 128 */
|
||||
#define SPI_PSC_256 CTL0_PSC(7) /*!< SPI clock prescale factor is 256 */
|
||||
|
||||
/* I2S parameter options */
|
||||
#define I2S_AUDIOSAMPLE_8K ((uint32_t)8000U) /*!< I2S audio sample rate is 8khz */
|
||||
#define I2S_AUDIOSAMPLE_11K ((uint32_t)11025U) /*!< I2S audio sample rate is 11khz */
|
||||
#define I2S_AUDIOSAMPLE_16K ((uint32_t)16000U) /*!< I2S audio sample rate is 16khz */
|
||||
#define I2S_AUDIOSAMPLE_22K ((uint32_t)22050U) /*!< I2S audio sample rate is 22khz */
|
||||
#define I2S_AUDIOSAMPLE_32K ((uint32_t)32000U) /*!< I2S audio sample rate is 32khz */
|
||||
#define I2S_AUDIOSAMPLE_44K ((uint32_t)44100U) /*!< I2S audio sample rate is 44khz */
|
||||
#define I2S_AUDIOSAMPLE_48K ((uint32_t)48000U) /*!< I2S audio sample rate is 48khz */
|
||||
#define I2S_AUDIOSAMPLE_96K ((uint32_t)96000U) /*!< I2S audio sample rate is 96khz */
|
||||
#define I2S_AUDIOSAMPLE_192K ((uint32_t)192000U) /*!< I2S audio sample rate is 192khz */
|
||||
/* I2S audio sample rate */
|
||||
#define I2S_AUDIOSAMPLE_8K ((uint32_t)8000U) /*!< I2S audio sample rate is 8KHz */
|
||||
#define I2S_AUDIOSAMPLE_11K ((uint32_t)11025U) /*!< I2S audio sample rate is 11KHz */
|
||||
#define I2S_AUDIOSAMPLE_16K ((uint32_t)16000U) /*!< I2S audio sample rate is 16KHz */
|
||||
#define I2S_AUDIOSAMPLE_22K ((uint32_t)22050U) /*!< I2S audio sample rate is 22KHz */
|
||||
#define I2S_AUDIOSAMPLE_32K ((uint32_t)32000U) /*!< I2S audio sample rate is 32KHz */
|
||||
#define I2S_AUDIOSAMPLE_44K ((uint32_t)44100U) /*!< I2S audio sample rate is 44KHz */
|
||||
#define I2S_AUDIOSAMPLE_48K ((uint32_t)48000U) /*!< I2S audio sample rate is 48KHz */
|
||||
#define I2S_AUDIOSAMPLE_96K ((uint32_t)96000U) /*!< I2S audio sample rate is 96KHz */
|
||||
#define I2S_AUDIOSAMPLE_192K ((uint32_t)192000U) /*!< I2S audio sample rate is 192KHz */
|
||||
|
||||
/* I2S frame format */
|
||||
#define I2SCTL_DTLEN(regval) (BITS(1,2)&((uint32_t)(regval)<<1))
|
||||
#define I2S_FRAMEFORMAT_DT16B_CH16B I2SCTL_DTLEN(0) /*!< I2S data length is 16 bit and channel length is 16 bit */
|
||||
#define I2S_FRAMEFORMAT_DT16B_CH32B (I2SCTL_DTLEN(0)|SPI_I2SCTL_CHLEN) /*!< I2S data length is 16 bit and channel length is 32 bit */
|
||||
#define I2S_FRAMEFORMAT_DT24B_CH32B (I2SCTL_DTLEN(1)|SPI_I2SCTL_CHLEN) /*!< I2S data length is 24 bit and channel length is 32 bit */
|
||||
#define I2S_FRAMEFORMAT_DT32B_CH32B (I2SCTL_DTLEN(2)|SPI_I2SCTL_CHLEN) /*!< I2S data length is 32 bit and channel length is 32 bit */
|
||||
|
||||
|
||||
/* I2S master clock output */
|
||||
#define I2S_MCKOUT_DISABLE ((uint32_t)0x00000000U) /*!< I2S master clock output disable */
|
||||
#define I2S_MCKOUT_ENABLE SPI_I2SPSC_MCKOEN /*!< I2S master clock output enable */
|
||||
|
||||
|
||||
/* I2S operation mode */
|
||||
#define I2SCTL_I2SOPMOD(regval) (BITS(8,9)&((uint32_t)(regval)<<8))
|
||||
#define I2S_MODE_SLAVETX I2SCTL_I2SOPMOD(0) /*!< I2S slave transmit mode */
|
||||
#define I2S_MODE_SLAVERX I2SCTL_I2SOPMOD(1) /*!< I2S slave receive mode */
|
||||
#define I2S_MODE_MASTERTX I2SCTL_I2SOPMOD(2) /*!< I2S master transmit mode */
|
||||
#define I2S_MODE_MASTERRX I2SCTL_I2SOPMOD(3) /*!< I2S master receive mode */
|
||||
|
||||
/* I2S standard */
|
||||
#define I2SCTL_I2SSTD(regval) (BITS(4,5)&((uint32_t)(regval)<<4))
|
||||
#define I2S_STD_PHILLIPS I2SCTL_I2SSTD(0) /*!< I2S phillips standard */
|
||||
#define I2S_STD_MSB I2SCTL_I2SSTD(1) /*!< I2S MSB standard */
|
||||
#define I2S_STD_LSB I2SCTL_I2SSTD(2) /*!< I2S LSB standard */
|
||||
#define I2S_STD_PCMSHORT I2SCTL_I2SSTD(3) /*!< I2S PCM short standard */
|
||||
#define I2S_STD_PCMLONG (I2SCTL_I2SSTD(3)|SPI_I2SCTL_PCMSMOD) /*!< I2S PCM long standard */
|
||||
#define I2S_STD_PCMLONG (I2SCTL_I2SSTD(3) | SPI_I2SCTL_PCMSMOD) /*!< I2S PCM long standard */
|
||||
|
||||
/* I2S clock polarity */
|
||||
#define I2S_CKPL_LOW ((uint32_t)0x00000000U) /*!< I2S clock polarity low level */
|
||||
#define I2S_CKPL_HIGH SPI_I2SCTL_CKPL /*!< I2S clock polarity high level */
|
||||
|
||||
/* SPI dma constants definitions */
|
||||
#define SPI_DMA_TRANSMIT ((uint8_t)0x00U) /*!< SPI transmit data DMA */
|
||||
#define SPI_DMA_RECEIVE ((uint8_t)0x01U) /*!< SPI receive data DMA */
|
||||
/* SPI DMA constants definitions */
|
||||
#define SPI_DMA_TRANSMIT ((uint8_t)0x00U) /*!< SPI transmit data use DMA */
|
||||
#define SPI_DMA_RECEIVE ((uint8_t)0x01U) /*!< SPI receive data use DMA */
|
||||
|
||||
/* SPI CRC constants definitions */
|
||||
#define SPI_CRC_TX ((uint8_t)0x00U) /*!< SPI transmit CRC value */
|
||||
#define SPI_CRC_RX ((uint8_t)0x01U) /*!< SPI receive CRC value */
|
||||
|
||||
/* SPI interrupt constants definitions */
|
||||
/* SPI/I2S interrupt enable/disable constants definitions */
|
||||
#define SPI_I2S_INT_TBE ((uint8_t)0x00U) /*!< transmit buffer empty interrupt */
|
||||
#define SPI_I2S_INT_RBNE ((uint8_t)0x01U) /*!< receive buffer not empty interrupt */
|
||||
#define SPI_I2S_INT_RXORERR ((uint8_t)0x02U) /*!< overrun interrupt */
|
||||
#define SPI_INT_CONFERR ((uint8_t)0x03U) /*!< config error interrupt */
|
||||
#define SPI_INT_CRCERR ((uint8_t)0x04U) /*!< CRC error interrupt */
|
||||
#define I2S_INT_TXURERR ((uint8_t)0x05U) /*!< underrun error interrupt */
|
||||
#define SPI_I2S_INT_ERR ((uint8_t)0x06U) /*!< error interrupt */
|
||||
#define SPI_I2S_INT_FERR ((uint8_t)0x07U) /*!< format error interrupt */
|
||||
#define SPI_I2S_INT_ERR ((uint8_t)0x02U) /*!< error interrupt */
|
||||
|
||||
/* SPI flag definitions */
|
||||
/* SPI/I2S interrupt flag constants definitions */
|
||||
#define SPI_I2S_INT_FLAG_TBE ((uint8_t)0x00U) /*!< transmit buffer empty interrupt flag */
|
||||
#define SPI_I2S_INT_FLAG_RBNE ((uint8_t)0x01U) /*!< receive buffer not empty interrupt flag */
|
||||
#define SPI_I2S_INT_FLAG_RXORERR ((uint8_t)0x02U) /*!< overrun interrupt flag */
|
||||
#define SPI_INT_FLAG_CONFERR ((uint8_t)0x03U) /*!< config error interrupt flag */
|
||||
#define SPI_INT_FLAG_CRCERR ((uint8_t)0x04U) /*!< CRC error interrupt flag */
|
||||
#define I2S_INT_FLAG_TXURERR ((uint8_t)0x05U) /*!< underrun error interrupt flag */
|
||||
#define SPI_I2S_INT_FLAG_FERR ((uint8_t)0x06U) /*!< format error interrupt flag */
|
||||
|
||||
/* SPI/I2S flag definitions */
|
||||
#define SPI_FLAG_RBNE SPI_STAT_RBNE /*!< receive buffer not empty flag */
|
||||
#define SPI_FLAG_TBE SPI_STAT_TBE /*!< transmit buffer empty flag */
|
||||
#define SPI_FLAG_CRCERR SPI_STAT_CRCERR /*!< CRC error flag */
|
||||
#define SPI_FLAG_CONFERR SPI_STAT_CONFERR /*!< mode config error flag */
|
||||
#define SPI_FLAG_RXORERR SPI_STAT_RXORERR /*!< receive overrun flag */
|
||||
#define SPI_FLAG_RXORERR SPI_STAT_RXORERR /*!< receive overrun error flag */
|
||||
#define SPI_FLAG_TRANS SPI_STAT_TRANS /*!< transmit on-going flag */
|
||||
#define SPI_FLAG_FERR SPI_STAT_FERR /*!< format error interrupt flag */
|
||||
#define SPI_FLAG_FERR SPI_STAT_FERR /*!< format error flag */
|
||||
#define I2S_FLAG_RBNE SPI_STAT_RBNE /*!< receive buffer not empty flag */
|
||||
#define I2S_FLAG_TBE SPI_STAT_TBE /*!< transmit buffer empty flag */
|
||||
#define I2S_FLAG_CH SPI_STAT_I2SCH /*!< transmit buffer empty interrupt */
|
||||
#define I2S_FLAG_CH SPI_STAT_I2SCH /*!< channel side flag */
|
||||
#define I2S_FLAG_TXURERR SPI_STAT_TXURERR /*!< underrun error flag */
|
||||
#define I2S_FLAG_RXORERR SPI_STAT_RXORERR /*!< overrun flag */
|
||||
#define I2S_FLAG_RXORERR SPI_STAT_RXORERR /*!< overrun error flag */
|
||||
#define I2S_FLAG_TRANS SPI_STAT_TRANS /*!< transmit on-going flag */
|
||||
#define I2S_FLAG_FERR SPI_STAT_FERR /*!< format error interrupt flag */
|
||||
#define I2S_FLAG_FERR SPI_STAT_FERR /*!< format error flag */
|
||||
|
||||
/* function declarations */
|
||||
/* SPI and I2S reset */
|
||||
/* initialization functions */
|
||||
/* deinitialize SPI and I2S */
|
||||
void spi_i2s_deinit(uint32_t spi_periph);
|
||||
/* SPI parameter initialization */
|
||||
/* initialize the parameters of SPI struct with the default values */
|
||||
void spi_struct_para_init(spi_parameter_struct* spi_struct);
|
||||
/* initialize SPI parameter */
|
||||
void spi_init(uint32_t spi_periph,spi_parameter_struct* spi_struct);
|
||||
/* SPI enable */
|
||||
/* enable SPI */
|
||||
void spi_enable(uint32_t spi_periph);
|
||||
/* SPI disable */
|
||||
/* disable SPI */
|
||||
void spi_disable(uint32_t spi_periph);
|
||||
|
||||
/* I2S parameter initialization */
|
||||
/* initialize I2S parameter */
|
||||
void i2s_init(uint32_t spi_periph,uint32_t i2s_mode,uint32_t i2s_standard,uint32_t i2s_ckpl);
|
||||
/* I2S prescale configuration */
|
||||
/* configure I2S prescale */
|
||||
void i2s_psc_config(uint32_t spi_periph,uint32_t i2s_audiosample,uint32_t i2s_frameformat,uint32_t i2s_mckout);
|
||||
/* I2S enable */
|
||||
/* enable I2S */
|
||||
void i2s_enable(uint32_t spi_periph);
|
||||
/* I2S disable */
|
||||
/* disable I2S */
|
||||
void i2s_disable(uint32_t spi_periph);
|
||||
|
||||
/* SPI nss output enable */
|
||||
/* NSS functions */
|
||||
/* enable SPI nss output */
|
||||
void spi_nss_output_enable(uint32_t spi_periph);
|
||||
/* SPI nss output disable */
|
||||
/* disable SPI nss output */
|
||||
void spi_nss_output_disable(uint32_t spi_periph);
|
||||
/* SPI nss pin high level in software mode */
|
||||
void spi_nss_internal_high(uint32_t spi_periph);
|
||||
/* SPI nss pin low level in software mode */
|
||||
void spi_nss_internal_low(uint32_t spi_periph);
|
||||
|
||||
/* SPI dma enable */
|
||||
/* SPI DMA functions */
|
||||
/* enable SPI DMA */
|
||||
void spi_dma_enable(uint32_t spi_periph,uint8_t spi_dma);
|
||||
/* SPI dma disable */
|
||||
/* disable SPI DMA */
|
||||
void spi_dma_disable(uint32_t spi_periph,uint8_t spi_dma);
|
||||
|
||||
/* SPI/I2S transfer configure functions */
|
||||
/* configure SPI/I2S data frame format */
|
||||
void spi_i2s_data_frame_format_config(uint32_t spi_periph,uint16_t frame_format);
|
||||
/* transmit data */
|
||||
/* SPI transmit data */
|
||||
void spi_i2s_data_transmit(uint32_t spi_periph,uint16_t data);
|
||||
/* receive data */
|
||||
/* SPI receive data */
|
||||
uint16_t spi_i2s_data_receive(uint32_t spi_periph);
|
||||
/* configure SPI bidirectional transfer direction */
|
||||
void spi_bidirectional_transfer_config(uint32_t spi_periph,uint32_t transfer_direction);
|
||||
|
||||
/* SPI CRC functions */
|
||||
/* set SPI CRC polynomial */
|
||||
void spi_crc_polynomial_set(uint32_t spi_periph,uint16_t crc_poly);
|
||||
/* get SPI CRC polynomial */
|
||||
uint16_t spi_crc_polynomial_get(uint32_t spi_periph);
|
||||
/* turn on SPI CRC function */
|
||||
void spi_crc_on(uint32_t spi_periph);
|
||||
/* turn off SPI CRC function */
|
||||
void spi_crc_off(uint32_t spi_periph);
|
||||
/* SPI next data is CRC value */
|
||||
void spi_crc_next(uint32_t spi_periph);
|
||||
/* get SPI CRC send value or receive value */
|
||||
uint16_t spi_crc_get(uint32_t spi_periph,uint8_t spi_crc);
|
||||
|
||||
/* SPI TI mode functions */
|
||||
/* enable SPI TI mode */
|
||||
void spi_ti_mode_enable(uint32_t spi_periph);
|
||||
/* disable SPI TI mode */
|
||||
void spi_ti_mode_disable(uint32_t spi_periph);
|
||||
|
||||
/* configure i2s full duplex mode */
|
||||
void i2s_full_duplex_mode_config(uint32_t i2s_add_periph,uint32_t i2s_mode,uint32_t i2s_standard,uint32_t i2s_ckpl,uint32_t i2s_frameformat);
|
||||
|
||||
/* quad wire SPI functions */
|
||||
/* enable quad wire SPI */
|
||||
void qspi_enable(uint32_t spi_periph);
|
||||
/* disable quad wire SPI */
|
||||
void qspi_disable(uint32_t spi_periph);
|
||||
/* enable quad wire SPI write */
|
||||
void qspi_write_enable(uint32_t spi_periph);
|
||||
/* enable quad wire SPI read */
|
||||
void qspi_read_enable(uint32_t spi_periph);
|
||||
/* enable quad wire SPI_IO2 and SPI_IO3 pin output */
|
||||
void qspi_io23_output_enable(uint32_t spi_periph);
|
||||
/* disable quad wire SPI_IO2 and SPI_IO3 pin output */
|
||||
void qspi_io23_output_disable(uint32_t spi_periph);
|
||||
|
||||
/* flag & interrupt functions */
|
||||
/* enable SPI interrupt */
|
||||
void spi_i2s_interrupt_enable(uint32_t spi_periph,uint8_t spi_i2s_int);
|
||||
/* disable SPI interrupt */
|
||||
@@ -290,38 +376,4 @@ FlagStatus spi_i2s_flag_get(uint32_t spi_periph,uint32_t spi_i2s_flag);
|
||||
/* clear SPI CRC error flag status */
|
||||
void spi_crc_error_clear(uint32_t spi_periph);
|
||||
|
||||
/* SPI CRC polynomial set */
|
||||
void spi_crc_polynomial_set(uint32_t spi_periph,uint16_t crc_poly);
|
||||
/* SPI CRC polynomial get */
|
||||
uint16_t spi_crc_polynomial_get(uint32_t spi_periph);
|
||||
/* SPI CRC function turn on */
|
||||
void spi_crc_on(uint32_t spi_periph);
|
||||
/* SPI CRC function turn off */
|
||||
void spi_crc_off(uint32_t spi_periph);
|
||||
/* SPI next data is CRC value */
|
||||
void spi_crc_next(uint32_t spi_periph);
|
||||
/* get SPI CRC send value or receive value */
|
||||
uint16_t spi_crc_get(uint32_t spi_periph,uint8_t spi_crc);
|
||||
|
||||
/* SPI TI mode enable */
|
||||
void spi_ti_mode_enable(uint32_t spi_periph);
|
||||
/* SPI TI mode disable */
|
||||
void spi_ti_mode_disable(uint32_t spi_periph);
|
||||
|
||||
/* configure i2s full duplex mode */
|
||||
void i2s_full_duplex_mode_config(uint32_t i2s_add_periph,uint32_t i2s_mode,uint32_t i2s_standard,uint32_t i2s_ckpl,uint32_t i2s_frameformat);
|
||||
|
||||
/* quad wire SPI enable */
|
||||
void qspi_enable(uint32_t spi_periph);
|
||||
/* quad wire SPI disable */
|
||||
void qspi_disable(uint32_t spi_periph);
|
||||
/* quad wire SPI write enable */
|
||||
void qspi_write_enable(uint32_t spi_periph);
|
||||
/* quad wire SPI read enable */
|
||||
void qspi_read_enable(uint32_t spi_periph);
|
||||
/* quad wire SPI_IO2 and SPI_IO3 pin output enable */
|
||||
void qspi_io23_output_enable(uint32_t spi_periph);
|
||||
/* quad wire SPI_IO2 and SPI_IO3 pin output disable */
|
||||
void qspi_io23_output_disable(uint32_t spi_periph);
|
||||
|
||||
#endif /* GD32F4XX_SPI_H */
|
||||
|
||||
+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
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_tli.h
|
||||
\brief definitions for the TLI
|
||||
\file gd32f4xx_tli.h
|
||||
\brief definitions for the TLI
|
||||
|
||||
\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.1, 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_TLI_H
|
||||
@@ -17,8 +42,8 @@
|
||||
/* TLI definitions */
|
||||
#define TLI TLI_BASE /*!< TLI base address */
|
||||
/* TLI layer definitions */
|
||||
#define LAYER0 TLI_BASE /*!< Layer0 base address */
|
||||
#define LAYER1 (TLI_BASE+0x80) /*!< Layer1 base address */
|
||||
#define LAYER0 TLI_BASE /*!< TLI layer0 base address */
|
||||
#define LAYER1 (TLI_BASE+0x80) /*!< TLI layer1 base address */
|
||||
|
||||
/* registers definitions */
|
||||
#define TLI_SPSZ REG32(TLI + 0x08U) /*!< TLI synchronous pulse size register */
|
||||
@@ -45,8 +70,7 @@
|
||||
#define TLI_LxFBADDR(layerx) REG32((layerx) + 0xACU) /*!< TLI layer x frame base address register */
|
||||
#define TLI_LxFLLEN(layerx) REG32((layerx) + 0xB0U) /*!< TLI layer x frame line length register */
|
||||
#define TLI_LxFTLN(layerx) REG32((layerx) + 0xB4U) /*!< TLI layer x frame total line number register */
|
||||
#define TLI_LxLUT(layerx) REG32((layerx) + 0xC4U) /*!< TLI ayer x Look Up Table register */
|
||||
|
||||
#define TLI_LxLUT(layerx) REG32((layerx) + 0xC4U) /*!< TLI layer x look up table register */
|
||||
|
||||
/* bits definitions */
|
||||
/* TLI_SPSZ */
|
||||
@@ -154,8 +178,8 @@
|
||||
#define TLI_LxFBADDR_FBADD BITS(0,31) /*!< frame buffer base address */
|
||||
|
||||
/* TLI_LxFLLEN */
|
||||
#define TLI_LxFLLEN_FLL BITS(0,12) /*!< frame line length */
|
||||
#define TLI_LxFLLEN_STDOFF BITS(16,28) /*!< frame buffer stride offset */
|
||||
#define TLI_LxFLLEN_FLL BITS(0,13) /*!< frame line length */
|
||||
#define TLI_LxFLLEN_STDOFF BITS(16,29) /*!< frame buffer stride offset */
|
||||
|
||||
/* TLI_LxFTLN */
|
||||
#define TLI_LxFTLN_FTLN BITS(0,10) /*!< frame total line number */
|
||||
@@ -167,14 +191,13 @@
|
||||
#define TLI_LxLUT_TADD BITS(24,31) /*!< look up table write address */
|
||||
|
||||
/* constants definitions */
|
||||
|
||||
/* TLI parameter struct definitions */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t synpsz_vpsz; /*!< size of the vertical synchronous pulse */
|
||||
uint32_t synpsz_hpsz; /*!< size of the horizontal synchronous pulse */
|
||||
uint32_t backpsz_vbpsz; /*!< size of the vertical back porch plus synchronous pulse */
|
||||
uint32_t backpsz_hbpsz; /*!< size of the horizontal back porch plus synchronous pulse */
|
||||
{
|
||||
uint16_t synpsz_vpsz; /*!< size of the vertical synchronous pulse */
|
||||
uint16_t synpsz_hpsz; /*!< size of the horizontal synchronous pulse */
|
||||
uint16_t backpsz_vbpsz; /*!< size of the vertical back porch plus synchronous pulse */
|
||||
uint16_t backpsz_hbpsz; /*!< size of the horizontal back porch plus synchronous pulse */
|
||||
uint32_t activesz_vasz; /*!< size of the vertical active area width plus back porch and synchronous pulse */
|
||||
uint32_t activesz_hasz; /*!< size of the horizontal active area width plus back porch and synchronous pulse */
|
||||
uint32_t totalsz_vtsz; /*!< vertical total size of the display */
|
||||
@@ -186,141 +209,168 @@ typedef struct
|
||||
uint32_t signalpolarity_vs; /*!< vertical pulse polarity selection */
|
||||
uint32_t signalpolarity_de; /*!< data enable polarity selection */
|
||||
uint32_t signalpolarity_pixelck; /*!< pixel clock polarity selection */
|
||||
}tli_parameter_struct;
|
||||
}tli_parameter_struct;
|
||||
|
||||
/* TLI Layer parameter struct definitions */
|
||||
/* TLI layer parameter struct definitions */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t layer_window_rightpos; /*!< window right position */
|
||||
uint32_t layer_window_leftpos; /*!< window left position */
|
||||
uint32_t layer_window_bottompos; /*!< window bottom position */
|
||||
uint32_t layer_window_toppos; /*!< window top position */
|
||||
{
|
||||
uint16_t layer_window_rightpos; /*!< window right position */
|
||||
uint16_t layer_window_leftpos; /*!< window left position */
|
||||
uint16_t layer_window_bottompos; /*!< window bottom position */
|
||||
uint16_t layer_window_toppos; /*!< window top position */
|
||||
uint32_t layer_ppf; /*!< packeted pixel format */
|
||||
uint32_t layer_sa; /*!< specified alpha */
|
||||
uint32_t layer_default_alpha; /*!< the default color alpha */
|
||||
uint32_t layer_default_red; /*!< the default color red */
|
||||
uint32_t layer_default_green; /*!< the default color green */
|
||||
uint32_t layer_default_blue; /*!< the default color blue */
|
||||
uint8_t layer_sa; /*!< specified alpha */
|
||||
uint8_t layer_default_alpha; /*!< the default color alpha */
|
||||
uint8_t layer_default_red; /*!< the default color red */
|
||||
uint8_t layer_default_green; /*!< the default color green */
|
||||
uint8_t layer_default_blue; /*!< the default color blue */
|
||||
uint32_t layer_acf1; /*!< alpha calculation factor 1 of blending method */
|
||||
uint32_t layer_acf2; /*!< alpha calculation factor 2 of blending method */
|
||||
uint32_t layer_frame_bufaddr; /*!< frame buffer base address */
|
||||
uint32_t layer_frame_buf_stride_offset; /*!< frame buffer stride offset */
|
||||
uint32_t layer_frame_line_length; /*!< frame line length */
|
||||
uint32_t layer_frame_total_line_number; /*!< frame total line number */
|
||||
}tli_layer_parameter_struct;
|
||||
uint16_t layer_frame_buf_stride_offset; /*!< frame buffer stride offset */
|
||||
uint16_t layer_frame_line_length; /*!< frame line length */
|
||||
uint16_t layer_frame_total_line_number; /*!< frame total line number */
|
||||
}tli_layer_parameter_struct;
|
||||
|
||||
/* TLI layer LUT parameter struct definitions */
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
uint32_t layer_table_addr; /*!< look up table write address */
|
||||
uint32_t layer_lut_channel_red; /*!< red channel of a LUT entry */
|
||||
uint32_t layer_lut_channel_green; /*!< green channel of a LUT entry */
|
||||
uint32_t layer_lut_channel_blue; /*!< blue channel of a LUT entry */
|
||||
}tli_layer_lut_parameter_struct;
|
||||
uint8_t layer_lut_channel_red; /*!< red channel of a LUT entry */
|
||||
uint8_t layer_lut_channel_green; /*!< green channel of a LUT entry */
|
||||
uint8_t layer_lut_channel_blue; /*!< blue channel of a LUT entry */
|
||||
}tli_layer_lut_parameter_struct;
|
||||
|
||||
/* packeted pixel format */
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
LAYER_PPF_ARGB8888, /*!< layerx pixel format ARGB8888 */
|
||||
LAYER_PPF_RGB888, /*!< layerx pixel format RGB888 */
|
||||
LAYER_PPF_RGB565, /*!< layerx pixel format RGB565 */
|
||||
LAYER_PPF_ARGB1555, /*!< layerx pixel format ARGB1555 */
|
||||
LAYER_PPF_ARGB4444, /*!< layerx pixel format ARGB4444 */
|
||||
LAYER_PPF_L8, /*!< layerx pixel format L8 */
|
||||
LAYER_PPF_AL44, /*!< layerx pixel format AL44 */
|
||||
LAYER_PPF_AL88 /*!< layerx pixel format AL88 */
|
||||
} tli_layer_ppf_enum;
|
||||
LAYER_PPF_ARGB8888, /*!< layerx pixel format ARGB8888 */
|
||||
LAYER_PPF_RGB888, /*!< layerx pixel format RGB888 */
|
||||
LAYER_PPF_RGB565, /*!< layerx pixel format RGB565 */
|
||||
LAYER_PPF_ARGB1555, /*!< layerx pixel format ARGB1555 */
|
||||
LAYER_PPF_ARGB4444, /*!< layerx pixel format ARGB4444 */
|
||||
LAYER_PPF_L8, /*!< layerx pixel format L8 */
|
||||
LAYER_PPF_AL44, /*!< layerx pixel format AL44 */
|
||||
LAYER_PPF_AL88 /*!< layerx pixel format AL88 */
|
||||
}tli_layer_ppf_enum;
|
||||
|
||||
/* TLI flags */
|
||||
#define TLI_FLAG_VDE TLI_STAT_VDE /*!< current VDE status */
|
||||
#define TLI_FLAG_HDE TLI_STAT_HDE /*!< current HDE status */
|
||||
#define TLI_FLAG_VS TLI_STAT_VS /*!< current VS status of the TLI */
|
||||
#define TLI_FLAG_HS TLI_STAT_HS /*!< current HS status of the TLI */
|
||||
#define TLI_FLAG_LM BIT(0) | BIT(31) /*!< line mark interrupt flag */
|
||||
#define TLI_FLAG_FE BIT(1) | BIT(31) /*!< FIFO error interrupt flag */
|
||||
#define TLI_FLAG_TE BIT(2) | BIT(31) /*!< transaction error interrupt flag */
|
||||
#define TLI_FLAG_LCR BIT(3) | BIT(31) /*!< layer configuration reloaded interrupt flag */
|
||||
|
||||
/* TLI interrupt enable or disable */
|
||||
#define TLI_INT_LM BIT(0) /*!< line mark interrupt */
|
||||
#define TLI_INT_FE BIT(1) /*!< FIFO error interrupt */
|
||||
#define TLI_INT_TE BIT(2) /*!< transaction error interrupt */
|
||||
#define TLI_INT_LCR BIT(3) /*!< layer configuration reloaded interrupt */
|
||||
|
||||
/* TLI interrupt flag */
|
||||
#define TLI_INT_FLAG_LM BIT(0) /*!< line mark interrupt flag */
|
||||
#define TLI_INT_FLAG_FE BIT(1) /*!< FIFO error interrupt flag */
|
||||
#define TLI_INT_FLAG_TE BIT(2) /*!< transaction error interrupt flag */
|
||||
#define TLI_INT_FLAG_LCR BIT(3) /*!< layer configuration reloaded interrupt flag */
|
||||
|
||||
/* layer reload configure */
|
||||
#define TLI_FRAME_BLANK_RELOAD_EN ((uint8_t)0x00U) /*!< the layer configuration will be reloaded at frame blank */
|
||||
#define TLI_REQUEST_RELOAD_EN ((uint8_t)0x01U) /*!< the layer configuration will be reloaded after this bit sets */
|
||||
#define TLI_FRAME_BLANK_RELOAD_EN ((uint8_t)0x00U) /*!< the layer configuration will be reloaded at frame blank */
|
||||
#define TLI_REQUEST_RELOAD_EN ((uint8_t)0x01U) /*!< the layer configuration will be reloaded after this bit sets */
|
||||
|
||||
/* dither Function */
|
||||
#define TLI_DITHER_DISABLE ((uint8_t)0x00U) /*!< dither function disable */
|
||||
#define TLI_DITHER_ENABLE ((uint8_t)0x01U) /*!< dither function enable */
|
||||
/* dither function */
|
||||
#define TLI_DITHER_DISABLE ((uint8_t)0x00U) /*!< dither function disable */
|
||||
#define TLI_DITHER_ENABLE ((uint8_t)0x01U) /*!< dither function enable */
|
||||
|
||||
/* horizontal pulse polarity selection */
|
||||
|
||||
#define TLI_HSYN_ACTLIVE_LOW ((uint32_t)0x00000000U) /*!< horizontal synchronous pulse active low */
|
||||
#define TLI_HSYN_ACTLIVE_HIGHT TLI_CTL_HPPS /*!< horizontal synchronous pulse active high */
|
||||
|
||||
#define TLI_HSYN_ACTLIVE_LOW ((uint32_t)0x00000000U) /*!< horizontal synchronous pulse active low */
|
||||
#define TLI_HSYN_ACTLIVE_HIGHT TLI_CTL_HPPS /*!< horizontal synchronous pulse active high */
|
||||
|
||||
/* vertical pulse polarity selection */
|
||||
#define TLI_VSYN_ACTLIVE_LOW ((uint32_t)0x00000000U) /*!< vertical synchronous pulse active low */
|
||||
#define TLI_VSYN_ACTLIVE_HIGHT TLI_CTL_VPPS /*!< vertical synchronous pulse active high */
|
||||
|
||||
#define TLI_VSYN_ACTLIVE_LOW ((uint32_t)0x00000000U) /*!< vertical synchronous pulse active low */
|
||||
#define TLI_VSYN_ACTLIVE_HIGHT TLI_CTL_VPPS /*!< vertical synchronous pulse active high */
|
||||
/* pixel clock polarity selection */
|
||||
#define TLI_PIXEL_CLOCK_TLI ((uint32_t)0x00000000U) /*!< pixel clock is TLI clock */
|
||||
#define TLI_PIXEL_CLOCK_INVERTEDTLI TLI_CTL_CLKPS /*!< pixel clock is inverted TLI clock */
|
||||
|
||||
|
||||
/* pixel Clock Polarity Selection */
|
||||
|
||||
#define TLI_PIXEL_CLOCK_TLI ((uint32_t)0x00000000U) /*!< pixel clock is TLI clock */
|
||||
#define TLI_PIXEL_CLOCK_INVERTEDTLI TLI_CTL_CLKPS /*!< pixel clock is inverted TLI clock */
|
||||
|
||||
|
||||
/* data Enable Polarity Selection */
|
||||
|
||||
#define TLI_DE_ACTLIVE_LOW ((uint32_t)0x00000000U) /*!< data enable active low */
|
||||
#define TLI_DE_ACTLIVE_HIGHT TLI_CTL_DEPS /*!< data enable active high */
|
||||
/* data enable polarity selection */
|
||||
#define TLI_DE_ACTLIVE_LOW ((uint32_t)0x00000000U) /*!< data enable active low */
|
||||
#define TLI_DE_ACTLIVE_HIGHT TLI_CTL_DEPS /*!< data enable active high */
|
||||
|
||||
/* alpha calculation factor 1 of blending method */
|
||||
#define LxBLEND_ACF1(regval) (BITS(8,10) & ((regval)<<8))
|
||||
#define LAYER_ACF1_SA LxBLEND_ACF1(4) /*!< normalization specified alpha */
|
||||
#define LAYER_ACF1_PASA LxBLEND_ACF1(6) /*!< normalization pixel alpha * normalization specified alpha */
|
||||
#define LxBLEND_ACF1(regval) (BITS(8,10) & ((uint32_t)(regval)<<8))
|
||||
#define LAYER_ACF1_SA LxBLEND_ACF1(4) /*!< normalization specified alpha */
|
||||
#define LAYER_ACF1_PASA LxBLEND_ACF1(6) /*!< normalization pixel alpha * normalization specified alpha */
|
||||
|
||||
/* alpha calculation factor 2 of blending method */
|
||||
#define LxBLEND_ACF2(regval) (BITS(0,2) & ((uint32_t)(regval)))
|
||||
#define LAYER_ACF2_SA LxBLEND_ACF2(5) /*!< normalization specified alpha */
|
||||
#define LAYER_ACF2_PASA LxBLEND_ACF2(7) /*!< normalization pixel alpha * normalization specified alpha */
|
||||
|
||||
/* alpha calculation factor 2 of blending method*/
|
||||
#define LxBLEND_ACF2(regval) (BITS(0,2) & ((regval)))
|
||||
#define LAYER_ACF2_SA LxBLEND_ACF2(5) /*!< normalization specified alpha */
|
||||
#define LAYER_ACF2_PASA LxBLEND_ACF2(7) /*!< normalization pixel alpha x normalization specified alpha */
|
||||
/* function declarations */
|
||||
|
||||
/* deinitialize TLI */
|
||||
/* initialization functions, TLI enable or disable, TLI reload mode configuration */
|
||||
/* deinitialize TLI registers */
|
||||
void tli_deinit(void);
|
||||
/* initialize the parameters of TLI parameter structure with the default values, it is suggested
|
||||
that call this function after a tli_parameter_struct structure is defined */
|
||||
void tli_struct_para_init(tli_parameter_struct *tli_struct);
|
||||
/* initialize TLI */
|
||||
void tli_init(tli_parameter_struct *tli_struct);
|
||||
/* TLI dither function enable */
|
||||
void tli_dither_config(uint8_t ditherstat);
|
||||
/* configure TLI dither function */
|
||||
void tli_dither_config(uint8_t dither_stat);
|
||||
/* enable TLI */
|
||||
void tli_enable(void);
|
||||
/* disable TLI */
|
||||
void tli_disable(void);
|
||||
/* TLI reload mode config*/
|
||||
void tli_reload_config(uint8_t reloadmod);
|
||||
/* configurate TLI reload mode */
|
||||
void tli_reload_config(uint8_t reload_mod);
|
||||
|
||||
/* TLI interrupt enable */
|
||||
void tli_interrupt_enable(uint32_t inttype);
|
||||
/* TLI interrupt disable */
|
||||
void tli_interrupt_disable(uint32_t inttype);
|
||||
/* get TLI interrupt flag */
|
||||
FlagStatus tli_interrupt_flag_get(uint32_t intflag);
|
||||
/* clear TLI interrupt flag */
|
||||
void tli_interrupt_flag_clear(uint32_t intflag);
|
||||
/* TLI layer configuration functions */
|
||||
/* initialize the parameters of TLI layer structure with the default values, it is suggested
|
||||
that call this function after a tli_layer_parameter_struct structure is defined */
|
||||
void tli_layer_struct_para_init(tli_layer_parameter_struct *layer_struct);
|
||||
/* initialize TLI layer */
|
||||
void tli_layer_init(uint32_t layerx,tli_layer_parameter_struct *layer_struct);
|
||||
/* reconfigure window position */
|
||||
void tli_layer_window_offset_modify(uint32_t layerx,uint16_t offset_x,uint16_t offset_y);
|
||||
/* initialize the parameters of TLI layer LUT structure with the default values, it is suggested
|
||||
that call this function after a tli_layer_lut_parameter_struct structure is defined */
|
||||
void tli_lut_struct_para_init(tli_layer_lut_parameter_struct *lut_struct);
|
||||
/* initialize TLI layer LUT */
|
||||
void tli_lut_init(uint32_t layerx,tli_layer_lut_parameter_struct *lut_struct);
|
||||
/* initialize TLI layer color key */
|
||||
void tli_color_key_init(uint32_t layerx,uint8_t redkey,uint8_t greenkey,uint8_t bluekey);
|
||||
/* enable TLI layer */
|
||||
void tli_layer_enable(uint32_t layerx);
|
||||
/* disable TLI layer */
|
||||
void tli_layer_disable(uint32_t layerx);
|
||||
/* enable TLI layer color keying */
|
||||
void tli_color_key_enable(uint32_t layerx);
|
||||
/* disable TLI layer color keying */
|
||||
void tli_color_key_disable(uint32_t layerx);
|
||||
/* enable TLI layer LUT */
|
||||
void tli_lut_enable(uint32_t layerx);
|
||||
/* disable TLI layer LUT */
|
||||
void tli_lut_disable(uint32_t layerx);
|
||||
|
||||
/* set line mark value */
|
||||
void tli_line_mark_set(uint32_t linenum);
|
||||
void tli_line_mark_set(uint16_t line_num);
|
||||
/* get current displayed position */
|
||||
uint32_t tli_current_pos_get(void);
|
||||
/* get TLI state */
|
||||
FlagStatus tli_flag_get(uint32_t state);
|
||||
|
||||
/* TLI layer enable */
|
||||
void tli_layer_enable(uint32_t layerx);
|
||||
/* TLI layer disable */
|
||||
void tli_layer_disable(uint32_t layerx);
|
||||
/* TLI layer color keying enable */
|
||||
void tli_color_key_enable(uint32_t layerx);
|
||||
/* TLI layer color keying disable */
|
||||
void tli_color_key_disable(uint32_t layerx);
|
||||
/* TLI layer LUT enable */
|
||||
void tli_lut_enable(uint32_t layerx);
|
||||
/* TLI layer LUT disable */
|
||||
void tli_lut_disable(uint32_t layerx);
|
||||
/* TLI layer initialize */
|
||||
void tli_layer_init(uint32_t layerx,tli_layer_parameter_struct *layer_struct);
|
||||
/* TLI layer initialize */
|
||||
void tli_layer_window_offset_modify(uint32_t layerx,uint32_t offset_x,uint32_t offset_y);
|
||||
/* TLI layer lut initialize */
|
||||
void tli_lut_init(uint32_t layerx,tli_layer_lut_parameter_struct *lut_struct);
|
||||
/* TLI layer key initialize */
|
||||
void tli_ckey_init(uint32_t layerx,uint32_t redkey,uint32_t greenkey,uint32_t bluekey);
|
||||
/* flag and interrupt functions */
|
||||
/* enable TLI interrupt */
|
||||
void tli_interrupt_enable(uint32_t int_flag);
|
||||
/* disable TLI interrupt */
|
||||
void tli_interrupt_disable(uint32_t int_flag);
|
||||
/* get TLI interrupt flag */
|
||||
FlagStatus tli_interrupt_flag_get(uint32_t int_flag);
|
||||
/* clear TLI interrupt flag */
|
||||
void tli_interrupt_flag_clear(uint32_t int_flag);
|
||||
/* get TLI flag or state in TLI_INTF register or TLI_STAT register */
|
||||
FlagStatus tli_flag_get(uint32_t flag);
|
||||
|
||||
#endif /* GD32F4XX_TLI_H */
|
||||
|
||||
@@ -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
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_usart.h
|
||||
\brief definitions for the USART
|
||||
\file gd32f4xx_usart.h
|
||||
\brief definitions for the USART
|
||||
|
||||
\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_USART_H
|
||||
@@ -14,8 +39,8 @@
|
||||
|
||||
#include "gd32f4xx.h"
|
||||
|
||||
/* USARTx(x=0,1) definitions */
|
||||
#define USART1 USART_BASE
|
||||
/* USARTx(x=0,1,2,5)/UARTx(x=3,4,6,7) definitions */
|
||||
#define USART1 USART_BASE /*!< USART1 base address */
|
||||
#define USART2 (USART_BASE+0x00000400U) /*!< USART2 base address */
|
||||
#define UART3 (USART_BASE+0x00000800U) /*!< UART3 base address */
|
||||
#define UART4 (USART_BASE+0x00000C00U) /*!< UART4 base address */
|
||||
@@ -102,7 +127,7 @@
|
||||
/* USARTx_GP */
|
||||
#define USART_GP_PSC BITS(0,7) /*!< prescaler value for dividing the system clock */
|
||||
#define USART_GP_GUAT BITS(8,15) /*!< guard time value in smartcard mode */
|
||||
|
||||
|
||||
/* USARTx_CTL3 */
|
||||
#define USART_CTL3_RTEN BIT(0) /*!< receiver timeout enable */
|
||||
#define USART_CTL3_SCRTNUM BITS(1,3) /*!< smartcard auto-retry number */
|
||||
@@ -131,59 +156,85 @@
|
||||
/* constants definitions */
|
||||
/* define the USART bit position and its register index offset */
|
||||
#define USART_REGIDX_BIT(regidx, bitpos) (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos))
|
||||
#define USART_REG_VAL(usartx, offset) (REG32((usartx) + ((uint32_t)(offset) >> 6)))
|
||||
#define USART_REG_VAL(usartx, offset) (REG32((usartx) + (((uint32_t)(offset) & 0xFFFFU) >> 6)))
|
||||
#define USART_BIT_POS(val) ((uint32_t)(val) & 0x1FU)
|
||||
#define USART_REGIDX_BIT2(regidx, bitpos, regidx2, bitpos2) (((uint32_t)(regidx2) << 22) | (uint32_t)((bitpos2) << 16)\
|
||||
| (((uint32_t)(regidx) << 6) | (uint32_t)(bitpos)))
|
||||
#define USART_REG_VAL2(usartx, offset) (REG32((usartx) + ((uint32_t)(offset) >> 22)))
|
||||
#define USART_BIT_POS2(val) (((uint32_t)(val) & 0x1F0000U) >> 16)
|
||||
|
||||
/* register offset */
|
||||
#define STAT0_REG_OFFSET 0x00U /*!< STAT0 register offset */
|
||||
#define STAT1_REG_OFFSET 0x88U /*!< STAT1 register offset */
|
||||
#define CHC_REG_OFFSET 0xC0U /*!< CHC register offset */
|
||||
#define CTL0_REG_OFFSET 0x0CU /*!< CTL0 register offset */
|
||||
#define CTL1_REG_OFFSET 0x10U /*!< CTL1 register offset */
|
||||
#define CTL2_REG_OFFSET 0x14U /*!< CTL2 register offset */
|
||||
#define CTL3_REG_OFFSET 0x80U /*!< CTL2 register offset */
|
||||
#define USART_STAT0_REG_OFFSET 0x00U /*!< STAT0 register offset */
|
||||
#define USART_STAT1_REG_OFFSET 0x88U /*!< STAT1 register offset */
|
||||
#define USART_CTL0_REG_OFFSET 0x0CU /*!< CTL0 register offset */
|
||||
#define USART_CTL1_REG_OFFSET 0x10U /*!< CTL1 register offset */
|
||||
#define USART_CTL2_REG_OFFSET 0x14U /*!< CTL2 register offset */
|
||||
#define USART_CTL3_REG_OFFSET 0x80U /*!< CTL3 register offset */
|
||||
#define USART_CHC_REG_OFFSET 0xC0U /*!< CHC register offset */
|
||||
|
||||
/* USART flags */
|
||||
typedef enum
|
||||
{
|
||||
/* flags in STAT0 register */
|
||||
USART_FLAG_CTSF = USART_REGIDX_BIT(STAT0_REG_OFFSET, 9U), /*!< CTS change flag */
|
||||
USART_FLAG_LBDF = USART_REGIDX_BIT(STAT0_REG_OFFSET, 8U), /*!< LIN break detected flag */
|
||||
USART_FLAG_TBE = USART_REGIDX_BIT(STAT0_REG_OFFSET, 7U), /*!< transmit data buffer empty */
|
||||
USART_FLAG_TC = USART_REGIDX_BIT(STAT0_REG_OFFSET, 6U), /*!< transmission complete */
|
||||
USART_FLAG_RBNE = USART_REGIDX_BIT(STAT0_REG_OFFSET, 5U), /*!< read data buffer not empty */
|
||||
USART_FLAG_IDLEF = USART_REGIDX_BIT(STAT0_REG_OFFSET, 4U), /*!< IDLE frame detected flag */
|
||||
USART_FLAG_ORERR = USART_REGIDX_BIT(STAT0_REG_OFFSET, 3U), /*!< overrun error */
|
||||
USART_FLAG_NERR = USART_REGIDX_BIT(STAT0_REG_OFFSET, 2U), /*!< noise error flag */
|
||||
USART_FLAG_FERR = USART_REGIDX_BIT(STAT0_REG_OFFSET, 1U), /*!< frame error flag */
|
||||
USART_FLAG_PERR = USART_REGIDX_BIT(STAT0_REG_OFFSET, 0U), /*!< parity error flag */
|
||||
USART_FLAG_CTS = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 9U), /*!< CTS change flag */
|
||||
USART_FLAG_LBD = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 8U), /*!< LIN break detected flag */
|
||||
USART_FLAG_TBE = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 7U), /*!< transmit data buffer empty */
|
||||
USART_FLAG_TC = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 6U), /*!< transmission complete */
|
||||
USART_FLAG_RBNE = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 5U), /*!< read data buffer not empty */
|
||||
USART_FLAG_IDLE = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 4U), /*!< IDLE frame detected flag */
|
||||
USART_FLAG_ORERR = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 3U), /*!< overrun error */
|
||||
USART_FLAG_NERR = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 2U), /*!< noise error flag */
|
||||
USART_FLAG_FERR = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 1U), /*!< frame error flag */
|
||||
USART_FLAG_PERR = USART_REGIDX_BIT(USART_STAT0_REG_OFFSET, 0U), /*!< parity error flag */
|
||||
/* flags in STAT1 register */
|
||||
USART_FLAG_BSY = USART_REGIDX_BIT(STAT1_REG_OFFSET, 16U), /*!< busy flag */
|
||||
USART_FLAG_EBF = USART_REGIDX_BIT(STAT1_REG_OFFSET, 12U), /*!< end of block flag */
|
||||
USART_FLAG_RTF = USART_REGIDX_BIT(STAT1_REG_OFFSET, 11U), /*!< receiver timeout flag */
|
||||
USART_FLAG_BSY = USART_REGIDX_BIT(USART_STAT1_REG_OFFSET, 16U), /*!< busy flag */
|
||||
USART_FLAG_EB = USART_REGIDX_BIT(USART_STAT1_REG_OFFSET, 12U), /*!< end of block flag */
|
||||
USART_FLAG_RT = USART_REGIDX_BIT(USART_STAT1_REG_OFFSET, 11U), /*!< receiver timeout flag */
|
||||
/* flags in CHC register */
|
||||
USART_FLAG_EPERR = USART_REGIDX_BIT(CHC_REG_OFFSET, 8U), /*!< early parity error flag */
|
||||
USART_FLAG_EPERR = USART_REGIDX_BIT(USART_CHC_REG_OFFSET, 8U), /*!< early parity error flag */
|
||||
}usart_flag_enum;
|
||||
|
||||
/* USART interrupt flags */
|
||||
typedef enum
|
||||
{
|
||||
/* interrupt flags in CTL0 register */
|
||||
USART_INT_PERRIE = USART_REGIDX_BIT(CTL0_REG_OFFSET, 8U), /*!< parity error interrupt */
|
||||
USART_INT_TBEIE = USART_REGIDX_BIT(CTL0_REG_OFFSET, 7U), /*!< transmitter buffer empty interrupt */
|
||||
USART_INT_TCIE = USART_REGIDX_BIT(CTL0_REG_OFFSET, 6U), /*!< transmission complete interrupt */
|
||||
USART_INT_RBNEIE = USART_REGIDX_BIT(CTL0_REG_OFFSET, 5U), /*!< read data buffer not empty interrupt and overrun error interrupt */
|
||||
USART_INT_IDLEIE = USART_REGIDX_BIT(CTL0_REG_OFFSET, 4U), /*!< IDLE line detected interrupt */
|
||||
USART_INT_FLAG_PERR = USART_REGIDX_BIT2(USART_CTL0_REG_OFFSET, 8U, USART_STAT0_REG_OFFSET, 0U), /*!< parity error interrupt and flag */
|
||||
USART_INT_FLAG_TBE = USART_REGIDX_BIT2(USART_CTL0_REG_OFFSET, 7U, USART_STAT0_REG_OFFSET, 7U), /*!< transmitter buffer empty interrupt and flag */
|
||||
USART_INT_FLAG_TC = USART_REGIDX_BIT2(USART_CTL0_REG_OFFSET, 6U, USART_STAT0_REG_OFFSET, 6U), /*!< transmission complete interrupt and flag */
|
||||
USART_INT_FLAG_RBNE = USART_REGIDX_BIT2(USART_CTL0_REG_OFFSET, 5U, USART_STAT0_REG_OFFSET, 5U), /*!< read data buffer not empty interrupt and flag */
|
||||
USART_INT_FLAG_RBNE_ORERR = USART_REGIDX_BIT2(USART_CTL0_REG_OFFSET, 5U, USART_STAT0_REG_OFFSET, 3U), /*!< read data buffer not empty interrupt and overrun error flag */
|
||||
USART_INT_FLAG_IDLE = USART_REGIDX_BIT2(USART_CTL0_REG_OFFSET, 4U, USART_STAT0_REG_OFFSET, 4U), /*!< IDLE line detected interrupt and flag */
|
||||
/* interrupt flags in CTL1 register */
|
||||
USART_INT_LBDIE = USART_REGIDX_BIT(CTL1_REG_OFFSET, 6U), /*!< LIN break detected interrupt */
|
||||
USART_INT_FLAG_LBD = USART_REGIDX_BIT2(USART_CTL1_REG_OFFSET, 6U, USART_STAT0_REG_OFFSET, 8U), /*!< LIN break detected interrupt and flag */
|
||||
/* interrupt flags in CTL2 register */
|
||||
USART_INT_CTSIE = USART_REGIDX_BIT(CTL2_REG_OFFSET, 10U), /*!< CTS interrupt */
|
||||
USART_INT_ERRIE = USART_REGIDX_BIT(CTL2_REG_OFFSET, 0U), /*!< error interrupt */
|
||||
USART_INT_FLAG_CTS = USART_REGIDX_BIT2(USART_CTL2_REG_OFFSET, 10U, USART_STAT0_REG_OFFSET, 9U), /*!< CTS interrupt and flag */
|
||||
USART_INT_FLAG_ERR_ORERR = USART_REGIDX_BIT2(USART_CTL2_REG_OFFSET, 0U, USART_STAT0_REG_OFFSET, 3U), /*!< error interrupt and overrun error */
|
||||
USART_INT_FLAG_ERR_NERR = USART_REGIDX_BIT2(USART_CTL2_REG_OFFSET, 0U, USART_STAT0_REG_OFFSET, 2U), /*!< error interrupt and noise error flag */
|
||||
USART_INT_FLAG_ERR_FERR = USART_REGIDX_BIT2(USART_CTL2_REG_OFFSET, 0U, USART_STAT0_REG_OFFSET, 1U), /*!< error interrupt and frame error flag */
|
||||
/* interrupt flags in CTL3 register */
|
||||
USART_INT_EBIE = USART_REGIDX_BIT(CTL3_REG_OFFSET, 5U), /*!< interrupt enable bit of end of block event */
|
||||
USART_INT_RTIE = USART_REGIDX_BIT(CTL3_REG_OFFSET, 4U), /*!< interrupt enable bit of receive timeout event */
|
||||
USART_INT_FLAG_EB = USART_REGIDX_BIT2(USART_CTL3_REG_OFFSET, 5U, USART_STAT1_REG_OFFSET, 12U), /*!< interrupt enable bit of end of block event and flag */
|
||||
USART_INT_FLAG_RT = USART_REGIDX_BIT2(USART_CTL3_REG_OFFSET, 4U, USART_STAT1_REG_OFFSET, 11U), /*!< interrupt enable bit of receive timeout event and flag */
|
||||
}usart_interrupt_flag_enum;
|
||||
|
||||
/* USART interrupt flags */
|
||||
typedef enum
|
||||
{
|
||||
/* interrupt in CTL0 register */
|
||||
USART_INT_PERR = USART_REGIDX_BIT(USART_CTL0_REG_OFFSET, 8U), /*!< parity error interrupt */
|
||||
USART_INT_TBE = USART_REGIDX_BIT(USART_CTL0_REG_OFFSET, 7U), /*!< transmitter buffer empty interrupt */
|
||||
USART_INT_TC = USART_REGIDX_BIT(USART_CTL0_REG_OFFSET, 6U), /*!< transmission complete interrupt */
|
||||
USART_INT_RBNE = USART_REGIDX_BIT(USART_CTL0_REG_OFFSET, 5U), /*!< read data buffer not empty interrupt and overrun error interrupt */
|
||||
USART_INT_IDLE = USART_REGIDX_BIT(USART_CTL0_REG_OFFSET, 4U), /*!< IDLE line detected interrupt */
|
||||
/* interrupt in CTL1 register */
|
||||
USART_INT_LBD = USART_REGIDX_BIT(USART_CTL1_REG_OFFSET, 6U), /*!< LIN break detected interrupt */
|
||||
/* interrupt in CTL2 register */
|
||||
USART_INT_CTS = USART_REGIDX_BIT(USART_CTL2_REG_OFFSET, 10U), /*!< CTS interrupt */
|
||||
USART_INT_ERR = USART_REGIDX_BIT(USART_CTL2_REG_OFFSET, 0U), /*!< error interrupt */
|
||||
/* interrupt in CTL3 register */
|
||||
USART_INT_EB = USART_REGIDX_BIT(USART_CTL3_REG_OFFSET, 5U), /*!< interrupt enable bit of end of block event */
|
||||
USART_INT_RT = USART_REGIDX_BIT(USART_CTL3_REG_OFFSET, 4U), /*!< interrupt enable bit of receive timeout event */
|
||||
}usart_interrupt_enum;
|
||||
|
||||
/* USART invert configure */
|
||||
typedef enum
|
||||
{
|
||||
@@ -211,8 +262,8 @@ typedef enum
|
||||
/* USART parity bits definitions */
|
||||
#define CTL0_PM(regval) (BITS(9,10) & ((uint32_t)(regval) << 9))
|
||||
#define USART_PM_NONE CTL0_PM(0) /*!< no parity */
|
||||
#define USART_PM_ODD CTL0_PM(2) /*!< odd parity */
|
||||
#define USART_PM_EVEN CTL0_PM(3) /*!< even parity */
|
||||
#define USART_PM_EVEN CTL0_PM(2) /*!< even parity */
|
||||
#define USART_PM_ODD CTL0_PM(3) /*!< odd parity */
|
||||
|
||||
/* USART wakeup method in mute mode */
|
||||
#define CTL0_WM(regval) (BIT(11) & ((uint32_t)(regval) << 11))
|
||||
@@ -306,30 +357,6 @@ typedef enum
|
||||
#define USART_HCM_NONE CHC_HCM(0) /*!< nRTS signal equals to the rxne status register */
|
||||
#define USART_HCM_EN CHC_HCM(1) /*!< nRTS signal is set when the last data bit has been sampled */
|
||||
|
||||
/* interrupt enable in USART_CTL0 */
|
||||
#define USART_INTEN_PERRIE ((uint32_t)0x10000100U) /*!< parity error interrupt */
|
||||
#define USART_INTEN_TBEIE ((uint32_t)0x10000080U) /*!< transmitter buffer empty interrupt */
|
||||
#define USART_INTEN_TCIE ((uint32_t)0x10000040U) /*!< transmission complete interrupt */
|
||||
#define USART_INTEN_RBNEIE ((uint32_t)0x10000020U) /*!< read data buffer not empty interrupt and overrun error interrupt */
|
||||
#define USART_INTEN_IDLEIE ((uint32_t)0x10000010U) /*!< IDLE line detected interrupt */
|
||||
|
||||
/* interrupt enable flag in USART_CTL1 */
|
||||
#define USART_INTEN_LBDIE ((uint32_t)0x20000040U) /*!< LIN break detected interrupt */
|
||||
|
||||
/* interrupt enable flag in USART_CTL2 */
|
||||
#define USART_INTEN_ERRIE ((uint32_t)0x40000001U) /*!< error interrupt */
|
||||
#define USART_INTEN_CTSIE ((uint32_t)0x40000400U) /*!< CTS interrupt*/
|
||||
|
||||
/* interrupt enable flag in USART_CTL3 */
|
||||
#define USART_INTEN_RTIE ((uint32_t)0x80000010U) /*!< interrupt enable bit of receive timeout event */
|
||||
#define USART_INTEN_EBIE ((uint32_t)0x80000020U) /*!< interrupt enable bit of end of block event */
|
||||
|
||||
#define USART_INTEN_MASK ((uint32_t)0x00000FFFU) /*!< USART interrupt mask */
|
||||
#define USART_INTS_CTL0 ((uint32_t)0x10000000U) /*!< interrupt in USART_CTL0 */
|
||||
#define USART_INTS_CTL1 ((uint32_t)0x20000000U) /*!< interrupt in USART_CTL1 */
|
||||
#define USART_INTS_CTL2 ((uint32_t)0x40000000U) /*!< interrupt in USART_CTL2 */
|
||||
#define USART_INTS_CTL3 ((uint32_t)0x80000000U) /*!< interrupt in USART_CTL3 */
|
||||
|
||||
/* function declarations */
|
||||
/* initialization functions */
|
||||
/* reset USART */
|
||||
@@ -342,8 +369,6 @@ void usart_parity_config(uint32_t usart_periph, uint32_t paritycfg);
|
||||
void usart_word_length_set(uint32_t usart_periph, uint32_t wlen);
|
||||
/* configure usart stop bit length */
|
||||
void usart_stop_bit_set(uint32_t usart_periph, uint32_t stblen);
|
||||
|
||||
/* USART normal mode communication */
|
||||
/* enable usart */
|
||||
void usart_enable(uint32_t usart_periph);
|
||||
/* disable usart */
|
||||
@@ -352,6 +377,8 @@ void usart_disable(uint32_t usart_periph);
|
||||
void usart_transmit_config(uint32_t usart_periph, uint32_t txconfig);
|
||||
/* configure USART receiver */
|
||||
void usart_receive_config(uint32_t usart_periph, uint32_t rxconfig);
|
||||
|
||||
/* USART normal mode communication */
|
||||
/* data is transmitted/received with the LSB/MSB first */
|
||||
void usart_data_first_config(uint32_t usart_periph, uint32_t msbf);
|
||||
/* configure USART inverted */
|
||||
@@ -382,43 +409,43 @@ void usart_mute_mode_disable(uint32_t usart_periph);
|
||||
void usart_mute_mode_wakeup_config(uint32_t usart_periph, uint32_t wmehtod);
|
||||
|
||||
/* LIN mode communication */
|
||||
/* LIN mode enable */
|
||||
/* enable LIN mode */
|
||||
void usart_lin_mode_enable(uint32_t usart_periph);
|
||||
/* LIN mode disable */
|
||||
/* disable LIN mode */
|
||||
void usart_lin_mode_disable(uint32_t usart_periph);
|
||||
/* LIN break detection length */
|
||||
void usart_lin_break_dection_length_config(uint32_t usart_periph, uint32_t lblen);
|
||||
void usart_lin_break_detection_length_config(uint32_t usart_periph, uint32_t lblen);
|
||||
/* send break frame */
|
||||
void usart_send_break(uint32_t usart_periph);
|
||||
|
||||
/* half-duplex communication */
|
||||
/* half-duplex enable */
|
||||
/* enable half-duplex mode */
|
||||
void usart_halfduplex_enable(uint32_t usart_periph);
|
||||
/* half-duplex disable */
|
||||
/* disable half-duplex mode */
|
||||
void usart_halfduplex_disable(uint32_t usart_periph);
|
||||
|
||||
/* synchronous communication */
|
||||
/* clock enable */
|
||||
/* enable CK pin in synchronous mode */
|
||||
void usart_synchronous_clock_enable(uint32_t usart_periph);
|
||||
/* clock disable */
|
||||
/* disable CK pin in synchronous mode */
|
||||
void usart_synchronous_clock_disable(uint32_t usart_periph);
|
||||
/* configure usart synchronous mode parameters */
|
||||
void usart_synchronous_clock_config(uint32_t usart_periph, uint32_t clen, uint32_t cph, uint32_t cpl);
|
||||
|
||||
/* smartcard communication */
|
||||
/* guard time value configure in smartcard mode */
|
||||
void usart_guard_time_config(uint32_t usart_periph,uint32_t gaut);
|
||||
/* smartcard mode enable */
|
||||
/* configure guard time value in smartcard mode */
|
||||
void usart_guard_time_config(uint32_t usart_periph, uint32_t guat);
|
||||
/* enable smartcard mode */
|
||||
void usart_smartcard_mode_enable(uint32_t usart_periph);
|
||||
/* smartcard mode disable */
|
||||
/* disable smartcard mode */
|
||||
void usart_smartcard_mode_disable(uint32_t usart_periph);
|
||||
/* NACK enable in smartcard mode */
|
||||
/* enable NACK in smartcard mode */
|
||||
void usart_smartcard_mode_nack_enable(uint32_t usart_periph);
|
||||
/* NACK disable in smartcard mode */
|
||||
/* disable NACK in smartcard mode */
|
||||
void usart_smartcard_mode_nack_disable(uint32_t usart_periph);
|
||||
/* smartcard auto-retry number configure */
|
||||
/* configure smartcard auto-retry number */
|
||||
void usart_smartcard_autoretry_config(uint32_t usart_periph, uint32_t scrtnum);
|
||||
/* block length configure */
|
||||
/* configure block length */
|
||||
void usart_block_length_config(uint32_t usart_periph, uint32_t bl);
|
||||
|
||||
/* IrDA communication */
|
||||
@@ -427,7 +454,7 @@ void usart_irda_mode_enable(uint32_t usart_periph);
|
||||
/* disable IrDA mode */
|
||||
void usart_irda_mode_disable(uint32_t usart_periph);
|
||||
/* configure the peripheral clock prescaler */
|
||||
void usart_prescaler_config(uint32_t usart_periph, uint32_t psc);
|
||||
void usart_prescaler_config(uint32_t usart_periph, uint8_t psc);
|
||||
/* configure IrDA low-power */
|
||||
void usart_irda_lowpower_config(uint32_t usart_periph, uint32_t irlp);
|
||||
|
||||
@@ -445,23 +472,24 @@ void usart_parity_check_coherence_config(uint32_t usart_periph, uint32_t pcm);
|
||||
/* configure hardware flow control coherence mode */
|
||||
void usart_hardware_flow_coherence_config(uint32_t usart_periph, uint32_t hcm);
|
||||
|
||||
/* DMA communication */
|
||||
/* configure USART DMA for reception */
|
||||
void usart_dma_receive_config(uint32_t usart_periph, uint32_t dmacmd);
|
||||
/* configure USART DMA for transmission */
|
||||
void usart_dma_transmit_config(uint32_t usart_periph, uint32_t dmacmd);
|
||||
|
||||
/* flag functions */
|
||||
/* get flag in STAT0/STAT1/CHC register */
|
||||
/* flag & interrupt functions */
|
||||
/* get flag in STAT0/STAT1 register */
|
||||
FlagStatus usart_flag_get(uint32_t usart_periph, usart_flag_enum flag);
|
||||
/* clear flag in STAT0/STAT1/CHC register */
|
||||
/* clear flag in STAT0/STAT1 register */
|
||||
void usart_flag_clear(uint32_t usart_periph, usart_flag_enum flag);
|
||||
|
||||
/* interrupt functions */
|
||||
/* enable USART interrupt */
|
||||
void usart_interrupt_enable(uint32_t usart_periph, uint32_t int_flag);
|
||||
void usart_interrupt_enable(uint32_t usart_periph, usart_interrupt_enum interrupt);
|
||||
/* disable USART interrupt */
|
||||
void usart_interrupt_disable(uint32_t usart_periph, uint32_t int_flag);
|
||||
/* get USART interrupt enable flag */
|
||||
FlagStatus usart_interrupt_flag_get(uint32_t usart_periph, uint32_t int_flag);
|
||||
void usart_interrupt_disable(uint32_t usart_periph, usart_interrupt_enum interrupt);
|
||||
/* get USART interrupt and flag status */
|
||||
FlagStatus usart_interrupt_flag_get(uint32_t usart_periph, usart_interrupt_flag_enum int_flag);
|
||||
/* clear interrupt flag in STAT0/STAT1 register */
|
||||
void usart_interrupt_flag_clear(uint32_t usart_periph, usart_interrupt_flag_enum int_flag);
|
||||
|
||||
#endif /* GD32F4XX_USART_H */
|
||||
#endif /* GD32F4XX_USART_H */
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,49 @@
|
||||
/*!
|
||||
\file gd32f4xx_ctc.c
|
||||
\brief CTC driver
|
||||
\file gd32f4xx_ctc.c
|
||||
\brief CTC 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_ctc.h"
|
||||
|
||||
#define CTC_FLAG_MASK ((uint32_t)0x00000700U)
|
||||
|
||||
/* CTC register bit offset */
|
||||
#define CTC_TRIMVALUE_OFFSET ((uint32_t)8U)
|
||||
#define CTC_TRIM_VALUE_OFFSET ((uint32_t)8U)
|
||||
#define CTC_REFCAP_OFFSET ((uint32_t)16U)
|
||||
#define CTC_LIMIT_VALUE_OFFSET ((uint32_t)16U)
|
||||
|
||||
/*!
|
||||
\brief reset CTC clock trim controller
|
||||
\param[in] none
|
||||
@@ -27,17 +58,40 @@ void ctc_deinit(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure the IRC48M trim value
|
||||
\param[in] ctc_trim_value: 8-bit IRC48M trim value
|
||||
\brief enable CTC trim counter
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_irc48m_trim_value_config(uint8_t ctc_trim_value)
|
||||
void ctc_counter_enable(void)
|
||||
{
|
||||
CTC_CTL0 |= (uint32_t)CTC_CTL0_CNTEN;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable CTC trim counter
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_counter_disable(void)
|
||||
{
|
||||
CTC_CTL0 &= (uint32_t)(~CTC_CTL0_CNTEN);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure the IRC48M trim value
|
||||
\param[in] ctc_trim_value: 8-bit IRC48M trim value
|
||||
\arg 0x00 - 0x3F
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_irc48m_trim_value_config(uint8_t trim_value)
|
||||
{
|
||||
/* clear TRIMVALUE bits */
|
||||
CTC_CTL0 &= (~(uint32_t)CTC_CTL0_TRIMVALUE);
|
||||
/* set TRIMVALUE bits */
|
||||
CTC_CTL0 |= ((uint32_t)ctc_trim_value << 8);
|
||||
CTC_CTL0 |= ((uint32_t)trim_value << CTC_TRIM_VALUE_OFFSET);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -53,86 +107,68 @@ void ctc_software_refsource_pulse_generate(void)
|
||||
|
||||
/*!
|
||||
\brief configure hardware automatically trim mode
|
||||
\param[in] ctc_hardmode:
|
||||
\param[in] hardmode:
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg CTC_HARDWARE_TRIM_MODE_ENABLE: hardware automatically trim mode enable
|
||||
\arg CTC_HARDWARE_TRIM_MODE_DISABLE: hardware automatically trim mode disable
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_hardware_trim_mode_config(uint32_t ctc_hardmode)
|
||||
void ctc_hardware_trim_mode_config(uint32_t hardmode)
|
||||
{
|
||||
CTC_CTL0 &= (uint32_t)(~CTC_CTL0_AUTOTRIM);
|
||||
CTC_CTL0 |= (uint32_t)ctc_hardmode;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable CTC counter
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_counter_enable(void)
|
||||
{
|
||||
CTC_CTL0 |= (uint32_t)CTC_CTL0_CNTEN;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable CTC counter
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_counter_disable(void)
|
||||
{
|
||||
CTC_CTL0 &= (uint32_t)(~CTC_CTL0_CNTEN);
|
||||
CTC_CTL0 |= (uint32_t)hardmode;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure reference signal source polarity
|
||||
\param[in] ctc_polarity:
|
||||
\param[in] polarity:
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg CTC_REFSOURCE_POLARITY_FALLING: reference signal source polarity is falling edge
|
||||
\arg CTC_REFSOURCE_POLARITY_RISING: reference signal source polarity is rising edge
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_refsource_polarity_config(uint32_t ctc_polarity)
|
||||
void ctc_refsource_polarity_config(uint32_t polarity)
|
||||
{
|
||||
CTC_CTL1 &= (uint32_t)(~CTC_CTL1_REFPOL);
|
||||
CTC_CTL1 |= (uint32_t)ctc_polarity;
|
||||
CTC_CTL1 |= (uint32_t)polarity;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief select USBFS or USBHS SOF signal
|
||||
\param[in] ctc_usbsof:
|
||||
\param[in] usbsof:
|
||||
\arg CTC_USBSOFSEL_USBHS: USBHS SOF signal is selected
|
||||
\arg CTC_USBSOFSEL_USBFS: USBFS SOF signal is selected
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_usbsof_signal_select(uint32_t ctc_usbsof)
|
||||
void ctc_usbsof_signal_select(uint32_t usbsof)
|
||||
{
|
||||
CTC_CTL1 &= (uint32_t)(~CTC_CTL1_USBSOFSEL);
|
||||
CTC_CTL1 |= (uint32_t)ctc_usbsof;
|
||||
CTC_CTL1 |= (uint32_t)usbsof;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief select reference signal source
|
||||
\param[in] ctc_refs:
|
||||
\param[in] refs:
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg CTC_REFSOURCE_GPIO: GPIO is selected
|
||||
\arg CTC_REFSOURCE_LXTAL: LXTAL is clock selected
|
||||
\arg CTC_REFSOURCE_LXTAL: LXTAL is selected
|
||||
\arg CTC_REFSOURCE_USBSOF: USBSOF is selected
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_refsource_signal_select(uint32_t ctc_refs)
|
||||
void ctc_refsource_signal_select(uint32_t refs)
|
||||
{
|
||||
CTC_CTL1 &= (uint32_t)(~CTC_CTL1_REFSEL);
|
||||
CTC_CTL1 |= (uint32_t)ctc_refs;
|
||||
CTC_CTL1 |= (uint32_t)refs;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure reference signal source prescaler
|
||||
\param[in] ctc_prescaler:
|
||||
\param[in] prescaler:
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg CTC_REFSOURCE_PSC_OFF: reference signal not divided
|
||||
\arg CTC_REFSOURCE_PSC_DIV2: reference signal divided by 2
|
||||
\arg CTC_REFSOURCE_PSC_DIV4: reference signal divided by 4
|
||||
@@ -144,34 +180,36 @@ void ctc_refsource_signal_select(uint32_t ctc_refs)
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_refsource_prescaler_config(uint32_t ctc_prescaler)
|
||||
void ctc_refsource_prescaler_config(uint32_t prescaler)
|
||||
{
|
||||
CTC_CTL1 &= (uint32_t)(~CTC_CTL1_REFPSC);
|
||||
CTC_CTL1 |= (uint32_t)ctc_prescaler;
|
||||
CTC_CTL1 |= (uint32_t)prescaler;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure clock trim base limit value
|
||||
\param[in] ctc_limit_value: 8-bit clock trim base limit value
|
||||
\param[in] limit_value: 8-bit clock trim base limit value
|
||||
\arg 0x00 - 0xFF
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_clock_limit_value_config(uint8_t ctc_limit_value)
|
||||
void ctc_clock_limit_value_config(uint8_t limit_value)
|
||||
{
|
||||
CTC_CTL1 &= (uint32_t)(~CTC_CTL1_CKLIM);
|
||||
CTC_CTL1 |= (uint32_t)((uint32_t)ctc_limit_value << 16);
|
||||
CTC_CTL1 |= (uint32_t)((uint32_t)limit_value << CTC_LIMIT_VALUE_OFFSET);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief configure CTC counter reload value
|
||||
\param[in] ctc_reload_value: 16-bit CTC counter reload value
|
||||
\param[in] reload_value: 16-bit CTC counter reload value
|
||||
\arg 0x0000 - 0xFFFF
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_counter_reload_value_config(uint16_t ctc_reload_value)
|
||||
void ctc_counter_reload_value_config(uint16_t reload_value)
|
||||
{
|
||||
CTC_CTL1 &= (uint32_t)(~CTC_CTL1_RLVALUE);
|
||||
CTC_CTL1 |= (uint32_t)ctc_reload_value;
|
||||
CTC_CTL1 |= (uint32_t)reload_value;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -183,7 +221,7 @@ void ctc_counter_reload_value_config(uint16_t ctc_reload_value)
|
||||
uint16_t ctc_counter_capture_value_read(void)
|
||||
{
|
||||
uint16_t capture_value = 0U;
|
||||
capture_value = (uint16_t)((CTC_STAT & CTC_STAT_REFCAP)>> 16);
|
||||
capture_value = (uint16_t)((CTC_STAT & CTC_STAT_REFCAP)>> CTC_REFCAP_OFFSET);
|
||||
return (capture_value);
|
||||
}
|
||||
|
||||
@@ -226,65 +264,71 @@ uint16_t ctc_counter_reload_value_read(void)
|
||||
uint8_t ctc_irc48m_trim_value_read(void)
|
||||
{
|
||||
uint8_t trim_value = 0U;
|
||||
trim_value = (uint8_t)((CTC_CTL0 & CTC_CTL0_TRIMVALUE) >> 8);
|
||||
trim_value = (uint8_t)((CTC_CTL0 & CTC_CTL0_TRIMVALUE) >> CTC_TRIMVALUE_OFFSET);
|
||||
return (trim_value);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable the CTC interrupt
|
||||
\param[in] ctc_interrupt: CTC interrupt enable
|
||||
\arg CTC_INT_CKOKIE: clock trim OK interrupt enable
|
||||
\arg CTC_INT_CKWARNIE: clock trim warning interrupt enable
|
||||
\arg CTC_INT_ERRIE: error interrupt enable
|
||||
\arg CTC_INT_EREFIE: expect reference interrupt enable
|
||||
\param[in] interrupt: CTC interrupt enable
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg CTC_INT_CKOK: clock trim OK interrupt enable
|
||||
\arg CTC_INT_CKWARN: clock trim warning interrupt enable
|
||||
\arg CTC_INT_ERR: error interrupt enable
|
||||
\arg CTC_INT_EREF: expect reference interrupt enable
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_interrupt_enable(uint32_t ctc_interrupt)
|
||||
void ctc_interrupt_enable(uint32_t interrupt)
|
||||
{
|
||||
CTC_CTL0 |= (uint32_t)ctc_interrupt;
|
||||
CTC_CTL0 |= (uint32_t)interrupt;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable the CTC interrupt
|
||||
\param[in] ctc_interrupt: CTC interrupt enable source
|
||||
\arg CTC_INT_CKOKIE: clock trim OK interrupt enable
|
||||
\arg CTC_INT_CKWARNIE: clock trim warning interrupt enable
|
||||
\arg CTC_INT_ERRIE: error interrupt enable
|
||||
\arg CTC_INT_EREFIE: expect reference interrupt enable
|
||||
\param[in] interrupt: CTC interrupt enable source
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg CTC_INT_CKOK: clock trim OK interrupt enable
|
||||
\arg CTC_INT_CKWARN: clock trim warning interrupt enable
|
||||
\arg CTC_INT_ERR: error interrupt enable
|
||||
\arg CTC_INT_EREF: expect reference interrupt enable
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_interrupt_disable(uint32_t ctc_interrupt)
|
||||
void ctc_interrupt_disable(uint32_t interrupt)
|
||||
{
|
||||
CTC_CTL0 &= (uint32_t)(~ctc_interrupt);
|
||||
CTC_CTL0 &= (uint32_t)(~interrupt);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get CTC interrupt flag
|
||||
\param[in] ctc_interrupt: the CTC interrupt flag
|
||||
\arg CTC_INT_CKOK: clock trim OK interrupt
|
||||
\arg CTC_INT_CKWARN: clock trim warning interrupt
|
||||
\arg CTC_INT_ERR: error interrupt
|
||||
\arg CTC_INT_EREF: expect reference interrupt
|
||||
\arg CTC_INT_CKERR: clock trim error bit interrupt
|
||||
\arg CTC_INT_REFMISS: reference sync pulse miss interrupt
|
||||
\arg CTC_INT_TRIMERR: trim value error interrupt
|
||||
\param[in] int_flag: the CTC interrupt flag
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg CTC_INT_FLAG_CKOK: clock trim OK interrupt
|
||||
\arg CTC_INT_FLAG_CKWARN: clock trim warning interrupt
|
||||
\arg CTC_INT_FLAG_ERR: error interrupt
|
||||
\arg CTC_INT_FLAG_EREF: expect reference interrupt
|
||||
\arg CTC_INT_FLAG_CKERR: clock trim error bit interrupt
|
||||
\arg CTC_INT_FLAG_REFMISS: reference sync pulse miss interrupt
|
||||
\arg CTC_INT_FLAG_TRIMERR: trim value error interrupt
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
FlagStatus ctc_interrupt_flag_get(uint32_t ctc_interrupt)
|
||||
FlagStatus ctc_interrupt_flag_get(uint32_t int_flag)
|
||||
{
|
||||
uint32_t interrupt = 0U, intenable = 0U;
|
||||
uint32_t interrupt_flag = 0U, intenable = 0U;
|
||||
|
||||
if(ctc_interrupt & CTC_FLAG_MASK){
|
||||
intenable = CTC_CTL0 & CTC_INT_ERRIE;
|
||||
/* check whether the interrupt is enabled */
|
||||
if(RESET != (int_flag & CTC_FLAG_MASK)){
|
||||
intenable = CTC_CTL0 & CTC_CTL0_ERRIE;
|
||||
}else{
|
||||
intenable = CTC_CTL0 & ctc_interrupt;
|
||||
intenable = CTC_CTL0 & int_flag;
|
||||
}
|
||||
interrupt = CTC_STAT & ctc_interrupt;
|
||||
|
||||
if(interrupt && intenable){
|
||||
/* get interrupt flag status */
|
||||
interrupt_flag = CTC_STAT & int_flag;
|
||||
|
||||
if(interrupt_flag && intenable){
|
||||
return SET;
|
||||
}else{
|
||||
return RESET;
|
||||
@@ -293,32 +337,34 @@ FlagStatus ctc_interrupt_flag_get(uint32_t ctc_interrupt)
|
||||
|
||||
/*!
|
||||
\brief clear CTC interrupt flag
|
||||
\param[in] ctc_interrupt: the CTC interrupt flag
|
||||
\arg CTC_INT_CKOK: clock trim OK interrupt
|
||||
\arg CTC_INT_CKWARN: clock trim warning interrupt
|
||||
\arg CTC_INT_ERR: error interrupt
|
||||
\arg CTC_INT_EREF: expect reference interrupt
|
||||
\arg CTC_INT_CKERR: clock trim error bit interrupt
|
||||
\arg CTC_INT_REFMISS: reference sync pulse miss interrupt
|
||||
\arg CTC_INT_TRIMERR: trim value error interrupt
|
||||
\param[in] int_flag: the CTC interrupt flag
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg CTC_INT_FLAG_CKOK: clock trim OK interrupt
|
||||
\arg CTC_INT_FLAG_CKWARN: clock trim warning interrupt
|
||||
\arg CTC_INT_FLAG_ERR: error interrupt
|
||||
\arg CTC_INT_FLAG_EREF: expect reference interrupt
|
||||
\arg CTC_INT_FLAG_CKERR: clock trim error bit interrupt
|
||||
\arg CTC_INT_FLAG_REFMISS: reference sync pulse miss interrupt
|
||||
\arg CTC_INT_FLAG_TRIMERR: trim value error interrupt
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_interrupt_flag_clear(uint32_t ctc_interrupt)
|
||||
*/
|
||||
void ctc_interrupt_flag_clear(uint32_t int_flag)
|
||||
{
|
||||
if(ctc_interrupt & CTC_FLAG_MASK){
|
||||
if(RESET != (int_flag & CTC_FLAG_MASK)){
|
||||
CTC_INTC |= CTC_INTC_ERRIC;
|
||||
}else{
|
||||
CTC_INTC |= ctc_interrupt;
|
||||
CTC_INTC |= int_flag;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get CTC flag
|
||||
\param[in] ctc_flag: the CTC flag
|
||||
\param[in] flag: the CTC flag
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg CTC_FLAG_CKOK: clock trim OK flag
|
||||
\arg CTC_FLAG_CKWARN: clock trim warning flag
|
||||
\arg CTC_FLAG_ERR: error flag
|
||||
\arg CTC_FLAG_CKWARN: clock trim warning flag
|
||||
\arg CTC_FLAG_ERR: error flag
|
||||
\arg CTC_FLAG_EREF: expect reference flag
|
||||
\arg CTC_FLAG_CKERR: clock trim error bit
|
||||
\arg CTC_FLAG_REFMISS: reference sync pulse miss
|
||||
@@ -326,9 +372,9 @@ void ctc_interrupt_flag_clear(uint32_t ctc_interrupt)
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
FlagStatus ctc_flag_get(uint32_t ctc_flag)
|
||||
FlagStatus ctc_flag_get(uint32_t flag)
|
||||
{
|
||||
if(RESET != (CTC_STAT & ctc_flag)){
|
||||
if(RESET != (CTC_STAT & flag)){
|
||||
return SET;
|
||||
}else{
|
||||
return RESET;
|
||||
@@ -337,10 +383,11 @@ FlagStatus ctc_flag_get(uint32_t ctc_flag)
|
||||
|
||||
/*!
|
||||
\brief clear CTC flag
|
||||
\param[in] ctc_flag: the CTC flag
|
||||
\param[in] flag: the CTC flag
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg CTC_FLAG_CKOK: clock trim OK flag
|
||||
\arg CTC_FLAG_CKWARN: clock trim warning flag
|
||||
\arg CTC_FLAG_ERR: error flag
|
||||
\arg CTC_FLAG_CKWARN: clock trim warning flag
|
||||
\arg CTC_FLAG_ERR: error flag
|
||||
\arg CTC_FLAG_EREF: expect reference flag
|
||||
\arg CTC_FLAG_CKERR: clock trim error bit
|
||||
\arg CTC_FLAG_REFMISS: reference sync pulse miss
|
||||
@@ -348,11 +395,11 @@ FlagStatus ctc_flag_get(uint32_t ctc_flag)
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void ctc_flag_clear(uint32_t ctc_flag)
|
||||
void ctc_flag_clear(uint32_t flag)
|
||||
{
|
||||
if(ctc_flag & CTC_FLAG_MASK){
|
||||
if(RESET != (flag & CTC_FLAG_MASK)){
|
||||
CTC_INTC |= CTC_INTC_ERRIC;
|
||||
}else{
|
||||
CTC_INTC |= ctc_flag;
|
||||
CTC_INTC |= flag;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -1,12 +1,37 @@
|
||||
/*!
|
||||
\file gd32f4xx_dci.c
|
||||
\brief DCI driver
|
||||
\file gd32f4xx_dci.c
|
||||
\brief DCI 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_dci.h"
|
||||
@@ -25,11 +50,11 @@ void dci_deinit(void)
|
||||
|
||||
/*!
|
||||
\brief initialize DCI registers
|
||||
\param[in] dci_struct: DCI parameter initialization stuct
|
||||
\param[in] dci_struct: DCI parameter initialization structure
|
||||
members of the structure and the member values are shown as below:
|
||||
capture_mode : DCI_CAPTURE_MODE_CONTINUOUS, DCI_CAPTURE_MODE_SNAPSHOT
|
||||
colck_polarity : DCI_CK_POLARITY_FALLING, DCI_CK_POLARITY_RISING
|
||||
hsync_polarity : DCI_HSYNC_POLARITY_LOW, DCI_HSYNC_POLARITY_HIGH
|
||||
hsync_polarity : DCI_HSYNC_POLARITY_LOW, DCI_HSYNC_POLARITY_HIGH
|
||||
vsync_polarity : DCI_VSYNC_POLARITY_LOW, DCI_VSYNC_POLARITY_HIGH
|
||||
frame_rate : DCI_FRAME_RATE_ALL, DCI_FRAME_RATE_1_2, DCI_FRAME_RATE_1_4
|
||||
interface_format: DCI_INTERFACE_FORMAT_8BITS, DCI_INTERFACE_FORMAT_10BITS,
|
||||
@@ -39,10 +64,10 @@ void dci_deinit(void)
|
||||
*/
|
||||
void dci_init(dci_parameter_struct* dci_struct)
|
||||
{
|
||||
uint32_t reg =0U;
|
||||
uint32_t reg = 0U;
|
||||
/* disable capture function and DCI */
|
||||
DCI_CTL &= ~(DCI_CTL_CAP | DCI_CTL_DCIEN);
|
||||
/* config DCI parameter */
|
||||
/* configure DCI parameter */
|
||||
reg |= dci_struct->capture_mode;
|
||||
reg |= dci_struct->clock_polarity;
|
||||
reg |= dci_struct->hsync_polarity;
|
||||
@@ -54,18 +79,18 @@ void dci_init(dci_parameter_struct* dci_struct)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable DCI function
|
||||
\brief enable DCI function
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void dci_enable(void)
|
||||
{
|
||||
DCI_CTL |= DCI_CTL_DCIEN;
|
||||
DCI_CTL |= DCI_CTL_DCIEN;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable DCI function
|
||||
\brief disable DCI function
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -76,7 +101,7 @@ void dci_disable(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable DCI capture
|
||||
\brief enable DCI capture
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -87,7 +112,7 @@ void dci_capture_enable(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable DCI capture
|
||||
\brief disable DCI capture
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -98,7 +123,7 @@ void dci_capture_disable(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable DCI jpeg mode
|
||||
\brief enable DCI jpeg mode
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -109,7 +134,7 @@ void dci_jpeg_enable(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable DCI jpeg mode
|
||||
\brief disable DCI jpeg mode
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -142,11 +167,11 @@ void dci_crop_window_disable(void)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief config DCI cropping window
|
||||
\brief configure DCI cropping window
|
||||
\param[in] start_x: window horizontal start position
|
||||
\param[in] start_y: window vertical start position
|
||||
\param[in] size_height: window horizontal size
|
||||
\param[in] size_width: window vertical size
|
||||
\param[in] size_width: window horizontal size
|
||||
\param[in] size_height: window vertical size
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
@@ -157,28 +182,28 @@ void dci_crop_window_config(uint16_t start_x, uint16_t start_y, uint16_t size_wi
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable sync codes function
|
||||
\brief enable embedded synchronous mode
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void dci_sync_codes_enable(void)
|
||||
void dci_embedded_sync_enable(void)
|
||||
{
|
||||
DCI_CTL |= DCI_CTL_ESM;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable sync codes function
|
||||
\brief disble embedded synchronous mode
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void dci_sync_codes_disable(void)
|
||||
void dci_embedded_sync_disable(void)
|
||||
{
|
||||
DCI_CTL &= ~DCI_CTL_ESM;
|
||||
}
|
||||
/*!
|
||||
\brief config sync codes
|
||||
\brief config synchronous codes in embedded synchronous mode
|
||||
\param[in] frame_start: frame start code in embedded synchronous mode
|
||||
\param[in] line_start: line start code in embedded synchronous mode
|
||||
\param[in] line_end: line end code in embedded synchronous mode
|
||||
@@ -192,7 +217,7 @@ void dci_sync_codes_config(uint8_t frame_start, uint8_t line_start, uint8_t line
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief config sync codes unmask
|
||||
\brief config synchronous codes unmask in embedded synchronous mode
|
||||
\param[in] frame_start: frame start code unmask bits in embedded synchronous mode
|
||||
\param[in] line_start: line start code unmask bits in embedded synchronous mode
|
||||
\param[in] line_end: line end code unmask bits in embedded synchronous mode
|
||||
@@ -202,7 +227,7 @@ void dci_sync_codes_config(uint8_t frame_start, uint8_t line_start, uint8_t line
|
||||
*/
|
||||
void dci_sync_codes_unmask_config(uint8_t frame_start, uint8_t line_start, uint8_t line_end, uint8_t frame_end)
|
||||
{
|
||||
DCI_SCUMSK = ((uint32_t)frame_start | ((uint32_t)line_start<<8) | ((uint32_t)line_end<<16) | ((uint32_t)frame_end<<24));
|
||||
DCI_SCUMSK = ((uint32_t)frame_start | ((uint32_t)line_start<<8) | ((uint32_t)line_end<<16) | ((uint32_t)frame_end<<24));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -216,13 +241,46 @@ uint32_t dci_data_read(void)
|
||||
return DCI_DATA;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get specified flag
|
||||
\param[in] flag:
|
||||
\arg DCI_FLAG_HS: HS line status
|
||||
\arg DCI_FLAG_VS: VS line status
|
||||
\arg DCI_FLAG_FV:FIFO valid
|
||||
\arg DCI_FLAG_EF: end of frame flag
|
||||
\arg DCI_FLAG_OVR: FIFO overrun flag
|
||||
\arg DCI_FLAG_ESE: embedded synchronous error flag
|
||||
\arg DCI_FLAG_VSYNC: vsync flag
|
||||
\arg DCI_FLAG_EL: end of line flag
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
FlagStatus dci_flag_get(uint32_t flag)
|
||||
{
|
||||
uint32_t stat = 0U;
|
||||
|
||||
if(flag >> 31){
|
||||
/* get flag status from DCI_STAT1 register */
|
||||
stat = DCI_STAT1;
|
||||
}else{
|
||||
/* get flag status from DCI_STAT0 register */
|
||||
stat = DCI_STAT0;
|
||||
}
|
||||
|
||||
if(flag & stat){
|
||||
return SET;
|
||||
}else{
|
||||
return RESET;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable specified DCI interrupt
|
||||
\param[in] interrupt:
|
||||
\arg DCI_INT_EF: end of frame interrupt
|
||||
\arg DCI_INT_OVR: FIFO overrun interrupt
|
||||
\arg DCI_INT_ESE: embedded synchronous error interrupt
|
||||
\arg DCI_INT_VS: vsync interrupt
|
||||
\arg DCI_INT_ESE: embedded synchronous error interrupt
|
||||
\arg DCI_INT_VSYNC: vsync interrupt
|
||||
\arg DCI_INT_EL: end of line interrupt
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -237,8 +295,8 @@ void dci_interrupt_enable(uint32_t interrupt)
|
||||
\param[in] interrupt:
|
||||
\arg DCI_INT_EF: end of frame interrupt
|
||||
\arg DCI_INT_OVR: FIFO overrun interrupt
|
||||
\arg DCI_INT_ESE: embedded synchronous error interrupt
|
||||
\arg DCI_INT_VS: vsync interrupt
|
||||
\arg DCI_INT_ESE: embedded synchronous error interrupt
|
||||
\arg DCI_INT_VSYNC: vsync interrupt
|
||||
\arg DCI_INT_EL: end of line interrupt
|
||||
\param[out] none
|
||||
\retval none
|
||||
@@ -249,93 +307,39 @@ void dci_interrupt_disable(uint32_t interrupt)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief clear specified interrupt
|
||||
\param[in] interrupt:
|
||||
\brief clear specified interrupt flag
|
||||
\param[in] int_flag:
|
||||
\arg DCI_INT_EF: end of frame interrupt
|
||||
\arg DCI_INT_OVR: FIFO overrun interrupt
|
||||
\arg DCI_INT_ESE: embedded synchronous error interrupt
|
||||
\arg DCI_INT_VS: vsync interrupt
|
||||
\arg DCI_INT_ESE: embedded synchronous error interrupt
|
||||
\arg DCI_INT_VSYNC: vsync interrupt
|
||||
\arg DCI_INT_EL: end of line interrupt
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void dci_interrupt_clear(uint32_t interrupt)
|
||||
void dci_interrupt_flag_clear(uint32_t int_flag)
|
||||
{
|
||||
DCI_INTC |= interrupt;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get specified flag
|
||||
\param[in] flag:
|
||||
\arg DCI_FLAG_HS: HS line status
|
||||
\arg DCI_FLAG_VS: VS line status
|
||||
\arg DCI_FLAG_FV:FIFO valid
|
||||
\arg DCI_FLAG_EFF: end of frame flag
|
||||
\arg DCI_FLAG_OVRF: FIFO overrun flag
|
||||
\arg DCI_FLAG_ESEF: embedded synchronous error flag
|
||||
\arg DCI_FLAG_VSF: vsync flag
|
||||
\arg DCI_FLAG_ELF: end of line flag
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
FlagStatus dci_flag_get(uint32_t flag)
|
||||
{
|
||||
uint32_t ret = 0U;
|
||||
|
||||
switch(flag){
|
||||
/* get flag status from DCI_STAT0 register */
|
||||
case DCI_FLAG_HS:
|
||||
ret = (DCI_STAT0 & DCI_STAT0_HS);
|
||||
break;
|
||||
case DCI_FLAG_VS:
|
||||
ret = (DCI_STAT0 & DCI_STAT0_VS);
|
||||
break;
|
||||
case DCI_FLAG_FV:
|
||||
ret = (DCI_STAT0 & DCI_STAT0_FV);
|
||||
break;
|
||||
/* get flag status from DCI_STAT1 register */
|
||||
case DCI_FLAG_EFF:
|
||||
ret = (DCI_STAT1 & DCI_STAT1_EFF);
|
||||
break;
|
||||
case DCI_FLAG_OVRF:
|
||||
ret = (DCI_STAT1 & DCI_STAT1_OVRF);
|
||||
break;
|
||||
case DCI_FLAG_ESEF:
|
||||
ret = (DCI_STAT1 & DCI_STAT1_ESEF);
|
||||
break;
|
||||
case DCI_FLAG_VSF:
|
||||
ret = (DCI_STAT1 & DCI_STAT1_VSF);
|
||||
break;
|
||||
case DCI_FLAG_ELF:
|
||||
ret = (DCI_STAT1 & DCI_STAT1_ELF);
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
if(RESET == ret){
|
||||
return RESET;
|
||||
}else{
|
||||
return SET;
|
||||
}
|
||||
DCI_INTC |= int_flag;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get specified interrupt flag
|
||||
\param[in] interrupt:
|
||||
\arg DCI_INT_EF: end of frame interrupt
|
||||
\arg DCI_INT_OVR: FIFO overrun interrupt
|
||||
\arg DCI_INT_ESE: embedded synchronous error interrupt
|
||||
\arg DCI_INT_VS: vsync interrupt
|
||||
\arg DCI_INT_EL: end of line interrupt
|
||||
\param[in] int_flag:
|
||||
\arg DCI_INT_FLAG_EF: end of frame interrupt flag
|
||||
\arg DCI_INT_FLAG_OVR: FIFO overrun interrupt flag
|
||||
\arg DCI_INT_FLAG_ESE: embedded synchronous error interrupt flag
|
||||
\arg DCI_INT_FLAG_VSYNC: vsync interrupt flag
|
||||
\arg DCI_INT_FLAG_EL: end of line interrupt flag
|
||||
\param[out] none
|
||||
\retval FlagStatus: SET or RESET
|
||||
*/
|
||||
FlagStatus dci_interrupt_flag_get(uint32_t interrupt)
|
||||
FlagStatus dci_interrupt_flag_get(uint32_t int_flag)
|
||||
{
|
||||
if(RESET == (DCI_INTF & interrupt)){
|
||||
if(RESET == (DCI_INTF & int_flag)){
|
||||
return RESET;
|
||||
}else{
|
||||
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_exti.c
|
||||
\brief EXTI driver
|
||||
\file gd32f4xx_exti.c
|
||||
\brief EXTI driver
|
||||
|
||||
\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.
|
||||
*/
|
||||
|
||||
#include "gd32f4xx_exti.h"
|
||||
@@ -41,6 +66,7 @@ void exti_deinit(void)
|
||||
\arg EXTI_TRIG_RISING: rising edge trigger
|
||||
\arg EXTI_TRIG_FALLING: falling trigger
|
||||
\arg EXTI_TRIG_BOTH: rising and falling trigger
|
||||
\arg EXTI_TRIG_NONE: without rising edge or falling edge trigger
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
@@ -53,7 +79,7 @@ void exti_init(exti_line_enum linex, \
|
||||
EXTI_EVEN &= ~(uint32_t)linex;
|
||||
EXTI_RTEN &= ~(uint32_t)linex;
|
||||
EXTI_FTEN &= ~(uint32_t)linex;
|
||||
|
||||
|
||||
/* set the EXTI mode and enable the interrupts or events from EXTI line x */
|
||||
switch(mode){
|
||||
case EXTI_INTERRUPT:
|
||||
@@ -65,7 +91,7 @@ void exti_init(exti_line_enum linex, \
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* set the EXTI trigger type */
|
||||
switch(trig_type){
|
||||
case EXTI_TRIG_RISING:
|
||||
@@ -80,6 +106,7 @@ void exti_init(exti_line_enum linex, \
|
||||
EXTI_RTEN |= (uint32_t)linex;
|
||||
EXTI_FTEN |= (uint32_t)linex;
|
||||
break;
|
||||
case EXTI_TRIG_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -98,19 +125,6 @@ void exti_interrupt_enable(exti_line_enum linex)
|
||||
EXTI_INTEN |= (uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable the events from EXTI line x
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void exti_event_enable(exti_line_enum linex)
|
||||
{
|
||||
EXTI_EVEN |= (uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable the interrupt from EXTI line x
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
@@ -124,6 +138,19 @@ void exti_interrupt_disable(exti_line_enum linex)
|
||||
EXTI_INTEN &= ~(uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable the events from EXTI line x
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void exti_event_enable(exti_line_enum linex)
|
||||
{
|
||||
EXTI_EVEN |= (uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief disable the events from EXTI line x
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
@@ -137,71 +164,6 @@ void exti_event_disable(exti_line_enum linex)
|
||||
EXTI_EVEN &= ~(uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get EXTI lines flag
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval FlagStatus: status of flag (RESET or SET)
|
||||
*/
|
||||
FlagStatus exti_flag_get(exti_line_enum linex)
|
||||
{
|
||||
if(RESET != (EXTI_PD & (uint32_t)linex)){
|
||||
return SET;
|
||||
}else{
|
||||
return RESET;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief clear EXTI lines pending flag
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void exti_flag_clear(exti_line_enum linex)
|
||||
{
|
||||
EXTI_PD = (uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get EXTI lines flag when the interrupt flag is set
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval FlagStatus: status of flag (RESET or SET)
|
||||
*/
|
||||
FlagStatus exti_interrupt_flag_get(exti_line_enum linex)
|
||||
{
|
||||
uint32_t flag_left, flag_right;
|
||||
|
||||
flag_left = EXTI_PD & (uint32_t)linex;
|
||||
flag_right = EXTI_INTEN & (uint32_t)linex;
|
||||
|
||||
if((RESET != flag_left) && (RESET != flag_right)){
|
||||
return SET;
|
||||
}else{
|
||||
return RESET;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief clear EXTI lines pending flag
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void exti_interrupt_flag_clear(exti_line_enum linex)
|
||||
{
|
||||
EXTI_PD = (uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief enable EXTI software interrupt event
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
@@ -227,3 +189,69 @@ void exti_software_interrupt_disable(exti_line_enum linex)
|
||||
{
|
||||
EXTI_SWIEV &= ~(uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get EXTI lines flag
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval FlagStatus: status of flag (RESET or SET)
|
||||
*/
|
||||
FlagStatus exti_flag_get(exti_line_enum linex)
|
||||
{
|
||||
if(RESET != (EXTI_PD & (uint32_t)linex)){
|
||||
return SET;
|
||||
}else{
|
||||
return RESET;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief clear EXTI lines pending flag
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void exti_flag_clear(exti_line_enum linex)
|
||||
{
|
||||
EXTI_PD = (uint32_t)linex;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get EXTI lines flag when the interrupt flag is set
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval FlagStatus: status of flag (RESET or SET)
|
||||
*/
|
||||
FlagStatus exti_interrupt_flag_get(exti_line_enum linex)
|
||||
{
|
||||
uint32_t flag_left, flag_right;
|
||||
|
||||
flag_left = EXTI_PD & (uint32_t)linex;
|
||||
flag_right = EXTI_INTEN & (uint32_t)linex;
|
||||
|
||||
if((RESET != flag_left) && (RESET != flag_right)){
|
||||
return SET;
|
||||
}else{
|
||||
return RESET;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief clear EXTI lines pending flag
|
||||
\param[in] linex: EXTI line number, refer to exti_line_enum
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg EXTI_x (x=0..22): EXTI line x
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void exti_interrupt_flag_clear(exti_line_enum linex)
|
||||
{
|
||||
EXTI_PD = (uint32_t)linex;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,46 @@
|
||||
/*!
|
||||
\file gd32f4xx_gpio.c
|
||||
\brief GPIO driver
|
||||
\file gd32f4xx_gpio.c
|
||||
\brief GPIO 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_gpio.h"
|
||||
|
||||
/*!
|
||||
\brief reset GPIO port
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
@@ -71,22 +98,26 @@ void gpio_deinit(uint32_t gpio_periph)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief set GPIO output mode
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] mode: gpio pin mode
|
||||
\brief set GPIO mode
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] mode: GPIO pin mode
|
||||
\arg GPIO_MODE_INPUT: input mode
|
||||
\arg GPIO_MODE_OUTPUT: output mode
|
||||
\arg GPIO_MODE_AF: alternate function mode
|
||||
\arg GPIO_MODE_ANALOG: analog mode
|
||||
\param[in] pull_up_down: gpio pin with pull-up or pull-down resistor
|
||||
\arg GPIO_PUPD_NONE: without weak pull-up and pull-down resistors
|
||||
\arg GPIO_PUPD_PULLUP: with weak pull-up resistor
|
||||
\arg GPIO_PUPD_PULLDOWN:with weak pull-down resistor
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[in] pull_up_down: GPIO pin with pull-up or pull-down resistor
|
||||
\arg GPIO_PUPD_NONE: floating mode, no pull-up and pull-down resistors
|
||||
\arg GPIO_PUPD_PULLUP: with pull-up resistor
|
||||
\arg GPIO_PUPD_PULLDOWN:with pull-down resistor
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_mode_set(uint32_t gpio_periph,uint32_t mode,uint32_t pull_up_down,uint32_t pin)
|
||||
void gpio_mode_set(uint32_t gpio_periph, uint32_t mode, uint32_t pull_up_down, uint32_t pin)
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t ctl, pupd;
|
||||
@@ -114,25 +145,29 @@ void gpio_mode_set(uint32_t gpio_periph,uint32_t mode,uint32_t pull_up_down,uint
|
||||
|
||||
/*!
|
||||
\brief set GPIO output type and speed
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] otype: gpio pin output mode
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] otype: GPIO pin output mode
|
||||
\arg GPIO_OTYPE_PP: push pull mode
|
||||
\arg GPIO_OTYPE_OD: open drain mode
|
||||
\param[in] speed: gpio pin output max speed
|
||||
\arg GPIO_OSPEED_2MHZ: output max speed 2M
|
||||
\arg GPIO_OSPEED_25MHZ: output max speed 25M
|
||||
\arg GPIO_OSPEED_50MHZ: output max speed 50M
|
||||
\arg GPIO_OSPEED_200MHZ: output max speed 200M
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[in] speed: GPIO pin output max speed
|
||||
\arg GPIO_OSPEED_2MHZ: output max speed 2MHz
|
||||
\arg GPIO_OSPEED_25MHZ: output max speed 25MHz
|
||||
\arg GPIO_OSPEED_50MHZ: output max speed 50MHz
|
||||
\arg GPIO_OSPEED_200MHZ: output max speed 200MHz
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_output_options_set(uint32_t gpio_periph,uint8_t otype,uint32_t speed,uint32_t pin)
|
||||
void gpio_output_options_set(uint32_t gpio_periph, uint8_t otype, uint32_t speed, uint32_t pin)
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t ospeedr;
|
||||
|
||||
if(0x1U == otype){
|
||||
if(GPIO_OTYPE_OD == otype){
|
||||
GPIO_OMODE(gpio_periph) |= (uint32_t)pin;
|
||||
}else{
|
||||
GPIO_OMODE(gpio_periph) &= (uint32_t)(~pin);
|
||||
@@ -153,40 +188,52 @@ void gpio_output_options_set(uint32_t gpio_periph,uint8_t otype,uint32_t speed,u
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief set GPIO pin
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\brief set GPIO pin bit
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_bit_set(uint32_t gpio_periph,uint32_t pin)
|
||||
void gpio_bit_set(uint32_t gpio_periph, uint32_t pin)
|
||||
{
|
||||
GPIO_BOP(gpio_periph) = (uint32_t)pin;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief reset GPIO pin
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\brief reset GPIO pin bit
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_bit_reset(uint32_t gpio_periph,uint32_t pin)
|
||||
void gpio_bit_reset(uint32_t gpio_periph, uint32_t pin)
|
||||
{
|
||||
GPIO_BC(gpio_periph) = (uint32_t)pin;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief write data to the specified GPIO pin
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[in] bitvalue: SET or RESET
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[in] bit_value: SET or RESET
|
||||
\arg RESET: clear the port pin
|
||||
\arg SET: set the port pin
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_bit_write(uint32_t gpio_periph,uint32_t pin,bit_status bit_value)
|
||||
void gpio_bit_write(uint32_t gpio_periph, uint32_t pin, bit_status bit_value)
|
||||
{
|
||||
if(RESET != bit_value){
|
||||
GPIO_BOP(gpio_periph) = (uint32_t)pin;
|
||||
@@ -197,27 +244,33 @@ void gpio_bit_write(uint32_t gpio_periph,uint32_t pin,bit_status bit_value)
|
||||
|
||||
/*!
|
||||
\brief write data to the specified GPIO port
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] data: specify the value to be written to the port output data register
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] data: specify the value to be written to the port output control register
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_port_write(uint32_t gpio_periph,uint16_t data)
|
||||
void gpio_port_write(uint32_t gpio_periph, uint16_t data)
|
||||
{
|
||||
GPIO_OCTL(gpio_periph) = (uint32_t)data;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get GPIO pin input status
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval input state of gpio pin: SET or RESET
|
||||
\retval input status of GPIO pin: SET or RESET
|
||||
*/
|
||||
FlagStatus gpio_input_bit_get(uint32_t gpio_periph,uint32_t pin)
|
||||
FlagStatus gpio_input_bit_get(uint32_t gpio_periph, uint32_t pin)
|
||||
{
|
||||
if((uint32_t)RESET != (GPIO_ISTAT(gpio_periph)&(pin))){
|
||||
return SET;
|
||||
return SET;
|
||||
}else{
|
||||
return RESET;
|
||||
}
|
||||
@@ -225,23 +278,29 @@ FlagStatus gpio_input_bit_get(uint32_t gpio_periph,uint32_t pin)
|
||||
|
||||
/*!
|
||||
\brief get GPIO all pins input status
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[out] none
|
||||
\retval input state of gpio all pins
|
||||
\retval input status of GPIO all pins
|
||||
*/
|
||||
uint16_t gpio_input_port_get(uint32_t gpio_periph)
|
||||
{
|
||||
return (uint16_t)(GPIO_ISTAT(gpio_periph));
|
||||
return ((uint16_t)GPIO_ISTAT(gpio_periph));
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief get GPIO pin output status
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval output state of gpio pin: SET or RESET
|
||||
\retval output status of GPIO pin: SET or RESET
|
||||
*/
|
||||
FlagStatus gpio_output_bit_get(uint32_t gpio_periph,uint32_t pin)
|
||||
FlagStatus gpio_output_bit_get(uint32_t gpio_periph, uint32_t pin)
|
||||
{
|
||||
if((uint32_t)RESET !=(GPIO_OCTL(gpio_periph)&(pin))){
|
||||
return SET;
|
||||
@@ -252,9 +311,11 @@ FlagStatus gpio_output_bit_get(uint32_t gpio_periph,uint32_t pin)
|
||||
|
||||
/*!
|
||||
\brief get GPIO all pins output status
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[out] none
|
||||
\retval output state of gpio all pins
|
||||
\retval output status of GPIO all pins
|
||||
*/
|
||||
uint16_t gpio_output_port_get(uint32_t gpio_periph)
|
||||
{
|
||||
@@ -263,29 +324,33 @@ uint16_t gpio_output_port_get(uint32_t gpio_periph)
|
||||
|
||||
/*!
|
||||
\brief set GPIO alternate function
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] alt_func_num: gpio pin af function
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] alt_func_num: GPIO pin af function
|
||||
\arg GPIO_AF_0: SYSTEM
|
||||
\arg GPIO_AF_1: TIMER0, TIMER1
|
||||
\arg GPIO_AF_2: TIMER2, TIMER3, TIMER4
|
||||
\arg GPIO_AF_3: TIMER7, TIMER8, TIMER9, TIMER10
|
||||
\arg GPIO_AF_4: I2C0, I2C1, I2C2
|
||||
\arg GPIO_AF_5: SPI0, SPI1, SPI2, SPI3, SPI4, SPI5
|
||||
\arg GPIO_AF_6: SPI1, SPI2, SAI0
|
||||
\arg GPIO_AF_6: SPI1, SPI2, SAI0
|
||||
\arg GPIO_AF_7: USART0, USART1, USART2
|
||||
\arg GPIO_AF_8: UART3, UART4, USART5, UART6, UART7
|
||||
\arg GPIO_AF_9: CAN0,CAN1, TLI, TIMER11, TIMER12, TIMER13
|
||||
\arg GPIO_AF_9: CAN0, CAN1, TLI, TIMER11, TIMER12, TIMER13
|
||||
\arg GPIO_AF_10: USB_FS, USB_HS
|
||||
\arg GPIO_AF_11: ENET
|
||||
\arg GPIO_AF_12: FMC, SDIO, USB_HS
|
||||
\arg GPIO_AF_12: EXMC, SDIO, USB_HS
|
||||
\arg GPIO_AF_13: DCI
|
||||
\arg GPIO_AF_14: TLI
|
||||
\arg GPIO_AF_15: EVENTOUT
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_af_set(uint32_t gpio_periph,uint32_t alt_func_num,uint32_t pin)
|
||||
void gpio_af_set(uint32_t gpio_periph, uint32_t alt_func_num, uint32_t pin)
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t afrl, afrh;
|
||||
@@ -314,18 +379,22 @@ void gpio_af_set(uint32_t gpio_periph,uint32_t alt_func_num,uint32_t pin)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief lock GPIO pin
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\brief lock GPIO pin bit
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_pin_lock(uint32_t gpio_periph,uint32_t pin)
|
||||
void gpio_pin_lock(uint32_t gpio_periph, uint32_t pin)
|
||||
{
|
||||
uint32_t lock = 0x00010000U;
|
||||
lock |= pin;
|
||||
|
||||
/* lock key writing sequence: write 1->write 0->write 1-> read 0-> read 1 */
|
||||
/* lock key writing sequence: write 1->write 0->write 1->read 0->read 1 */
|
||||
GPIO_LOCK(gpio_periph) = (uint32_t)lock;
|
||||
GPIO_LOCK(gpio_periph) = (uint32_t)pin;
|
||||
GPIO_LOCK(gpio_periph) = (uint32_t)lock;
|
||||
@@ -334,20 +403,27 @@ void gpio_pin_lock(uint32_t gpio_periph,uint32_t pin)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief toggle GPIO pin
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\brief toggle GPIO pin status
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\param[in] pin: GPIO pin
|
||||
one or more parameters can be selected which are shown as below:
|
||||
\arg GPIO_PIN_x(x=0..15), GPIO_PIN_ALL
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void gpio_bit_toggle(uint32_t gpio_periph,uint32_t pin)
|
||||
void gpio_bit_toggle(uint32_t gpio_periph, uint32_t pin)
|
||||
{
|
||||
GPIO_TG(gpio_periph) = (uint32_t)pin;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief toggle GPIO port
|
||||
\param[in] gpio_periph: GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
\brief toggle GPIO port status
|
||||
\param[in] gpio_periph: GPIO port
|
||||
only one parameter can be selected which is shown as below:
|
||||
\arg GPIOx(x = A,B,C,D,E,F,G,H,I)
|
||||
|
||||
\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
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user