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

UM1725

HAL ADC Extension Driver

5.1.2ADC_MultiModeTypeDef

Data Fields

uint32_t Mode

uint32_t DMAAccessMode

uint32_t TwoSamplingDelay

Field Documentation

uint32_t ADC_MultiModeTypeDef::Mode

Configures the ADC to operate in independent or multi mode. This parameter can be

a value of ADCEx_Common_mode

uint32_t ADC_MultiModeTypeDef::DMAAccessMode

Configures the Direct memory access mode for multi ADC mode. This parameter can be a value of ADCEx_Direct_memory_access_mode_for_multi_mode

uint32_t ADC_MultiModeTypeDef::TwoSamplingDelay

Configures the Delay between 2 sampling phases. This parameter can be a value of

ADC_delay_between_2_sampling_phases

5.2ADCEx Firmware driver API description

5.2.1How to use this driver

1.Initialize the ADC low level resources by implementing the HAL_ADC_MspInit():

a.Enable the ADC interface clock using __HAL_RCC_ADC_CLK_ENABLE()

b.ADC pins configuration

Enable the clock for the ADC GPIOs using the following function: __HAL_RCC_GPIOx_CLK_ENABLE()

Configure these ADC pins in analog mode using HAL_GPIO_Init()

c.In case of using interrupts (e.g. HAL_ADC_Start_IT())

Configure the ADC interrupt priority using HAL_NVIC_SetPriority()

Enable the ADC IRQ handler using HAL_NVIC_EnableIRQ()

In ADC IRQ handler, call HAL_ADC_IRQHandler()

d.In case of using DMA to control data transfer (e.g. HAL_ADC_Start_DMA())

Enable the DMAx interface clock using

__HAL_RCC_DMAx_CLK_ENABLE()

Configure and enable two DMA streams stream for managing data transfer from peripheral to memory (output stream)

Associate the initialized DMA handle to the ADC DMA handle using

__HAL_LINKDMA()

Configure the priority and enable the NVIC for the transfer complete interrupt on the two DMA Streams. The output stream should have higher priority than the input stream.

2.Configure the ADC Prescaler, conversion resolution and data alignment using the HAL_ADC_Init() function.

3.Configure the ADC Injected channels group features, use HAL_ADC_Init() and HAL_ADC_ConfigChannel() functions.

DOCID025834 Rev 2

121/900

HAL ADC Extension Driver

UM1725

4. Three operation modes are available within this driver :

 

Polling mode IO operation

Start the ADC peripheral using HAL_ADCEx_InjectedStart()

Wait for end of conversion using HAL_ADC_PollForConversion(), at this stage user can specify the value of timeout according to his end application

To read the ADC converted values, use the HAL_ADCEx_InjectedGetValue() function.

Stop the ADC peripheral using HAL_ADCEx_InjectedStop()

Interrupt mode IO operation

Start the ADC peripheral using HAL_ADCEx_InjectedStart_IT()

Use HAL_ADC_IRQHandler() called under ADC_IRQHandler() Interrupt subroutine

At ADC end of conversion HAL_ADCEx_InjectedConvCpltCallback() function is executed and user can add his own code by customization of function pointer HAL_ADCEx_InjectedConvCpltCallback

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

Stop the ADC peripheral using HAL_ADCEx_InjectedStop_IT()

DMA mode IO operation

Start the ADC peripheral using HAL_ADCEx_InjectedStart_DMA(), at this stage the user specify the length of data to be transferred at each end of conversion

At The end of data transfer ba HAL_ADCEx_InjectedConvCpltCallback() function is executed and user can add his own code by customization of function pointer HAL_ADCEx_InjectedConvCpltCallback

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

Stop the ADC peripheral using HAL_ADCEx_InjectedStop_DMA()

Multi mode ADCs Regular channels configuration

Select the Multi mode ADC regular channels features (dual or triple mode) and configure the DMA mode using HAL_ADCEx_MultiModeConfigChannel() functions.

Start the ADC peripheral using HAL_ADCEx_MultiModeStart_DMA(), at this stage the user specify the length of data to be transferred at each end of conversion

Read the ADCs converted values using the HAL_ADCEx_MultiModeGetValue() function.

5.2.2Extended features functions

This section provides functions allowing to:

Start conversion of injected channel.

Stop conversion of injected channel.

Start multimode and enable DMA transfer.

122/900

DOCID025834 Rev 2

UM1725

HAL ADC Extension Driver

 

Stop multimode and disable DMA transfer.

 

