Bouffalo SDK  1.0
Bouffalolab Software Development Kit
EMAC
Collaboration diagram for EMAC:

Modules

 emac feature control cmd definition
 
 phy state definition
 

Data Structures

struct  bflb_emac_config_s
 EMAC configuration structure. More...
 
struct  bflb_emac_phy_cfg_s
 EMAC phy configuration structure. More...
 

Macros

#define EMAC_DO_FLUSH_DATA   (1)
 
#define EMAC_CLK_USE_EXTERNAL   (0)
 
#define EMAC_CLK_USE_INTERNAL   (1)
 
#define EMAC_NORMAL_PACKET   (uint32_t)(0)
 
#define EMAC_FRAGMENT_PACKET   (uint32_t)(0x01)
 
#define EMAC_NOCOPY_PACKET   (uint32_t)(0x02)
 
#define ETH_MAX_PACKET_SIZE   ((uint32_t)1524U)
 
#define ETH_HEADER_SZIE   ((uint32_t)14U)
 
#define ETH_CRC_SIZE   ((uint32_t)4U)
 
#define ETH_EXTRA_SIZE   ((uint32_t)2U)
 
#define ETH_VLAN_TAG_SIZE   ((uint32_t)4U)
 
#define ETH_MIN_ETH_PAYLOAD_SIZE   ((uint32_t)46U)
 
#define ETH_MAX_ETH_PAYLOAD_SIZE   ((uint32_t)1500U)
 
#define ETH_JUMBO_FRAME_PAYLOAD_SIZE   ((uint32_t)9000U)
 
#define ETH_TX_BUFFER_SIZE   (ETH_MAX_PACKET_SIZE)
 
#define ETH_RX_BUFFER_SIZE   (ETH_MAX_PACKET_SIZE)
 
#define EMAC_INT_EN_TX_DONE   (1 << 0)
 
#define EMAC_INT_EN_TX_ERROR   (1 << 1)
 
#define EMAC_INT_EN_RX_DONE   (1 << 2)
 
#define EMAC_INT_EN_RX_ERROR   (1 << 3)
 
#define EMAC_INT_EN_RX_BUSY   (1 << 4)
 
#define EMAC_INT_EN_TX_CTRL   (1 << 5)
 
#define EMAC_INT_EN_RX_CTRL   (1 << 6)
 
#define EMAC_INT_EN_ALL   (0x7f << 0)
 
#define EMAC_INT_STS_TX_DONE   (1 << 0)
 
#define EMAC_INT_STS_TX_ERROR   (1 << 1)
 
#define EMAC_INT_STS_RX_DONE   (1 << 2)
 
#define EMAC_INT_STS_RX_ERROR   (1 << 3)
 
#define EMAC_INT_STS_RX_BUSY   (1 << 4)
 
#define EMAC_INT_STS_TX_CTRL   (1 << 5)
 
#define EMAC_INT_STS_RX_CTRL   (1 << 6)
 
#define EMAC_INT_STS_ALL   (0x7f << 0)
 
#define EMAC_BD_TYPE_INVLAID   (0)
 
#define EMAC_BD_TYPE_TX   (1)
 
#define EMAC_BD_TYPE_RX   (2)
 
#define EMAC_BD_TYPE_NONE   (3)
 
#define EMAC_BD_TYPE_MAX   (0x7FFFFFFF)
 

Functions

void bflb_emac_init (struct bflb_device_s *dev, const struct bflb_emac_config_s *config)
 
void bflb_emac_stop (struct bflb_device_s *dev)
 
void bflb_emac_start (struct bflb_device_s *dev)
 
void bflb_emac_start_tx (struct bflb_device_s *dev)
 
void bflb_emac_stop_tx (struct bflb_device_s *dev)
 
void bflb_emac_start_rx (struct bflb_device_s *dev)
 
void bflb_emac_stop_rx (struct bflb_device_s *dev)
 
void bflb_emac_bd_init (struct bflb_device_s *dev, uint8_t *eth_tx_buff, uint8_t tx_buf_count, uint8_t *eth_rx_buff, uint8_t rx_buf_count)
 
uint32_t bflb_emac_bd_get_cur_active (struct bflb_device_s *dev, uint8_t bdt)
 
