1
6
7
8
9
10
11
12
13
14
15
16
17
18
19
23
28
29
33
39
40
44
51
58
71
72
73
74
75
76
77
78
79
80
81
82
83
84
93
94
95
102
103
104
105
106
/* ... */
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "esp_eth_phy.h"
#include "esp_eth_mac.h"
#include "driver/spi_master.h"
#define CS_HOLD_TIME_MIN_NS 210
/* ... */
typedef struct {
spi_host_device_t spi_host_id;
spi_device_interface_config_t *spi_devcfg;
int int_gpio_num;
}{ ... } eth_enc28j60_config_t;
/* ... */
typedef enum {
ENC28J60_REV_B1 = 0b00000010,
ENC28J60_REV_B4 = 0b00000100,
ENC28J60_REV_B5 = 0b00000101,
ENC28J60_REV_B7 = 0b00000110
}{ ... } eth_enc28j60_rev_t;
/* ... */
#define ETH_ENC28J60_DEFAULT_CONFIG(spi_host, spi_devcfg_p) \
{ \
.spi_host_id = spi_host, \
.spi_devcfg = spi_devcfg_p, \
.int_gpio_num = 4, \
}{...}
...
/* ... */
static inline uint8_t enc28j60_cal_spi_cs_hold_time(int clock_speed_mhz)
{
if (clock_speed_mhz <= 0 || clock_speed_mhz > 20) {
return 0;
}{...}
int temp = clock_speed_mhz * CS_HOLD_TIME_MIN_NS;
uint8_t cs_posttrans = temp / 1000;
if (temp % 1000) {
cs_posttrans += 1;
}{...}
return cs_posttrans;
}{ ... }
/* ... */
esp_eth_mac_t *esp_eth_mac_new_enc28j60(const eth_enc28j60_config_t *enc28j60_config, const eth_mac_config_t *mac_config);
/* ... */
esp_eth_phy_t *esp_eth_phy_new_enc28j60(const eth_phy_config_t *config);
/* ... */
eth_enc28j60_rev_t emac_enc28j60_get_chip_info(esp_eth_mac_t *mac);
#ifdef __cplusplus
}{...}
#endif