MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / efm_eth_sendCmd

Function efm_eth_sendCmd

bsp/efm32/drv_ethernet.c:205–237  ·  view source on GitHub ↗

/ * @brief * Wrapper function of send command to Ethernet device * * @details * * @note * * @param[in] cmd * Command index * * @param[in] addr * Register address * * @param[in/out] data * Pointer to the buffer of register value * * @return * Error code ******************************************************************************/

Source from the content-addressed store, hash-verified

203 * Error code
204 ******************************************************************************/
205static rt_err_t efm_eth_sendCmd(
206 rt_uint8_t cmd,
207 rt_uint8_t addr,
208 rt_uint8_t *data)
209{
210 rt_err_t ret;
211
212 eth_debug("ETH: Send command %x (%x %x)\n", cmd, addr, *data);
213 do
214 {
215 /* Change bank */
216 if(((addr & BANK_MASK) != ethBank) && ((addr < EIE) || (addr > ECON1)))
217 {
218 rt_uint8_t temp;
219
220 if ((ret = efm_eth_cmd(ENC28J60_READ_CTRL_REG, ECON1, &temp)) != RT_EOK)
221 {
222 break;
223 }
224 temp &= 0xFC;
225 ethBank = (addr & BANK_MASK);
226 temp |= ethBank >> BANK_SHIFT;
227 if ((ret = efm_eth_cmd(ENC28J60_WRITE_CTRL_REG, ECON1, &temp)) != RT_EOK)
228 {
229 break;
230 }
231 }
232 /* Send command */
233 ret = efm_eth_cmd(cmd, addr, data);
234 } while(0);
235
236 return ret;
237}
238
239/***************************************************************************//**
240 * @brief

Callers 6

efm_eth_readRegFunction · 0.85
efm_eth_writeRegFunction · 0.85
efm_eth_isrFunction · 0.85
efm_eth_initFunction · 0.85
efm_eth_rxFunction · 0.85
efm_eth_txFunction · 0.85

Calls 1

efm_eth_cmdFunction · 0.85

Tested by

no test coverage detected