Skip to content

Commit c387fec

Browse files
authored
Merge pull request #8725 from ChazJin/master
Add support for GD32F307VG
2 parents 0a832dd + 6ac625d commit c387fec

File tree

91 files changed

+37592
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+37592
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2018 GigaDevice Semiconductor Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "gd32f30x.h"
20+
21+
/**
22+
* Initializes the HW pin for enet
23+
*
24+
*/
25+
void enet_bsp_init(void)
26+
{
27+
/* Enable GPIOs clocks */
28+
rcu_periph_clock_enable(RCU_GPIOA);
29+
rcu_periph_clock_enable(RCU_GPIOB);
30+
rcu_periph_clock_enable(RCU_GPIOC);
31+
rcu_periph_clock_enable(RCU_AF);
32+
33+
gpio_para_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_MAX, GPIO_PIN_8);
34+
rcu_pll2_config(RCU_PLL2_MUL10);
35+
rcu_osci_on(RCU_PLL2_CK);
36+
rcu_osci_stab_wait(RCU_PLL2_CK);
37+
rcu_ckout0_config(RCU_CKOUT0SRC_CKPLL2);
38+
gpio_ethernet_phy_select(GPIO_ENET_PHY_RMII);
39+
40+
/** ETH GPIO Configuration
41+
RMII_REF_CLK ----------------------> PA1
42+
RMII_MDIO -------------------------> PA2
43+
RMII_MDC --------------------------> PC1
44+
RMII_MII_CRS_DV -------------------> PA7
45+
RMII_MII_RXD0 ---------------------> PC4
46+
RMII_MII_RXD1 ---------------------> PC5
47+
RMII_MII_TX_EN --------------------> PB11
48+
RMII_MII_TXD0 ---------------------> PB12
49+
RMII_MII_TXD1 ---------------------> PB13
50+
*/
51+
/* PA1: ETH_RMII_REF_CLK */
52+
gpio_para_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_MAX, GPIO_PIN_1);
53+
/* PA2: ETH_MDIO */
54+
gpio_para_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_MAX, GPIO_PIN_2);
55+
/* PA7: ETH_RMII_CRS_DV */
56+
gpio_para_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_MAX, GPIO_PIN_7);
57+
58+
/* PB11: ETH_RMII_TX_EN */
59+
gpio_para_init(GPIOB, GPIO_MODE_AF_PP, GPIO_OSPEED_MAX, GPIO_PIN_11);
60+
/* PB12: ETH_RMII_TXD0 */
61+
gpio_para_init(GPIOB, GPIO_MODE_AF_PP, GPIO_OSPEED_MAX, GPIO_PIN_12);
62+
/* PB13: ETH_RMII_TXD1 */
63+
gpio_para_init(GPIOB, GPIO_MODE_AF_PP, GPIO_OSPEED_MAX, GPIO_PIN_13);
64+
65+
/* PC1: ETH_MDC */
66+
gpio_para_init(GPIOC, GPIO_MODE_AF_PP, GPIO_OSPEED_MAX, GPIO_PIN_1);
67+
/* PC4: ETH_RMII_RXD0 */
68+
gpio_para_init(GPIOC, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_MAX, GPIO_PIN_4);
69+
/* PC5: ETH_RMII_RXD1 */
70+
gpio_para_init(GPIOC, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_MAX, GPIO_PIN_5);
71+
72+
/* Enable the Ethernet global Interrupt */
73+
nvic_irq_enable(ENET_IRQn, 0x7, 0);
74+
75+
/* Enable ETHERNET clock */
76+
rcu_periph_clock_enable(RCU_ENET);
77+
rcu_periph_clock_enable(RCU_ENETTX);
78+
rcu_periph_clock_enable(RCU_ENETRX);
79+
}

0 commit comments

Comments
 (0)