Skip to content

Commit 7ab5260

Browse files
authored
Merge pull request #15343 from daniel-starke/complete-nucleo-h723zg
Add proper support for NUCLEO-H723ZG.
2 parents 90837c5 + ffcfa2f commit 7ab5260

File tree

13 files changed

+1515
-94
lines changed

13 files changed

+1515
-94
lines changed

connectivity/drivers/emac/TARGET_STM/TARGET_STM32H7/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ elseif("NUCLEO_H743ZI" IN_LIST MBED_TARGET_LABELS)
99
add_subdirectory(TARGET_NUCLEO_H743ZI)
1010
elseif("NUCLEO_H743ZI2" IN_LIST MBED_TARGET_LABELS)
1111
add_subdirectory(TARGET_NUCLEO_H743ZI2)
12+
elseif("NUCLEO_H723ZG" IN_LIST MBED_TARGET_LABELS)
13+
add_subdirectory(TARGET_NUCLEO_H723ZG)
1214
endif()
1315

1416
target_include_directories(mbed-emac
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
target_sources(mbed-emac
5+
INTERFACE
6+
stm32h7_eth_init.c
7+
)
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2018, STMicroelectronics
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice,
9+
* this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
14+
* may be used to endorse or promote products derived from this software
15+
* without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#ifndef USE_USER_DEFINED_HAL_ETH_MSPINIT
30+
31+
#include "stm32h7xx_hal.h"
32+
#include "platform/mbed_critical.h"
33+
34+
#define MCO_Pin GPIO_PIN_0
35+
#define MCO_GPIO_Port GPIOH
36+
#define RMII_MDC_Pin GPIO_PIN_1
37+
#define RMII_MDC_GPIO_Port GPIOC
38+
#define RMII_REF_CLK_Pin GPIO_PIN_1
39+
#define RMII_REF_CLK_GPIO_Port GPIOA
40+
#define RMII_MDIO_Pin GPIO_PIN_2
41+
#define RMII_MDIO_GPIO_Port GPIOA
42+
#define RMII_CRS_DV_Pin GPIO_PIN_7
43+
#define RMII_CRS_DV_GPIO_Port GPIOA
44+
#define RMII_RXD0_Pin GPIO_PIN_4
45+
#define RMII_RXD0_GPIO_Port GPIOC
46+
#define RMII_RXD1_Pin GPIO_PIN_5
47+
#define RMII_RXD1_GPIO_Port GPIOC
48+
#define RMII_TXD1_Pin GPIO_PIN_13
49+
#define RMII_TXD1_GPIO_Port GPIOB
50+
#define TMS_Pin GPIO_PIN_13
51+
#define TMS_GPIO_Port GPIOA
52+
#define TCK_Pin GPIO_PIN_14
53+
#define TCK_GPIO_Port GPIOA
54+
#define RMII_TX_EN_Pin GPIO_PIN_11
55+
#define RMII_TX_EN_GPIO_Port GPIOG
56+
#define RMII_TXD0_Pin GPIO_PIN_13
57+
#define RMII_TXD0_GPIO_Port GPIOG
58+
59+
/**
60+
* Override HAL Eth Init function
61+
*/
62+
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
63+
{
64+
GPIO_InitTypeDef GPIO_InitStruct;
65+
if (heth->Instance == ETH) {
66+
/* Disable DCache for STM32H7 family */
67+
core_util_critical_section_enter();
68+
SCB_DisableDCache();
69+
core_util_critical_section_exit();
70+
71+
/* GPIO Ports Clock Enable */
72+
__HAL_RCC_GPIOH_CLK_ENABLE();
73+
__HAL_RCC_GPIOC_CLK_ENABLE();
74+
__HAL_RCC_GPIOA_CLK_ENABLE();
75+
__HAL_RCC_GPIOB_CLK_ENABLE();
76+
__HAL_RCC_GPIOG_CLK_ENABLE();
77+
78+
/* Enable Peripheral clock */
79+
__HAL_RCC_ETH1MAC_CLK_ENABLE();
80+
__HAL_RCC_ETH1TX_CLK_ENABLE();
81+
__HAL_RCC_ETH1RX_CLK_ENABLE();
82+
83+
/**ETH GPIO Configuration
84+
PC1 ------> ETH_MDC
85+
PA1 ------> ETH_REF_CLK
86+
PA2 ------> ETH_MDIO
87+
PA7 ------> ETH_CRS_DV
88+
PC4 ------> ETH_RXD0
89+
PC5 ------> ETH_RXD1
90+
PB13 ------> ETH_TXD1
91+
PG11 ------> ETH_TX_EN
92+
PG13 ------> ETH_TXD0
93+
*/
94+
GPIO_InitStruct.Pin = RMII_MDC_Pin;
95+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
96+
GPIO_InitStruct.Pull = GPIO_NOPULL;
97+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
98+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
99+
HAL_GPIO_Init(RMII_MDC_GPIO_Port, &GPIO_InitStruct);
100+
101+
GPIO_InitStruct.Pin = RMII_REF_CLK_Pin | RMII_MDIO_Pin | RMII_CRS_DV_Pin;
102+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
103+
GPIO_InitStruct.Pull = GPIO_NOPULL;
104+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
105+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
106+
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
107+
108+
GPIO_InitStruct.Pin = RMII_RXD0_Pin | RMII_RXD1_Pin;
109+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
110+
GPIO_InitStruct.Pull = GPIO_NOPULL;
111+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
112+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
113+
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
114+
115+
GPIO_InitStruct.Pin = RMII_TXD1_Pin;
116+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
117+
GPIO_InitStruct.Pull = GPIO_NOPULL;
118+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
119+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
120+
HAL_GPIO_Init(RMII_TXD1_GPIO_Port, &GPIO_InitStruct);
121+
122+
GPIO_InitStruct.Pin = RMII_TX_EN_Pin | RMII_TXD0_Pin;
123+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
124+
GPIO_InitStruct.Pull = GPIO_NOPULL;
125+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
126+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
127+
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
128+
}
129+
}
130+
131+
/**
132+
* Override HAL Eth DeInit function
133+
*/
134+
void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
135+
{
136+
if (heth->Instance == ETH) {
137+
/* Disable Peripheral clock */
138+
__HAL_RCC_ETH1MAC_CLK_DISABLE();
139+
__HAL_RCC_ETH1TX_CLK_DISABLE();
140+
__HAL_RCC_ETH1RX_CLK_DISABLE();
141+
142+
/**ETH GPIO Configuration
143+
PC1 ------> ETH_MDC
144+
PA1 ------> ETH_REF_CLK
145+
PA2 ------> ETH_MDIO
146+
PA7 ------> ETH_CRS_DV
147+
PC4 ------> ETH_RXD0
148+
PC5 ------> ETH_RXD1
149+
PB13 ------> ETH_TXD1
150+
PG11 ------> ETH_TX_EN
151+
PG13 ------> ETH_TXD0
152+
*/
153+
HAL_GPIO_DeInit(GPIOC, RMII_MDC_Pin | RMII_RXD0_Pin | RMII_RXD1_Pin);
154+
155+
HAL_GPIO_DeInit(GPIOA, RMII_REF_CLK_Pin | RMII_MDIO_Pin | RMII_CRS_DV_Pin);
156+
157+
HAL_GPIO_DeInit(RMII_TXD1_GPIO_Port, RMII_TXD1_Pin);
158+
159+
HAL_GPIO_DeInit(GPIOG, RMII_TX_EN_Pin | RMII_TXD0_Pin);
160+
}
161+
}
162+
163+
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H723xG/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2020 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
add_subdirectory(TARGET_NUCLEO_H723ZG EXCLUDE_FROM_ALL)
5+
46
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
57
set(STARTUP_FILE TOOLCHAIN_GCC_ARM/startup_stm32h723xx.S)
68
set(LINKER_FILE TOOLCHAIN_GCC_ARM/stm32h723xg.ld)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(mbed-nucleo-h723zg INTERFACE)
5+
6+
target_sources(mbed-nucleo-h723zg
7+
INTERFACE
8+
PeripheralPins.c
9+
system_clock.c
10+
)
11+
12+
target_include_directories(mbed-nucleo-h723zg
13+
INTERFACE
14+
.
15+
)
16+
17+
target_link_libraries(mbed-nucleo-h723zg INTERFACE mbed-stm32h723xg)

0 commit comments

Comments
 (0)