Skip to content

Commit 02df759

Browse files
committed
OLIMEX_STM32E407_F407ZG: Added new target platform
Added Olimex STM32-E407 (STM32F407ZG) evaluation board. USB, UART, External HS XTAL and Ethernet are all working correctly.
1 parent ef4fe98 commit 02df759

File tree

9 files changed

+1263
-1
lines changed

9 files changed

+1263
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "stm32f4xx_hal.h"
18+
19+
void _eth_config_mac(ETH_HandleTypeDef *heth)
20+
{
21+
ETH_MACInitTypeDef macconf = {
22+
.Watchdog = ETH_WATCHDOG_ENABLE,
23+
.Jabber = ETH_JABBER_ENABLE,
24+
.InterFrameGap = ETH_INTERFRAMEGAP_96BIT,
25+
.CarrierSense = ETH_CARRIERSENCE_ENABLE,
26+
.ReceiveOwn = ETH_RECEIVEOWN_ENABLE,
27+
.LoopbackMode = ETH_LOOPBACKMODE_DISABLE,
28+
.ChecksumOffload = ETH_CHECKSUMOFFLAOD_ENABLE,
29+
.RetryTransmission = ETH_RETRYTRANSMISSION_DISABLE,
30+
.AutomaticPadCRCStrip = ETH_AUTOMATICPADCRCSTRIP_DISABLE,
31+
.BackOffLimit = ETH_BACKOFFLIMIT_10,
32+
.DeferralCheck = ETH_DEFFERRALCHECK_DISABLE,
33+
.ReceiveAll = ETH_RECEIVEAll_DISABLE,
34+
.SourceAddrFilter = ETH_SOURCEADDRFILTER_DISABLE,
35+
.PassControlFrames = ETH_PASSCONTROLFRAMES_BLOCKALL,
36+
.BroadcastFramesReception = ETH_BROADCASTFRAMESRECEPTION_ENABLE,
37+
.DestinationAddrFilter = ETH_DESTINATIONADDRFILTER_NORMAL,
38+
.PromiscuousMode = ETH_PROMISCUOUS_MODE_DISABLE,
39+
.MulticastFramesFilter = ETH_MULTICASTFRAMESFILTER_NONE, // Disable multicast filter
40+
.UnicastFramesFilter = ETH_UNICASTFRAMESFILTER_PERFECT,
41+
.HashTableHigh = 0x0U,
42+
.HashTableLow = 0x0U,
43+
.PauseTime = 0x0U,
44+
.ZeroQuantaPause = ETH_ZEROQUANTAPAUSE_DISABLE,
45+
.PauseLowThreshold = ETH_PAUSELOWTHRESHOLD_MINUS4,
46+
.UnicastPauseFrameDetect = ETH_UNICASTPAUSEFRAMEDETECT_DISABLE,
47+
.ReceiveFlowControl = ETH_RECEIVEFLOWCONTROL_DISABLE,
48+
.TransmitFlowControl = ETH_TRANSMITFLOWCONTROL_DISABLE,
49+
.VLANTagComparison = ETH_VLANTAGCOMPARISON_16BIT,
50+
.VLANTagIdentifier = 0x0U,
51+
};
52+
53+
if (heth->Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE) {
54+
macconf.ChecksumOffload = ETH_CHECKSUMOFFLAOD_ENABLE;
55+
} else {
56+
macconf.ChecksumOffload = ETH_CHECKSUMOFFLAOD_DISABLE;
57+
}
58+
59+
(void) HAL_ETH_ConfigMAC(heth, &macconf);
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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 "stm32f4xx_hal.h"
32+
33+
/**
34+
* Override HAL Eth Init function
35+
*/
36+
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
37+
{
38+
GPIO_InitTypeDef GPIO_InitStructure;
39+
if (heth->Instance == ETH) {
40+
41+
/* Enable GPIOs clocks */
42+
__HAL_RCC_GPIOA_CLK_ENABLE();
43+
__HAL_RCC_GPIOB_CLK_ENABLE();
44+
__HAL_RCC_GPIOC_CLK_ENABLE();
45+
__HAL_RCC_GPIOG_CLK_ENABLE();
46+
47+
/** ETH GPIO Configuration
48+
RMII_REF_CLK ----------------------> PA1
49+
RMII_MDIO -------------------------> PA2
50+
RMII_MDC --------------------------> PC1
51+
RMII_MII_CRS_DV -------------------> PA7
52+
RMII_MII_RXD0 ---------------------> PC4
53+
RMII_MII_RXD1 ---------------------> PC5
54+
RMII_MII_RXER ---------------------> none
55+
RMII_MII_TX_EN --------------------> PG11
56+
RMII_MII_TXD0 ---------------------> PG13
57+
RMII_MII_TXD1 ---------------------> PG14
58+
*/
59+
/* Configure PA1, PA2 and PA7 */
60+
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
61+
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
62+
GPIO_InitStructure.Pull = GPIO_NOPULL;
63+
GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
64+
GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;
65+
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
66+
67+
/* Configure PC1, PC4 and PC5 */
68+
GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;
69+
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
70+
71+
/* Configure PG2, PG11 and PG13 */
72+
GPIO_InitStructure.Pin = GPIO_PIN_11 | GPIO_PIN_13 | GPIO_PIN_14;
73+
HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
74+
75+
/* Enable the Ethernet global Interrupt */
76+
HAL_NVIC_SetPriority(ETH_IRQn, 0x7, 0);
77+
HAL_NVIC_EnableIRQ(ETH_IRQn);
78+
79+
/* Enable ETHERNET clock */
80+
__HAL_RCC_ETH_CLK_ENABLE();
81+
}
82+
}
83+
84+
/**
85+
* Override HAL Eth DeInit function
86+
*/
87+
void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
88+
{
89+
if (heth->Instance == ETH) {
90+
/* Peripheral clock disable */
91+
__HAL_RCC_ETH_CLK_DISABLE();
92+
93+
/** ETH GPIO Configuration
94+
RMII_REF_CLK ----------------------> PA1
95+
RMII_MDIO -------------------------> PA2
96+
RMII_MDC --------------------------> PC1
97+
RMII_MII_CRS_DV -------------------> PA7
98+
RMII_MII_RXD0 ---------------------> PC4
99+
RMII_MII_RXD1 ---------------------> PC5
100+
RMII_MII_RXER ---------------------> none
101+
RMII_MII_TX_EN --------------------> PG11
102+
RMII_MII_TXD0 ---------------------> PG13
103+
RMII_MII_TXD1 ---------------------> PG14
104+
*/
105+
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7);
106+
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5);
107+
HAL_GPIO_DeInit(GPIOG, GPIO_PIN_11 | GPIO_PIN_13 | GPIO_PIN_14);
108+
109+
/* Disable the Ethernet global Interrupt */
110+
NVIC_DisableIRQ(ETH_IRQn);
111+
}
112+
}
113+
114+
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/* mbed Microcontroller Library
2+
*******************************************************************************
3+
* Copyright (c) 2014, 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_0 = 0,
47+
DAC_1
48+
} DACName;
49+
50+
typedef enum {
51+
UART_1 = (int)USART1_BASE,
52+
UART_2 = (int)USART2_BASE,
53+
UART_3 = (int)USART3_BASE,
54+
UART_4 = (int)UART4_BASE,
55+
UART_5 = (int)UART5_BASE,
56+
UART_6 = (int)USART6_BASE,
57+
} UARTName;
58+
59+
#define DEVICE_SPI_COUNT 3
60+
typedef enum {
61+
SPI_1 = (int)SPI1_BASE,
62+
SPI_2 = (int)SPI2_BASE,
63+
SPI_3 = (int)SPI3_BASE
64+
} SPIName;
65+
66+
typedef enum {
67+
I2C_1 = (int)I2C1_BASE,
68+
I2C_2 = (int)I2C2_BASE,
69+
I2C_3 = (int)I2C3_BASE
70+
} I2CName;
71+
72+
typedef enum {
73+
PWM_1 = (int)TIM1_BASE,
74+
PWM_2 = (int)TIM2_BASE,
75+
PWM_3 = (int)TIM3_BASE,
76+
PWM_4 = (int)TIM4_BASE,
77+
PWM_5 = (int)TIM5_BASE,
78+
PWM_8 = (int)TIM8_BASE,
79+
PWM_9 = (int)TIM9_BASE,
80+
PWM_10 = (int)TIM10_BASE,
81+
PWM_11 = (int)TIM11_BASE,
82+
PWM_12 = (int)TIM12_BASE,
83+
PWM_13 = (int)TIM13_BASE,
84+
PWM_14 = (int)TIM14_BASE
85+
} PWMName;
86+
87+
typedef enum {
88+
CAN_1 = (int)CAN1_BASE,
89+
CAN_2 = (int)CAN2_BASE
90+
} CANName;
91+
92+
#ifdef __cplusplus
93+
}
94+
#endif
95+
96+
#endif

0 commit comments

Comments
 (0)