Skip to content

Commit 491c063

Browse files
More renames, fix !=
1 parent 65be6a8 commit 491c063

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

connectivity/drivers/emac/CompositeEMAC.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ A descriptor is a structure in memory that contains control information and one
3737
But we don't want the DMA to have to wait for the CPU, do we? To avoid this, each descriptor also specifies a "next descriptor", either via an offset or a pointer. The DMA can move to this next descriptor and start processing it right away to send or receive the next packet. The CPU will process the completed descriptor on its own time and give it back to the DMA. In this manner, as long as your ring of descriptors is big enough and your CPU can keep up with the processing them, the CPU and MAC never have to wait for each other!
3838

3939
## Components of the Composite EMAC
40+
Now that we've covered how an EMAC works in hardware, we can talk through how CompositeEMAC works, and what needs to be implemented for each MCU target.
41+
4042
### MAC Driver
4143

4244
The MAC driver (which must be implemented as a subclass of `CompositeEMAC::MACDriver`) is usually fairly simple. It provides an interface between Mbed and the MAC's configuration register block and MDIO master interface. Its responsibilities include:
@@ -66,7 +68,7 @@ Unlike the MAC driver and the DMA, the PHY driver does not need to be subclassed
6668

6769
This will work out of the box, as long as `LAN8742` names a PHY driver defined in PhyDrivers.cpp. Individual PHY models will generally need their own drivers, since often PHYs have errata that need to be worked around or need other configuration that isn't defined in the standard. However, GenericEthPhy allows implementing the absolute minimum amount of logic per-phy as possible!
6870

69-
Since user boards may want to use a different ethernet PHY, the driver can be customized in an application by overriding the `mbed::get_eth_phy_driver` weak function. This might look something like
71+
Since user boards may want to use a different ethernet PHY, the driver can be customized in an application by overriding the `mbed::get_eth_phy_driver` weak function to return a different driver class. This might look something like
7072

7173
```c++
7274
namespace MY_PHY {
@@ -94,4 +96,8 @@ CompositeEMAC::PHYDriver * get_eth_phy_driver()
9496
return &phyDriver;
9597
}
9698
}
97-
```
99+
```
100+
101+
### Tx DMA
102+
103+
The Rx and Tx DMAs are implemented as their own driver classes, as they are somewhat complicated and generally don't interact with the other pieces of the EMAC very much. The Tx DMA must be implemented as a subclass of `CompositeEMAC::TxDMA`. However, since the large majority of microcontrollers implement Tx DMA in a very similar way, the `GenericTxDMARing` class has been provided which implements most of the needed functionality.

connectivity/drivers/emac/TARGET_STM/STM32EthMACv1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace mbed
3333
*/
3434
class STM32EthMACv1 : public CompositeEMAC
3535
{
36-
class TxDMA : public GenericTxDMALoop
36+
class TxDMA : public GenericTxDMARing
3737
{
3838
protected:
3939
ETH_TypeDef * const base; // Base address of Ethernet peripheral

connectivity/drivers/emac/TARGET_STM/STM32EthMACv2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace mbed {
2727
*/
2828
class STM32EthMACv2 : public CompositeEMAC {
2929

30-
class TxDMA : public GenericTxDMALoop
30+
class TxDMA : public GenericTxDMARing
3131
{
3232
protected:
3333
ETH_TypeDef * const base; // Base address of Ethernet peripheral

connectivity/drivers/emac/include/GenericEthDMA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace mbed {
3333
* This implementation of Tx DMA should work for the large majority of embedded MCUs that use a DMA ring-based
3434
* ethernet MAC.
3535
*/
36-
class GenericTxDMALoop : public CompositeEMAC::TxDMA
36+
class GenericTxDMARing : public CompositeEMAC::TxDMA
3737
{
3838
protected:
3939
/// Number of entries in the Tx descriptor ring

connectivity/drivers/emac/sources/GenericEthPhy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ CompositeEMAC::ErrCode GenericEthPhy::init() {
7272
}
7373

7474
// Software reset, if we couldn't use the hardware reset line earlier
75-
if(mac->getPhyResetPin() != NC) {
75+
if(mac->getPhyResetPin() == NC) {
7676
uint16_t bmcrVal;
7777
FORWARD_ERR(mac->mdioRead(config.address, GenPhyRegs::BMCR, bmcrVal));
7878
FORWARD_ERR(mac->mdioWrite(config.address, GenPhyRegs::BMCR, bmcrVal | GenPhyRegs::BMCR_SW_RST_Msk));

0 commit comments

Comments
 (0)