Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
HAL_L476/stm32l4xx_ll_swpmi.c@1:d0dfbce63a89, 2017-02-24 (annotated)
- Committer:
- elmot
- Date:
- Fri Feb 24 21:13:56 2017 +0000
- Revision:
- 1:d0dfbce63a89
Ready-to-copy
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| elmot | 1:d0dfbce63a89 | 1 | /** |
| elmot | 1:d0dfbce63a89 | 2 | ****************************************************************************** |
| elmot | 1:d0dfbce63a89 | 3 | * @file stm32l4xx_ll_swpmi.c |
| elmot | 1:d0dfbce63a89 | 4 | * @author MCD Application Team |
| elmot | 1:d0dfbce63a89 | 5 | * @version V1.5.1 |
| elmot | 1:d0dfbce63a89 | 6 | * @date 31-May-2016 |
| elmot | 1:d0dfbce63a89 | 7 | * @brief SWPMI LL module driver. |
| elmot | 1:d0dfbce63a89 | 8 | ****************************************************************************** |
| elmot | 1:d0dfbce63a89 | 9 | * @attention |
| elmot | 1:d0dfbce63a89 | 10 | * |
| elmot | 1:d0dfbce63a89 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
| elmot | 1:d0dfbce63a89 | 12 | * |
| elmot | 1:d0dfbce63a89 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
| elmot | 1:d0dfbce63a89 | 14 | * are permitted provided that the following conditions are met: |
| elmot | 1:d0dfbce63a89 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
| elmot | 1:d0dfbce63a89 | 16 | * this list of conditions and the following disclaimer. |
| elmot | 1:d0dfbce63a89 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| elmot | 1:d0dfbce63a89 | 18 | * this list of conditions and the following disclaimer in the documentation |
| elmot | 1:d0dfbce63a89 | 19 | * and/or other materials provided with the distribution. |
| elmot | 1:d0dfbce63a89 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| elmot | 1:d0dfbce63a89 | 21 | * may be used to endorse or promote products derived from this software |
| elmot | 1:d0dfbce63a89 | 22 | * without specific prior written permission. |
| elmot | 1:d0dfbce63a89 | 23 | * |
| elmot | 1:d0dfbce63a89 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| elmot | 1:d0dfbce63a89 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| elmot | 1:d0dfbce63a89 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| elmot | 1:d0dfbce63a89 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| elmot | 1:d0dfbce63a89 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| elmot | 1:d0dfbce63a89 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| elmot | 1:d0dfbce63a89 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| elmot | 1:d0dfbce63a89 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| elmot | 1:d0dfbce63a89 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| elmot | 1:d0dfbce63a89 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| elmot | 1:d0dfbce63a89 | 34 | * |
| elmot | 1:d0dfbce63a89 | 35 | ****************************************************************************** |
| elmot | 1:d0dfbce63a89 | 36 | */ |
| elmot | 1:d0dfbce63a89 | 37 | #if defined(USE_FULL_LL_DRIVER) |
| elmot | 1:d0dfbce63a89 | 38 | |
| elmot | 1:d0dfbce63a89 | 39 | /* Includes ------------------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 40 | #include "stm32l4xx_ll_swpmi.h" |
| elmot | 1:d0dfbce63a89 | 41 | #include "stm32l4xx_ll_bus.h" |
| elmot | 1:d0dfbce63a89 | 42 | #ifdef USE_FULL_ASSERT |
| elmot | 1:d0dfbce63a89 | 43 | #include "stm32_assert.h" |
| elmot | 1:d0dfbce63a89 | 44 | #else |
| elmot | 1:d0dfbce63a89 | 45 | #define assert_param(expr) ((void)0U) |
| elmot | 1:d0dfbce63a89 | 46 | #endif |
| elmot | 1:d0dfbce63a89 | 47 | |
| elmot | 1:d0dfbce63a89 | 48 | /** @addtogroup STM32L4xx_LL_Driver |
| elmot | 1:d0dfbce63a89 | 49 | * @{ |
| elmot | 1:d0dfbce63a89 | 50 | */ |
| elmot | 1:d0dfbce63a89 | 51 | |
| elmot | 1:d0dfbce63a89 | 52 | #if defined (SWPMI1) |
| elmot | 1:d0dfbce63a89 | 53 | |
| elmot | 1:d0dfbce63a89 | 54 | /** @addtogroup SWPMI_LL |
| elmot | 1:d0dfbce63a89 | 55 | * @{ |
| elmot | 1:d0dfbce63a89 | 56 | */ |
| elmot | 1:d0dfbce63a89 | 57 | |
| elmot | 1:d0dfbce63a89 | 58 | /* Private types -------------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 59 | /* Private variables ---------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 60 | /* Private constants ---------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 61 | /* Private macros ------------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 62 | /** @addtogroup SWPMI_LL_Private_Macros |
| elmot | 1:d0dfbce63a89 | 63 | * @{ |
| elmot | 1:d0dfbce63a89 | 64 | */ |
| elmot | 1:d0dfbce63a89 | 65 | |
| elmot | 1:d0dfbce63a89 | 66 | #define IS_LL_SWPMI_BITRATE_VALUE(__VALUE__) (((__VALUE__) <= 63)) |
| elmot | 1:d0dfbce63a89 | 67 | |
| elmot | 1:d0dfbce63a89 | 68 | #define IS_LL_SWPMI_SW_BUFFER_RX(__VALUE__) (((__VALUE__) == LL_SWPMI_SW_BUFFER_RX_SINGLE) \ |
| elmot | 1:d0dfbce63a89 | 69 | || ((__VALUE__) == LL_SWPMI_SW_BUFFER_RX_MULTI)) |
| elmot | 1:d0dfbce63a89 | 70 | |
| elmot | 1:d0dfbce63a89 | 71 | #define IS_LL_SWPMI_SW_BUFFER_TX(__VALUE__) (((__VALUE__) == LL_SWPMI_SW_BUFFER_TX_SINGLE) \ |
| elmot | 1:d0dfbce63a89 | 72 | || ((__VALUE__) == LL_SWPMI_SW_BUFFER_TX_MULTI)) |
| elmot | 1:d0dfbce63a89 | 73 | |
| elmot | 1:d0dfbce63a89 | 74 | #define IS_LL_SWPMI_VOLTAGE_CLASS(__VALUE__) (((__VALUE__) == LL_SWPMI_VOLTAGE_CLASS_C) \ |
| elmot | 1:d0dfbce63a89 | 75 | || ((__VALUE__) == LL_SWPMI_VOLTAGE_CLASS_B)) |
| elmot | 1:d0dfbce63a89 | 76 | |
| elmot | 1:d0dfbce63a89 | 77 | /** |
| elmot | 1:d0dfbce63a89 | 78 | * @} |
| elmot | 1:d0dfbce63a89 | 79 | */ |
| elmot | 1:d0dfbce63a89 | 80 | |
| elmot | 1:d0dfbce63a89 | 81 | /* Private function prototypes -----------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 82 | |
| elmot | 1:d0dfbce63a89 | 83 | /* Exported functions --------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 84 | /** @addtogroup SWPMI_LL_Exported_Functions |
| elmot | 1:d0dfbce63a89 | 85 | * @{ |
| elmot | 1:d0dfbce63a89 | 86 | */ |
| elmot | 1:d0dfbce63a89 | 87 | |
| elmot | 1:d0dfbce63a89 | 88 | /** @addtogroup SWPMI_LL_EF_Init |
| elmot | 1:d0dfbce63a89 | 89 | * @{ |
| elmot | 1:d0dfbce63a89 | 90 | */ |
| elmot | 1:d0dfbce63a89 | 91 | |
| elmot | 1:d0dfbce63a89 | 92 | /** |
| elmot | 1:d0dfbce63a89 | 93 | * @brief De-initialize the SWPMI peripheral registers to their default reset values. |
| elmot | 1:d0dfbce63a89 | 94 | * @param SWPMIx SWPMI Instance |
| elmot | 1:d0dfbce63a89 | 95 | * @retval An ErrorStatus enumeration value |
| elmot | 1:d0dfbce63a89 | 96 | * - SUCCESS: SWPMI registers are de-initialized |
| elmot | 1:d0dfbce63a89 | 97 | * - ERROR: Not applicable |
| elmot | 1:d0dfbce63a89 | 98 | */ |
| elmot | 1:d0dfbce63a89 | 99 | ErrorStatus LL_SWPMI_DeInit(SWPMI_TypeDef *SWPMIx) |
| elmot | 1:d0dfbce63a89 | 100 | { |
| elmot | 1:d0dfbce63a89 | 101 | /* Check the parameter */ |
| elmot | 1:d0dfbce63a89 | 102 | assert_param(IS_SWPMI_INSTANCE(SWPMIx)); |
| elmot | 1:d0dfbce63a89 | 103 | |
| elmot | 1:d0dfbce63a89 | 104 | LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_SWPMI1); |
| elmot | 1:d0dfbce63a89 | 105 | LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_SWPMI1); |
| elmot | 1:d0dfbce63a89 | 106 | |
| elmot | 1:d0dfbce63a89 | 107 | return SUCCESS; |
| elmot | 1:d0dfbce63a89 | 108 | } |
| elmot | 1:d0dfbce63a89 | 109 | |
| elmot | 1:d0dfbce63a89 | 110 | /** |
| elmot | 1:d0dfbce63a89 | 111 | * @brief Initialize the SWPMI peripheral according to the specified parameters in the SWPMI_InitStruct. |
| elmot | 1:d0dfbce63a89 | 112 | * @note As some bits in SWPMI configuration registers can only be written when the SWPMI is deactivated (SWPMI_CR_SWPACT bit = 0), |
| elmot | 1:d0dfbce63a89 | 113 | * SWPMI IP should be in deactivated state prior calling this function. Otherwise, ERROR result will be returned. |
| elmot | 1:d0dfbce63a89 | 114 | * @param SWPMIx SWPMI Instance |
| elmot | 1:d0dfbce63a89 | 115 | * @param SWPMI_InitStruct pointer to a @ref LL_SWPMI_InitTypeDef structure that contains |
| elmot | 1:d0dfbce63a89 | 116 | * the configuration information for the SWPMI peripheral. |
| elmot | 1:d0dfbce63a89 | 117 | * @retval An ErrorStatus enumeration value |
| elmot | 1:d0dfbce63a89 | 118 | * - SUCCESS: SWPMI registers are initialized |
| elmot | 1:d0dfbce63a89 | 119 | * - ERROR: SWPMI registers are not initialized |
| elmot | 1:d0dfbce63a89 | 120 | */ |
| elmot | 1:d0dfbce63a89 | 121 | ErrorStatus LL_SWPMI_Init(SWPMI_TypeDef *SWPMIx, LL_SWPMI_InitTypeDef *SWPMI_InitStruct) |
| elmot | 1:d0dfbce63a89 | 122 | { |
| elmot | 1:d0dfbce63a89 | 123 | ErrorStatus status = SUCCESS; |
| elmot | 1:d0dfbce63a89 | 124 | |
| elmot | 1:d0dfbce63a89 | 125 | /* Check the parameters */ |
| elmot | 1:d0dfbce63a89 | 126 | assert_param(IS_SWPMI_INSTANCE(SWPMIx)); |
| elmot | 1:d0dfbce63a89 | 127 | assert_param(IS_LL_SWPMI_BITRATE_VALUE(SWPMI_InitStruct->BitRatePrescaler)); |
| elmot | 1:d0dfbce63a89 | 128 | assert_param(IS_LL_SWPMI_SW_BUFFER_TX(SWPMI_InitStruct->TxBufferingMode)); |
| elmot | 1:d0dfbce63a89 | 129 | assert_param(IS_LL_SWPMI_SW_BUFFER_RX(SWPMI_InitStruct->RxBufferingMode)); |
| elmot | 1:d0dfbce63a89 | 130 | assert_param(IS_LL_SWPMI_VOLTAGE_CLASS(SWPMI_InitStruct->VoltageClass)); |
| elmot | 1:d0dfbce63a89 | 131 | |
| elmot | 1:d0dfbce63a89 | 132 | /* SWPMI needs to be in deactivated state, in order to be able to configure some bits */ |
| elmot | 1:d0dfbce63a89 | 133 | if (LL_SWPMI_IsActivated(SWPMIx) == 0) |
| elmot | 1:d0dfbce63a89 | 134 | { |
| elmot | 1:d0dfbce63a89 | 135 | /* Configure the BRR register (Bitrate) */ |
| elmot | 1:d0dfbce63a89 | 136 | LL_SWPMI_SetBitRatePrescaler(SWPMIx, SWPMI_InitStruct->BitRatePrescaler); |
| elmot | 1:d0dfbce63a89 | 137 | |
| elmot | 1:d0dfbce63a89 | 138 | /* Configure the voltage class */ |
| elmot | 1:d0dfbce63a89 | 139 | LL_SWPMI_SetVoltageClass(SWPMIx, SWPMI_InitStruct->VoltageClass); |
| elmot | 1:d0dfbce63a89 | 140 | |
| elmot | 1:d0dfbce63a89 | 141 | /* Set the new configuration of the SWPMI peripheral */ |
| elmot | 1:d0dfbce63a89 | 142 | MODIFY_REG(SWPMIx->CR, |
| elmot | 1:d0dfbce63a89 | 143 | (SWPMI_CR_RXMODE | SWPMI_CR_TXMODE), |
| elmot | 1:d0dfbce63a89 | 144 | (SWPMI_InitStruct->TxBufferingMode | SWPMI_InitStruct->RxBufferingMode)); |
| elmot | 1:d0dfbce63a89 | 145 | } |
| elmot | 1:d0dfbce63a89 | 146 | /* Else (SWPMI not in deactivated state => return ERROR) */ |
| elmot | 1:d0dfbce63a89 | 147 | else |
| elmot | 1:d0dfbce63a89 | 148 | { |
| elmot | 1:d0dfbce63a89 | 149 | status = ERROR; |
| elmot | 1:d0dfbce63a89 | 150 | } |
| elmot | 1:d0dfbce63a89 | 151 | |
| elmot | 1:d0dfbce63a89 | 152 | return status; |
| elmot | 1:d0dfbce63a89 | 153 | } |
| elmot | 1:d0dfbce63a89 | 154 | |
| elmot | 1:d0dfbce63a89 | 155 | /** |
| elmot | 1:d0dfbce63a89 | 156 | * @brief Set each @ref LL_SWPMI_InitTypeDef field to default value. |
| elmot | 1:d0dfbce63a89 | 157 | * @param SWPMI_InitStruct pointer to a @ref LL_SWPMI_InitTypeDef structure that contains |
| elmot | 1:d0dfbce63a89 | 158 | * the configuration information for the SWPMI peripheral. |
| elmot | 1:d0dfbce63a89 | 159 | * @retval None |
| elmot | 1:d0dfbce63a89 | 160 | */ |
| elmot | 1:d0dfbce63a89 | 161 | void LL_SWPMI_StructInit(LL_SWPMI_InitTypeDef *SWPMI_InitStruct) |
| elmot | 1:d0dfbce63a89 | 162 | { |
| elmot | 1:d0dfbce63a89 | 163 | /* Set SWPMI_InitStruct fields to default values */ |
| elmot | 1:d0dfbce63a89 | 164 | SWPMI_InitStruct->VoltageClass = LL_SWPMI_VOLTAGE_CLASS_C; |
| elmot | 1:d0dfbce63a89 | 165 | SWPMI_InitStruct->BitRatePrescaler = (uint32_t)0x00000001; |
| elmot | 1:d0dfbce63a89 | 166 | SWPMI_InitStruct->TxBufferingMode = LL_SWPMI_SW_BUFFER_TX_SINGLE; |
| elmot | 1:d0dfbce63a89 | 167 | SWPMI_InitStruct->RxBufferingMode = LL_SWPMI_SW_BUFFER_RX_SINGLE; |
| elmot | 1:d0dfbce63a89 | 168 | } |
| elmot | 1:d0dfbce63a89 | 169 | |
| elmot | 1:d0dfbce63a89 | 170 | /** |
| elmot | 1:d0dfbce63a89 | 171 | * @} |
| elmot | 1:d0dfbce63a89 | 172 | */ |
| elmot | 1:d0dfbce63a89 | 173 | |
| elmot | 1:d0dfbce63a89 | 174 | /** |
| elmot | 1:d0dfbce63a89 | 175 | * @} |
| elmot | 1:d0dfbce63a89 | 176 | */ |
| elmot | 1:d0dfbce63a89 | 177 | |
| elmot | 1:d0dfbce63a89 | 178 | /** |
| elmot | 1:d0dfbce63a89 | 179 | * @} |
| elmot | 1:d0dfbce63a89 | 180 | */ |
| elmot | 1:d0dfbce63a89 | 181 | |
| elmot | 1:d0dfbce63a89 | 182 | #endif /* defined (SWPMI1) */ |
| elmot | 1:d0dfbce63a89 | 183 | |
| elmot | 1:d0dfbce63a89 | 184 | /** |
| elmot | 1:d0dfbce63a89 | 185 | * @} |
| elmot | 1:d0dfbce63a89 | 186 | */ |
| elmot | 1:d0dfbce63a89 | 187 | |
| elmot | 1:d0dfbce63a89 | 188 | #endif /* USE_FULL_LL_DRIVER */ |
| elmot | 1:d0dfbce63a89 | 189 | |
| elmot | 1:d0dfbce63a89 | 190 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |