mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #7015 from SeppoTakalo/fix_odin
Fix build for MBT_ODIN_W2 and MBED_CONNECT_ODIN when using WiFipull/7022/head
commit
7031ab1c1f
|
@ -1,143 +0,0 @@
|
|||
#include <string.h>
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "mbed_toolchain.h"
|
||||
|
||||
#define C029_OTP_START_ADDRESS (0x1FFF7800U)
|
||||
#define C029_OTP_END_ADDRESS (C029_OTP_START_ADDRESS + (16*32))
|
||||
#define C029_MAC_ETHERNET_ID (3)
|
||||
|
||||
typedef MBED_PACKED(struct) C029_OTP_Header {
|
||||
uint8_t id;
|
||||
uint8_t len;
|
||||
uint8_t data[];
|
||||
} C029_OTP_Header;
|
||||
|
||||
static int _macRetrieved = 0;
|
||||
static char _macAddr[6] = { 0x02, 0x02, 0xF7, 0xF0, 0x00, 0x00 };
|
||||
|
||||
static C029_OTP_Header *increment(C029_OTP_Header *pTemp)
|
||||
{
|
||||
uint8_t len = 0;
|
||||
uint8_t id = 0;
|
||||
uint8_t *p = (uint8_t*)pTemp;
|
||||
|
||||
memcpy((void*)&id, (void*)pTemp, 1);
|
||||
|
||||
if (id == 0xFF){
|
||||
p++;
|
||||
} else {
|
||||
p++;
|
||||
memcpy((void*)&len, (void*)p++, 1);
|
||||
p += len;
|
||||
}
|
||||
return (C029_OTP_Header*)p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override HAL Eth Init function
|
||||
*/
|
||||
void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
if (heth->Instance == ETH) {
|
||||
|
||||
/* Enable GPIOs clocks */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
|
||||
/** ETH GPIO Configuration
|
||||
RMII_REF_CLK ----------------------> PA1
|
||||
RMII_MDIO -------------------------> PA2
|
||||
RMII_MDC --------------------------> PC1
|
||||
RMII_MII_CRS_DV -------------------> PA7
|
||||
RMII_MII_RXD0 ---------------------> PC4
|
||||
RMII_MII_RXD1 ---------------------> PC5
|
||||
RMII_MII_RXER ---------------------> PG2
|
||||
RMII_MII_TX_EN --------------------> PB11
|
||||
RMII_MII_TXD0 ---------------------> PB12
|
||||
RMII_MII_TXD1 ---------------------> PB13
|
||||
*/
|
||||
/* Configure PA1, PA2 and PA7 */
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_7;
|
||||
GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_1;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
/* Configure PB13 */
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_13 | GPIO_PIN_11 | GPIO_PIN_12;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
/* Configure PC1, PC4 and PC5 */
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
/* Enable the Ethernet global Interrupt */
|
||||
HAL_NVIC_SetPriority(ETH_IRQn, 0x7, 0);
|
||||
HAL_NVIC_EnableIRQ(ETH_IRQn);
|
||||
|
||||
/* Enable ETHERNET clock */
|
||||
__HAL_RCC_ETH_CLK_ENABLE();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override HAL Eth DeInit function
|
||||
*/
|
||||
void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
|
||||
{
|
||||
if (heth->Instance == ETH) {
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_ETH_CLK_DISABLE();
|
||||
|
||||
/** ETH GPIO Configuration
|
||||
RMII_REF_CLK ----------------------> PA1
|
||||
RMII_MDIO -------------------------> PA2
|
||||
RMII_MDC --------------------------> PC1
|
||||
RMII_MII_CRS_DV -------------------> PA7
|
||||
RMII_MII_RXD0 ---------------------> PC4
|
||||
RMII_MII_RXD1 ---------------------> PC5
|
||||
RMII_MII_RXER ---------------------> PG2
|
||||
RMII_MII_TX_EN --------------------> PB11
|
||||
RMII_MII_TXD0 ---------------------> PB12
|
||||
RMII_MII_TXD1 ---------------------> PB13
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7);
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13 | GPIO_PIN_11 | GPIO_PIN_12);
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5);
|
||||
|
||||
/* Disable the Ethernet global Interrupt */
|
||||
NVIC_DisableIRQ(ETH_IRQn);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t mbed_otp_mac_address(char *mac)
|
||||
{
|
||||
C029_OTP_Header *pFound = NULL;
|
||||
C029_OTP_Header *pTemp = (C029_OTP_Header*)C029_OTP_START_ADDRESS;
|
||||
C029_OTP_Header temp;
|
||||
|
||||
if (_macRetrieved == 0) {
|
||||
while ((pTemp >= (C029_OTP_Header*)C029_OTP_START_ADDRESS) && (pTemp < (C029_OTP_Header*)C029_OTP_END_ADDRESS)){
|
||||
memcpy((void*)&temp, (void*)pTemp, sizeof(temp));
|
||||
if (temp.id == C029_MAC_ETHERNET_ID){
|
||||
pFound = pTemp;
|
||||
break;
|
||||
}
|
||||
pTemp = increment(pTemp);
|
||||
}
|
||||
if (pFound != NULL) {
|
||||
memcpy(_macAddr, pFound->data, 6);
|
||||
_macRetrieved = 1;
|
||||
}
|
||||
}
|
||||
memcpy(mac, _macAddr, 6);
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
void _eth_config_mac(ETH_HandleTypeDef *heth)
|
||||
{
|
||||
ETH_MACInitTypeDef macconf =
|
||||
{
|
||||
.Watchdog = ETH_WATCHDOG_ENABLE,
|
||||
.Jabber = ETH_JABBER_ENABLE,
|
||||
.InterFrameGap = ETH_INTERFRAMEGAP_96BIT,
|
||||
.CarrierSense = ETH_CARRIERSENCE_ENABLE,
|
||||
.ReceiveOwn = ETH_RECEIVEOWN_ENABLE,
|
||||
.LoopbackMode = ETH_LOOPBACKMODE_DISABLE,
|
||||
.ChecksumOffload = ETH_CHECKSUMOFFLAOD_ENABLE,
|
||||
.RetryTransmission = ETH_RETRYTRANSMISSION_DISABLE,
|
||||
.AutomaticPadCRCStrip = ETH_AUTOMATICPADCRCSTRIP_DISABLE,
|
||||
.BackOffLimit = ETH_BACKOFFLIMIT_10,
|
||||
.DeferralCheck = ETH_DEFFERRALCHECK_DISABLE,
|
||||
.ReceiveAll = ETH_RECEIVEAll_DISABLE,
|
||||
.SourceAddrFilter = ETH_SOURCEADDRFILTER_DISABLE,
|
||||
.PassControlFrames = ETH_PASSCONTROLFRAMES_BLOCKALL,
|
||||
.BroadcastFramesReception = ETH_BROADCASTFRAMESRECEPTION_ENABLE,
|
||||
.DestinationAddrFilter = ETH_DESTINATIONADDRFILTER_NORMAL,
|
||||
.PromiscuousMode = ETH_PROMISCUOUS_MODE_DISABLE,
|
||||
.MulticastFramesFilter = ETH_MULTICASTFRAMESFILTER_NONE, // Disable multicast filter
|
||||
.UnicastFramesFilter = ETH_UNICASTFRAMESFILTER_PERFECT,
|
||||
.HashTableHigh = 0x0U,
|
||||
.HashTableLow = 0x0U,
|
||||
.PauseTime = 0x0U,
|
||||
.ZeroQuantaPause = ETH_ZEROQUANTAPAUSE_DISABLE,
|
||||
.PauseLowThreshold = ETH_PAUSELOWTHRESHOLD_MINUS4,
|
||||
.UnicastPauseFrameDetect = ETH_UNICASTPAUSEFRAMEDETECT_DISABLE,
|
||||
.ReceiveFlowControl = ETH_RECEIVEFLOWCONTROL_DISABLE,
|
||||
.TransmitFlowControl = ETH_TRANSMITFLOWCONTROL_DISABLE,
|
||||
.VLANTagComparison = ETH_VLANTAGCOMPARISON_16BIT,
|
||||
.VLANTagIdentifier = 0x0U
|
||||
};
|
||||
|
||||
if (heth->Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE) {
|
||||
macconf.ChecksumOffload = ETH_CHECKSUMOFFLAOD_ENABLE;
|
||||
} else {
|
||||
macconf.ChecksumOffload = ETH_CHECKSUMOFFLAOD_DISABLE;
|
||||
}
|
||||
|
||||
(void) HAL_ETH_ConfigMAC(heth, &macconf);
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
/* Copyright (c) 2017 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "mbed_toolchain.h"
|
||||
|
||||
#define C029_OTP_START_ADDRESS (0x1FFF7800U)
|
||||
#define C029_OTP_END_ADDRESS (C029_OTP_START_ADDRESS + (16*32))
|
||||
#define C029_MAC_ETHERNET_ID (3)
|
||||
|
||||
typedef MBED_PACKED(struct) C029_OTP_Header {
|
||||
uint8_t id;
|
||||
uint8_t len;
|
||||
uint8_t data[];
|
||||
} C029_OTP_Header;
|
||||
|
||||
static int _macRetrieved = 0;
|
||||
static char _macAddr[6] = { 0x02, 0x02, 0xF7, 0xF0, 0x00, 0x00 };
|
||||
|
||||
static C029_OTP_Header *increment(C029_OTP_Header *pTemp)
|
||||
{
|
||||
uint8_t len = 0;
|
||||
uint8_t id = 0;
|
||||
uint8_t *p = (uint8_t*)pTemp;
|
||||
|
||||
memcpy((void*)&id, (void*)pTemp, 1);
|
||||
|
||||
if (id == 0xFF){
|
||||
p++;
|
||||
} else {
|
||||
p++;
|
||||
memcpy((void*)&len, (void*)p++, 1);
|
||||
p += len;
|
||||
}
|
||||
return (C029_OTP_Header*)p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override HAL Eth Init function
|
||||
*/
|
||||
void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
if (heth->Instance == ETH) {
|
||||
|
||||
/* Enable GPIOs clocks */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
|
||||
/** ETH GPIO Configuration
|
||||
RMII_REF_CLK ----------------------> PA1
|
||||
RMII_MDIO -------------------------> PA2
|
||||
RMII_MDC --------------------------> PC1
|
||||
RMII_MII_CRS_DV -------------------> PA7
|
||||
RMII_MII_RXD0 ---------------------> PC4
|
||||
RMII_MII_RXD1 ---------------------> PC5
|
||||
RMII_MII_RXER ---------------------> PG2
|
||||
RMII_MII_TX_EN --------------------> PB11
|
||||
RMII_MII_TXD0 ---------------------> PB12
|
||||
RMII_MII_TXD1 ---------------------> PB13
|
||||
*/
|
||||
/* Configure PA1, PA2 and PA7 */
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_7;
|
||||
GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_1;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
/* Configure PB13 */
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_13 | GPIO_PIN_11 | GPIO_PIN_12;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
/* Configure PC1, PC4 and PC5 */
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
/* Enable the Ethernet global Interrupt */
|
||||
HAL_NVIC_SetPriority(ETH_IRQn, 0x7, 0);
|
||||
HAL_NVIC_EnableIRQ(ETH_IRQn);
|
||||
|
||||
/* Enable ETHERNET clock */
|
||||
__HAL_RCC_ETH_CLK_ENABLE();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override HAL Eth DeInit function
|
||||
*/
|
||||
void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
|
||||
{
|
||||
if (heth->Instance == ETH) {
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_ETH_CLK_DISABLE();
|
||||
|
||||
/** ETH GPIO Configuration
|
||||
RMII_REF_CLK ----------------------> PA1
|
||||
RMII_MDIO -------------------------> PA2
|
||||
RMII_MDC --------------------------> PC1
|
||||
RMII_MII_CRS_DV -------------------> PA7
|
||||
RMII_MII_RXD0 ---------------------> PC4
|
||||
RMII_MII_RXD1 ---------------------> PC5
|
||||
RMII_MII_RXER ---------------------> PG2
|
||||
RMII_MII_TX_EN --------------------> PB11
|
||||
RMII_MII_TXD0 ---------------------> PB12
|
||||
RMII_MII_TXD1 ---------------------> PB13
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7);
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13 | GPIO_PIN_11 | GPIO_PIN_12);
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5);
|
||||
|
||||
/* Disable the Ethernet global Interrupt */
|
||||
NVIC_DisableIRQ(ETH_IRQn);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t mbed_otp_mac_address(char *mac)
|
||||
{
|
||||
C029_OTP_Header *pFound = NULL;
|
||||
C029_OTP_Header *pTemp = (C029_OTP_Header*)C029_OTP_START_ADDRESS;
|
||||
C029_OTP_Header temp;
|
||||
|
||||
if (_macRetrieved == 0) {
|
||||
while ((pTemp >= (C029_OTP_Header*)C029_OTP_START_ADDRESS) && (pTemp < (C029_OTP_Header*)C029_OTP_END_ADDRESS)){
|
||||
memcpy((void*)&temp, (void*)pTemp, sizeof(temp));
|
||||
if (temp.id == C029_MAC_ETHERNET_ID){
|
||||
pFound = pTemp;
|
||||
break;
|
||||
}
|
||||
pTemp = increment(pTemp);
|
||||
}
|
||||
if (pFound != NULL) {
|
||||
memcpy(_macAddr, pFound->data, 6);
|
||||
_macRetrieved = 1;
|
||||
}
|
||||
}
|
||||
memcpy(mac, _macAddr, 6);
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
void _eth_config_mac(ETH_HandleTypeDef *heth)
|
||||
{
|
||||
ETH_MACInitTypeDef macconf =
|
||||
{
|
||||
.Watchdog = ETH_WATCHDOG_ENABLE,
|
||||
.Jabber = ETH_JABBER_ENABLE,
|
||||
.InterFrameGap = ETH_INTERFRAMEGAP_96BIT,
|
||||
.CarrierSense = ETH_CARRIERSENCE_ENABLE,
|
||||
.ReceiveOwn = ETH_RECEIVEOWN_ENABLE,
|
||||
.LoopbackMode = ETH_LOOPBACKMODE_DISABLE,
|
||||
.ChecksumOffload = ETH_CHECKSUMOFFLAOD_ENABLE,
|
||||
.RetryTransmission = ETH_RETRYTRANSMISSION_DISABLE,
|
||||
.AutomaticPadCRCStrip = ETH_AUTOMATICPADCRCSTRIP_DISABLE,
|
||||
.BackOffLimit = ETH_BACKOFFLIMIT_10,
|
||||
.DeferralCheck = ETH_DEFFERRALCHECK_DISABLE,
|
||||
.ReceiveAll = ETH_RECEIVEAll_DISABLE,
|
||||
.SourceAddrFilter = ETH_SOURCEADDRFILTER_DISABLE,
|
||||
.PassControlFrames = ETH_PASSCONTROLFRAMES_BLOCKALL,
|
||||
.BroadcastFramesReception = ETH_BROADCASTFRAMESRECEPTION_ENABLE,
|
||||
.DestinationAddrFilter = ETH_DESTINATIONADDRFILTER_NORMAL,
|
||||
.PromiscuousMode = ETH_PROMISCUOUS_MODE_DISABLE,
|
||||
.MulticastFramesFilter = ETH_MULTICASTFRAMESFILTER_NONE, // Disable multicast filter
|
||||
.UnicastFramesFilter = ETH_UNICASTFRAMESFILTER_PERFECT,
|
||||
.HashTableHigh = 0x0U,
|
||||
.HashTableLow = 0x0U,
|
||||
.PauseTime = 0x0U,
|
||||
.ZeroQuantaPause = ETH_ZEROQUANTAPAUSE_DISABLE,
|
||||
.PauseLowThreshold = ETH_PAUSELOWTHRESHOLD_MINUS4,
|
||||
.UnicastPauseFrameDetect = ETH_UNICASTPAUSEFRAMEDETECT_DISABLE,
|
||||
.ReceiveFlowControl = ETH_RECEIVEFLOWCONTROL_DISABLE,
|
||||
.TransmitFlowControl = ETH_TRANSMITFLOWCONTROL_DISABLE,
|
||||
.VLANTagComparison = ETH_VLANTAGCOMPARISON_16BIT,
|
||||
.VLANTagIdentifier = 0x0U
|
||||
};
|
||||
|
||||
if (heth->Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE) {
|
||||
macconf.ChecksumOffload = ETH_CHECKSUMOFFLAOD_ENABLE;
|
||||
} else {
|
||||
macconf.ChecksumOffload = ETH_CHECKSUMOFFLAOD_DISABLE;
|
||||
}
|
||||
|
||||
(void) HAL_ETH_ConfigMAC(heth, &macconf);
|
||||
}
|
Loading…
Reference in New Issue