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

HAL HCD Generic Driver

UM1725

29 HAL HCD Generic Driver

29.1HCD Firmware driver registers structures

29.1.1HCD_HandleTypeDef

Data Fields

HCD_TypeDef * Instance

HCD_InitTypeDef Init

HCD_HCTypeDef hc

HAL_LockTypeDef Lock

__IO HCD_StateTypeDef State

void * pData

Field Documentation

HCD_TypeDef* HCD_HandleTypeDef::Instance

Register base address

HCD_InitTypeDef HCD_HandleTypeDef::Init

HCD required parameters

HCD_HCTypeDef HCD_HandleTypeDef::hc[15]

Host channels parameters

HAL_LockTypeDef HCD_HandleTypeDef::Lock

HCD peripheral status

__IO HCD_StateTypeDef HCD_HandleTypeDef::State

HCD communication state

void* HCD_HandleTypeDef::pData

Pointer Stack Handler

29.2HCD Firmware driver API description

29.2.1How to use this driver

1.Declare a HCD_HandleTypeDef handle structure, for example: HCD_HandleTypeDef hhcd;

2.Fill parameters of Init structure in HCD handle

3.Call HAL_HCD_Init() API to initialize the HCD peripheral (Core, Host core, ...)

4.Initialize the HCD low level resources through the HAL_HCD_MspInit() API:

a.Enable the HCD/USB Low Level interface clock using the following macros

__OTGFS-OTG_CLK_ENABLE() or __OTGHS-OTG_CLK_ENABLE()

__OTGHSULPI_CLK_ENABLE() For High Speed Mode

b.Initialize the related GPIO clocks

c.Configure HCD pin-out

d.Configure HCD NVIC interrupt

5.Associate the Upper USB Host stack to the HAL HCD Driver:

a.hhcd.pData = phost;

6.Enable HCD transmission and reception:

388/900

DOCID025834 Rev 2

UM1725

HAL HCD Generic Driver

a.HAL_HCD_Start();

29.2.2Initialization and de-initialization functions

This section provides functions allowing to:

This section contains the following APIs:

HAL_HCD_Init()

HAL_HCD_HC_Init()

HAL_HCD_HC_Halt()

HAL_HCD_DeInit()

HAL_HCD_MspInit()

HAL_HCD_MspDeInit()

29.2.3IO operation functions

This section contains the following APIs:

HAL_HCD_HC_SubmitRequest()

HAL_HCD_IRQHandler()

HAL_HCD_SOF_Callback()

HAL_HCD_Connect_Callback()

HAL_HCD_Disconnect_Callback()

HAL_HCD_HC_NotifyURBChange_Callback()

29.2.4Peripheral Control functions

This subsection provides a set of functions allowing to control the HCD data transfers. This section contains the following APIs:

HAL_HCD_Start()

HAL_HCD_Stop()

HAL_HCD_ResetPort()

29.2.5Peripheral State functions

This subsection permits to get in run-time the status of the peripheral and the data flow. This section contains the following APIs:

HAL_HCD_GetState()

HAL_HCD_HC_GetURBState()

HAL_HCD_HC_GetXferCount()

HAL_HCD_HC_GetState()

HAL_HCD_GetCurrentFrame()

HAL_HCD_GetCurrentSpeed()

29.2.6HAL_HCD_Init

Function Name

HAL_StatusTypeDef HAL_HCD_Init (HCD_HandleTypeDef *

 

hhcd)

Function Description

Initialize the host driver.

Parameters

 

hhcd: HCD handle

Return values

 

HAL status

DOCID025834 Rev 2

389/900

HAL HCD Generic Driver

UM1725

29.2.7HAL_HCD_HC_Init

Function Name

HAL_StatusTypeDef HAL_HCD_HC_Init (HCD_HandleTypeDef

 

* hhcd, uint8_t ch_num, uint8_t epnum, uint8_t dev_address,

 

uint8_t speed, uint8_t ep_type, uint16_t mps)

Function Description

Initialize a host channel.

Parameters

 

hhcd: HCD handle

 

