Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
cubexHal.pdf
Скачиваний:
110
Добавлен:
10.02.2016
Размер:
16.16 Mб
Скачать

HAL ETH Generic Driver

UM1725

19.1.6ETH_HandleTypeDef

Data Fields

ETH_TypeDef * Instance

ETH_InitTypeDef Init

uint32_t LinkStatus

ETH_DMADescTypeDef * RxDesc

ETH_DMADescTypeDef * TxDesc

ETH_DMARxFrameInfos RxFrameInfos

__IO HAL_ETH_StateTypeDef State

HAL_LockTypeDef Lock

Field Documentation

ETH_TypeDef* ETH_HandleTypeDef::Instance

Register base address

ETH_InitTypeDef ETH_HandleTypeDef::Init

Ethernet Init Configuration

uint32_t ETH_HandleTypeDef::LinkStatus

Ethernet link status

ETH_DMADescTypeDef* ETH_HandleTypeDef::RxDesc

Rx descriptor to Get

ETH_DMADescTypeDef* ETH_HandleTypeDef::TxDesc

Tx descriptor to Set

ETH_DMARxFrameInfos ETH_HandleTypeDef::RxFrameInfos last Rx frame infos

__IO HAL_ETH_StateTypeDef ETH_HandleTypeDef::State

ETH communication state

HAL_LockTypeDef ETH_HandleTypeDef::Lock

ETH Lock

19.2ETH Firmware driver API description

19.2.1How to use this driver

1.Declare a ETH_HandleTypeDef handle structure, for example: ETH_HandleTypeDef heth;

2.Fill parameters of Init structure in heth handle

3.Call HAL_ETH_Init() API to initialize the Ethernet peripheral (MAC, DMA, ...)

4.Initialize the ETH low level resources through the HAL_ETH_MspInit() API:

a.Enable the Ethernet interface clock using

__HAL_RCC_ETHMAC_CLK_ENABLE();

__HAL_RCC_ETHMACTX_CLK_ENABLE();

__HAL_RCC_ETHMACRX_CLK_ENABLE();

b.Initialize the related GPIO clocks

c.Configure Ethernet pin-out

d.Configure Ethernet NVIC interrupt (IT mode)

5.Initialize Ethernet DMA Descriptors in chain mode and point to allocated buffers:

a.HAL_ETH_DMATxDescListInit(); for Transmission process

270/900

DOCID025834 Rev 2

UM1725

HAL ETH Generic Driver

b.HAL_ETH_DMARxDescListInit(); for Reception process

6.Enable MAC and DMA transmission and reception:

a.HAL_ETH_Start();

7.Prepare ETH DMA TX Descriptors and give the hand to ETH DMA to transfer the frame to MAC TX FIFO:

a.HAL_ETH_TransmitFrame();

8.Poll for a received frame in ETH RX DMA Descriptors and get received frame parameters

a.HAL_ETH_GetReceivedFrame(); (should be called into an infinite loop)

9.Get a received frame when an ETH RX interrupt occurs:

a.HAL_ETH_GetReceivedFrame_IT(); (called in IT mode only)

10.Communicate with external PHY device:

a.Read a specific register from the PHY HAL_ETH_ReadPHYRegister();

b.Write data to a specific RHY register: HAL_ETH_WritePHYRegister();

11.Configure the Ethernet MAC after ETH peripheral initialization

HAL_ETH_ConfigMAC(); all MAC parameters should be filled.

12.Configure the Ethernet DMA after ETH peripheral initialization

HAL_ETH_ConfigDMA(); all DMA parameters should be filled. The PTP protocol and the DMA descriptors ring mode are not supported in this driver

19.2.2Initialization and de-initialization functions

This section provides functions allowing to:

Initialize and configure the Ethernet peripheral

De-initialize the Ethernet peripheral

This section contains the following APIs:

HAL_ETH_Init()

HAL_ETH_DeInit()

HAL_ETH_DMATxDescListInit()

HAL_ETH_DMARxDescListInit()

HAL_ETH_MspInit()

HAL_ETH_MspDeInit()

19.2.3IO operation functions

This section provides functions allowing to:

Transmit a frame HAL_ETH_TransmitFrame();

Receive a frame HAL_ETH_GetReceivedFrame(); HAL_ETH_GetReceivedFrame_IT();

Read from an External PHY register HAL_ETH_ReadPHYRegister();

Write to an External PHY register HAL_ETH_WritePHYRegister();

This section contains the following APIs:

HAL_ETH_TransmitFrame()

HAL_ETH_GetReceivedFrame()

HAL_ETH_GetReceivedFrame_IT()

HAL_ETH_IRQHandler()

HAL_ETH_TxCpltCallback()

HAL_ETH_RxCpltCallback()

