Skip to content

Commit ef86bf9

Browse files
author
Cruz Monrreal
authored
Merge pull request #7121 from kjbracey-arm/ns-emac-hardfault
Nanostack EMAC - avoid initialisation race
2 parents 2ac81de + 852445a commit ef86bf9

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

features/nanostack/mbed-mesh-api/source/NanostackEMACInterface.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void EMACPhy::emac_phy_rx(emac_mem_buf_t *mem)
8888
}
8989
}
9090

91-
if (ptr) {
91+
if (ptr && phy.phy_rx_cb) {
9292
phy.phy_rx_cb(ptr, total_len, 0xff, 0, device_id);
9393
}
9494
ns_dyn_mem_free(tmpbuf);
@@ -125,6 +125,18 @@ int8_t EMACPhy::phy_register()
125125
{
126126
if (device_id < 0) {
127127

128+
phy.PHY_MAC = mac_addr;
129+
phy.address_write = emac_phy_address_write;
130+
phy.driver_description = const_cast<char*>("ETH");
131+
phy.link_type = PHY_LINK_ETHERNET_TYPE;
132+
phy.phy_MTU = 0;
133+
phy.phy_header_length = 0;
134+
phy.phy_tail_length = 0;
135+
phy.state_control = emac_phy_interface_state_control;
136+
phy.tx = emac_phy_tx;
137+
phy.phy_rx_cb = NULL;
138+
phy.phy_tx_done_cb = NULL;
139+
128140
emac.set_memory_manager(memory_manager);
129141
emac.set_link_input_cb(callback(this, &EMACPhy::emac_phy_rx));
130142

@@ -141,17 +153,6 @@ int8_t EMACPhy::phy_register()
141153

142154
emac.set_all_multicast(true);
143155

144-
phy.PHY_MAC = mac_addr;
145-
phy.address_write = emac_phy_address_write;
146-
phy.driver_description = const_cast<char*>("ETH");
147-
phy.link_type = PHY_LINK_ETHERNET_TYPE;
148-
phy.phy_MTU = 0;
149-
phy.phy_header_length = 0;
150-
phy.phy_tail_length = 0;
151-
phy.state_control = emac_phy_interface_state_control;
152-
phy.tx = emac_phy_tx;
153-
phy.phy_rx_cb = NULL;
154-
phy.phy_tx_done_cb = NULL;
155156
device_id = arm_net_phy_register(&phy);
156157
// driver_readiness_status_callback = driver_status_cb;
157158

0 commit comments

Comments
 (0)