void bflb_emac_bd_rx_enqueue (uint32_t index)
 
void bflb_emac_bd_rx_on_err (uint32_t index)
 
void bflb_emac_bd_tx_dequeue (uint32_t index)
 
void bflb_emac_bd_tx_on_err (uint32_t index)
 
int bflb_emac_bd_tx_enqueue (uint32_t flags, uint32_t len, const uint8_t *data_in)
 
int bflb_emac_bd_rx_dequeue (uint32_t flags, uint32_t *len, uint8_t *data_out)
 
int emac_bd_fragment_support (void)
 
void bflb_emac_int_enable (struct bflb_device_s *dev, uint32_t flag, bool enable)
 
void bflb_emac_int_clear (struct bflb_device_s *dev, uint32_t flag)
 
uint32_t bflb_emac_get_int_status (struct bflb_device_s *dev)
 
int bflb_emac_feature_control (struct bflb_device_s *dev, int cmd, size_t arg)
 
int bflb_emac_phy_reg_read (struct bflb_device_s *dev, uint16_t phy_reg, uint16_t *phy_reg_val)
 
int bflb_emac_phy_reg_write (struct bflb_device_s *dev, uint16_t phy_reg, uint16_t phy_reg_val)
 

Detailed Description

Macro Definition Documentation

◆ EMAC_BD_TYPE_INVLAID

#define EMAC_BD_TYPE_INVLAID   (0)

Definition at line 102 of file bflb_emac.h.

◆ EMAC_BD_TYPE_MAX

#define EMAC_BD_TYPE_MAX   (0x7FFFFFFF)

Definition at line 106 of file bflb_emac.h.

◆ EMAC_BD_TYPE_NONE

#define EMAC_BD_TYPE_NONE   (3)

Definition at line 105 of file bflb_emac.h.

◆ EMAC_BD_TYPE_RX

#define EMAC_BD_TYPE_RX   (2)

Definition at line 104 of file bflb_emac.h.

◆ EMAC_BD_TYPE_TX

#define EMAC_BD_TYPE_TX   (1)

Definition at line 103 of file bflb_emac.h.

◆ EMAC_CLK_USE_EXTERNAL

#define EMAC_CLK_USE_EXTERNAL   (0)

Definition at line 17 of file bflb_emac.h.

◆ EMAC_CLK_USE_INTERNAL

#define EMAC_CLK_USE_INTERNAL   (1)

Definition at line 18 of file bflb_emac.h.

◆ EMAC_DO_FLUSH_DATA

#define EMAC_DO_FLUSH_DATA   (1)

Definition at line 14 of file bflb_emac.h.

◆ EMAC_FRAGMENT_PACKET

#define EMAC_FRAGMENT_PACKET   (uint32_t)(0x01)

Definition at line 58 of file bflb_emac.h.

◆ EMAC_INT_EN_ALL

#define EMAC_INT_EN_ALL   (0x7f << 0)

Definition at line 89 of file bflb_emac.h.

◆ EMAC_INT_EN_RX_BUSY

#define EMAC_INT_EN_RX_BUSY   (1 << 4)

Definition at line 86 of file bflb_emac.h.

◆ EMAC_INT_EN_RX_CTRL

#define EMAC_INT_EN_RX_CTRL   (1 << 6)

Definition at line 88 of file bflb_emac.h.

◆ EMAC_INT_EN_RX_DONE

#define EMAC_INT_EN_RX_DONE   (1 << 2)

Definition at line 84 of file bflb_emac.h.

◆ EMAC_INT_EN_RX_ERROR

#define EMAC_INT_EN_RX_ERROR   (1 << 3)

Definition at line 85 of file bflb_emac.h.

◆ EMAC_INT_EN_TX_CTRL

#define EMAC_INT_EN_TX_CTRL   (1 << 5)

Definition at line 87 of file bflb_emac.h.

◆ EMAC_INT_EN_TX_DONE

#define EMAC_INT_EN_TX_DONE   (1 << 0)

Definition at line 82 of file bflb_emac.h.

◆ EMAC_INT_EN_TX_ERROR

#define EMAC_INT_EN_TX_ERROR   (1 << 1)

Definition at line 83 of file bflb_emac.h.