Get result of injected channel conversion.

 

Get result of multimode conversion.

 

Configure injected channels.

 

Configure multimode.

This section contains the following APIs:

HAL_ADCEx_InjectedStart()

HAL_ADCEx_InjectedStart_IT()

HAL_ADCEx_InjectedStop()

HAL_ADCEx_InjectedPollForConversion()

HAL_ADCEx_InjectedStop_IT()

HAL_ADCEx_InjectedGetValue()

HAL_ADCEx_MultiModeStart_DMA()

HAL_ADCEx_MultiModeStop_DMA()

HAL_ADCEx_MultiModeGetValue()

HAL_ADCEx_InjectedConvCpltCallback()

HAL_ADCEx_InjectedConfigChannel()

HAL_ADCEx_MultiModeConfigChannel()

5.2.3HAL_ADCEx_InjectedStart

Function Name

HAL_StatusTypeDef HAL_ADCEx_InjectedStart

 

(ADC_HandleTypeDef * hadc)

Function Description

Enables the selected ADC software start conversion of the injected

 

channels.

Parameters

 

hadc: pointer to a ADC_HandleTypeDef structure that

 

 

contains the configuration information for the specified ADC.

Return values

 

HAL status

5.2.4HAL_ADCEx_InjectedStart_IT

Function Name

HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT

 

(ADC_HandleTypeDef * hadc)

Function Description

Enables the interrupt and starts ADC conversion of injected

 

channels.

Parameters

 

hadc: pointer to a ADC_HandleTypeDef structure that

 

 

contains the configuration information for the specified ADC.

Return values

 

HAL status.

5.2.5HAL_ADCEx_InjectedStop

Function Name

HAL_StatusTypeDef HAL_ADCEx_InjectedStop

 

 

(ADC_HandleTypeDef * hadc)

 

Function Description

Disables ADC and stop conversion of injected channels.

 

Parameters

 

hadc: pointer to a ADC_HandleTypeDef structure that

 

 

contains the configuration information for the specified ADC.

Return values

 

HAL status.

 

Notes

Caution: This function will stop also regular channels.

 

 

 

DOCID025834 Rev 2

123/900

HAL ADC Extension Driver

UM1725

5.2.6HAL_ADCEx_InjectedPollForConversion

Function Name

HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion

 

(ADC_HandleTypeDef * hadc, uint32_t Timeout)

Function Description

Poll for injected conversion complete.

Parameters

 

hadc: pointer to a ADC_HandleTypeDef structure that

 

 

contains the configuration information for the specified ADC.

 

 

Timeout: Timeout value in millisecond.

Return values

 

HAL status

5.2.7HAL_ADCEx_InjectedStop_IT

Function Name

HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT

 

(ADC_HandleTypeDef * hadc)

Function Description

Disables the interrupt and stop ADC conversion of injected

 

channels.

Parameters

 

hadc: pointer to a ADC_HandleTypeDef structure that

 

 

contains the configuration information for the specified ADC.

Return values

 

HAL status.

Notes

 

Caution: This function will stop also regular channels.

5.2.8HAL_ADCEx_InjectedGetValue

Function Name

uint32_t HAL_ADCEx_InjectedGetValue (ADC_HandleTypeDef

 

* hadc, uint32_t InjectedRank)

Function Description

Gets the converted value from data register of injected channel.

Parameters

 

hadc: pointer to a ADC_HandleTypeDef structure that

 

 

contains the configuration information for the specified ADC.

 

InjectedRank: the ADC injected rank. This parameter can be

 

 

one of the following values: ADC_INJECTED_RANK_1:

 

 

Injected Channel1 selectedADC_INJECTED_RANK_2:

 

 

Injected Channel2 selectedADC_INJECTED_RANK_3:

 

 

Injected Channel3 selectedADC_INJECTED_RANK_4:

 

 

Injected Channel4 selected

Return values

 

None

5.2.9HAL_ADCEx_MultiModeStart_DMA

Function Name

HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA

 

(ADC_HandleTypeDef * hadc, uint32_t * pData, uint32_t

 

Length)

Function Description

Enables ADC DMA request after last transfer (Multi-ADC mode)

 

and enables ADC peripheral.

Parameters

hadc: pointer to a ADC_HandleTypeDef structure that

 

contains the configuration information for the specified ADC.

 

pData: Pointer to buffer in which transferred from ADC

 

peripheral to memory will be stored.

 

Length: The length of data to be transferred from ADC

124/900

DOCID025834 Rev 2

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