![]() |
|
|||
File indexing completed on 2025-05-11 08:23:10
0001 /** 0002 ****************************************************************************** 0003 * @file stm32h7xx_ll_swpmi.c 0004 * @author MCD Application Team 0005 * @brief SWPMI LL module driver. 0006 ****************************************************************************** 0007 * @attention 0008 * 0009 * Copyright (c) 2017 STMicroelectronics. 0010 * All rights reserved. 0011 * 0012 * This software is licensed under terms that can be found in the LICENSE file 0013 * in the root directory of this software component. 0014 * If no LICENSE file comes with this software, it is provided AS-IS. 0015 * 0016 ****************************************************************************** 0017 */ 0018 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__) 0019 0020 /* Includes ------------------------------------------------------------------*/ 0021 #include "stm32h7xx_ll_swpmi.h" 0022 #include "stm32h7xx_ll_bus.h" 0023 #ifdef USE_FULL_ASSERT 0024 #include "stm32_assert.h" 0025 #else 0026 #define assert_param(expr) ((void)0U) 0027 #endif 0028 0029 /** @addtogroup STM32H7xx_LL_Driver 0030 * @{ 0031 */ 0032 0033 0034 /** @addtogroup SWPMI_LL 0035 * @{ 0036 */ 0037 0038 /* Private types -------------------------------------------------------------*/ 0039 /* Private variables ---------------------------------------------------------*/ 0040 /* Private constants ---------------------------------------------------------*/ 0041 /* Private macros ------------------------------------------------------------*/ 0042 /** @addtogroup SWPMI_LL_Private_Macros 0043 * @{ 0044 */ 0045 0046 #define IS_LL_SWPMI_BITRATE_VALUE(__VALUE__) (((__VALUE__) <= 255U)) 0047 0048 #define IS_LL_SWPMI_SW_BUFFER_RX(__VALUE__) (((__VALUE__) == LL_SWPMI_SW_BUFFER_RX_SINGLE) \ 0049 || ((__VALUE__) == LL_SWPMI_SW_BUFFER_RX_MULTI)) 0050 0051 #define IS_LL_SWPMI_SW_BUFFER_TX(__VALUE__) (((__VALUE__) == LL_SWPMI_SW_BUFFER_TX_SINGLE) \ 0052 || ((__VALUE__) == LL_SWPMI_SW_BUFFER_TX_MULTI)) 0053 0054 #define IS_LL_SWPMI_VOLTAGE_CLASS(__VALUE__) (((__VALUE__) == LL_SWPMI_VOLTAGE_CLASS_C) \ 0055 || ((__VALUE__) == LL_SWPMI_VOLTAGE_CLASS_B)) 0056 0057 /** 0058 * @} 0059 */ 0060 0061 /* Private function prototypes -----------------------------------------------*/ 0062 0063 /* Exported functions --------------------------------------------------------*/ 0064 /** @addtogroup SWPMI_LL_Exported_Functions 0065 * @{ 0066 */ 0067 0068 /** @addtogroup SWPMI_LL_EF_Init 0069 * @{ 0070 */ 0071 0072 /** 0073 * @brief De-initialize the SWPMI peripheral registers to their default reset values. 0074 * @param SWPMIx SWPMI Instance 0075 * @retval An ErrorStatus enumeration value 0076 * - SUCCESS: SWPMI registers are de-initialized 0077 * - ERROR: Not applicable 0078 */ 0079 ErrorStatus LL_SWPMI_DeInit(SWPMI_TypeDef *SWPMIx) 0080 { 0081 ErrorStatus status = SUCCESS; 0082 0083 /* Check the parameter */ 0084 assert_param(IS_SWPMI_INSTANCE(SWPMIx)); 0085 0086 if (SWPMIx == SWPMI1) 0087 { 0088 LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_SWPMI1); 0089 LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_SWPMI1); 0090 } 0091 else 0092 { 0093 status = ERROR; 0094 } 0095 0096 return status; 0097 } 0098 0099 /** 0100 * @brief Initialize the SWPMI peripheral according to the specified parameters in the SWPMI_InitStruct. 0101 * @note As some bits in SWPMI configuration registers can only be written when the SWPMI is deactivated 0102 * (SWPMI_CR_SWPACT bit = 0), the SWPMI peripheral should be in deactivated state prior calling 0103 * this function. Otherwise, ERROR result will be returned. 0104 * @param SWPMIx SWPMI Instance 0105 * @param SWPMI_InitStruct pointer to a @ref LL_SWPMI_InitTypeDef structure that contains 0106 * the configuration information for the SWPMI peripheral. 0107 * @retval An ErrorStatus enumeration value 0108 * - SUCCESS: SWPMI registers are initialized 0109 * - ERROR: SWPMI registers are not initialized 0110 */ 0111 ErrorStatus LL_SWPMI_Init(SWPMI_TypeDef *SWPMIx, LL_SWPMI_InitTypeDef *SWPMI_InitStruct) 0112 { 0113 ErrorStatus status = SUCCESS; 0114 0115 /* Check the parameters */ 0116 assert_param(IS_SWPMI_INSTANCE(SWPMIx)); 0117 assert_param(IS_LL_SWPMI_BITRATE_VALUE(SWPMI_InitStruct->BitRatePrescaler)); 0118 assert_param(IS_LL_SWPMI_SW_BUFFER_TX(SWPMI_InitStruct->TxBufferingMode)); 0119 assert_param(IS_LL_SWPMI_SW_BUFFER_RX(SWPMI_InitStruct->RxBufferingMode)); 0120 assert_param(IS_LL_SWPMI_VOLTAGE_CLASS(SWPMI_InitStruct->VoltageClass)); 0121 0122 /* SWPMI needs to be in deactivated state, in order to be able to configure some bits */ 0123 if (LL_SWPMI_IsActivated(SWPMIx) == 0U) 0124 { 0125 /* Configure the BRR register (Bitrate) */ 0126 LL_SWPMI_SetBitRatePrescaler(SWPMIx, SWPMI_InitStruct->BitRatePrescaler); 0127 0128 /* Configure the voltage class */ 0129 LL_SWPMI_SetVoltageClass(SWPMIx, SWPMI_InitStruct->VoltageClass); 0130 0131 /* Set the new configuration of the SWPMI peripheral */ 0132 MODIFY_REG(SWPMIx->CR, 0133 (SWPMI_CR_RXMODE | SWPMI_CR_TXMODE), 0134 (SWPMI_InitStruct->TxBufferingMode | SWPMI_InitStruct->RxBufferingMode)); 0135 } 0136 /* Else (SWPMI not in deactivated state => return ERROR) */ 0137 else 0138 { 0139 status = ERROR; 0140 } 0141 0142 return status; 0143 } 0144 0145 /** 0146 * @brief Set each @ref LL_SWPMI_InitTypeDef field to default value. 0147 * @param SWPMI_InitStruct pointer to a @ref LL_SWPMI_InitTypeDef structure that contains 0148 * the configuration information for the SWPMI peripheral. 0149 * @retval None 0150 */ 0151 void LL_SWPMI_StructInit(LL_SWPMI_InitTypeDef *SWPMI_InitStruct) 0152 { 0153 /* Set SWPMI_InitStruct fields to default values */ 0154 SWPMI_InitStruct->VoltageClass = LL_SWPMI_VOLTAGE_CLASS_C; 0155 SWPMI_InitStruct->BitRatePrescaler = (uint32_t)0x00000001; 0156 SWPMI_InitStruct->TxBufferingMode = LL_SWPMI_SW_BUFFER_TX_SINGLE; 0157 SWPMI_InitStruct->RxBufferingMode = LL_SWPMI_SW_BUFFER_RX_SINGLE; 0158 } 0159 0160 /** 0161 * @} 0162 */ 0163 0164 /** 0165 * @} 0166 */ 0167 0168 /** 0169 * @} 0170 */ 0171 0172 0173 /** 0174 * @} 0175 */ 0176 0177 #endif /* USE_FULL_LL_DRIVER */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |