Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit 1dd1b60

Browse files
committed
Adding STM32F4 ETH files missed from prior commit (oops!)
1 parent a7217a6 commit 1dd1b60

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_lwip_adapter.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ static BOOL LinkStatus = FALSE;
2929
static int nAttempts = 0;
3030
static BOOL isPhyPoweringUp = FALSE;
3131

32-
/* these define the region to zero initialize */
33-
extern UINT32 Image$$ER_ETHERNET$$ZI$$Base;
34-
extern UINT32 Image$$ER_ETHERNET$$ZI$$Length;
32+
extern void ZeroRxDesc();
33+
extern void ZeroTxDesc();
3534

3635
extern NETWORK_CONFIG g_NetworkConfig;
3736

@@ -58,9 +57,12 @@ void lwip_interrupt_continuation( void )
5857
STM32F4_ETH_LWIP_recv( &g_STM32F4_ETH_NetIF );
5958
}
6059

61-
// MCBSTM32F400 is wired up in such a way that there is no link status
62-
// interrupt available in hadware. Thus this continuation is used to
63-
// poll the PHY to determine the current state at regular intervals.
60+
// completion used when system is wired up in such a way that there is
61+
// no link status interrupt available in hardware. Thus this continuation
62+
// is used to poll the PHY to determine the current state at regular
63+
// intervals.
64+
//
65+
// NOTE:
6466
// This is not a recommended design for hardware as it requires waking
6567
// the system from sleep for polling, thus wasting power on battery
6668
// operated systems.
@@ -145,12 +147,8 @@ void DeInitContinuations( )
145147

146148
void EthernetPrepareZero( )
147149
{
148-
/* The ethernet section (TX/RX descriptors and their buffers) is in a separate memory zone
149-
which is not zero initialized. It must be done manually */
150-
void* base = ( void* )&Image$$ER_ETHERNET$$ZI$$Base;
151-
UINT32 length = ( UINT32 )&Image$$ER_ETHERNET$$ZI$$Length;
152-
153-
memset( base, 0x00, length );
150+
ZeroRxDesc();
151+
ZeroTxDesc();
154152
}
155153

156154
void EthernetWakeUp( )
@@ -211,8 +209,6 @@ int STM32F4_ETH_LWIP_Driver::Open( int index )
211209
return g_STM32F4_ETH_NetIF.num;
212210
}
213211

214-
// -- //
215-
216212
BOOL STM32F4_ETH_LWIP_Driver::Close( void )
217213
{
218214
CPU_INTC_DeactivateInterrupt( ETH_IRQn );

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_phy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ BOOL eth_isPhyLinkValid(BOOL isCallBlocking)
133133
// Read status register until a valid link is detected or a timeout is elapsed
134134
do
135135
{
136-
if( !readRegister(PHY_STATUS_REGISTER, &status) )
136+
if( !readRegister(PHY_STATUS_REGISTER, &status) || 0xFFFF == status )
137137
return FALSE;
138138

139139
if (status & PHY_SR_LINK)

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_rx_desc.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ static RxDesc_t s_rxDescriptor[N_RX_DESC]; // RX descriptors
6969
static RxDesc_t *s_pRxDesc; // Pointer on the current RX descriptor
7070
static uint8_t s_rxBuffer[N_RX_DESC][RX_BUFFER_LENGTH]; // RX buffers
7171

72+
void ZeroRxDesc()
73+
{
74+
s_pRxDesc = NULL;
75+
memset(s_rxDescriptor, 0, sizeof(s_rxDescriptor));
76+
memset(s_rxBuffer, 0, sizeof(s_rxBuffer));
77+
}
78+
7279
//--------------------------------------------------------------------------------------------
7380
// Local functions declarations
7481
//--------------------------------------------------------------------------------------------

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_tx_desc.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ static TxDesc_t s_txDescriptor[N_TX_DESC]; // TX descriptors
6868
static TxDesc_t *s_pTxDesc; // Pointer on the current TX descriptor
6969
static uint8_t s_txBuffer[N_TX_DESC][TX_BUFFER_LENGTH];
7070

71+
void ZeroTxDesc()
72+
{
73+
s_pTxDesc = NULL;
74+
memset(s_txDescriptor, 0, sizeof(s_txDescriptor));
75+
memset(s_txBuffer, 0, sizeof(s_txBuffer));
76+
}
77+
7178
//--------------------------------------------------------------------------------------------
7279
// Functions definitions
7380
//--------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)