STM32Cube  Version 2.0
Create Projects for STM32H7 Series with STM32Cube HAL and STM32CubeMX
 All Files Functions Variables Macros Pages
EMAC_STM32H7xx.c File Reference
#include "EMAC_STM32H7xx.h"

Macros

#define EMAC_TXBUF_ADDRESS   0x30042000
 
#define EMAC_CHECKSUM_OFFLOAD   1
 
#define EMAC_TIME_STAMP   0
 
#define ARM_ETH_MAC_DRV_VERSION   ARM_DRIVER_VERSION_MAJOR_MINOR(1,0)
 

Functions

static uint8_t TX_Buff[ETH_TX_DESC_CNT][ETH_MAX_PACKET_SIZE] __MEM_AT (EMAC_TXBUF_ADDRESS)
 
static uint32_t crc32_8bit_rev (uint32_t crc32, uint8_t val)
 Calculate 32-bit CRC (Polynomial: 0x04C11DB7, data bit-reversed). More...
 
static uint32_t crc32_data (const uint8_t *data, uint32_t len)
 Calculate standard 32-bit Ethernet CRC. More...
 
static ARM_DRIVER_VERSION GetVersion (void)
 Get driver version. More...
 
static ARM_ETH_MAC_CAPABILITIES GetCapabilities (void)
 Get driver capabilities. More...
 
static int32_t Initialize (ARM_ETH_MAC_SignalEvent_t cb_event)
 Initialize Ethernet MAC Device. More...
 
static int32_t Uninitialize (void)
 De-initialize Ethernet MAC Device. More...
 
static int32_t PowerControl (ARM_POWER_STATE state)
 Control Ethernet MAC Device Power. More...
 
static int32_t GetMacAddress (ARM_ETH_MAC_ADDR *ptr_addr)
 Get Ethernet MAC Address. More...
 
static int32_t SetMacAddress (const ARM_ETH_MAC_ADDR *ptr_addr)
 Set Ethernet MAC Address. More...
 
static int32_t SetAddressFilter (const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t num_addr)
 Configure Address Filter. More...
 
static int32_t SendFrame (const uint8_t *frame, uint32_t len, uint32_t flags)
 Send Ethernet frame. More...
 
static int32_t ReadFrame (uint8_t *frame, uint32_t len)
 Read data of received Ethernet frame. More...
 
static uint32_t GetRxFrameSize (void)
 Get size of received Ethernet frame. More...
 
static int32_t GetRxFrameTime (ARM_ETH_MAC_TIME *time)
 Get time of received Ethernet frame. More...
 
static int32_t GetTxFrameTime (ARM_ETH_MAC_TIME *time)
 Get time of transmitted Ethernet frame. More...
 
static int32_t ControlTimer (uint32_t control, ARM_ETH_MAC_TIME *time)
 Control Precision Timer. More...
 
static int32_t Control (uint32_t control, uint32_t arg)
 Control Ethernet Interface. More...
 
static int32_t PHY_Read (uint8_t phy_addr, uint8_t reg_addr, uint16_t *data)
 Read Ethernet PHY Register through Management Interface. More...
 
static int32_t PHY_Write (uint8_t phy_addr, uint8_t reg_addr, uint16_t data)
 Write Ethernet PHY Register through Management Interface. More...
 
void HAL_ETH_TxCpltCallback (ETH_HandleTypeDef *heth)
 
void HAL_ETH_RxCpltCallback (ETH_HandleTypeDef *heth)
 
void HAL_ETH_PMTCallback (ETH_HandleTypeDef *heth)
 

Variables

ETH_HandleTypeDef heth
 
ETH_DMADescTypeDef DMARxDscrTab [ETH_RX_DESC_CNT]
 
ETH_DMADescTypeDef DMATxDscrTab [ETH_TX_DESC_CNT]
 
uint8_t Rx_Buff [ETH_RX_DESC_CNT][ETH_MAX_PACKET_SIZE]
 
static const ARM_DRIVER_VERSION DriverVersion
 
static const
ARM_ETH_MAC_CAPABILITIES 
DriverCapabilities
 
static EMAC_CTRL Emac
 
static ETH_MACConfigTypeDef MAC_Config
 
static ETH_MACFilterConfigTypeDef MAC_Filter
 
static ETH_TxPacketConfig TX_Config
 
ARM_DRIVER_ETH_MAC Driver_ETH_MAC0
 

Macro Definition Documentation

#define ARM_ETH_MAC_DRV_VERSION   ARM_DRIVER_VERSION_MAJOR_MINOR(1,0)
#define EMAC_CHECKSUM_OFFLOAD   1
#define EMAC_TIME_STAMP   0
#define EMAC_TXBUF_ADDRESS   0x30042000

Function Documentation

static uint8_t TX_Buff [ETH_TX_DESC_CNT][ETH_MAX_PACKET_SIZE] __MEM_AT ( EMAC_TXBUF_ADDRESS  )
static
int32_t Control ( uint32_t  control,
uint32_t  arg 
)
static
Parameters
[in]controloperation
[in]argargument of operation (optional)
Returns
execution_status
int32_t ControlTimer ( uint32_t  control,
ARM_ETH_MAC_TIME *  time 
)
static
Parameters
[in]controloperation
[in]timePointer to time structure
Returns
execution_status
uint32_t crc32_8bit_rev ( uint32_t  crc32,
uint8_t  val 
)
static
Parameters
[in]crc32CRC initial value
[in]valInput value
Returns
Calculated CRC value
uint32_t crc32_data ( const uint8_t *  data,
uint32_t  len 
)
static
Parameters
[in]dataPointer to buffer containing the data
[in]lenData length in bytes
Returns
Calculated CRC value
ARM_ETH_MAC_CAPABILITIES GetCapabilities ( void  )
static
Returns
ARM_ETH_MAC_CAPABILITIES
int32_t GetMacAddress ( ARM_ETH_MAC_ADDR *  ptr_addr)
static
Parameters
[in]ptr_addrPointer to address
Returns
execution_status
uint32_t GetRxFrameSize ( void  )
static
Returns
number of bytes in received frame
int32_t GetRxFrameTime ( ARM_ETH_MAC_TIME *  time)
static
Parameters
[in]timePointer to time structure for data to read into
Returns
execution_status
int32_t GetTxFrameTime ( ARM_ETH_MAC_TIME *  time)
static
Parameters
[in]timePointer to time structure for data to read into
Returns
execution_status
ARM_DRIVER_VERSION GetVersion ( void  )
static
Returns
ARM_DRIVER_VERSION
void HAL_ETH_PMTCallback ( ETH_HandleTypeDef *  heth)
void HAL_ETH_RxCpltCallback ( ETH_HandleTypeDef *  heth)
void HAL_ETH_TxCpltCallback ( ETH_HandleTypeDef *  heth)
int32_t Initialize ( ARM_ETH_MAC_SignalEvent_t  cb_event)
static
Parameters
[in]cb_eventPointer to ARM_ETH_MAC_SignalEvent
Returns
execution_status
int32_t PHY_Read ( uint8_t  phy_addr,
uint8_t  reg_addr,
uint16_t *  data 
)
static
Parameters
[in]phy_addr5-bit device address
[in]reg_addr5-bit register address
[out]dataPointer where the result is written to
Returns
execution_status
int32_t PHY_Write ( uint8_t  phy_addr,
uint8_t  reg_addr,
uint16_t  data 
)
static
Parameters
[in]phy_addr5-bit device address
[in]reg_addr5-bit register address
[in]data16-bit data to write
Returns
execution_status
int32_t PowerControl ( ARM_POWER_STATE  state)
static
Parameters
[in]statePower state
Returns
execution_status
int32_t ReadFrame ( uint8_t *  frame,
uint32_t  len 
)
static
Parameters
[in]framePointer to frame buffer for data to read into
[in]lenFrame buffer length in bytes
Returns
number of data bytes read or execution status
  • value >= 0: number of data bytes read
  • value < 0: error occurred, value is execution status as defined with execution_status
int32_t SendFrame ( const uint8_t *  frame,
uint32_t  len,
uint32_t  flags 
)
static
Parameters
[in]framePointer to frame buffer with data to send
[in]lenFrame buffer length in bytes
[in]flagsFrame transmit flags (see ARM_ETH_MAC_TX_FRAME_...)
Returns
execution_status
int32_t SetAddressFilter ( const ARM_ETH_MAC_ADDR *  ptr_addr,
uint32_t  num_addr 
)
static
Parameters
[in]ptr_addrPointer to addresses
[in]num_addrNumber of addresses to configure
Returns
execution_status
int32_t SetMacAddress ( const ARM_ETH_MAC_ADDR *  ptr_addr)
static
Parameters
[in]ptr_addrPointer to address
Returns
execution_status
int32_t Uninitialize ( void  )
static
Returns
execution_status

