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

UM1725

HAL SPDIFRX Generic Driver

DMA_HandleTypeDef * hdmaDrRx

__IO HAL_LockTypeDef Lock

__IO HAL_SPDIFRX_StateTypeDef State

__IO uint32_t ErrorCode

Field Documentation

SPDIFRX_TypeDef* SPDIFRX_HandleTypeDef::Instance

SPDIFRX_InitTypeDef SPDIFRX_HandleTypeDef::Init

uint32_t* SPDIFRX_HandleTypeDef::pRxBuffPtr

uint32_t* SPDIFRX_HandleTypeDef::pCsBuffPtr

__IO uint16_t SPDIFRX_HandleTypeDef::RxXferSize

__IO uint16_t SPDIFRX_HandleTypeDef::RxXferCount

__IO uint16_t SPDIFRX_HandleTypeDef::CsXferSize

__IO uint16_t SPDIFRX_HandleTypeDef::CsXferCount

DMA_HandleTypeDef* SPDIFRX_HandleTypeDef::hdmaCsRx

DMA_HandleTypeDef* SPDIFRX_HandleTypeDef::hdmaDrRx

__IO HAL_LockTypeDef SPDIFRX_HandleTypeDef::Lock

__IO HAL_SPDIFRX_StateTypeDef SPDIFRX_HandleTypeDef::State

__IO uint32_t SPDIFRX_HandleTypeDef::ErrorCode

55.2SPDIFRX Firmware driver API description

55.2.1How to use this driver

The SPDIFRX HAL driver can be used as follow:

1.Declare SPDIFRX_HandleTypeDef handle structure.

2.Initialize the SPDIFRX low level resources by implement the HAL_SPDIFRX_MspInit() API:

a.Enable the SPDIFRX interface clock.

b.SPDIFRX pins configuration:

Enable the clock for the SPDIFRX GPIOs.

Configure these SPDIFRX pins as alternate function pull-up.

