/*!
\file gd32f4xx_enet.c
\brief ENET driver
\version 2016-08-15, V1.0.0, firmware for GD32F4xx
\version 2018-12-12, V2.0.0, firmware for GD32F4xx
*/
/*
Copyright (c) 2018, GigaDevice Semiconductor Inc.
All rights reserved.
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_enet.h"
#if defined (__CC_ARM) /*!< ARM compiler */
__align(4)
enet_descriptors_struct rxdesc_tab[ENET_RXBUF_NUM]; /*!< ENET RxDMA descriptor */
__align(4)
enet_descriptors_struct txdesc_tab[ENET_TXBUF_NUM]; /*!< ENET TxDMA descriptor */
__align(4)
uint8_t rx_buff[ENET_RXBUF_NUM][ENET_RXBUF_SIZE]; /*!< ENET receive buffer */
__align(4)
uint8_t tx_buff[ENET_TXBUF_NUM][ENET_TXBUF_SIZE]; /*!< ENET transmit buffer */
#elif defined ( __ICCARM__ ) /*!< IAR compiler */
#pragma data_alignment=4
enet_descriptors_struct rxdesc_tab[ENET_RXBUF_NUM]; /*!< ENET RxDMA descriptor */
#pragma data_alignment=4
enet_descriptors_struct txdesc_tab[ENET_TXBUF_NUM]; /*!< ENET TxDMA descriptor */
#pragma data_alignment=4
uint8_t rx_buff[ENET_RXBUF_NUM][ENET_RXBUF_SIZE]; /*!< ENET receive buffer */
#pragma data_alignment=4
uint8_t tx_buff[ENET_TXBUF_NUM][ENET_TXBUF_SIZE]; /*!< ENET transmit buffer */
#elif defined (__GNUC__) /* GNU Compiler */
enet_descriptors_struct rxdesc_tab[ENET_RXBUF_NUM] __attribute__ ((aligned (4))); /*!< ENET RxDMA descriptor */
enet_descriptors_struct txdesc_tab[ENET_TXBUF_NUM] __attribute__ ((aligned (4))); /*!< ENET TxDMA descriptor */
uint8_t rx_buff[ENET_RXBUF_NUM][ENET_RXBUF_SIZE] __attribute__ ((aligned (4))); /*!< ENET receive buffer */
uint8_t tx_buff[ENET_TXBUF_NUM][ENET_TXBUF_SIZE] __attribute__ ((aligned (4))); /*!< ENET transmit buffer */
#endif /* __CC_ARM */
/* global transmit and receive descriptors pointers */
enet_descriptors_struct *dma_current_txdesc;
enet_descriptors_struct *dma_current_rxdesc;
/* structure pointer of ptp descriptor for normal mode */
enet_descriptors_struct *dma_current_ptp_txdesc = NULL;
enet_descriptors_struct *dma_current_ptp_rxdesc = NULL;
/* init structure parameters for ENET initialization */
static enet_initpara_struct enet_initpara ={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static uint32_t enet_unknow_err = 0U;
/* array of register offset for debug information get */
static const uint16_t enet_reg_tab[] = {
0x0000, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C, 0x0028, 0x002C, 0x0034,
0x0038, 0x003C, 0x0040, 0x0044, 0x0048, 0x004C, 0x0050, 0x0054, 0x0058, 0x005C, 0x1080,
0x0100, 0x0104, 0x0108, 0x010C, 0x0110, 0x014C, 0x0150, 0x0168, 0x0194, 0x0198, 0x01C4,
0x0700, 0x0704,0x0708, 0x070C, 0x0710, 0x0714, 0x0718, 0x071C, 0x0720, 0x0728, 0x072C,
0x1000, 0x1004, 0x1008, 0x100C, 0x1010, 0x1014, 0x1018, 0x101C, 0x1020, 0x1024, 0x1048,
0x104C, 0x1050, 0x1054};
/* initialize ENET peripheral with generally concerned parameters, call it by enet_init() */
static void enet_default_init(void);
#ifdef USE_DELAY
/* user can provide more timing precise _ENET_DELAY_ function */
#define _ENET_DELAY_ delay_ms
#else
/* insert a delay time */
static void enet_delay(uint32_t ncount);
/* default _ENET_DELAY_ function with less precise timing */
#define _ENET_DELAY_ enet_delay
#endif
/*!
\brief deinitialize the ENET, and reset structure parameters for ENET initialization
\param[in] none
\param[out] none
\retval none
*/
void enet_deinit(void)
{
rcu_periph_reset_enable(RCU_ENETRST);
rcu_periph_reset_disable(RCU_ENETRST);
enet_initpara_reset();
}
/*!
\brief configure the parameters which are usually less cared for initialization
note -- this function must be called before enet_init(), otherwise
configuration will be no effect
\param[in] option: different function option, which is related to several parameters, refer to enet_option_enum
only one parameter can be selected which is shown as below
\arg FORWARD_OPTION: choose to configure the frame forward related parameters
\arg DMABUS_OPTION: choose to configure the DMA bus mode related parameters
\arg DMA_MAXBURST_OPTION: choose to configure the DMA max burst related parameters
\arg DMA_ARBITRATION_OPTION: choose to configure the DMA arbitration related parameters
\arg STORE_OPTION: choose to configure the store forward mode related parameters
\arg DMA_OPTION: choose to configure the DMA descriptor related parameters
\arg VLAN_OPTION: choose to configure vlan related parameters
\arg FLOWCTL_OPTION: choose to configure flow control related parameters
\arg HASHH_OPTION: choose to configure hash high
\arg HASHL_OPTION: choose to configure hash low
\arg FILTER_OPTION: choose to configure frame filter related parameters
\arg HALFDUPLEX_OPTION: choose to configure halfduplex mode related parameters
\arg TIMER_OPTION: choose to configure time counter related parameters
\arg INTERFRAMEGAP_OPTION: choose to configure the inter frame gap related parameters
\param[in] para: the related parameters according to the option
all the related parameters should be configured which are shown as below
FORWARD_OPTION related parameters:
- ENET_AUTO_PADCRC_DROP_ENABLE/ ENET_AUTO_PADCRC_DROP_DISABLE ;
- ENET_TYPEFRAME_CRC_DROP_ENABLE/ ENET_TYPEFRAME_CRC_DROP_DISABLE ;
- ENET_FORWARD_ERRFRAMES_ENABLE/ ENET_FORWARD_ERRFRAMES_DISABLE ;
- ENET_FORWARD_UNDERSZ_GOODFRAMES_ENABLE/ ENET_FORWARD_UNDERSZ_GOODFRAMES_DISABLE .
DMABUS_OPTION related parameters:
- ENET_ADDRESS_ALIGN_ENABLE/ ENET_ADDRESS_ALIGN_DISABLE ;
- ENET_FIXED_BURST_ENABLE/ ENET_FIXED_BURST_DISABLE ;
- ENET_MIXED_BURST_ENABLE/ ENET_MIXED_BURST_DISABLE ;
DMA_MAXBURST_OPTION related parameters:
- ENET_RXDP_1BEAT/ ENET_RXDP_2BEAT/ ENET_RXDP_4BEAT/
没有合适的资源?快使用搜索试试~ 我知道了~
GD32F407_TIM.rar
共101个文件
h:51个
c:42个
s:6个
1星 需积分: 50 46 下载量 99 浏览量
2020-09-12
10:34:23
上传
评论
收藏 405KB RAR 举报
温馨提示
基于GD32F407库函数的定时器基本历程,完成keil4工程,适用于新手学习移至使用,GD32F407不能使用stm32库函数
资源推荐
资源详情
资源评论
收起资源包目录
GD32F407_TIM.rar (101个子文件)
keilkilll.bat 399B
gd32f4xx_enet.c 149KB
gd32f4xx_timer.c 87KB
gd32f4xx_exmc.c 56KB
gd32f4xx_adc.c 49KB
gd32f4xx_rcu.c 49KB
gd32f4xx_rtc.c 46KB
gd32f4xx_can.c 40KB
usbh_std.c 36KB
gd32f4xx_usart.c 34KB
gd32f4xx_dma.c 34KB
usb_core.c 32KB
gd32f4xx_fmc.c 30KB
gd32f4xx_spi.c 30KB
gd32f4xx_i2c.c 28KB
gd32f4xx_sdio.c 28KB
system_gd32f4xx.c 28KB
gd32f4xx_ipa.c 26KB
usbh_core.c 26KB
usbd_std.c 25KB
usbh_ctrl.c 25KB
gd32f4xx_tli.c 24KB
usbd_int.c 23KB
usbh_int.c 21KB
gd32f4xx_dac.c 20KB
usbd_core.c 15KB
gd32f4xx_gpio.c 15KB
gd32f4xx_ctc.c 13KB
gd32f4xx_pmu.c 11KB
gd32f4xx_dci.c 10KB
gd32f4xx_dbg.c 8KB
gd32f4xx_exti.c 8KB
gd32f4xx_syscfg.c 8KB
gd32f4xx_misc.c 7KB
usbh_hcs.c 6KB
gd32f4xx_fwdgt.c 5KB
gd32f4xx_it.c 5KB
gd32f4xx_wwdgt.c 5KB
gd32f4xx_trng.c 5KB
BSP_Config.c 4KB
gd32f4xx_crc.c 4KB
gd32f4xx_iref.c 4KB
main.c 2KB
gd32f4xx_enet.h 141KB
core_cm4.h 107KB
gd32f4xx_rcu.h 93KB
gd32f4xx_exmc.h 63KB
gd32f4xx_timer.h 58KB
gd32f4xx_can.h 53KB
gd32f4xx_rtc.h 51KB
usb_regs.h 46KB
gd32f4xx_adc.h 41KB
gd32f4xx_dma.h 30KB
gd32f4xx_sdio.h 30KB
gd32f4xx_usart.h 30KB
gd32f4xx_gpio.h 28KB
gd32f4xx_i2c.h 28KB
gd32f4xx.h 28KB
gd32f4xx_fmc.h 26KB
gd32f4xx_ipa.h 25KB
gd32f4xx_spi.h 25KB
gd32f4xx_tli.h 23KB
core_cm4_simd.h 22KB
gd32f4xx_exti.h 20KB
usbh_core.h 17KB
core_cmInstr.h 17KB
gd32f4xx_dac.h 16KB
core_cmFunc.h 15KB
gd32f4xx_dci.h 13KB
usb_std.h 13KB
gd32f4xx_iref.h 13KB
usb_core.h 13KB
gd32f4xx_ctc.h 12KB
gd32f4xx_syscfg.h 11KB
gd32f4xx_pmu.h 11KB
gd32f4xx_dbg.h 10KB
usb_defines.h 7KB
gd32f4xx_fwdgt.h 5KB
usbh_std.h 5KB
gd32f4xx_misc.h 5KB
usbd_std.h 5KB
gd32f4xx_trng.h 4KB
gd32f4xx_wwdgt.h 4KB
usbd_core.h 4KB
gd32f4xx_crc.h 3KB
usbh_ctrl.h 3KB
usbh_hcs.h 3KB
gd32f4xx_libopt.h 3KB
gd32f4xx_it.h 3KB
usbd_int.h 2KB
system_gd32f4xx.h 2KB
usbh_int.h 2KB
main.h 2KB
BSP_Config.H 300B
JLinkSettings.ini 650B
startup_gd32f450.s 27KB
startup_gd32f407.s 25KB
startup_gd32f405.s 24KB
startup_gd32f450.s 23KB
startup_gd32f407.s 21KB
共 101 条
- 1
- 2
资源评论
- wenchanghe2020-10-16文件不全,坑人,说好的定时器代码,只有中断服务函数,时钟初始化代码都没有,浪费积分。
XW@YSN
- 粉丝: 6
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- mmqrcode1714153659780.png
- Screenshot_2024-04-27-06-08-58-486_com.baidu.xin.aiqicha.jpg
- 基于Javaweb+Tomcat+MySQL的大学生公寓管理系统+sql文件.zip
- 实训作业基于javaweb的订单管理系统源码+数据库+实训报告.zip
- 多机调度问题贪心算法基于最小堆和贪心算法求解多机调度问题.zip
- 基于同态加密技术的匿名电子投票系统源码.zip
- Pyqt5项目框架-PyQt项目开发实践
- 基于C通过MQTT的智能农业大棚管理系统(本科毕业设计)
- python+CNN的网络入侵检测算法源码.zip
- js 实现记住密码功能 js.cookie.min.js
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功