RTEMS 6.1-rc7
Loading...
Searching...
No Matches
stm32h7xx_hal_cordic.c File Reference

CORDIC HAL module driver. This file provides firmware functions to manage the following functionalities of the CORDIC peripheral: More...

#include "stm32h7xx_hal.h"

Detailed Description

CORDIC HAL module driver. This file provides firmware functions to manage the following functionalities of the CORDIC peripheral:

Author
MCD Application Team
  • Initialization and de-initialization functions
  • Peripheral Control functions
  • Callback functions
  • IRQ handler management
  • Peripheral State functions
Attention

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

================================================================================
          ##### How to use this driver #####
================================================================================
  [..]
    The CORDIC HAL driver can be used as follows:

    (#) Initialize the CORDIC low level resources by implementing the HAL_CORDIC_MspInit():
       (++) Enable the CORDIC interface clock using __HAL_RCC_CORDIC_CLK_ENABLE()
       (++) In case of using interrupts (e.g. HAL_CORDIC_Calculate_IT())
           (+++) Configure the CORDIC interrupt priority using HAL_NVIC_SetPriority()
           (+++) Enable the CORDIC IRQ handler using HAL_NVIC_EnableIRQ()
           (+++) In CORDIC IRQ handler, call HAL_CORDIC_IRQHandler()
       (++) In case of using DMA to control data transfer (e.g. HAL_CORDIC_Calculate_DMA())
           (+++) Enable the DMA2 interface clock using
               __HAL_RCC_DMA2_CLK_ENABLE()
           (+++) Configure and enable two DMA channels one for managing data transfer from
               memory to peripheral (input channel) and another channel for managing data
               transfer from peripheral to memory (output channel)
           (+++) Associate the initialized DMA handle to the CORDIC DMA handle
               using __HAL_LINKDMA()
           (+++) Configure the priority and enable the NVIC for the transfer complete
               interrupt on the two DMA channels.
               Resort to HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ()

    (#) Initialize the CORDIC HAL using HAL_CORDIC_Init(). This function
       (++) resorts to HAL_CORDIC_MspInit() for low-level initialization,

    (#) Configure CORDIC processing (calculation) using HAL_CORDIC_Configure().
        This function configures:
       (++) Processing functions: Cosine, Sine, Phase, Modulus, Arctangent,
            Hyperbolic cosine, Hyperbolic sine, Hyperbolic arctangent,
            Natural log, Square root
       (++) Scaling factor: 1 to 2exp(-7)
       (++) Width of input data: 32 bits input data size (Q1.31 format) or 16 bits
            input data size (Q1.15 format)
       (++) Width of output data: 32 bits output data size (Q1.31 format) or 16 bits
            output data size (Q1.15 format)
       (++) Number of 32-bit write expected for one calculation: One 32-bits write
            or Two 32-bit write
       (++) Number of 32-bit read expected after one calculation: One 32-bits read
            or Two 32-bit read
       (++) Precision: 1 to 15 cycles for calculation (the more cycles, the better precision)

    (#) Four processing (calculation) functions are available:
       (++) Polling mode: processing API is blocking function
            i.e. it processes the data and wait till the processing is finished
            API is HAL_CORDIC_Calculate
       (++) Polling Zero-overhead mode: processing API is blocking function
            i.e. it processes the data and wait till the processing is finished
            A bit faster than standard polling mode, but blocking also AHB bus
            API is HAL_CORDIC_CalculateZO
       (++) Interrupt mode: processing API is not blocking functions
            i.e. it processes the data under interrupt
            API is HAL_CORDIC_Calculate_IT
       (++) DMA mode: processing API is not blocking functions and the CPU is
            not used for data transfer,
            i.e. the data transfer is ensured by DMA
            API is HAL_CORDIC_Calculate_DMA

    (#) Call HAL_CORDIC_DeInit() to de-initialize the CORDIC peripheral. This function
       (++) resorts to HAL_CORDIC_MspDeInit() for low-level de-initialization,

*** Callback registration ***
=============================================

The compilation define  USE_HAL_CORDIC_REGISTER_CALLBACKS when set to 1
allows the user to configure dynamically the driver callbacks.
Use Function HAL_CORDIC_RegisterCallback() to register an interrupt callback.

Function HAL_CORDIC_RegisterCallback() allows to register following callbacks:
  (+) ErrorCallback             : Error Callback.
  (+) CalculateCpltCallback     : Calculate complete Callback.
  (+) MspInitCallback           : CORDIC MspInit.
  (+) MspDeInitCallback         : CORDIC MspDeInit.
This function takes as parameters the HAL peripheral handle, the Callback ID
and a pointer to the user callback function.

Use function HAL_CORDIC_UnRegisterCallback() to reset a callback to the default
weak function.
HAL_CORDIC_UnRegisterCallback takes as parameters the HAL peripheral handle,
and the Callback ID.
This function allows to reset following callbacks:
  (+) ErrorCallback             : Error Callback.
  (+) CalculateCpltCallback     : Calculate complete Callback.
  (+) MspInitCallback           : CORDIC MspInit.
  (+) MspDeInitCallback         : CORDIC MspDeInit.

By default, after the HAL_CORDIC_Init() and when the state is HAL_CORDIC_STATE_RESET,
all callbacks are set to the corresponding weak functions:
examples HAL_CORDIC_ErrorCallback(), HAL_CORDIC_CalculateCpltCallback().
Exception done for MspInit and MspDeInit functions that are
reset to the legacy weak function in the HAL_CORDIC_Init()/ HAL_CORDIC_DeInit() only when
these callbacks are null (not registered beforehand).
if not, MspInit or MspDeInit are not null, the HAL_CORDIC_Init()/ HAL_CORDIC_DeInit()
keep and use the user MspInit/MspDeInit callbacks (registered beforehand)

Callbacks can be registered/unregistered in HAL_CORDIC_STATE_READY state only.
Exception done MspInit/MspDeInit that can be registered/unregistered
in HAL_CORDIC_STATE_READY or HAL_CORDIC_STATE_RESET state,
thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
In that case first register the MspInit/MspDeInit user callbacks
using HAL_CORDIC_RegisterCallback() before calling HAL_CORDIC_DeInit()
or HAL_CORDIC_Init() function.

When The compilation define USE_HAL_CORDIC_REGISTER_CALLBACKS is set to 0 or
not defined, the callback registration feature is not available and all callbacks
are set to the corresponding weak functions.