◆ EMAC_INT_STS_ALL

#define EMAC_INT_STS_ALL   (0x7f << 0)

Definition at line 99 of file bflb_emac.h.

◆ EMAC_INT_STS_RX_BUSY

#define EMAC_INT_STS_RX_BUSY   (1 << 4)

Definition at line 96 of file bflb_emac.h.

◆ EMAC_INT_STS_RX_CTRL

#define EMAC_INT_STS_RX_CTRL   (1 << 6)

Definition at line 98 of file bflb_emac.h.

◆ EMAC_INT_STS_RX_DONE

#define EMAC_INT_STS_RX_DONE   (1 << 2)

Definition at line 94 of file bflb_emac.h.

◆ EMAC_INT_STS_RX_ERROR

#define EMAC_INT_STS_RX_ERROR   (1 << 3)

Definition at line 95 of file bflb_emac.h.

◆ EMAC_INT_STS_TX_CTRL

#define EMAC_INT_STS_TX_CTRL   (1 << 5)

Definition at line 97 of file bflb_emac.h.

◆ EMAC_INT_STS_TX_DONE

#define EMAC_INT_STS_TX_DONE   (1 << 0)

Definition at line 92 of file bflb_emac.h.

◆ EMAC_INT_STS_TX_ERROR

#define EMAC_INT_STS_TX_ERROR   (1 << 1)

Definition at line 93 of file bflb_emac.h.

◆ EMAC_NOCOPY_PACKET

#define EMAC_NOCOPY_PACKET   (uint32_t)(0x02)

Definition at line 59 of file bflb_emac.h.

◆ EMAC_NORMAL_PACKET

#define EMAC_NORMAL_PACKET   (uint32_t)(0)

Definition at line 57 of file bflb_emac.h.

◆ ETH_CRC_SIZE

#define ETH_CRC_SIZE   ((uint32_t)4U)

Ethernet CRC

Definition at line 66 of file bflb_emac.h.

◆ ETH_EXTRA_SIZE

#define ETH_EXTRA_SIZE   ((uint32_t)2U)

Extra bytes in some cases

Definition at line 67 of file bflb_emac.h.

◆ ETH_HEADER_SZIE

#define ETH_HEADER_SZIE   ((uint32_t)14U)

6 byte Dest addr, 6 byte Src addr, 2 byte length/type

Definition at line 65 of file bflb_emac.h.

◆ ETH_JUMBO_FRAME_PAYLOAD_SIZE

#define ETH_JUMBO_FRAME_PAYLOAD_SIZE   ((uint32_t)9000U)

Jumbo frame payload size

Definition at line 71 of file bflb_emac.h.

◆ ETH_MAX_ETH_PAYLOAD_SIZE

#define ETH_MAX_ETH_PAYLOAD_SIZE   ((uint32_t)1500U)

Maximum Ethernet payload size

Definition at line 70 of file bflb_emac.h.

◆ ETH_MAX_PACKET_SIZE

#define ETH_MAX_PACKET_SIZE   ((uint32_t)1524U)

ETH_HEADER + ETH_EXTRA + ETH_VLAN_TAG + ETH_MAX_ETH_PAYLOAD + ETH_CRC

Definition at line 64 of file bflb_emac.h.

◆ ETH_MIN_ETH_PAYLOAD_SIZE

#define ETH_MIN_ETH_PAYLOAD_SIZE   ((uint32_t)46U)

Minimum Ethernet payload size

Definition at line 69 of file bflb_emac.h.

◆ ETH_RX_BUFFER_SIZE

#define ETH_RX_BUFFER_SIZE   (ETH_MAX_PACKET_SIZE)

Definition at line 78 of file bflb_emac.h.

◆ ETH_TX_BUFFER_SIZE

#define ETH_TX_BUFFER_SIZE   (ETH_MAX_PACKET_SIZE)

Definition at line 75 of file bflb_emac.h.

◆ ETH_VLAN_TAG_SIZE

#define ETH_VLAN_TAG_SIZE   ((uint32_t)4U)

optional 802.1q VLAN Tag

Definition at line 68 of file bflb_emac.h.

Function Documentation

◆ bflb_emac_bd_get_cur_active()

