Portenta: enable ETH power supply

pull/13826/head
pennam 2020-11-11 16:35:56 +01:00 committed by Martino Facchin
parent 7e2acee49a
commit f665f1d391
3 changed files with 90 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#ifndef USE_USER_DEFINED_HAL_ETH_MSPINIT
#include "stm32h7xx_hal.h"
#include "portenta_power.h"
#define ETH_TX_EN_Pin GPIO_PIN_11
#define ETH_TX_EN_GPIO_Port GPIOG
@ -59,6 +60,8 @@ void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
GPIO_InitTypeDef GPIO_InitStruct;
if(heth->Instance == ETH)
{
enableEthPowerSupply();
#if !(defined(DUAL_CORE) && defined(CORE_CM4))
/* Disable DCache for STM32H7 family */
SCB_DisableDCache();

View File

@ -0,0 +1,54 @@
/*
Copyright (c) 2019 Arduino. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/******************************************************************************
INCLUDE
******************************************************************************/
#include "mbed.h"
#include "portenta_power.h"
/******************************************************************************
PUBLIC MEMBER FUNCTIONS
******************************************************************************/
void enableEthPowerSupply(void)
{
/* Ensure ETH power supply */
mbed::I2C i2c(PB_7, PB_6);
char data[2];
// LDO3 to 1.2V
data[0]=0x52;
data[1]=0x9;
i2c.write(8 << 1, data, sizeof(data));
data[0]=0x53;
data[1]=0xF;
i2c.write(8 << 1, data, sizeof(data));
// SW2 to 3.3V (SW2_VOLT)
data[0]=0x3B;
data[1]=0xF;
i2c.write(8 << 1, data, sizeof(data));
// SW1 to 3.0V (SW1_VOLT)
data[0]=0x35;
data[1]=0xF;
i2c.write(8 << 1, data, sizeof(data));
}

View File

@ -0,0 +1,33 @@
/*
Copyright (c) 2019 Arduino. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PORTENTA_POWER
#define PORTENTA_POWER
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
extern void enableEthPowerSupply(void);
#if defined(__cplusplus)
}
#endif
#endif