HAL_ETH_ErrorCallback()

HAL_ETH_ReadPHYRegister()

HAL_ETH_WritePHYRegister()

DOCID025834 Rev 2

271/900

HAL ETH Generic Driver

UM1725

19.2.4Peripheral Control functions

This section provides functions allowing to:

Enable MAC and DMA transmission and reception. HAL_ETH_Start();

Disable MAC and DMA transmission and reception. HAL_ETH_Stop();

Set the MAC configuration in runtime mode HAL_ETH_ConfigMAC();

Set the DMA configuration in runtime mode HAL_ETH_ConfigDMA(); This section contains the following APIs:

HAL_ETH_Start()

HAL_ETH_Stop()

HAL_ETH_ConfigMAC()

HAL_ETH_ConfigDMA()

19.2.5Peripheral State functions

This subsection permits to get in run-time the status of the peripheral and the data flow.

Get the ETH handle state: HAL_ETH_GetState(); This section contains the following APIs:

HAL_ETH_GetState()

19.2.6HAL_ETH_Init

Function Name

HAL_StatusTypeDef HAL_ETH_Init (ETH_HandleTypeDef *

 

heth)

Function Description

Initializes the Ethernet MAC and DMA according to default

 

parameters.

Parameters

 

heth: pointer to a ETH_HandleTypeDef structure that

 

 

contains the configuration information for ETHERNET module

Return values

 

HAL status

19.2.7HAL_ETH_DeInit

Function Name

HAL_StatusTypeDef HAL_ETH_DeInit (ETH_HandleTypeDef *

 

heth)

Function Description

De-Initializes the ETH peripheral.

Parameters

 

heth: pointer to a ETH_HandleTypeDef structure that

 

 

contains the configuration information for ETHERNET module

Return values

 

HAL status

19.2.8HAL_ETH_DMATxDescListInit

Function Name

HAL_StatusTypeDef HAL_ETH_DMATxDescListInit

 

(ETH_HandleTypeDef * heth, ETH_DMADescTypeDef *

 

DMATxDescTab, uint8_t * TxBuff, uint32_t TxBuffCount)

Function Description

Initializes the DMA Tx descriptors in chain mode.

Parameters

heth: pointer to a ETH_HandleTypeDef structure that

 

contains the configuration information for ETHERNET module

 

DMATxDescTab: Pointer to the first Tx desc list

272/900

DOCID025834 Rev 2

UM1725

 

HAL ETH Generic Driver

 

TxBuff: Pointer to the first TxBuffer list

 

 

TxBuffCount: Number of the used Tx desc in the list

Return values

 

HAL status

19.2.9HAL_ETH_DMARxDescListInit

Function Name

HAL_StatusTypeDef HAL_ETH_DMARxDescListInit

 

(ETH_HandleTypeDef * heth, ETH_DMADescTypeDef *

 

DMARxDescTab, uint8_t * RxBuff, uint32_t RxBuffCount)

Function Description

Initializes the DMA Rx descriptors in chain mode.

Parameters

 

heth: pointer to a ETH_HandleTypeDef structure that

 

 

contains the configuration information for ETHERNET module

 

DMARxDescTab: Pointer to the first Rx desc list

 

RxBuff: Pointer to the first RxBuffer list

 

RxBuffCount: Number of the used Rx desc in the list

Return values

 

HAL status

19.2.10HAL_ETH_MspInit

Function Name

void HAL_ETH_MspInit (ETH_HandleTypeDef * heth)

Function Description

Initializes the ETH MSP.

Parameters

 

heth: pointer to a ETH_HandleTypeDef structure that

 

 

contains the configuration information for ETHERNET module

Return values

 

None

19.2.11HAL_ETH_MspDeInit

Function Name

void HAL_ETH_MspDeInit (ETH_HandleTypeDef * heth)

Function Description

DeInitializes ETH MSP.

Parameters

 

heth: pointer to a ETH_HandleTypeDef structure that

 

 

contains the configuration information for ETHERNET module

Return values

 

None

19.2.12HAL_ETH_TransmitFrame

Function Name

HAL_StatusTypeDef HAL_ETH_TransmitFrame

 

(ETH_HandleTypeDef * heth, uint32_t FrameLength)

Function Description

Sends an Ethernet frame.

Parameters

 

heth: pointer to a ETH_HandleTypeDef structure that

 

 

contains the configuration information for ETHERNET module

 

FrameLength: Amount of data to be sent

Return values

 

HAL status

19.2.13HAL_ETH_GetReceivedFrame

Function Name

HAL_StatusTypeDef HAL_ETH_GetReceivedFrame

 

 

(ETH_HandleTypeDef * heth)

 

 

DOCID025834 Rev 2

273/900

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]