uint32_t bflb_emac_bd_get_cur_active ( struct bflb_device_s dev,
uint8_t  bdt 
)
Parameters
[in]dev
[in]bdt
Returns
uint32_t

◆ bflb_emac_bd_init()

void bflb_emac_bd_init ( struct bflb_device_s dev,
uint8_t *  eth_tx_buff,
uint8_t  tx_buf_count,
uint8_t *  eth_rx_buff,
uint8_t  rx_buf_count 
)
Parameters
[in]dev
[in]eth_tx_buff
[in]tx_buf_count
[in]eth_rx_buff
[in]rx_buf_count

◆ bflb_emac_bd_rx_dequeue()

int bflb_emac_bd_rx_dequeue ( uint32_t  flags,
uint32_t *  len,
uint8_t *  data_out 
)
Parameters
[in]flags
[in]len
[in]data_out
Returns
int

◆ bflb_emac_bd_rx_enqueue()

void bflb_emac_bd_rx_enqueue ( uint32_t  index)
Parameters
[in]index

◆ bflb_emac_bd_rx_on_err()

void bflb_emac_bd_rx_on_err ( uint32_t  index)
Parameters
[in]index

◆ bflb_emac_bd_tx_dequeue()

void bflb_emac_bd_tx_dequeue ( uint32_t  index)
Parameters
[in]index

◆ bflb_emac_bd_tx_enqueue()

int bflb_emac_bd_tx_enqueue ( uint32_t  flags,
uint32_t  len,
const uint8_t *  data_in 
)
Parameters
[in]flags
[in]len
[in]data_in
Returns
int

◆ bflb_emac_bd_tx_on_err()

void bflb_emac_bd_tx_on_err ( uint32_t  index)
Parameters
[in]index

◆ bflb_emac_feature_control()

int bflb_emac_feature_control ( struct bflb_device_s dev,
int  cmd,
size_t  arg 
)
Parameters
[in]dev
[in]cmd
[in]arg
Returns
int

◆ bflb_emac_get_int_status()

uint32_t bflb_emac_get_int_status ( struct bflb_device_s dev)
Parameters
[in]dev
Returns
uint32_t

◆ bflb_emac_init()

void bflb_emac_init ( struct bflb_device_s dev,
const struct bflb_emac_config_s config 
)
Parameters
[in]dev
[in]config

◆ bflb_emac_int_clear()

void bflb_emac_int_clear ( struct bflb_device_s dev,
uint32_t  flag 
)
Parameters
[in]dev
[in]flag

◆ bflb_emac_int_enable()

void bflb_emac_int_enable ( struct bflb_device_s dev,
uint32_t  flag,
bool  enable 
)
Parameters
[in]dev
[in]flag
[in]enable

◆ bflb_emac_phy_reg_read()

int bflb_emac_phy_reg_read ( struct bflb_device_s dev,
uint16_t  phy_reg,
uint16_t *  phy_reg_val 
)
Parameters
[in]dev
[in]phy_reg
[in]phy_reg_val
Returns
int

◆ bflb_emac_phy_reg_write()

int bflb_emac_phy_reg_write ( struct bflb_device_s dev,
uint16_t  phy_reg,
uint16_t  phy_reg_val 
)
Parameters
[in]dev
[in]phy_reg
[in]phy_reg_val
Returns
int

◆ bflb_emac_start()

void bflb_emac_start ( struct bflb_device_s dev)
Parameters
[in]dev

◆ bflb_emac_start_rx()

void bflb_emac_start_rx ( struct bflb_device_s dev)
Parameters
[in]dev

◆ bflb_emac_start_tx()

void bflb_emac_start_tx ( struct bflb_device_s dev)
Parameters
[in]dev

◆ bflb_emac_stop()

void bflb_emac_stop ( struct bflb_device_s dev)
Parameters
[in]dev

◆ bflb_emac_stop_rx()

void bflb_emac_stop_rx ( struct bflb_device_s dev)
Parameters
[in]dev

◆ bflb_emac_stop_tx()

void bflb_emac_stop_tx ( struct bflb_device_s dev)
Parameters
[in]dev

◆ emac_bd_fragment_support()

int emac_bd_fragment_support ( void  )
Returns
int