Variable Documentation

ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]
ARM_DRIVER_ETH_MAC Driver_ETH_MAC0
Initial value:
= {
}
static int32_t PHY_Write(uint8_t phy_addr, uint8_t reg_addr, uint16_t data)
Write Ethernet PHY Register through Management Interface.
Definition: EMAC_STM32H7xx.c:824
static ARM_ETH_MAC_CAPABILITIES GetCapabilities(void)
Get driver capabilities.
Definition: EMAC_STM32H7xx.c:253
static int32_t SetMacAddress(const ARM_ETH_MAC_ADDR *ptr_addr)
Set Ethernet MAC Address.
Definition: EMAC_STM32H7xx.c:391
static int32_t GetMacAddress(ARM_ETH_MAC_ADDR *ptr_addr)
Get Ethernet MAC Address.
Definition: EMAC_STM32H7xx.c:362
static int32_t Control(uint32_t control, uint32_t arg)
Control Ethernet Interface.
Definition: EMAC_STM32H7xx.c:629
static int32_t PHY_Read(uint8_t phy_addr, uint8_t reg_addr, uint16_t *data)
Read Ethernet PHY Register through Management Interface.
Definition: EMAC_STM32H7xx.c:804
static int32_t GetTxFrameTime(ARM_ETH_MAC_TIME *time)
Get time of transmitted Ethernet frame.
Definition: EMAC_STM32H7xx.c:604
static int32_t Uninitialize(void)
De-initialize Ethernet MAC Device.
Definition: EMAC_STM32H7xx.c:294
static ARM_DRIVER_VERSION GetVersion(void)
Get driver version.
Definition: EMAC_STM32H7xx.c:243
static int32_t PowerControl(ARM_POWER_STATE state)
Control Ethernet MAC Device Power.
Definition: EMAC_STM32H7xx.c:308
static int32_t Initialize(ARM_ETH_MAC_SignalEvent_t cb_event)
Initialize Ethernet MAC Device.
Definition: EMAC_STM32H7xx.c:264
static int32_t GetRxFrameTime(ARM_ETH_MAC_TIME *time)
Get time of received Ethernet frame.
Definition: EMAC_STM32H7xx.c:593
static int32_t SendFrame(const uint8_t *frame, uint32_t len, uint32_t flags)
Send Ethernet frame.
Definition: EMAC_STM32H7xx.c:493
static uint32_t GetRxFrameSize(void)
Get size of received Ethernet frame.
Definition: EMAC_STM32H7xx.c:574
static int32_t SetAddressFilter(const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t num_addr)
Configure Address Filter.
Definition: EMAC_STM32H7xx.c:417
static int32_t ReadFrame(uint8_t *frame, uint32_t len)
Read data of received Ethernet frame.
Definition: EMAC_STM32H7xx.c:546
static int32_t ControlTimer(uint32_t control, ARM_ETH_MAC_TIME *time)
Control Precision Timer.
Definition: EMAC_STM32H7xx.c:616
const ARM_ETH_MAC_CAPABILITIES DriverCapabilities
static
Initial value:
= {
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(EMAC_CHECKSUM_OFFLOAD != 0) ? 1U : 0U,
(ETH_MII != 0) ?
ARM_ETH_INTERFACE_MII :
ARM_ETH_INTERFACE_RMII,
0U,
1U,
1U,
1U,
0U
}
#define EMAC_CHECKSUM_OFFLOAD
Definition: EMAC_STM32H7xx.c:139
const ARM_DRIVER_VERSION DriverVersion
static
Initial value:
= {
ARM_ETH_MAC_API_VERSION,
}
#define ARM_ETH_MAC_DRV_VERSION
Definition: EMAC_STM32H7xx.c:150
EMAC_CTRL Emac
static
ETH_HandleTypeDef heth
ETH_MACConfigTypeDef MAC_Config
static
ETH_MACFilterConfigTypeDef MAC_Filter
static
uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_MAX_PACKET_SIZE]
ETH_TxPacketConfig TX_Config
static