Skip to content

Commit d7347cc

Browse files
Ashok Rao0xc0170
authored andcommitted
Adding STM S2_LP as a new target
1 parent a71a08c commit d7347cc

File tree

3 files changed

+180
-1
lines changed

3 files changed

+180
-1
lines changed
Lines changed: 60 additions & 0 deletions
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+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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 ---------------------> PG2
55+
RMII_MII_TX_EN --------------------> PG11
56+
RMII_MII_TXD0 ---------------------> PG13
57+
RMII_MII_TXD1 ---------------------> PB13
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 PB13 */
68+
GPIO_InitStructure.Pin = GPIO_PIN_13;
69+
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
70+
71+
/* Configure PC1, PC4 and PC5 */
72+
GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;
73+
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
74+
75+
/* Configure PG2, PG11 and PG13 */
76+
GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_11 | GPIO_PIN_13;
77+
HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
78+
79+
/* Enable the Ethernet global Interrupt */
80+
HAL_NVIC_SetPriority(ETH_IRQn, 0x7, 0);
81+
HAL_NVIC_EnableIRQ(ETH_IRQn);
82+
83+
/* Enable ETHERNET clock */
84+
__HAL_RCC_ETH_CLK_ENABLE();
85+
}
86+
}
87+
88+
/**
89+
* Override HAL Eth DeInit function
90+
*/
91+
void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
92+
{
93+
if (heth->Instance == ETH) {
94+
/* Peripheral clock disable */
95+
__HAL_RCC_ETH_CLK_DISABLE();
96+
97+
/** ETH GPIO Configuration
98+
RMII_REF_CLK ----------------------> PA1
99+
RMII_MDIO -------------------------> PA2
100+
RMII_MDC --------------------------> PC1
101+
RMII_MII_CRS_DV -------------------> PA7
102+
RMII_MII_RXD0 ---------------------> PC4
103+
RMII_MII_RXD1 ---------------------> PC5
104+
RMII_MII_RXER ---------------------> PG2
105+
RMII_MII_TX_EN --------------------> PG11
106+
RMII_MII_TXD0 ---------------------> PG13
107+
RMII_MII_TXD1 ---------------------> PB13
108+
*/
109+
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7);
110+
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13);
111+
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5);
112+
HAL_GPIO_DeInit(GPIOG, GPIO_PIN_2 | GPIO_PIN_11 | GPIO_PIN_13);
113+
114+
/* Disable the Ethernet global Interrupt */
115+
NVIC_DisableIRQ(ETH_IRQn);
116+
}
117+
}
118+
119+
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */

targets/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2849,7 +2849,7 @@
28492849
"device_has_add": ["ANALOGOUT", "CAN", "SERIAL_ASYNCH", "SERIAL_FC", "TRNG", "FLASH"],
28502850
"detect_code": ["0467"],
28512851
"release_versions": ["5"],
2852-
"device_name": "STM32F429VI",
2852+
"device_name": "STM32F429ZI",
28532853
"bootloader_supported": true
28542854
},
28552855
"NUCLEO_F439ZI": {

0 commit comments

Comments
 (0)