Skip to content

Commit 4d9daca

Browse files
giulcioffifacchinm
authored andcommitted
Opta: initial: Add target
1 parent 06e36fe commit 4d9daca

Some content is hidden

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

44 files changed

+34843
-0
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
@@ -5,6 +5,8 @@ if("DISCO_H747I" IN_LIST MBED_TARGET_LABELS)
55
add_subdirectory(TARGET_DISCO_H747I)
66
elseif("PORTENTA_H7" IN_LIST MBED_TARGET_LABELS)
77
add_subdirectory(TARGET_PORTENTA_H7)
8+
elseif("OPTA" IN_LIST MBED_TARGET_LABELS)
9+
add_subdirectory(TARGET_OPTA)
810
elseif("NUCLEO_H743ZI" IN_LIST MBED_TARGET_LABELS)
911
add_subdirectory(TARGET_NUCLEO_H743ZI)
1012
elseif("NUCLEO_H743ZI2" IN_LIST MBED_TARGET_LABELS)
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: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2018, STMicroelectronics
3+
* Copyright (c) 2020, Arduino SA
4+
*
5+
* SPDX-License-Identifier: BSD-3-Clause
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
* 2. Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
#define ETHERNET 1
33+
34+
#ifndef USE_USER_DEFINED_HAL_ETH_MSPINIT
35+
36+
#include "stm32h7xx_hal.h"
37+
#include "opta_power.h"
38+
39+
#define ETH_TX_EN_Pin GPIO_PIN_11
40+
#define ETH_TX_EN_GPIO_Port GPIOG
41+
#define ETH_TXD1_Pin GPIO_PIN_12
42+
#define ETH_TXD1_GPIO_Port GPIOG
43+
#define ETH_TXD0_Pin GPIO_PIN_13
44+
#define ETH_TXD0_GPIO_Port GPIOG
45+
#define ETH_MDC_SAI4_D1_Pin GPIO_PIN_1
46+
#define ETH_MDC_SAI4_D1_GPIO_Port GPIOC
47+
#define ETH_MDIO_Pin GPIO_PIN_2
48+
#define ETH_MDIO_GPIO_Port GPIOA
49+
#define ETH_REF_CLK_Pin GPIO_PIN_1
50+
#define ETH_REF_CLK_GPIO_Port GPIOA
51+
#define ETH_CRS_DV_Pin GPIO_PIN_7
52+
#define ETH_CRS_DV_GPIO_Port GPIOA
53+
#define ETH_RXD0_Pin GPIO_PIN_4
54+
#define ETH_RXD0_GPIO_Port GPIOC
55+
#define ETH_RXD1_Pin GPIO_PIN_5
56+
#define ETH_RXD1_GPIO_Port GPIOC
57+
58+
/**
59+
* Override HAL Eth Init function
60+
*/
61+
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
62+
{
63+
GPIO_InitTypeDef GPIO_InitStruct;
64+
if (heth->Instance == ETH) {
65+
enableEthPowerSupply();
66+
67+
#if !(defined(DUAL_CORE) && defined(CORE_CM4))
68+
/* Disable DCache for STM32H7 family */
69+
SCB_DisableDCache();
70+
#endif
71+
72+
/* GPIO Ports Clock Enable */
73+
__HAL_RCC_GPIOA_CLK_ENABLE();
74+
// __HAL_RCC_GPIOB_CLK_ENABLE();
75+
__HAL_RCC_GPIOC_CLK_ENABLE();
76+
__HAL_RCC_GPIOG_CLK_ENABLE();
77+
// __HAL_RCC_GPIOH_CLK_ENABLE();
78+
79+
/* Enable Peripheral clock */
80+
__HAL_RCC_ETH1MAC_CLK_ENABLE();
81+
__HAL_RCC_ETH1TX_CLK_ENABLE();
82+
__HAL_RCC_ETH1RX_CLK_ENABLE();
83+
84+
/* Set pinstrap for 100mbit */
85+
// TODO
86+
87+
/* Reset ETH Phy */
88+
__HAL_RCC_GPIOJ_CLK_ENABLE();
89+
GPIO_InitTypeDef gpio_eth_rst_init_structure;
90+
gpio_eth_rst_init_structure.Pin = GPIO_PIN_15;
91+
gpio_eth_rst_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
92+
gpio_eth_rst_init_structure.Pull = GPIO_NOPULL;
93+
gpio_eth_rst_init_structure.Speed = GPIO_SPEED_FREQ_LOW;
94+
HAL_GPIO_Init(GPIOJ, &gpio_eth_rst_init_structure);
95+
96+
gpio_eth_rst_init_structure.Pin = ETH_RXD0_Pin | ETH_RXD1_Pin;
97+
HAL_GPIO_Init(GPIOC, &gpio_eth_rst_init_structure);
98+
HAL_GPIO_WritePin(GPIOC, ETH_RXD0_Pin, 1);
99+
HAL_GPIO_WritePin(GPIOC, ETH_RXD1_Pin, 1);
100+
gpio_eth_rst_init_structure.Pin = ETH_CRS_DV_Pin;
101+
HAL_GPIO_Init(GPIOA, &gpio_eth_rst_init_structure);
102+
HAL_GPIO_WritePin(GPIOA, ETH_CRS_DV_Pin, 1);
103+
104+
HAL_Delay(25);
105+
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_15, 0);
106+
HAL_Delay(100);
107+
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_15, 1);
108+
109+
/**ETH GPIO Configuration
110+
PG11 ------> ETH_TX_EN
111+
PG12 ------> ETH_TXD1
112+
PG13 ------> ETH_TXD0
113+
PC1 ------> ETH_MDC
114+
PA2 ------> ETH_MDIO
115+
PA1 ------> ETH_REF_CLK
116+
PA7 ------> ETH_CRS_DV
117+
PC4 ------> ETH_RXD0
118+
PC5 ------> ETH_RXD1
119+
*/
120+
GPIO_InitStruct.Pin = ETH_TX_EN_Pin | ETH_TXD1_Pin | ETH_TXD0_Pin;
121+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
122+
GPIO_InitStruct.Pull = GPIO_NOPULL;
123+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
124+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
125+
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
126+
127+
GPIO_InitStruct.Pin = ETH_MDC_SAI4_D1_Pin | ETH_RXD0_Pin | ETH_RXD1_Pin;
128+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
129+
GPIO_InitStruct.Pull = GPIO_NOPULL;
130+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
131+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
132+
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
133+
134+
GPIO_InitStruct.Pin = ETH_MDIO_Pin | ETH_REF_CLK_Pin | ETH_CRS_DV_Pin;
135+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
136+
GPIO_InitStruct.Pull = GPIO_NOPULL;
137+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
138+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
139+
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
140+
}
141+
}
142+
143+
/**
144+
* Override HAL Eth DeInit function
145+
*/
146+
void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
147+
{
148+
if (heth->Instance == ETH) {
149+
/* Peripheral clock disable */
150+
__HAL_RCC_ETH1MAC_CLK_DISABLE();
151+
__HAL_RCC_ETH1TX_CLK_DISABLE();
152+
__HAL_RCC_ETH1RX_CLK_DISABLE();
153+
154+
/**ETH GPIO Configuration
155+
PG11 ------> ETH_TX_EN
156+
PG12 ------> ETH_TXD1
157+
PG13 ------> ETH_TXD0
158+
PC1 ------> ETH_MDC
159+
PA2 ------> ETH_MDIO
160+
PA1 ------> ETH_REF_CLK
161+
PA7 ------> ETH_CRS_DV
162+
PC4 ------> ETH_RXD0
163+
PC5 ------> ETH_RXD1
164+
*/
165+
HAL_GPIO_DeInit(GPIOG, ETH_TX_EN_Pin | ETH_TXD1_Pin | ETH_TXD0_Pin);
166+
167+
HAL_GPIO_DeInit(GPIOC, ETH_MDC_SAI4_D1_Pin | ETH_RXD0_Pin | ETH_RXD1_Pin);
168+
169+
HAL_GPIO_DeInit(GPIOA, ETH_MDIO_Pin | ETH_REF_CLK_Pin | ETH_CRS_DV_Pin);
170+
171+
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_15, 0);
172+
}
173+
}
174+
175+
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */

connectivity/lwipstack/mbed_lib.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@
228228
"NICLA_VISION": {
229229
"mem-size": 16000
230230
},
231+
"OPTA": {
232+
"mem-size": 16000
233+
},
231234
"FVP_MPS2_M3": {
232235
"mem-size": 36560
233236
},
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_subdirectory(COMPONENT_WHD EXCLUDE_FROM_ALL)
5+
6+
add_library(mbed-opta INTERFACE)
7+
8+
target_sources(mbed-opta
9+
INTERFACE
10+
PeripheralPins.c
11+
system_clock_override.c
12+
opta_power.cpp
13+
)
14+
15+
target_include_directories(mbed-opta
16+
INTERFACE
17+
.
18+
)
19+
20+
target_link_libraries(mbed-opta INTERFACE mbed-stm32h747xi-cm7)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_subdirectory(firmware)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if("4343W_FS" IN_LIST MBED_TARGET_LABELS)
5+
add_subdirectory(COMPONENT_4343W)
6+
endif()
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-ble
5+
INTERFACE
6+
w_bt_firmware_controller.c
7+
)

0 commit comments

Comments
 (0)