STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_ll_swpmi.c
Go to the documentation of this file.
1 
19 #if defined(USE_FULL_LL_DRIVER)
20 
21 /* Includes ------------------------------------------------------------------*/
22 #include "stm32l4xx_ll_swpmi.h"
23 #include "stm32l4xx_ll_bus.h"
24 #ifdef USE_FULL_ASSERT
25 #include "stm32_assert.h"
26 #else
27 #define assert_param(expr) ((void)0U)
28 #endif
29 
34 #if defined(SWPMI1)
35 
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private constants ---------------------------------------------------------*/
43 /* Private macros ------------------------------------------------------------*/
48 #define IS_LL_SWPMI_BITRATE_VALUE(__VALUE__) (((__VALUE__) <= 63U))
49 
50 #define IS_LL_SWPMI_SW_BUFFER_RX(__VALUE__) (((__VALUE__) == LL_SWPMI_SW_BUFFER_RX_SINGLE) \
51  || ((__VALUE__) == LL_SWPMI_SW_BUFFER_RX_MULTI))
52 
53 #define IS_LL_SWPMI_SW_BUFFER_TX(__VALUE__) (((__VALUE__) == LL_SWPMI_SW_BUFFER_TX_SINGLE) \
54  || ((__VALUE__) == LL_SWPMI_SW_BUFFER_TX_MULTI))
55 
56 #define IS_LL_SWPMI_VOLTAGE_CLASS(__VALUE__) (((__VALUE__) == LL_SWPMI_VOLTAGE_CLASS_C) \
57  || ((__VALUE__) == LL_SWPMI_VOLTAGE_CLASS_B))
58 
63 /* Private function prototypes -----------------------------------------------*/
64 
65 /* Exported functions --------------------------------------------------------*/
81 ErrorStatus LL_SWPMI_DeInit(SWPMI_TypeDef *SWPMIx)
82 {
83  ErrorStatus status = SUCCESS;
84 
85  /* Check the parameter */
86  assert_param(IS_SWPMI_INSTANCE(SWPMIx));
87 
88  if (SWPMIx == SWPMI1)
89  {
90  LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_SWPMI1);
91  LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_SWPMI1);
92  }
93  else
94  {
95  status = ERROR;
96  }
97 
98  return status;
99 }
100 
112 ErrorStatus LL_SWPMI_Init(SWPMI_TypeDef *SWPMIx, LL_SWPMI_InitTypeDef *SWPMI_InitStruct)
113 {
114  ErrorStatus status = SUCCESS;
115 
116  /* Check the parameters */
117  assert_param(IS_SWPMI_INSTANCE(SWPMIx));
118  assert_param(IS_LL_SWPMI_BITRATE_VALUE(SWPMI_InitStruct->BitRatePrescaler));
119  assert_param(IS_LL_SWPMI_SW_BUFFER_TX(SWPMI_InitStruct->TxBufferingMode));
120  assert_param(IS_LL_SWPMI_SW_BUFFER_RX(SWPMI_InitStruct->RxBufferingMode));
121  assert_param(IS_LL_SWPMI_VOLTAGE_CLASS(SWPMI_InitStruct->VoltageClass));
122 
123  /* SWPMI needs to be in deactivated state, in order to be able to configure some bits */
124  if (LL_SWPMI_IsActivated(SWPMIx) == 0U)
125  {
126  /* Configure the BRR register (Bitrate) */
127  LL_SWPMI_SetBitRatePrescaler(SWPMIx, SWPMI_InitStruct->BitRatePrescaler);
128 
129  /* Configure the voltage class */
130  LL_SWPMI_SetVoltageClass(SWPMIx, SWPMI_InitStruct->VoltageClass);
131 
132  /* Set the new configuration of the SWPMI peripheral */
133  MODIFY_REG(SWPMIx->CR,
134  (SWPMI_CR_RXMODE | SWPMI_CR_TXMODE),
135  (SWPMI_InitStruct->TxBufferingMode | SWPMI_InitStruct->RxBufferingMode));
136  }
137  /* Else (SWPMI not in deactivated state => return ERROR) */
138  else
139  {
140  status = ERROR;
141  }
142 
143  return status;
144 }
145 
153 {
154  /* Set SWPMI_InitStruct fields to default values */
155  SWPMI_InitStruct->VoltageClass = LL_SWPMI_VOLTAGE_CLASS_C;
156  SWPMI_InitStruct->BitRatePrescaler = (uint32_t)0x00000001;
157  SWPMI_InitStruct->TxBufferingMode = LL_SWPMI_SW_BUFFER_TX_SINGLE;
158  SWPMI_InitStruct->RxBufferingMode = LL_SWPMI_SW_BUFFER_RX_SINGLE;
159 }
160 
173 #endif /* SWPMI1 */
174 
179 #endif /* USE_FULL_LL_DRIVER */
180 
181 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Header file of SWPMI LL module.
__STATIC_INLINE uint32_t LL_SWPMI_IsActivated(SWPMI_TypeDef *SWPMIx)
Check if Single wire protocol bus is in ACTIVATED state. CR SWPACT LL_SWPMI_Activate.
__STATIC_INLINE void LL_SWPMI_SetBitRatePrescaler(SWPMI_TypeDef *SWPMIx, uint32_t BitRatePrescaler)
Set Bitrate prescaler SWPMI_freq = SWPMI_clk / (((BitRate) + 1) * 4) BRR BR LL_SWPMI_SetBitRatePresc...
__STATIC_INLINE void LL_SWPMI_SetVoltageClass(SWPMI_TypeDef *SWPMIx, uint32_t VoltageClass)
Set SWP Voltage Class OR CLASS LL_SWPMI_SetVoltageClass.
SWPMI Init structures definition.
__STATIC_INLINE void LL_APB1_GRP2_ForceReset(uint32_t Periphs)
Force APB1 peripherals reset. APB1RSTR2 LPUART1RST LL_APB1_GRP2_ForceReset APB1RSTR2 I2C4RST LL_APB...
__STATIC_INLINE void LL_APB1_GRP2_ReleaseReset(uint32_t Periphs)
Release APB1 peripherals reset. APB1RSTR2 LPUART1RST LL_APB1_GRP2_ReleaseReset APB1RSTR2 I2C4RST LL...
Header file of BUS LL module.
ErrorStatus LL_SWPMI_Init(SWPMI_TypeDef *SWPMIx, LL_SWPMI_InitTypeDef *SWPMI_InitStruct)
Initialize the SWPMI peripheral according to the specified parameters in the SWPMI_InitStruct.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
ErrorStatus LL_SWPMI_DeInit(SWPMI_TypeDef *SWPMIx)
De-initialize the SWPMI peripheral registers to their default reset values.
void LL_SWPMI_StructInit(LL_SWPMI_InitTypeDef *SWPMI_InitStruct)
Set each LL_SWPMI_InitTypeDef field to default value.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))