Skip to content

Commit 8384685

Browse files
committed
Add PORTENTA_H7 target board
1 parent 73b7e45 commit 8384685

File tree

18 files changed

+3785
-3
lines changed

18 files changed

+3785
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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+
#define ETHERNET 1
30+
31+
#ifndef USE_USER_DEFINED_HAL_ETH_MSPINIT
32+
33+
#include "stm32h7xx_hal.h"
34+
35+
#define ETH_TX_EN_Pin GPIO_PIN_11
36+
#define ETH_TX_EN_GPIO_Port GPIOG
37+
#define ETH_TXD1_Pin GPIO_PIN_12
38+
#define ETH_TXD1_GPIO_Port GPIOG
39+
#define ETH_TXD0_Pin GPIO_PIN_13
40+
#define ETH_TXD0_GPIO_Port GPIOG
41+
#define ETH_MDC_SAI4_D1_Pin GPIO_PIN_1
42+
#define ETH_MDC_SAI4_D1_GPIO_Port GPIOC
43+
#define ETH_MDIO_Pin GPIO_PIN_2
44+
#define ETH_MDIO_GPIO_Port GPIOA
45+
#define ETH_REF_CLK_Pin GPIO_PIN_1
46+
#define ETH_REF_CLK_GPIO_Port GPIOA
47+
#define ETH_CRS_DV_Pin GPIO_PIN_7
48+
#define ETH_CRS_DV_GPIO_Port GPIOA
49+
#define ETH_RXD0_Pin GPIO_PIN_4
50+
#define ETH_RXD0_GPIO_Port GPIOC
51+
#define ETH_RXD1_Pin GPIO_PIN_5
52+
#define ETH_RXD1_GPIO_Port GPIOC
53+
54+
/**
55+
* Override HAL Eth Init function
56+
*/
57+
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
58+
{
59+
GPIO_InitTypeDef GPIO_InitStruct;
60+
if(heth->Instance == ETH)
61+
{
62+
#if !(defined(DUAL_CORE) && defined(CORE_CM4))
63+
/* Disable DCache for STM32H7 family */
64+
SCB_DisableDCache();
65+
#endif
66+
67+
/* GPIO Ports Clock Enable */
68+
__HAL_RCC_GPIOA_CLK_ENABLE();
69+
// __HAL_RCC_GPIOB_CLK_ENABLE();
70+
__HAL_RCC_GPIOC_CLK_ENABLE();
71+
__HAL_RCC_GPIOG_CLK_ENABLE();
72+
// __HAL_RCC_GPIOH_CLK_ENABLE();
73+
74+
/* Enable Peripheral clock */
75+
__HAL_RCC_ETH1MAC_CLK_ENABLE();
76+
__HAL_RCC_ETH1TX_CLK_ENABLE();
77+
__HAL_RCC_ETH1RX_CLK_ENABLE();
78+
79+
/* Set pinstrap for 100mbit */
80+
// TODO
81+
82+
/* Reset ETH Phy */
83+
__HAL_RCC_GPIOJ_CLK_ENABLE();
84+
GPIO_InitTypeDef gpio_eth_rst_init_structure;
85+
gpio_eth_rst_init_structure.Pin = GPIO_PIN_15;
86+
gpio_eth_rst_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
87+
gpio_eth_rst_init_structure.Pull = GPIO_NOPULL;
88+
gpio_eth_rst_init_structure.Speed = GPIO_SPEED_FREQ_LOW;
89+
HAL_GPIO_Init(GPIOJ, &gpio_eth_rst_init_structure);
90+
91+
gpio_eth_rst_init_structure.Pin = ETH_RXD0_Pin | ETH_RXD1_Pin;
92+
HAL_GPIO_Init(GPIOC, &gpio_eth_rst_init_structure);
93+
HAL_GPIO_WritePin(GPIOC, ETH_RXD0_Pin, 1);
94+
HAL_GPIO_WritePin(GPIOC, ETH_RXD1_Pin, 1);
95+
gpio_eth_rst_init_structure.Pin = ETH_CRS_DV_Pin;
96+
HAL_GPIO_Init(GPIOA, &gpio_eth_rst_init_structure);
97+
HAL_GPIO_WritePin(GPIOA, ETH_CRS_DV_Pin, 1);
98+
99+
HAL_Delay(25);
100+
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_15, 0);
101+
HAL_Delay(100);
102+
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_15, 1);
103+
104+
/**ETH GPIO Configuration
105+
PG11 ------> ETH_TX_EN
106+
PG12 ------> ETH_TXD1
107+
PG13 ------> ETH_TXD0
108+
PC1 ------> ETH_MDC
109+
PA2 ------> ETH_MDIO
110+
PA1 ------> ETH_REF_CLK
111+
PA7 ------> ETH_CRS_DV
112+
PC4 ------> ETH_RXD0
113+
PC5 ------> ETH_RXD1
114+
*/
115+
GPIO_InitStruct.Pin = ETH_TX_EN_Pin|ETH_TXD1_Pin|ETH_TXD0_Pin;
116+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
117+
GPIO_InitStruct.Pull = GPIO_NOPULL;
118+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
119+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
120+
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
121+
122+
GPIO_InitStruct.Pin = ETH_MDC_SAI4_D1_Pin|ETH_RXD0_Pin|ETH_RXD1_Pin;
123+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
124+
GPIO_InitStruct.Pull = GPIO_NOPULL;
125+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
126+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
127+
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
128+
129+
GPIO_InitStruct.Pin = ETH_MDIO_Pin|ETH_REF_CLK_Pin|ETH_CRS_DV_Pin;
130+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
131+
GPIO_InitStruct.Pull = GPIO_NOPULL;
132+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
133+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
134+
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
135+
}
136+
}
137+
138+
/**
139+
* Override HAL Eth DeInit function
140+
*/
141+
void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
142+
{
143+
if(heth->Instance == ETH)
144+
{
145+
/* Peripheral clock disable */
146+
__HAL_RCC_ETH1MAC_CLK_DISABLE();
147+
__HAL_RCC_ETH1TX_CLK_DISABLE();
148+
__HAL_RCC_ETH1RX_CLK_DISABLE();
149+
150+
/**ETH GPIO Configuration
151+
PG11 ------> ETH_TX_EN
152+
PG12 ------> ETH_TXD1
153+
PG13 ------> ETH_TXD0
154+
PC1 ------> ETH_MDC
155+
PA2 ------> ETH_MDIO
156+
PA1 ------> ETH_REF_CLK
157+
PA7 ------> ETH_CRS_DV
158+
PC4 ------> ETH_RXD0
159+
PC5 ------> ETH_RXD1
160+
*/
161+
HAL_GPIO_DeInit(GPIOG, ETH_TX_EN_Pin|ETH_TXD1_Pin|ETH_TXD0_Pin);
162+
163+
HAL_GPIO_DeInit(GPIOC, ETH_MDC_SAI4_D1_Pin|ETH_RXD0_Pin|ETH_RXD1_Pin);
164+
165+
HAL_GPIO_DeInit(GPIOA, ETH_MDIO_Pin|ETH_REF_CLK_Pin|ETH_CRS_DV_Pin);
166+
167+
HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_15, 0);
168+
}
169+
}
170+
171+
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */

connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,10 @@ int STM32_EMAC::low_level_input(emac_mem_buf_t **buf)
654654
/* Build Rx descriptor to be ready for next data reception */
655655
HAL_ETH_BuildRxDescriptors(&EthHandle);
656656

657+
#if !(defined(DUAL_CORE) && defined(CORE_CM4))
657658
/* Invalidate data cache for ETH Rx Buffers */
658659
SCB_InvalidateDCache_by_Addr((uint32_t *)RxBuff.buffer, frameLength);
660+
#endif
659661

660662
*buf = pbuf_alloc(PBUF_RAW, frameLength, PBUF_POOL);
661663
if (*buf) {

connectivity/drivers/wifi/esp8266-driver/mbed_lib.json

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@
103103
"NUCLEO_F411RE": {
104104
"tx": "D8",
105105
"rx": "D2"
106+
},
107+
"PORTENTA_H7": {
108+
"tx": "PA_9",
109+
"rx": "PA_10"
106110
}
107111
}
108112
}

connectivity/lwipstack/mbed_lib.json

+3
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@
210210
"MIMXRT1050_EVK": {
211211
"mem-size": 36560
212212
},
213+
"PORTENTA_H7": {
214+
"mem-size": 16000
215+
},
213216
"FVP_MPS2_M3": {
214217
"mem-size": 36560
215218
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/* mbed Microcontroller Library
2+
*******************************************************************************
3+
* Copyright (c) 2016, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice,
10+
* this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*******************************************************************************
29+
*/
30+
#ifndef MBED_PERIPHERALNAMES_H
31+
#define MBED_PERIPHERALNAMES_H
32+
33+
#include "cmsis.h"
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
39+
typedef enum {
40+
ADC_1 = (int)ADC1_BASE,
41+
ADC_2 = (int)ADC2_BASE,
42+
ADC_3 = (int)ADC3_BASE
43+
} ADCName;
44+
45+
typedef enum {
46+
DAC_1 = DAC1_BASE
47+
} DACName;
48+
49+
typedef enum {
50+
UART_1 = (int)USART1_BASE,
51+
UART_2 = (int)USART2_BASE,
52+
UART_3 = (int)USART3_BASE,
53+
UART_4 = (int)UART4_BASE,
54+
UART_5 = (int)UART5_BASE,
55+
UART_6 = (int)USART6_BASE,
56+
UART_7 = (int)UART7_BASE,
57+
UART_8 = (int)UART8_BASE,
58+
LPUART_1 = (int)LPUART1_BASE
59+
} UARTName;
60+
61+
typedef enum {
62+
SPI_1 = (int)SPI1_BASE,
63+
SPI_2 = (int)SPI2_BASE,
64+
SPI_3 = (int)SPI3_BASE,
65+
SPI_4 = (int)SPI4_BASE,
66+
SPI_5 = (int)SPI5_BASE,
67+
SPI_6 = (int)SPI6_BASE
68+
} SPIName;
69+
70+
typedef enum {
71+
I2C_1 = (int)I2C1_BASE,
72+
I2C_2 = (int)I2C2_BASE,
73+
I2C_3 = (int)I2C3_BASE,
74+
I2C_4 = (int)I2C4_BASE
75+
} I2CName;
76+
77+
typedef enum {
78+
PWM_I = (int)HRTIM1_BASE,
79+
PWM_1 = (int)TIM1_BASE,
80+
PWM_2 = (int)TIM2_BASE,
81+
PWM_3 = (int)TIM3_BASE,
82+
PWM_4 = (int)TIM4_BASE,
83+
PWM_5 = (int)TIM5_BASE,
84+
PWM_8 = (int)TIM8_BASE,
85+
PWM_12 = (int)TIM12_BASE,
86+
PWM_13 = (int)TIM13_BASE,
87+
PWM_14 = (int)TIM14_BASE,
88+
PWM_15 = (int)TIM15_BASE,
89+
PWM_16 = (int)TIM16_BASE,
90+
PWM_17 = (int)TIM17_BASE
91+
} PWMName;
92+
93+
typedef enum {
94+
CAN_1 = (int)FDCAN1_BASE,
95+
CAN_2 = (int)FDCAN2_BASE
96+
} CANName;
97+
98+
typedef enum {
99+
QSPI_1 = (int)QSPI_R_BASE,
100+
} QSPIName;
101+
102+
#ifdef __cplusplus
103+
}
104+
#endif
105+
106+
#endif

0 commit comments

Comments
 (0)