c.NVIC configuration if you need to use interrupt process (HAL_SPDIFRX_ReceiveControlFlow_IT() and HAL_SPDIFRX_ReceiveDataFlow_IT() API's).

Configure the SPDIFRX interrupt priority.

Enable the NVIC SPDIFRX IRQ handle.

d.DMA Configuration if you need to use DMA process (HAL_SPDIFRX_ReceiveDataFlow_DMA() and HAL_SPDIFRX_ReceiveControlFlow_DMA() API's).

Declare a DMA handle structure for the reception of the Data Flow channel.

Declare a DMA handle structure for the reception of the Control Flow channel.

Enable the DMAx interface clock.

Configure the declared DMA handle structure CtrlRx/DataRx with the required parameters.

Configure the DMA Channel.

Associate the initialized DMA handle to the SPDIFRX DMA CtrlRx/DataRx handle.

DOCID025834 Rev 2

743/900

HAL SPDIFRX Generic Driver

UM1725

Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA CtrlRx/DataRx channel.

3.Program the input selection, re-tries number, wait for activity, channel status selection, data format, stereo mode and masking of user bits using HAL_SPDIFRX_Init() function. The specific SPDIFRX interrupts (RXNE/CSRNE and Error Interrupts) will be managed using the macros __SPDIFRX_ENABLE_IT() and __SPDIFRX_DISABLE_IT() inside the receive process. Make sure that ck_spdif clock is configured.

4.Three operation modes are available within this driver :

Polling mode for reception operation (for debug purpose)

Receive data flow in blocking mode using HAL_SPDIFRX_ReceiveDataFlow()

Receive control flow of data in blocking mode using

HAL_SPDIFRX_ReceiveControlFlow()

Interrupt mode for reception operation

Receive an amount of data (Data Flow) in non blocking mode using HAL_SPDIFRX_ReceiveDataFlow_IT()

Receive an amount of data (Control Flow) in non blocking mode using HAL_SPDIFRX_ReceiveControlFlow_IT()

At reception end of half transfer HAL_SPDIFRX_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_SPDIFRX_RxHalfCpltCallback

At reception end of transfer HAL_SPDIFRX_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_SPDIFRX_RxCpltCallback

In case of transfer Error, HAL_SPDIFRX_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SPDIFRX_ErrorCallback

DMA mode for reception operation

Receive an amount of data (Data Flow) in non blocking mode (DMA) using HAL_SPDIFRX_ReceiveDataFlow_DMA()

Receive an amount of data (Control Flow) in non blocking mode (DMA) using HAL_SPDIFRX_ReceiveControlFlow_DMA()

At reception end of half transfer HAL_SPDIFRX_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_SPDIFRX_RxHalfCpltCallback

At reception end of transfer HAL_SPDIFRX_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_SPDIFRX_RxCpltCallback

In case of transfer Error, HAL_SPDIFRX_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SPDIFRX_ErrorCallback

Stop the DMA Transfer using HAL_SPDIFRX_DMAStop()

SPDIFRX HAL driver macros list

Below the list of most used macros in USART HAL driver.

__HAL_SPDIFRX_IDLE: Disable the specified SPDIFRX peripheral (IDEL State)

744/900

DOCID025834 Rev 2

UM1725

HAL SPDIFRX Generic Driver

__HAL_SPDIFRX_SYNC: Enable the synchronization state of the specified SPDIFRX peripheral (SYNC State)

__HAL_SPDIFRX_RCV: Enable the receive state of the specified SPDIFRX peripheral (RCV State)

__HAL_SPDIFRX_ENABLE_IT : Enable the specified SPDIFRX interrupts

__HAL_SPDIFRX_DISABLE_IT : Disable the specified SPDIFRX interrupts

__HAL_SPDIFRX_GET_FLAG: Check whether the specified SPDIFRX flag is set or not.

You can refer to the SPDIFRX HAL driver header file for more useful macros

55.2.2Initialization and de-initialization functions

This subsection provides a set of functions allowing to initialize and de-initialize the SPDIFRX peripheral:

User must Implement HAL_SPDIFRX_MspInit() function in which he configures all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ).

Call the function HAL_SPDIFRX_Init() to configure the SPDIFRX peripheral with the selected configuration:

Input Selection (IN0, IN1,...)

Maximum allowed re-tries during synchronization phase

Wait for activity on SPDIF selected input

Channel status selection (from channel A or B)

Data format (LSB, MSB, ...)

Stereo mode

User bits masking (PT,C,U,V,...)

Call the function HAL_SPDIFRX_DeInit() to restore the default configuration of the selected SPDIFRXx peripheral.

This section contains the following APIs:

HAL_SPDIFRX_Init()

HAL_SPDIFRX_DeInit()

HAL_SPDIFRX_MspInit()

HAL_SPDIFRX_MspDeInit()

HAL_SPDIFRX_SetDataFormat()

55.2.3IO operation functions

This subsection provides a set of functions allowing to manage the SPDIFRX data transfers.

1.There is two mode of transfer:

Blocking mode : The communication is performed in the polling mode. The status of all data processing is returned by the same function after finishing transfer.

No-Blocking mode : The communication is performed using Interrupts or DMA. These functions return the status of the transfer start-up. The end of the data processing will be indicated through the dedicated SPDIFRX IRQ when using Interrupt mode or the DMA IRQ when using DMA mode.

2.Blocking mode functions are :

HAL_SPDIFRX_ReceiveDataFlow()

DOCID025834 Rev 2

745/900

HAL SPDIFRX Generic Driver

UM1725

HAL_SPDIFRX_ReceiveControlFlow() (+@) Do not use blocking mode to receive both control and data flow at the same time.

3.No-Blocking mode functions with Interrupt are :

HAL_SPDIFRX_ReceiveControlFlow_IT()

HAL_SPDIFRX_ReceiveDataFlow_IT()

4.No-Blocking mode functions with DMA are :

HAL_SPDIFRX_ReceiveControlFlow_DMA()

HAL_SPDIFRX_ReceiveDataFlow_DMA()

5.A set of Transfer Complete Callbacks are provided in No_Blocking mode:

HAL_SPDIFRX_RxCpltCallback()

HAL_SPDIFRX_ErrorCallback()

This section contains the following APIs:

HAL_SPDIFRX_ReceiveDataFlow()

HAL_SPDIFRX_ReceiveControlFlow()

HAL_SPDIFRX_ReceiveDataFlow_IT()

HAL_SPDIFRX_ReceiveControlFlow_IT()

HAL_SPDIFRX_ReceiveDataFlow_DMA()

HAL_SPDIFRX_ReceiveControlFlow_DMA()

HAL_SPDIFRX_DMAStop()

HAL_SPDIFRX_IRQHandler()

HAL_SPDIFRX_RxHalfCpltCallback()

HAL_SPDIFRX_RxCpltCallback()

HAL_SPDIFRX_CxHalfCpltCallback()

HAL_SPDIFRX_CxCpltCallback()

HAL_SPDIFRX_ErrorCallback()

55.2.4Peripheral State and Errors functions

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

This section contains the following APIs:

HAL_SPDIFRX_GetState()

HAL_SPDIFRX_GetError()

55.2.5HAL_SPDIFRX_Init

Function Name

HAL_StatusTypeDef HAL_SPDIFRX_Init

 

(SPDIFRX_HandleTypeDef * hspdif)

Function Description

Initializes the SPDIFRX according to the specified parameters in

 

the SPDIFRX_InitTypeDef and create the associated handle.

Parameters

 

hspdif: SPDIFRX handle

Return values

 

HAL status

55.2.6HAL_SPDIFRX_DeInit

Function Name

HAL_StatusTypeDef HAL_SPDIFRX_DeInit

 

(SPDIFRX_HandleTypeDef * hspdif)

Function Description

DeInitializes the SPDIFRX peripheral.

Parameters

 

hspdif: SPDIFRX handle

Return values

 

HAL status

746/900

 

DOCID025834 Rev 2

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