ch_num: Channel number. This parameter can be a value

 

 

from 1 to 15

 

epnum: Endpoint number. This parameter can be a value

 

 

from 1 to 15

 

dev_address: : Current device address This parameter can

 

 

be a value from 0 to 255

 

speed: Current device speed. This parameter can be one of

 

 

these values: HCD_SPEED_HIGH: High speed mode,

 

 

HCD_SPEED_FULL: Full speed mode, HCD_SPEED_LOW:

 

 

Low speed mode

 

ep_type: Endpoint Type. This parameter can be one of these

 

 

values: EP_TYPE_CTRL: Control type, EP_TYPE_ISOC:

 

 

Isochronous type, EP_TYPE_BULK: Bulk type,

 

 

EP_TYPE_INTR: Interrupt type

 

mps: Max Packet Size. This parameter can be a value from

 

 

0 to32K

Return values

 

HAL status

29.2.8HAL_HCD_HC_Halt

Function Name

HAL_StatusTypeDef HAL_HCD_HC_Halt

 

(HCD_HandleTypeDef * hhcd, uint8_t ch_num)

Function Description

Halt a host channel.

Parameters

 

hhcd: HCD handle

 

ch_num: Channel number. This parameter can be a value

 

 

from 1 to 15

Return values

 

HAL status

29.2.9HAL_HCD_DeInit

Function Name

HAL_StatusTypeDef HAL_HCD_DeInit (HCD_HandleTypeDef *

 

hhcd)

Function Description

DeInitialize the host driver.

Parameters

 

hhcd: HCD handle

Return values

 

HAL status

29.2.10HAL_HCD_MspInit

Function Name

void HAL_HCD_MspInit (HCD_HandleTypeDef * hhcd)

Function Description

Initializes the HCD MSP.

Parameters

hhcd: HCD handle

390/900

DOCID025834 Rev 2

UM1725

HAL HCD Generic Driver

Return values

None

29.2.11HAL_HCD_MspDeInit

Function Name

void HAL_HCD_MspDeInit (HCD_HandleTypeDef * hhcd)

Function Description

DeInitializes HCD MSP.

Parameters

 

hhcd: HCD handle

Return values

 

None

29.2.12HAL_HCD_HC_SubmitRequest

Function Name

HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest

 

(HCD_HandleTypeDef * hhcd, uint8_t ch_num, uint8_t

 

direction, uint8_t ep_type, uint8_t token, uint8_t * pbuff,

 

uint16_t length, uint8_t do_ping)

Function Description

Submit a new URB for processing.

Parameters

 

hhcd: HCD handle

 

ch_num: Channel number. This parameter can be a value

 

 

from 1 to 15

 

direction: Channel number. This parameter can be one of

 

 

these values: 0 : Output / 1 : Input

 

ep_type: Endpoint Type. This parameter can be one of these

 

 

values: EP_TYPE_CTRL: Control type/ EP_TYPE_ISOC:

 

 

Isochronous type/ EP_TYPE_BULK: Bulk type/

 

 

EP_TYPE_INTR: Interrupt type/

 

token: Endpoint Type. This parameter can be one of these

 

 

values: 0: HC_PID_SETUP / 1: HC_PID_DATA1

 

pbuff: pointer to URB data

 

length: Length of URB data

 

do_ping: activate do ping protocol (for high speed only). This

 

 

parameter can be one of these values: 0 : do ping inactive / 1

 

 

: do ping active

Return values

 

HAL status

29.2.13HAL_HCD_IRQHandler

Function Name

void HAL_HCD_IRQHandler (HCD_HandleTypeDef * hhcd)

Function Description

This function handles HCD interrupt request.

Parameters

 

hhcd: HCD handle

Return values

 

None

29.2.14HAL_HCD_SOF_Callback

Function Name

void HAL_HCD_SOF_Callback (HCD_HandleTypeDef * hhcd)

Function Description

SOF callback.

 

Parameters

 

hhcd: HCD handle

 

Return values

 

None

 

 

 

DOCID025834 Rev 2

391/900

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