STM32L443xx HAL User Manual
|
SWPMI HAL module driver. This file provides firmware functions to manage the following functionalities of the Single Wire Protocol Master Interface (SWPMI). + Initialization and Configuration + Data transfers functions + DMA transfers management + Interrupts and flags management. More...
#include "stm32l4xx_hal.h"
Go to the source code of this file.
Defines | |
#define | SWPMI_TIMEOUT_VALUE 22000U /* End of transmission timeout */ |
Functions | |
static void | SWPMI_DMATransmitCplt (DMA_HandleTypeDef *hdma) |
DMA SWPMI transmit process complete callback. | |
static void | SWPMI_DMATxHalfCplt (DMA_HandleTypeDef *hdma) |
DMA SWPMI transmit process half complete callback. | |
static void | SWPMI_DMAReceiveCplt (DMA_HandleTypeDef *hdma) |
DMA SWPMI receive process complete callback. | |
static void | SWPMI_DMARxHalfCplt (DMA_HandleTypeDef *hdma) |
DMA SWPMI receive process half complete callback. | |
static void | SWPMI_DMAError (DMA_HandleTypeDef *hdma) |
DMA SWPMI communication error callback. | |
static void | SWPMI_DMAAbortOnError (DMA_HandleTypeDef *hdma) |
DMA SWPMI communication abort callback. | |
static void | SWPMI_Transmit_IT (SWPMI_HandleTypeDef *hswpmi) |
Transmit an amount of data in interrupt mode. | |
static void | SWPMI_EndTransmit_IT (SWPMI_HandleTypeDef *hswpmi) |
Wraps up transmission in non-blocking mode. | |
static void | SWPMI_Receive_IT (SWPMI_HandleTypeDef *hswpmi) |
Receive an amount of data in interrupt mode. | |
static void | SWPMI_EndReceive_IT (SWPMI_HandleTypeDef *hswpmi) |
Wraps up reception in non-blocking mode. | |
static void | SWPMI_EndTransmitReceive_IT (SWPMI_HandleTypeDef *hswpmi) |
Wraps up transmission and reception in non-blocking mode. | |
static HAL_StatusTypeDef | SWPMI_WaitOnFlagSetUntilTimeout (SWPMI_HandleTypeDef *hswpmi, uint32_t Flag, uint32_t Tickstart, uint32_t Timeout) |
Handle SWPMI Communication Timeout. | |
HAL_StatusTypeDef | HAL_SWPMI_Init (SWPMI_HandleTypeDef *hswpmi) |
Initialize the SWPMI peripheral according to the specified parameters in the SWPMI_InitTypeDef. | |
HAL_StatusTypeDef | HAL_SWPMI_DeInit (SWPMI_HandleTypeDef *hswpmi) |
De-initialize the SWPMI peripheral. | |
__weak void | HAL_SWPMI_MspInit (SWPMI_HandleTypeDef *hswpmi) |
Initialize the SWPMI MSP. | |
__weak void | HAL_SWPMI_MspDeInit (SWPMI_HandleTypeDef *hswpmi) |
DeInitialize the SWPMI MSP. | |
HAL_StatusTypeDef | HAL_SWPMI_RegisterCallback (SWPMI_HandleTypeDef *hswpmi, HAL_SWPMI_CallbackIDTypeDef CallbackID, pSWPMI_CallbackTypeDef pCallback) |
Register a user SWPMI callback to be used instead of the weak predefined callback. | |
HAL_StatusTypeDef | HAL_SWPMI_UnRegisterCallback (SWPMI_HandleTypeDef *hswpmi, HAL_SWPMI_CallbackIDTypeDef CallbackID) |
Unregister a user SWPMI callback. | |
HAL_StatusTypeDef | HAL_SWPMI_Transmit (SWPMI_HandleTypeDef *hswpmi, uint32_t *pData, uint16_t Size, uint32_t Timeout) |
Transmit an amount of data in blocking mode. | |
HAL_StatusTypeDef | HAL_SWPMI_Receive (SWPMI_HandleTypeDef *hswpmi, uint32_t *pData, uint16_t Size, uint32_t Timeout) |
Receive an amount of data in blocking mode. | |
HAL_StatusTypeDef | HAL_SWPMI_Transmit_IT (SWPMI_HandleTypeDef *hswpmi, uint32_t *pData, uint16_t Size) |
Transmit an amount of data in non-blocking mode with interrupt. | |
HAL_StatusTypeDef | HAL_SWPMI_Receive_IT (SWPMI_HandleTypeDef *hswpmi, uint32_t *pData, uint16_t Size) |
Receive an amount of data in non-blocking mode with interrupt. | |
HAL_StatusTypeDef | HAL_SWPMI_Transmit_DMA (SWPMI_HandleTypeDef *hswpmi, uint32_t *pData, uint16_t Size) |
Transmit an amount of data in non-blocking mode with DMA interrupt. | |
HAL_StatusTypeDef | HAL_SWPMI_Receive_DMA (SWPMI_HandleTypeDef *hswpmi, uint32_t *pData, uint16_t Size) |
Receive an amount of data in non-blocking mode with DMA interrupt. | |
HAL_StatusTypeDef | HAL_SWPMI_DMAStop (SWPMI_HandleTypeDef *hswpmi) |
Stop all DMA transfers. | |
HAL_StatusTypeDef | HAL_SWPMI_EnableLoopback (SWPMI_HandleTypeDef *hswpmi) |
Enable the Loopback mode. | |
HAL_StatusTypeDef | HAL_SWPMI_DisableLoopback (SWPMI_HandleTypeDef *hswpmi) |
Disable the Loopback mode. | |
void | HAL_SWPMI_IRQHandler (SWPMI_HandleTypeDef *hswpmi) |
Handle SWPMI interrupt request. | |
__weak void | HAL_SWPMI_TxCpltCallback (SWPMI_HandleTypeDef *hswpmi) |
Tx Transfer completed callback. | |
__weak void | HAL_SWPMI_TxHalfCpltCallback (SWPMI_HandleTypeDef *hswpmi) |
Tx Half Transfer completed callback. | |
__weak void | HAL_SWPMI_RxCpltCallback (SWPMI_HandleTypeDef *hswpmi) |
Rx Transfer completed callback. | |
__weak void | HAL_SWPMI_RxHalfCpltCallback (SWPMI_HandleTypeDef *hswpmi) |
Rx Half Transfer completed callback. | |
__weak void | HAL_SWPMI_ErrorCallback (SWPMI_HandleTypeDef *hswpmi) |
SWPMI error callback. | |
HAL_SWPMI_StateTypeDef | HAL_SWPMI_GetState (SWPMI_HandleTypeDef *hswpmi) |
Return the SWPMI handle state. | |
uint32_t | HAL_SWPMI_GetError (SWPMI_HandleTypeDef *hswpmi) |
Return the SWPMI error code. |
SWPMI HAL module driver. This file provides firmware functions to manage the following functionalities of the Single Wire Protocol Master Interface (SWPMI). + Initialization and Configuration + Data transfers functions + DMA transfers management + Interrupts and flags management.
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 SWPMI HAL driver can be used as follows: (#) Declare a SWPMI_HandleTypeDef handle structure (eg. SWPMI_HandleTypeDef hswpmi). (#) Initialize the SWPMI low level resources by implementing the HAL_SWPMI_MspInit() API: (##) Enable the SWPMIx interface clock with __HAL_RCC_SWPMIx_CLK_ENABLE(). (##) SWPMI IO configuration: (+++) Enable the clock for the SWPMI GPIO. (+++) Configure these SWPMI pins as alternate function pull-up. (##) NVIC configuration if you need to use interrupt process (HAL_SWPMI_Transmit_IT() and HAL_SWPMI_Receive_IT() APIs): (+++) Configure the SWPMIx interrupt priority with HAL_NVIC_SetPriority(). (+++) Enable the NVIC SWPMI IRQ handle with HAL_NVIC_EnableIRQ(). (##) DMA Configuration if you need to use DMA process (HAL_SWPMI_Transmit_DMA() and HAL_SWPMI_Receive_DMA() APIs): (+++) Declare a DMA handle structure for the Tx/Rx channels. (+++) Enable the DMAx interface clock. (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters. (+++) Configure the DMA Tx/Rx channels and requests. (+++) Associate the initialized DMA handle to the SWPMI DMA Tx/Rx handle. (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx channels. (#) Program the Bite Rate, Tx Buffering mode, Rx Buffering mode in the Init structure. (#) Enable the SWPMI peripheral by calling the HAL_SWPMI_Init() function. [..] Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= [..] (+) Send an amount of data in blocking mode using HAL_SWPMI_Transmit() (+) Receive an amount of data in blocking mode using HAL_SWPMI_Receive() *** Interrupt mode IO operation *** =================================== [..] (+) Send an amount of data in non-blocking mode using HAL_SWPMI_Transmit_IT() (+) At transmission end of transfer HAL_SWPMI_TxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SWPMI_TxCpltCallback() (+) Receive an amount of data in non-blocking mode using HAL_SWPMI_Receive_IT() (+) At reception end of transfer HAL_SWPMI_RxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SWPMI_RxCpltCallback() (+) In case of flag error, HAL_SWPMI_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SWPMI_ErrorCallback() *** DMA mode IO operation *** ============================= [..] (+) Send an amount of data in non-blocking mode (DMA) using HAL_SWPMI_Transmit_DMA() (+) At transmission end of transfer HAL_SWPMI_TxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SWPMI_TxCpltCallback() (+) Receive an amount of data in non-blocking mode (DMA) using HAL_SWPMI_Receive_DMA() (+) At reception end of transfer HAL_SWPMI_RxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SWPMI_RxCpltCallback() (+) In case of flag error, HAL_SWPMI_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SWPMI_ErrorCallback() (+) Stop the DMA Transfer using HAL_SWPMI_DMAStop() *** SWPMI HAL driver additional function list *** =============================================== [..] Below the list the others API available SWPMI HAL driver : (+) HAL_SWPMI_EnableLoopback(): Enable the loopback mode for test purpose only (+) HAL_SWPMI_DisableLoopback(): Disable the loopback mode *** SWPMI HAL driver macros list *** ================================== [..] Below the list of most used macros in SWPMI HAL driver : (+) __HAL_SWPMI_ENABLE(): Enable the SWPMI peripheral (+) __HAL_SWPMI_DISABLE(): Disable the SWPMI peripheral (+) __HAL_SWPMI_ENABLE_IT(): Enable the specified SWPMI interrupts (+) __HAL_SWPMI_DISABLE_IT(): Disable the specified SWPMI interrupts (+) __HAL_SWPMI_GET_IT_SOURCE(): Check if the specified SWPMI interrupt source is enabled or disabled (+) __HAL_SWPMI_GET_FLAG(): Check whether the specified SWPMI flag is set or not *** Callback registration *** ============================= [..] The compilation define USE_HAL_SWPMI_REGISTER_CALLBACKS when set to 1 allows the user to configure dynamically the driver callbacks. [..] Use function HAL_SWPMI_RegisterCallback() to register a user callback. It allows to register the following callbacks: (+) RxCpltCallback : SWPMI receive complete. (+) RxHalfCpltCallback : SWPMI receive half complete. (+) TxCpltCallback : SWPMI transmit complete. (+) TxHalfCpltCallback : SWPMI transmit half complete. (+) ErrorCallback : SWPMI error. (+) MspInitCallback : SWPMI MspInit. (+) MspDeInitCallback : SWPMI MspDeInit. [..] This function takes as parameters the HAL peripheral handle, the callback ID and a pointer to the user callback function. [..] Use function HAL_SWPMI_UnRegisterCallback() to reset a callback to the default weak (surcharged) function. HAL_SWPMI_UnRegisterCallback() takes as parameters the HAL peripheral handle, and the callback ID. This function allows to reset following callbacks: (+) RxCpltCallback : SWPMI receive complete. (+) RxHalfCpltCallback : SWPMI receive half complete. (+) TxCpltCallback : SWPMI transmit complete. (+) TxHalfCpltCallback : SWPMI transmit half complete. (+) ErrorCallback : SWPMI error. (+) MspInitCallback : SWPMI MspInit. (+) MspDeInitCallback : SWPMI MspDeInit. [..] By default, after the HAL_SWPMI_Init and if the state is HAL_SWPMI_STATE_RESET all callbacks are reset to the corresponding legacy weak (surcharged) functions: examples HAL_SWPMI_RxCpltCallback(), HAL_SWPMI_ErrorCallback(). Exception done for MspInit and MspDeInit callbacks that are respectively reset to the legacy weak (surcharged) functions in the HAL_SWPMI_Init and HAL_SWPMI_DeInit only when these callbacks are null (not registered beforehand). If not, MspInit or MspDeInit are not null, the HAL_SWPMI_Init and HAL_SWPMI_DeInit keep and use the user MspInit/MspDeInit callbacks (registered beforehand). [..] Callbacks can be registered/unregistered in READY state only. Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered in READY or 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_SWPMI_RegisterCallback before calling HAL_SWPMI_DeInit or HAL_SWPMI_Init function. [..] When the compilation define USE_HAL_SWPMI_REGISTER_CALLBACKS is set to 0 or not defined, the callback registering feature is not available and weak (surcharged) callbacks are used.
Definition in file stm32l4xx_hal_swpmi.c.