SPKT

Dependents:   WAV

Committer:
phungductung
Date:
Tue Jun 04 21:51:46 2019 +0000
Revision:
0:e87aa4c49e95
libray

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phungductung 0:e87aa4c49e95 1 /**
phungductung 0:e87aa4c49e95 2 ******************************************************************************
phungductung 0:e87aa4c49e95 3 * @file stm32f7xx_hal_lptim.c
phungductung 0:e87aa4c49e95 4 * @author MCD Application Team
phungductung 0:e87aa4c49e95 5 * @version V1.0.4
phungductung 0:e87aa4c49e95 6 * @date 09-December-2015
phungductung 0:e87aa4c49e95 7 * @brief LPTIM HAL module driver.
phungductung 0:e87aa4c49e95 8 * This file provides firmware functions to manage the following
phungductung 0:e87aa4c49e95 9 * functionalities of the Low Power Timer (LPTIM) peripheral:
phungductung 0:e87aa4c49e95 10 * + Initialization and de-initialization functions.
phungductung 0:e87aa4c49e95 11 * + Start/Stop operation functions in polling mode.
phungductung 0:e87aa4c49e95 12 * + Start/Stop operation functions in interrupt mode.
phungductung 0:e87aa4c49e95 13 * + Reading operation functions.
phungductung 0:e87aa4c49e95 14 * + Peripheral State functions.
phungductung 0:e87aa4c49e95 15 *
phungductung 0:e87aa4c49e95 16 @verbatim
phungductung 0:e87aa4c49e95 17 ==============================================================================
phungductung 0:e87aa4c49e95 18 ##### How to use this driver #####
phungductung 0:e87aa4c49e95 19 ==============================================================================
phungductung 0:e87aa4c49e95 20 [..]
phungductung 0:e87aa4c49e95 21 The LPTIM HAL driver can be used as follows:
phungductung 0:e87aa4c49e95 22
phungductung 0:e87aa4c49e95 23 (#)Initialize the LPTIM low level resources by implementing the
phungductung 0:e87aa4c49e95 24 HAL_LPTIM_MspInit():
phungductung 0:e87aa4c49e95 25 (##) Enable the LPTIM interface clock using __LPTIMx_CLK_ENABLE().
phungductung 0:e87aa4c49e95 26 (##) In case of using interrupts (e.g. HAL_LPTIM_PWM_Start_IT()):
phungductung 0:e87aa4c49e95 27 (+) Configure the LPTIM interrupt priority using HAL_NVIC_SetPriority().
phungductung 0:e87aa4c49e95 28 (+) Enable the LPTIM IRQ handler using HAL_NVIC_EnableIRQ().
phungductung 0:e87aa4c49e95 29 (+) In LPTIM IRQ handler, call HAL_LPTIM_IRQHandler().
phungductung 0:e87aa4c49e95 30
phungductung 0:e87aa4c49e95 31 (#)Initialize the LPTIM HAL using HAL_LPTIM_Init(). This function
phungductung 0:e87aa4c49e95 32 configures mainly:
phungductung 0:e87aa4c49e95 33 (##) The instance: LPTIM1.
phungductung 0:e87aa4c49e95 34 (##) Clock: the counter clock.
phungductung 0:e87aa4c49e95 35 - Source : it can be either the ULPTIM input (IN1) or one of
phungductung 0:e87aa4c49e95 36 the internal clock; (APB, LSE, LSI or MSI).
phungductung 0:e87aa4c49e95 37 - Prescaler: select the clock divider.
phungductung 0:e87aa4c49e95 38 (##) UltraLowPowerClock : To be used only if the ULPTIM is selected
phungductung 0:e87aa4c49e95 39 as counter clock source.
phungductung 0:e87aa4c49e95 40 - Polarity: polarity of the active edge for the counter unit
phungductung 0:e87aa4c49e95 41 if the ULPTIM input is selected.
phungductung 0:e87aa4c49e95 42 - SampleTime: clock sampling time to configure the clock glitch
phungductung 0:e87aa4c49e95 43 filter.
phungductung 0:e87aa4c49e95 44 (##) Trigger: How the counter start.
phungductung 0:e87aa4c49e95 45 - Source: trigger can be software or one of the hardware triggers.
phungductung 0:e87aa4c49e95 46 - ActiveEdge : only for hardware trigger.
phungductung 0:e87aa4c49e95 47 - SampleTime : trigger sampling time to configure the trigger
phungductung 0:e87aa4c49e95 48 glitch filter.
phungductung 0:e87aa4c49e95 49 (##) OutputPolarity : 2 opposite polarities are possibles.
phungductung 0:e87aa4c49e95 50 (##) UpdateMode: specifies whether the update of the autoreload and
phungductung 0:e87aa4c49e95 51 the compare values is done immediately or after the end of current
phungductung 0:e87aa4c49e95 52 period.
phungductung 0:e87aa4c49e95 53
phungductung 0:e87aa4c49e95 54 (#)Six modes are available:
phungductung 0:e87aa4c49e95 55
phungductung 0:e87aa4c49e95 56 (##) PWM Mode: To generate a PWM signal with specified period and pulse,
phungductung 0:e87aa4c49e95 57 call HAL_LPTIM_PWM_Start() or HAL_LPTIM_PWM_Start_IT() for interruption
phungductung 0:e87aa4c49e95 58 mode.
phungductung 0:e87aa4c49e95 59
phungductung 0:e87aa4c49e95 60 (##) One Pulse Mode: To generate pulse with specified width in response
phungductung 0:e87aa4c49e95 61 to a stimulus, call HAL_LPTIM_OnePulse_Start() or
phungductung 0:e87aa4c49e95 62 HAL_LPTIM_OnePulse_Start_IT() for interruption mode.
phungductung 0:e87aa4c49e95 63
phungductung 0:e87aa4c49e95 64 (##) Set once Mode: In this mode, the output changes the level (from
phungductung 0:e87aa4c49e95 65 low level to high level if the output polarity is configured high, else
phungductung 0:e87aa4c49e95 66 the opposite) when a compare match occurs. To start this mode, call
phungductung 0:e87aa4c49e95 67 HAL_LPTIM_SetOnce_Start() or HAL_LPTIM_SetOnce_Start_IT() for
phungductung 0:e87aa4c49e95 68 interruption mode.
phungductung 0:e87aa4c49e95 69
phungductung 0:e87aa4c49e95 70 (##) Encoder Mode: To use the encoder interface call
phungductung 0:e87aa4c49e95 71 HAL_LPTIM_Encoder_Start() or HAL_LPTIM_Encoder_Start_IT() for
phungductung 0:e87aa4c49e95 72 interruption mode.
phungductung 0:e87aa4c49e95 73
phungductung 0:e87aa4c49e95 74 (##) Time out Mode: an active edge on one selected trigger input rests
phungductung 0:e87aa4c49e95 75 the counter. The first trigger event will start the timer, any
phungductung 0:e87aa4c49e95 76 successive trigger event will reset the counter and the timer will
phungductung 0:e87aa4c49e95 77 restart. To start this mode call HAL_LPTIM_TimeOut_Start_IT() or
phungductung 0:e87aa4c49e95 78 HAL_LPTIM_TimeOut_Start_IT() for interruption mode.
phungductung 0:e87aa4c49e95 79
phungductung 0:e87aa4c49e95 80 (##) Counter Mode: counter can be used to count external events on
phungductung 0:e87aa4c49e95 81 the LPTIM Input1 or it can be used to count internal clock cycles.
phungductung 0:e87aa4c49e95 82 To start this mode, call HAL_LPTIM_Counter_Start() or
phungductung 0:e87aa4c49e95 83 HAL_LPTIM_Counter_Start_IT() for interruption mode.
phungductung 0:e87aa4c49e95 84
phungductung 0:e87aa4c49e95 85
phungductung 0:e87aa4c49e95 86 (#) User can stop any process by calling the corresponding API:
phungductung 0:e87aa4c49e95 87 HAL_LPTIM_Xxx_Stop() or HAL_LPTIM_Xxx_Stop_IT() if the process is
phungductung 0:e87aa4c49e95 88 already started in interruption mode.
phungductung 0:e87aa4c49e95 89
phungductung 0:e87aa4c49e95 90 (#)Call HAL_LPTIM_DeInit() to deinitialize the LPTIM peripheral.
phungductung 0:e87aa4c49e95 91
phungductung 0:e87aa4c49e95 92 @endverbatim
phungductung 0:e87aa4c49e95 93 ******************************************************************************
phungductung 0:e87aa4c49e95 94 * @attention
phungductung 0:e87aa4c49e95 95 *
phungductung 0:e87aa4c49e95 96 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
phungductung 0:e87aa4c49e95 97 *
phungductung 0:e87aa4c49e95 98 * Redistribution and use in source and binary forms, with or without modification,
phungductung 0:e87aa4c49e95 99 * are permitted provided that the following conditions are met:
phungductung 0:e87aa4c49e95 100 * 1. Redistributions of source code must retain the above copyright notice,
phungductung 0:e87aa4c49e95 101 * this list of conditions and the following disclaimer.
phungductung 0:e87aa4c49e95 102 * 2. Redistributions in binary form must reproduce the above copyright notice,
phungductung 0:e87aa4c49e95 103 * this list of conditions and the following disclaimer in the documentation
phungductung 0:e87aa4c49e95 104 * and/or other materials provided with the distribution.
phungductung 0:e87aa4c49e95 105 * 3. Neither the name of STMicroelectronics nor the names of its contributors
phungductung 0:e87aa4c49e95 106 * may be used to endorse or promote products derived from this software
phungductung 0:e87aa4c49e95 107 * without specific prior written permission.
phungductung 0:e87aa4c49e95 108 *
phungductung 0:e87aa4c49e95 109 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
phungductung 0:e87aa4c49e95 110 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
phungductung 0:e87aa4c49e95 111 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
phungductung 0:e87aa4c49e95 112 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
phungductung 0:e87aa4c49e95 113 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
phungductung 0:e87aa4c49e95 114 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
phungductung 0:e87aa4c49e95 115 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
phungductung 0:e87aa4c49e95 116 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
phungductung 0:e87aa4c49e95 117 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
phungductung 0:e87aa4c49e95 118 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
phungductung 0:e87aa4c49e95 119 *
phungductung 0:e87aa4c49e95 120 ******************************************************************************
phungductung 0:e87aa4c49e95 121 */
phungductung 0:e87aa4c49e95 122
phungductung 0:e87aa4c49e95 123 /* Includes ------------------------------------------------------------------*/
phungductung 0:e87aa4c49e95 124 #include "stm32f7xx_hal.h"
phungductung 0:e87aa4c49e95 125
phungductung 0:e87aa4c49e95 126 /** @addtogroup STM32F7xx_HAL_Driver
phungductung 0:e87aa4c49e95 127 * @{
phungductung 0:e87aa4c49e95 128 */
phungductung 0:e87aa4c49e95 129
phungductung 0:e87aa4c49e95 130 /** @defgroup LPTIM LPTIM
phungductung 0:e87aa4c49e95 131 * @brief LPTIM HAL module driver.
phungductung 0:e87aa4c49e95 132 * @{
phungductung 0:e87aa4c49e95 133 */
phungductung 0:e87aa4c49e95 134
phungductung 0:e87aa4c49e95 135 #ifdef HAL_LPTIM_MODULE_ENABLED
phungductung 0:e87aa4c49e95 136 /* Private types -------------------------------------------------------------*/
phungductung 0:e87aa4c49e95 137 /** @defgroup LPTIM_Private_Types LPTIM Private Types
phungductung 0:e87aa4c49e95 138 * @{
phungductung 0:e87aa4c49e95 139 */
phungductung 0:e87aa4c49e95 140
phungductung 0:e87aa4c49e95 141 /**
phungductung 0:e87aa4c49e95 142 * @}
phungductung 0:e87aa4c49e95 143 */
phungductung 0:e87aa4c49e95 144
phungductung 0:e87aa4c49e95 145 /* Private defines -----------------------------------------------------------*/
phungductung 0:e87aa4c49e95 146 /** @defgroup LPTIM_Private_Defines LPTIM Private Defines
phungductung 0:e87aa4c49e95 147 * @{
phungductung 0:e87aa4c49e95 148 */
phungductung 0:e87aa4c49e95 149
phungductung 0:e87aa4c49e95 150 /**
phungductung 0:e87aa4c49e95 151 * @}
phungductung 0:e87aa4c49e95 152 */
phungductung 0:e87aa4c49e95 153
phungductung 0:e87aa4c49e95 154 /* Private variables ---------------------------------------------------------*/
phungductung 0:e87aa4c49e95 155 /** @addtogroup LPTIM_Private_Variables LPTIM Private Variables
phungductung 0:e87aa4c49e95 156 * @{
phungductung 0:e87aa4c49e95 157 */
phungductung 0:e87aa4c49e95 158
phungductung 0:e87aa4c49e95 159 /**
phungductung 0:e87aa4c49e95 160 * @}
phungductung 0:e87aa4c49e95 161 */
phungductung 0:e87aa4c49e95 162
phungductung 0:e87aa4c49e95 163 /* Private constants ---------------------------------------------------------*/
phungductung 0:e87aa4c49e95 164 /** @addtogroup LPTIM_Private_Constants LPTIM Private Constants
phungductung 0:e87aa4c49e95 165 * @{
phungductung 0:e87aa4c49e95 166 */
phungductung 0:e87aa4c49e95 167
phungductung 0:e87aa4c49e95 168 /**
phungductung 0:e87aa4c49e95 169 * @}
phungductung 0:e87aa4c49e95 170 */
phungductung 0:e87aa4c49e95 171
phungductung 0:e87aa4c49e95 172 /* Private macros ------------------------------------------------------------*/
phungductung 0:e87aa4c49e95 173 /** @addtogroup LPTIM_Private_Macros LPTIM Private Macros
phungductung 0:e87aa4c49e95 174 * @{
phungductung 0:e87aa4c49e95 175 */
phungductung 0:e87aa4c49e95 176
phungductung 0:e87aa4c49e95 177 /**
phungductung 0:e87aa4c49e95 178 * @}
phungductung 0:e87aa4c49e95 179 */
phungductung 0:e87aa4c49e95 180
phungductung 0:e87aa4c49e95 181 /* Private function prototypes -----------------------------------------------*/
phungductung 0:e87aa4c49e95 182 /** @addtogroup LPTIM_Private_Functions_Prototypes LPTIM Private Functions Prototypes
phungductung 0:e87aa4c49e95 183 * @{
phungductung 0:e87aa4c49e95 184 */
phungductung 0:e87aa4c49e95 185
phungductung 0:e87aa4c49e95 186 /**
phungductung 0:e87aa4c49e95 187 * @}
phungductung 0:e87aa4c49e95 188 */
phungductung 0:e87aa4c49e95 189
phungductung 0:e87aa4c49e95 190 /* Private functions ---------------------------------------------------------*/
phungductung 0:e87aa4c49e95 191 /** @addtogroup LPTIM_Private_Functions LPTIM Private Functions
phungductung 0:e87aa4c49e95 192 * @{
phungductung 0:e87aa4c49e95 193 */
phungductung 0:e87aa4c49e95 194
phungductung 0:e87aa4c49e95 195 /**
phungductung 0:e87aa4c49e95 196 * @}
phungductung 0:e87aa4c49e95 197 */
phungductung 0:e87aa4c49e95 198
phungductung 0:e87aa4c49e95 199 /* Exported functions ---------------------------------------------------------*/
phungductung 0:e87aa4c49e95 200 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
phungductung 0:e87aa4c49e95 201 * @{
phungductung 0:e87aa4c49e95 202 */
phungductung 0:e87aa4c49e95 203
phungductung 0:e87aa4c49e95 204 /** @defgroup LPTIM_Group1 Initialization/de-initialization functions
phungductung 0:e87aa4c49e95 205 * @brief Initialization and Configuration functions.
phungductung 0:e87aa4c49e95 206 *
phungductung 0:e87aa4c49e95 207 @verbatim
phungductung 0:e87aa4c49e95 208 ==============================================================================
phungductung 0:e87aa4c49e95 209 ##### Initialization and de-initialization functions #####
phungductung 0:e87aa4c49e95 210 ==============================================================================
phungductung 0:e87aa4c49e95 211 [..] This section provides functions allowing to:
phungductung 0:e87aa4c49e95 212 (+) Initialize the LPTIM according to the specified parameters in the
phungductung 0:e87aa4c49e95 213 LPTIM_InitTypeDef and creates the associated handle.
phungductung 0:e87aa4c49e95 214 (+) DeInitialize the LPTIM peripheral.
phungductung 0:e87aa4c49e95 215 (+) Initialize the LPTIM MSP.
phungductung 0:e87aa4c49e95 216 (+) DeInitialize LPTIM MSP.
phungductung 0:e87aa4c49e95 217
phungductung 0:e87aa4c49e95 218 @endverbatim
phungductung 0:e87aa4c49e95 219 * @{
phungductung 0:e87aa4c49e95 220 */
phungductung 0:e87aa4c49e95 221
phungductung 0:e87aa4c49e95 222 /**
phungductung 0:e87aa4c49e95 223 * @brief Initializes the LPTIM according to the specified parameters in the
phungductung 0:e87aa4c49e95 224 * LPTIM_InitTypeDef and creates the associated handle.
phungductung 0:e87aa4c49e95 225 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 226 * @retval HAL status
phungductung 0:e87aa4c49e95 227 */
phungductung 0:e87aa4c49e95 228 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 229 {
phungductung 0:e87aa4c49e95 230 uint32_t tmpcfgr = 0;
phungductung 0:e87aa4c49e95 231
phungductung 0:e87aa4c49e95 232 /* Check the LPTIM handle allocation */
phungductung 0:e87aa4c49e95 233 if(hlptim == NULL)
phungductung 0:e87aa4c49e95 234 {
phungductung 0:e87aa4c49e95 235 return HAL_ERROR;
phungductung 0:e87aa4c49e95 236 }
phungductung 0:e87aa4c49e95 237
phungductung 0:e87aa4c49e95 238 /* Check the parameters */
phungductung 0:e87aa4c49e95 239 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 240
phungductung 0:e87aa4c49e95 241 assert_param(IS_LPTIM_CLOCK_SOURCE(hlptim->Init.Clock.Source));
phungductung 0:e87aa4c49e95 242 assert_param(IS_LPTIM_CLOCK_PRESCALER(hlptim->Init.Clock.Prescaler));
phungductung 0:e87aa4c49e95 243 if ((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM)
phungductung 0:e87aa4c49e95 244 {
phungductung 0:e87aa4c49e95 245 assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));
phungductung 0:e87aa4c49e95 246 assert_param(IS_LPTIM_CLOCK_SAMPLE_TIME(hlptim->Init.UltraLowPowerClock.SampleTime));
phungductung 0:e87aa4c49e95 247 }
phungductung 0:e87aa4c49e95 248 assert_param(IS_LPTIM_TRG_SOURCE(hlptim->Init.Trigger.Source));
phungductung 0:e87aa4c49e95 249 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 250 {
phungductung 0:e87aa4c49e95 251 assert_param(IS_LPTIM_TRIG_SAMPLE_TIME(hlptim->Init.Trigger.SampleTime));
phungductung 0:e87aa4c49e95 252 assert_param(IS_LPTIM_EXT_TRG_POLARITY(hlptim->Init.Trigger.ActiveEdge));
phungductung 0:e87aa4c49e95 253 }
phungductung 0:e87aa4c49e95 254 assert_param(IS_LPTIM_OUTPUT_POLARITY(hlptim->Init.OutputPolarity));
phungductung 0:e87aa4c49e95 255 assert_param(IS_LPTIM_UPDATE_MODE(hlptim->Init.UpdateMode));
phungductung 0:e87aa4c49e95 256 assert_param(IS_LPTIM_COUNTER_SOURCE(hlptim->Init.CounterSource));
phungductung 0:e87aa4c49e95 257
phungductung 0:e87aa4c49e95 258 if(hlptim->State == HAL_LPTIM_STATE_RESET)
phungductung 0:e87aa4c49e95 259 {
phungductung 0:e87aa4c49e95 260 /* Allocate lock resource and initialize it */
phungductung 0:e87aa4c49e95 261 hlptim->Lock = HAL_UNLOCKED;
phungductung 0:e87aa4c49e95 262 /* Init the low level hardware */
phungductung 0:e87aa4c49e95 263 HAL_LPTIM_MspInit(hlptim);
phungductung 0:e87aa4c49e95 264 }
phungductung 0:e87aa4c49e95 265
phungductung 0:e87aa4c49e95 266 /* Change the LPTIM state */
phungductung 0:e87aa4c49e95 267 hlptim->State = HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 268
phungductung 0:e87aa4c49e95 269 /* Get the LPTIMx CFGR value */
phungductung 0:e87aa4c49e95 270 tmpcfgr = hlptim->Instance->CFGR;
phungductung 0:e87aa4c49e95 271
phungductung 0:e87aa4c49e95 272 if ((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM)
phungductung 0:e87aa4c49e95 273 {
phungductung 0:e87aa4c49e95 274 tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKPOL | LPTIM_CFGR_CKFLT));
phungductung 0:e87aa4c49e95 275 }
phungductung 0:e87aa4c49e95 276 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 277 {
phungductung 0:e87aa4c49e95 278 tmpcfgr &= (uint32_t)(~ (LPTIM_CFGR_TRGFLT | LPTIM_CFGR_TRIGSEL));
phungductung 0:e87aa4c49e95 279 }
phungductung 0:e87aa4c49e95 280
phungductung 0:e87aa4c49e95 281 /* Clear CKSEL, PRESC, TRIGEN, TRGFLT, WAVPOL, PRELOAD & COUNTMODE bits */
phungductung 0:e87aa4c49e95 282 tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKSEL | LPTIM_CFGR_TRIGEN | LPTIM_CFGR_PRELOAD |
phungductung 0:e87aa4c49e95 283 LPTIM_CFGR_WAVPOL | LPTIM_CFGR_PRESC | LPTIM_CFGR_COUNTMODE ));
phungductung 0:e87aa4c49e95 284
phungductung 0:e87aa4c49e95 285 /* Set initialization parameters */
phungductung 0:e87aa4c49e95 286 tmpcfgr |= (hlptim->Init.Clock.Source |
phungductung 0:e87aa4c49e95 287 hlptim->Init.Clock.Prescaler |
phungductung 0:e87aa4c49e95 288 hlptim->Init.OutputPolarity |
phungductung 0:e87aa4c49e95 289 hlptim->Init.UpdateMode |
phungductung 0:e87aa4c49e95 290 hlptim->Init.CounterSource);
phungductung 0:e87aa4c49e95 291
phungductung 0:e87aa4c49e95 292 if ((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM)
phungductung 0:e87aa4c49e95 293 {
phungductung 0:e87aa4c49e95 294 tmpcfgr |= (hlptim->Init.UltraLowPowerClock.Polarity |
phungductung 0:e87aa4c49e95 295 hlptim->Init.UltraLowPowerClock.SampleTime);
phungductung 0:e87aa4c49e95 296 }
phungductung 0:e87aa4c49e95 297
phungductung 0:e87aa4c49e95 298 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 299 {
phungductung 0:e87aa4c49e95 300 /* Enable External trigger and set the trigger source */
phungductung 0:e87aa4c49e95 301 tmpcfgr |= (hlptim->Init.Trigger.Source |
phungductung 0:e87aa4c49e95 302 hlptim->Init.Trigger.ActiveEdge |
phungductung 0:e87aa4c49e95 303 hlptim->Init.Trigger.SampleTime);
phungductung 0:e87aa4c49e95 304 }
phungductung 0:e87aa4c49e95 305
phungductung 0:e87aa4c49e95 306 /* Write to LPTIMx CFGR */
phungductung 0:e87aa4c49e95 307 hlptim->Instance->CFGR = tmpcfgr;
phungductung 0:e87aa4c49e95 308
phungductung 0:e87aa4c49e95 309 /* Change the LPTIM state */
phungductung 0:e87aa4c49e95 310 hlptim->State = HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 311
phungductung 0:e87aa4c49e95 312 /* Return function status */
phungductung 0:e87aa4c49e95 313 return HAL_OK;
phungductung 0:e87aa4c49e95 314 }
phungductung 0:e87aa4c49e95 315
phungductung 0:e87aa4c49e95 316 /**
phungductung 0:e87aa4c49e95 317 * @brief DeInitializes the LPTIM peripheral.
phungductung 0:e87aa4c49e95 318 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 319 * @retval HAL status
phungductung 0:e87aa4c49e95 320 */
phungductung 0:e87aa4c49e95 321 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 322 {
phungductung 0:e87aa4c49e95 323 /* Check the LPTIM handle allocation */
phungductung 0:e87aa4c49e95 324 if(hlptim == NULL)
phungductung 0:e87aa4c49e95 325 {
phungductung 0:e87aa4c49e95 326 return HAL_ERROR;
phungductung 0:e87aa4c49e95 327 }
phungductung 0:e87aa4c49e95 328
phungductung 0:e87aa4c49e95 329 /* Change the LPTIM state */
phungductung 0:e87aa4c49e95 330 hlptim->State = HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 331
phungductung 0:e87aa4c49e95 332 /* Disable the LPTIM Peripheral Clock */
phungductung 0:e87aa4c49e95 333 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 334
phungductung 0:e87aa4c49e95 335 /* DeInit the low level hardware: CLOCK, NVIC.*/
phungductung 0:e87aa4c49e95 336 HAL_LPTIM_MspDeInit(hlptim);
phungductung 0:e87aa4c49e95 337
phungductung 0:e87aa4c49e95 338 /* Change the LPTIM state */
phungductung 0:e87aa4c49e95 339 hlptim->State = HAL_LPTIM_STATE_RESET;
phungductung 0:e87aa4c49e95 340
phungductung 0:e87aa4c49e95 341 /* Release Lock */
phungductung 0:e87aa4c49e95 342 __HAL_UNLOCK(hlptim);
phungductung 0:e87aa4c49e95 343
phungductung 0:e87aa4c49e95 344 /* Return function status */
phungductung 0:e87aa4c49e95 345 return HAL_OK;
phungductung 0:e87aa4c49e95 346 }
phungductung 0:e87aa4c49e95 347
phungductung 0:e87aa4c49e95 348 /**
phungductung 0:e87aa4c49e95 349 * @brief Initializes the LPTIM MSP.
phungductung 0:e87aa4c49e95 350 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 351 * @retval None
phungductung 0:e87aa4c49e95 352 */
phungductung 0:e87aa4c49e95 353 __weak void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 354 {
phungductung 0:e87aa4c49e95 355 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 356 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 357
phungductung 0:e87aa4c49e95 358 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 359 the HAL_LPTIM_MspInit could be implemented in the user file
phungductung 0:e87aa4c49e95 360 */
phungductung 0:e87aa4c49e95 361 }
phungductung 0:e87aa4c49e95 362
phungductung 0:e87aa4c49e95 363 /**
phungductung 0:e87aa4c49e95 364 * @brief DeInitializes LPTIM MSP.
phungductung 0:e87aa4c49e95 365 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 366 * @retval None
phungductung 0:e87aa4c49e95 367 */
phungductung 0:e87aa4c49e95 368 __weak void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 369 {
phungductung 0:e87aa4c49e95 370 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 371 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 372
phungductung 0:e87aa4c49e95 373 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 374 the HAL_LPTIM_MspDeInit could be implemented in the user file
phungductung 0:e87aa4c49e95 375 */
phungductung 0:e87aa4c49e95 376 }
phungductung 0:e87aa4c49e95 377
phungductung 0:e87aa4c49e95 378 /**
phungductung 0:e87aa4c49e95 379 * @}
phungductung 0:e87aa4c49e95 380 */
phungductung 0:e87aa4c49e95 381
phungductung 0:e87aa4c49e95 382 /** @defgroup LPTIM_Group2 LPTIM Start-Stop operation functions
phungductung 0:e87aa4c49e95 383 * @brief Start-Stop operation functions.
phungductung 0:e87aa4c49e95 384 *
phungductung 0:e87aa4c49e95 385 @verbatim
phungductung 0:e87aa4c49e95 386 ==============================================================================
phungductung 0:e87aa4c49e95 387 ##### LPTIM Start Stop operation functions #####
phungductung 0:e87aa4c49e95 388 ==============================================================================
phungductung 0:e87aa4c49e95 389 [..] This section provides functions allowing to:
phungductung 0:e87aa4c49e95 390 (+) Start the PWM mode.
phungductung 0:e87aa4c49e95 391 (+) Stop the PWM mode.
phungductung 0:e87aa4c49e95 392 (+) Start the One pulse mode.
phungductung 0:e87aa4c49e95 393 (+) Stop the One pulse mode.
phungductung 0:e87aa4c49e95 394 (+) Start the Set once mode.
phungductung 0:e87aa4c49e95 395 (+) Stop the Set once mode.
phungductung 0:e87aa4c49e95 396 (+) Start the Encoder mode.
phungductung 0:e87aa4c49e95 397 (+) Stop the Encoder mode.
phungductung 0:e87aa4c49e95 398 (+) Start the Timeout mode.
phungductung 0:e87aa4c49e95 399 (+) Stop the Timeout mode.
phungductung 0:e87aa4c49e95 400 (+) Start the Counter mode.
phungductung 0:e87aa4c49e95 401 (+) Stop the Counter mode.
phungductung 0:e87aa4c49e95 402
phungductung 0:e87aa4c49e95 403
phungductung 0:e87aa4c49e95 404 @endverbatim
phungductung 0:e87aa4c49e95 405 * @{
phungductung 0:e87aa4c49e95 406 */
phungductung 0:e87aa4c49e95 407
phungductung 0:e87aa4c49e95 408 /**
phungductung 0:e87aa4c49e95 409 * @brief Starts the LPTIM PWM generation.
phungductung 0:e87aa4c49e95 410 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 411 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 412 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 413 * @param Pulse : Specifies the compare value.
phungductung 0:e87aa4c49e95 414 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 415 * @retval HAL status
phungductung 0:e87aa4c49e95 416 */
phungductung 0:e87aa4c49e95 417 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
phungductung 0:e87aa4c49e95 418 {
phungductung 0:e87aa4c49e95 419 /* Check the parameters */
phungductung 0:e87aa4c49e95 420 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 421 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 422 assert_param(IS_LPTIM_PULSE(Pulse));
phungductung 0:e87aa4c49e95 423
phungductung 0:e87aa4c49e95 424 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 425 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 426
phungductung 0:e87aa4c49e95 427 /* Reset WAVE bit to set PWM mode */
phungductung 0:e87aa4c49e95 428 hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;
phungductung 0:e87aa4c49e95 429
phungductung 0:e87aa4c49e95 430 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 431 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 432
phungductung 0:e87aa4c49e95 433 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 434 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 435
phungductung 0:e87aa4c49e95 436 /* Load the pulse value in the compare register */
phungductung 0:e87aa4c49e95 437 __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
phungductung 0:e87aa4c49e95 438
phungductung 0:e87aa4c49e95 439 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 440 __HAL_LPTIM_START_CONTINUOUS(hlptim);
phungductung 0:e87aa4c49e95 441
phungductung 0:e87aa4c49e95 442 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 443 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 444
phungductung 0:e87aa4c49e95 445 /* Return function status */
phungductung 0:e87aa4c49e95 446 return HAL_OK;
phungductung 0:e87aa4c49e95 447 }
phungductung 0:e87aa4c49e95 448
phungductung 0:e87aa4c49e95 449 /**
phungductung 0:e87aa4c49e95 450 * @brief Stops the LPTIM PWM generation.
phungductung 0:e87aa4c49e95 451 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 452 * @retval HAL status
phungductung 0:e87aa4c49e95 453 */
phungductung 0:e87aa4c49e95 454 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 455 {
phungductung 0:e87aa4c49e95 456 /* Check the parameters */
phungductung 0:e87aa4c49e95 457 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 458
phungductung 0:e87aa4c49e95 459 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 460 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 461
phungductung 0:e87aa4c49e95 462 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 463 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 464
phungductung 0:e87aa4c49e95 465 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 466 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 467
phungductung 0:e87aa4c49e95 468 /* Return function status */
phungductung 0:e87aa4c49e95 469 return HAL_OK;
phungductung 0:e87aa4c49e95 470 }
phungductung 0:e87aa4c49e95 471
phungductung 0:e87aa4c49e95 472 /**
phungductung 0:e87aa4c49e95 473 * @brief Starts the LPTIM PWM generation in interrupt mode.
phungductung 0:e87aa4c49e95 474 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 475 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 476 * This parameter must be a value between 0x0000 and 0xFFFF
phungductung 0:e87aa4c49e95 477 * @param Pulse : Specifies the compare value.
phungductung 0:e87aa4c49e95 478 * This parameter must be a value between 0x0000 and 0xFFFF
phungductung 0:e87aa4c49e95 479 * @retval HAL status
phungductung 0:e87aa4c49e95 480 */
phungductung 0:e87aa4c49e95 481 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
phungductung 0:e87aa4c49e95 482 {
phungductung 0:e87aa4c49e95 483 /* Check the parameters */
phungductung 0:e87aa4c49e95 484 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 485 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 486 assert_param(IS_LPTIM_PULSE(Pulse));
phungductung 0:e87aa4c49e95 487
phungductung 0:e87aa4c49e95 488 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 489 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 490
phungductung 0:e87aa4c49e95 491 /* Reset WAVE bit to set PWM mode */
phungductung 0:e87aa4c49e95 492 hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;
phungductung 0:e87aa4c49e95 493
phungductung 0:e87aa4c49e95 494 /* Enable Autoreload write complete interrupt */
phungductung 0:e87aa4c49e95 495 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);
phungductung 0:e87aa4c49e95 496
phungductung 0:e87aa4c49e95 497 /* Enable Compare write complete interrupt */
phungductung 0:e87aa4c49e95 498 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);
phungductung 0:e87aa4c49e95 499
phungductung 0:e87aa4c49e95 500 /* Enable Autoreload match interrupt */
phungductung 0:e87aa4c49e95 501 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);
phungductung 0:e87aa4c49e95 502
phungductung 0:e87aa4c49e95 503 /* Enable Compare match interrupt */
phungductung 0:e87aa4c49e95 504 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);
phungductung 0:e87aa4c49e95 505
phungductung 0:e87aa4c49e95 506 /* If external trigger source is used, then enable external trigger interrupt */
phungductung 0:e87aa4c49e95 507 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 508 {
phungductung 0:e87aa4c49e95 509 /* Enable external trigger interrupt */
phungductung 0:e87aa4c49e95 510 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
phungductung 0:e87aa4c49e95 511 }
phungductung 0:e87aa4c49e95 512
phungductung 0:e87aa4c49e95 513 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 514 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 515
phungductung 0:e87aa4c49e95 516 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 517 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 518
phungductung 0:e87aa4c49e95 519 /* Load the pulse value in the compare register */
phungductung 0:e87aa4c49e95 520 __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
phungductung 0:e87aa4c49e95 521
phungductung 0:e87aa4c49e95 522 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 523 __HAL_LPTIM_START_CONTINUOUS(hlptim);
phungductung 0:e87aa4c49e95 524
phungductung 0:e87aa4c49e95 525 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 526 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 527
phungductung 0:e87aa4c49e95 528 /* Return function status */
phungductung 0:e87aa4c49e95 529 return HAL_OK;
phungductung 0:e87aa4c49e95 530 }
phungductung 0:e87aa4c49e95 531
phungductung 0:e87aa4c49e95 532 /**
phungductung 0:e87aa4c49e95 533 * @brief Stops the LPTIM PWM generation in interrupt mode.
phungductung 0:e87aa4c49e95 534 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 535 * @retval HAL status
phungductung 0:e87aa4c49e95 536 */
phungductung 0:e87aa4c49e95 537 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 538 {
phungductung 0:e87aa4c49e95 539 /* Check the parameters */
phungductung 0:e87aa4c49e95 540 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 541
phungductung 0:e87aa4c49e95 542 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 543 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 544
phungductung 0:e87aa4c49e95 545 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 546 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 547
phungductung 0:e87aa4c49e95 548 /* Disable Autoreload write complete interrupt */
phungductung 0:e87aa4c49e95 549 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);
phungductung 0:e87aa4c49e95 550
phungductung 0:e87aa4c49e95 551 /* Disable Compare write complete interrupt */
phungductung 0:e87aa4c49e95 552 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);
phungductung 0:e87aa4c49e95 553
phungductung 0:e87aa4c49e95 554 /* Disable Autoreload match interrupt */
phungductung 0:e87aa4c49e95 555 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);
phungductung 0:e87aa4c49e95 556
phungductung 0:e87aa4c49e95 557 /* Disable Compare match interrupt */
phungductung 0:e87aa4c49e95 558 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);
phungductung 0:e87aa4c49e95 559
phungductung 0:e87aa4c49e95 560 /* If external trigger source is used, then disable external trigger interrupt */
phungductung 0:e87aa4c49e95 561 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 562 {
phungductung 0:e87aa4c49e95 563 /* Disable external trigger interrupt */
phungductung 0:e87aa4c49e95 564 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
phungductung 0:e87aa4c49e95 565 }
phungductung 0:e87aa4c49e95 566
phungductung 0:e87aa4c49e95 567 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 568 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 569
phungductung 0:e87aa4c49e95 570 /* Return function status */
phungductung 0:e87aa4c49e95 571 return HAL_OK;
phungductung 0:e87aa4c49e95 572 }
phungductung 0:e87aa4c49e95 573
phungductung 0:e87aa4c49e95 574 /**
phungductung 0:e87aa4c49e95 575 * @brief Starts the LPTIM One pulse generation.
phungductung 0:e87aa4c49e95 576 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 577 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 578 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 579 * @param Pulse : Specifies the compare value.
phungductung 0:e87aa4c49e95 580 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 581 * @retval HAL status
phungductung 0:e87aa4c49e95 582 */
phungductung 0:e87aa4c49e95 583 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
phungductung 0:e87aa4c49e95 584 {
phungductung 0:e87aa4c49e95 585 /* Check the parameters */
phungductung 0:e87aa4c49e95 586 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 587 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 588 assert_param(IS_LPTIM_PULSE(Pulse));
phungductung 0:e87aa4c49e95 589
phungductung 0:e87aa4c49e95 590 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 591 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 592
phungductung 0:e87aa4c49e95 593 /* Reset WAVE bit to set one pulse mode */
phungductung 0:e87aa4c49e95 594 hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;
phungductung 0:e87aa4c49e95 595
phungductung 0:e87aa4c49e95 596 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 597 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 598
phungductung 0:e87aa4c49e95 599 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 600 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 601
phungductung 0:e87aa4c49e95 602 /* Load the pulse value in the compare register */
phungductung 0:e87aa4c49e95 603 __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
phungductung 0:e87aa4c49e95 604
phungductung 0:e87aa4c49e95 605 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 606 __HAL_LPTIM_START_SINGLE(hlptim);
phungductung 0:e87aa4c49e95 607
phungductung 0:e87aa4c49e95 608 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 609 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 610
phungductung 0:e87aa4c49e95 611 /* Return function status */
phungductung 0:e87aa4c49e95 612 return HAL_OK;
phungductung 0:e87aa4c49e95 613 }
phungductung 0:e87aa4c49e95 614
phungductung 0:e87aa4c49e95 615 /**
phungductung 0:e87aa4c49e95 616 * @brief Stops the LPTIM One pulse generation.
phungductung 0:e87aa4c49e95 617 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 618 * @retval HAL status
phungductung 0:e87aa4c49e95 619 */
phungductung 0:e87aa4c49e95 620 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 621 {
phungductung 0:e87aa4c49e95 622 /* Check the parameters */
phungductung 0:e87aa4c49e95 623 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 624
phungductung 0:e87aa4c49e95 625 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 626 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 627
phungductung 0:e87aa4c49e95 628 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 629 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 630
phungductung 0:e87aa4c49e95 631 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 632 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 633
phungductung 0:e87aa4c49e95 634 /* Return function status */
phungductung 0:e87aa4c49e95 635 return HAL_OK;
phungductung 0:e87aa4c49e95 636 }
phungductung 0:e87aa4c49e95 637
phungductung 0:e87aa4c49e95 638 /**
phungductung 0:e87aa4c49e95 639 * @brief Starts the LPTIM One pulse generation in interrupt mode.
phungductung 0:e87aa4c49e95 640 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 641 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 642 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 643 * @param Pulse : Specifies the compare value.
phungductung 0:e87aa4c49e95 644 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 645 * @retval HAL status
phungductung 0:e87aa4c49e95 646 */
phungductung 0:e87aa4c49e95 647 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
phungductung 0:e87aa4c49e95 648 {
phungductung 0:e87aa4c49e95 649 /* Check the parameters */
phungductung 0:e87aa4c49e95 650 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 651 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 652 assert_param(IS_LPTIM_PULSE(Pulse));
phungductung 0:e87aa4c49e95 653
phungductung 0:e87aa4c49e95 654 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 655 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 656
phungductung 0:e87aa4c49e95 657 /* Reset WAVE bit to set one pulse mode */
phungductung 0:e87aa4c49e95 658 hlptim->Instance->CFGR &= ~LPTIM_CFGR_WAVE;
phungductung 0:e87aa4c49e95 659
phungductung 0:e87aa4c49e95 660 /* Enable Autoreload write complete interrupt */
phungductung 0:e87aa4c49e95 661 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);
phungductung 0:e87aa4c49e95 662
phungductung 0:e87aa4c49e95 663 /* Enable Compare write complete interrupt */
phungductung 0:e87aa4c49e95 664 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);
phungductung 0:e87aa4c49e95 665
phungductung 0:e87aa4c49e95 666 /* Enable Autoreload match interrupt */
phungductung 0:e87aa4c49e95 667 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);
phungductung 0:e87aa4c49e95 668
phungductung 0:e87aa4c49e95 669 /* Enable Compare match interrupt */
phungductung 0:e87aa4c49e95 670 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);
phungductung 0:e87aa4c49e95 671
phungductung 0:e87aa4c49e95 672 /* If external trigger source is used, then enable external trigger interrupt */
phungductung 0:e87aa4c49e95 673 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 674 {
phungductung 0:e87aa4c49e95 675 /* Enable external trigger interrupt */
phungductung 0:e87aa4c49e95 676 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
phungductung 0:e87aa4c49e95 677 }
phungductung 0:e87aa4c49e95 678
phungductung 0:e87aa4c49e95 679 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 680 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 681
phungductung 0:e87aa4c49e95 682 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 683 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 684
phungductung 0:e87aa4c49e95 685 /* Load the pulse value in the compare register */
phungductung 0:e87aa4c49e95 686 __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
phungductung 0:e87aa4c49e95 687
phungductung 0:e87aa4c49e95 688 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 689 __HAL_LPTIM_START_SINGLE(hlptim);
phungductung 0:e87aa4c49e95 690
phungductung 0:e87aa4c49e95 691 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 692 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 693
phungductung 0:e87aa4c49e95 694 /* Return function status */
phungductung 0:e87aa4c49e95 695 return HAL_OK;
phungductung 0:e87aa4c49e95 696 }
phungductung 0:e87aa4c49e95 697
phungductung 0:e87aa4c49e95 698 /**
phungductung 0:e87aa4c49e95 699 * @brief Stops the LPTIM One pulse generation in interrupt mode.
phungductung 0:e87aa4c49e95 700 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 701 * @retval HAL status
phungductung 0:e87aa4c49e95 702 */
phungductung 0:e87aa4c49e95 703 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 704 {
phungductung 0:e87aa4c49e95 705 /* Check the parameters */
phungductung 0:e87aa4c49e95 706 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 707
phungductung 0:e87aa4c49e95 708 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 709 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 710
phungductung 0:e87aa4c49e95 711 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 712 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 713
phungductung 0:e87aa4c49e95 714 /* Disable Autoreload write complete interrupt */
phungductung 0:e87aa4c49e95 715 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);
phungductung 0:e87aa4c49e95 716
phungductung 0:e87aa4c49e95 717 /* Disable Compare write complete interrupt */
phungductung 0:e87aa4c49e95 718 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);
phungductung 0:e87aa4c49e95 719
phungductung 0:e87aa4c49e95 720 /* Disable Autoreload match interrupt */
phungductung 0:e87aa4c49e95 721 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);
phungductung 0:e87aa4c49e95 722
phungductung 0:e87aa4c49e95 723 /* Disable Compare match interrupt */
phungductung 0:e87aa4c49e95 724 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);
phungductung 0:e87aa4c49e95 725
phungductung 0:e87aa4c49e95 726 /* If external trigger source is used, then disable external trigger interrupt */
phungductung 0:e87aa4c49e95 727 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 728 {
phungductung 0:e87aa4c49e95 729 /* Disable external trigger interrupt */
phungductung 0:e87aa4c49e95 730 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
phungductung 0:e87aa4c49e95 731 }
phungductung 0:e87aa4c49e95 732
phungductung 0:e87aa4c49e95 733 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 734 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 735
phungductung 0:e87aa4c49e95 736 /* Return function status */
phungductung 0:e87aa4c49e95 737 return HAL_OK;
phungductung 0:e87aa4c49e95 738 }
phungductung 0:e87aa4c49e95 739
phungductung 0:e87aa4c49e95 740 /**
phungductung 0:e87aa4c49e95 741 * @brief Starts the LPTIM in Set once mode.
phungductung 0:e87aa4c49e95 742 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 743 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 744 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 745 * @param Pulse : Specifies the compare value.
phungductung 0:e87aa4c49e95 746 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 747 * @retval HAL status
phungductung 0:e87aa4c49e95 748 */
phungductung 0:e87aa4c49e95 749 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
phungductung 0:e87aa4c49e95 750 {
phungductung 0:e87aa4c49e95 751 /* Check the parameters */
phungductung 0:e87aa4c49e95 752 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 753 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 754 assert_param(IS_LPTIM_PULSE(Pulse));
phungductung 0:e87aa4c49e95 755
phungductung 0:e87aa4c49e95 756 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 757 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 758
phungductung 0:e87aa4c49e95 759 /* Set WAVE bit to enable the set once mode */
phungductung 0:e87aa4c49e95 760 hlptim->Instance->CFGR |= LPTIM_CFGR_WAVE;
phungductung 0:e87aa4c49e95 761
phungductung 0:e87aa4c49e95 762 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 763 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 764
phungductung 0:e87aa4c49e95 765 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 766 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 767
phungductung 0:e87aa4c49e95 768 /* Load the pulse value in the compare register */
phungductung 0:e87aa4c49e95 769 __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
phungductung 0:e87aa4c49e95 770
phungductung 0:e87aa4c49e95 771 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 772 __HAL_LPTIM_START_SINGLE(hlptim);
phungductung 0:e87aa4c49e95 773
phungductung 0:e87aa4c49e95 774 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 775 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 776
phungductung 0:e87aa4c49e95 777 /* Return function status */
phungductung 0:e87aa4c49e95 778 return HAL_OK;
phungductung 0:e87aa4c49e95 779 }
phungductung 0:e87aa4c49e95 780
phungductung 0:e87aa4c49e95 781 /**
phungductung 0:e87aa4c49e95 782 * @brief Stops the LPTIM Set once mode.
phungductung 0:e87aa4c49e95 783 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 784 * @retval HAL status
phungductung 0:e87aa4c49e95 785 */
phungductung 0:e87aa4c49e95 786 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 787 {
phungductung 0:e87aa4c49e95 788 /* Check the parameters */
phungductung 0:e87aa4c49e95 789 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 790
phungductung 0:e87aa4c49e95 791 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 792 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 793
phungductung 0:e87aa4c49e95 794 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 795 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 796
phungductung 0:e87aa4c49e95 797 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 798 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 799
phungductung 0:e87aa4c49e95 800 /* Return function status */
phungductung 0:e87aa4c49e95 801 return HAL_OK;
phungductung 0:e87aa4c49e95 802 }
phungductung 0:e87aa4c49e95 803
phungductung 0:e87aa4c49e95 804 /**
phungductung 0:e87aa4c49e95 805 * @brief Starts the LPTIM Set once mode in interrupt mode.
phungductung 0:e87aa4c49e95 806 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 807 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 808 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 809 * @param Pulse : Specifies the compare value.
phungductung 0:e87aa4c49e95 810 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 811 * @retval HAL status
phungductung 0:e87aa4c49e95 812 */
phungductung 0:e87aa4c49e95 813 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse)
phungductung 0:e87aa4c49e95 814 {
phungductung 0:e87aa4c49e95 815 /* Check the parameters */
phungductung 0:e87aa4c49e95 816 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 817 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 818 assert_param(IS_LPTIM_PULSE(Pulse));
phungductung 0:e87aa4c49e95 819
phungductung 0:e87aa4c49e95 820 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 821 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 822
phungductung 0:e87aa4c49e95 823 /* Set WAVE bit to enable the set once mode */
phungductung 0:e87aa4c49e95 824 hlptim->Instance->CFGR |= LPTIM_CFGR_WAVE;
phungductung 0:e87aa4c49e95 825
phungductung 0:e87aa4c49e95 826 /* Enable Autoreload write complete interrupt */
phungductung 0:e87aa4c49e95 827 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);
phungductung 0:e87aa4c49e95 828
phungductung 0:e87aa4c49e95 829 /* Enable Compare write complete interrupt */
phungductung 0:e87aa4c49e95 830 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPOK);
phungductung 0:e87aa4c49e95 831
phungductung 0:e87aa4c49e95 832 /* Enable Autoreload match interrupt */
phungductung 0:e87aa4c49e95 833 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);
phungductung 0:e87aa4c49e95 834
phungductung 0:e87aa4c49e95 835 /* Enable Compare match interrupt */
phungductung 0:e87aa4c49e95 836 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);
phungductung 0:e87aa4c49e95 837
phungductung 0:e87aa4c49e95 838 /* If external trigger source is used, then enable external trigger interrupt */
phungductung 0:e87aa4c49e95 839 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 840 {
phungductung 0:e87aa4c49e95 841 /* Enable external trigger interrupt */
phungductung 0:e87aa4c49e95 842 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
phungductung 0:e87aa4c49e95 843 }
phungductung 0:e87aa4c49e95 844
phungductung 0:e87aa4c49e95 845 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 846 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 847
phungductung 0:e87aa4c49e95 848 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 849 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 850
phungductung 0:e87aa4c49e95 851 /* Load the pulse value in the compare register */
phungductung 0:e87aa4c49e95 852 __HAL_LPTIM_COMPARE_SET(hlptim, Pulse);
phungductung 0:e87aa4c49e95 853
phungductung 0:e87aa4c49e95 854 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 855 __HAL_LPTIM_START_SINGLE(hlptim);
phungductung 0:e87aa4c49e95 856
phungductung 0:e87aa4c49e95 857 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 858 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 859
phungductung 0:e87aa4c49e95 860 /* Return function status */
phungductung 0:e87aa4c49e95 861 return HAL_OK;
phungductung 0:e87aa4c49e95 862 }
phungductung 0:e87aa4c49e95 863
phungductung 0:e87aa4c49e95 864 /**
phungductung 0:e87aa4c49e95 865 * @brief Stops the LPTIM Set once mode in interrupt mode.
phungductung 0:e87aa4c49e95 866 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 867 * @retval HAL status
phungductung 0:e87aa4c49e95 868 */
phungductung 0:e87aa4c49e95 869 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 870 {
phungductung 0:e87aa4c49e95 871 /* Check the parameters */
phungductung 0:e87aa4c49e95 872 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 873
phungductung 0:e87aa4c49e95 874 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 875 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 876
phungductung 0:e87aa4c49e95 877 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 878 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 879
phungductung 0:e87aa4c49e95 880 /* Disable Autoreload write complete interrupt */
phungductung 0:e87aa4c49e95 881 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);
phungductung 0:e87aa4c49e95 882
phungductung 0:e87aa4c49e95 883 /* Disable Compare write complete interrupt */
phungductung 0:e87aa4c49e95 884 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPOK);
phungductung 0:e87aa4c49e95 885
phungductung 0:e87aa4c49e95 886 /* Disable Autoreload match interrupt */
phungductung 0:e87aa4c49e95 887 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);
phungductung 0:e87aa4c49e95 888
phungductung 0:e87aa4c49e95 889 /* Disable Compare match interrupt */
phungductung 0:e87aa4c49e95 890 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);
phungductung 0:e87aa4c49e95 891
phungductung 0:e87aa4c49e95 892 /* If external trigger source is used, then disable external trigger interrupt */
phungductung 0:e87aa4c49e95 893 if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
phungductung 0:e87aa4c49e95 894 {
phungductung 0:e87aa4c49e95 895 /* Disable external trigger interrupt */
phungductung 0:e87aa4c49e95 896 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_EXTTRIG);
phungductung 0:e87aa4c49e95 897 }
phungductung 0:e87aa4c49e95 898
phungductung 0:e87aa4c49e95 899 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 900 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 901
phungductung 0:e87aa4c49e95 902 /* Return function status */
phungductung 0:e87aa4c49e95 903 return HAL_OK;
phungductung 0:e87aa4c49e95 904 }
phungductung 0:e87aa4c49e95 905
phungductung 0:e87aa4c49e95 906 /**
phungductung 0:e87aa4c49e95 907 * @brief Starts the Encoder interface.
phungductung 0:e87aa4c49e95 908 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 909 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 910 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 911 * @retval HAL status
phungductung 0:e87aa4c49e95 912 */
phungductung 0:e87aa4c49e95 913 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period)
phungductung 0:e87aa4c49e95 914 {
phungductung 0:e87aa4c49e95 915 uint32_t tmpcfgr = 0;
phungductung 0:e87aa4c49e95 916
phungductung 0:e87aa4c49e95 917 /* Check the parameters */
phungductung 0:e87aa4c49e95 918 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 919 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 920 assert_param(hlptim->Init.Clock.Source == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC);
phungductung 0:e87aa4c49e95 921 assert_param(hlptim->Init.Clock.Prescaler == LPTIM_PRESCALER_DIV1);
phungductung 0:e87aa4c49e95 922 assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));
phungductung 0:e87aa4c49e95 923
phungductung 0:e87aa4c49e95 924 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 925 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 926
phungductung 0:e87aa4c49e95 927 /* Get the LPTIMx CFGR value */
phungductung 0:e87aa4c49e95 928 tmpcfgr = hlptim->Instance->CFGR;
phungductung 0:e87aa4c49e95 929
phungductung 0:e87aa4c49e95 930 /* Clear CKPOL bits */
phungductung 0:e87aa4c49e95 931 tmpcfgr &= (uint32_t)(~LPTIM_CFGR_CKPOL);
phungductung 0:e87aa4c49e95 932
phungductung 0:e87aa4c49e95 933 /* Set Input polarity */
phungductung 0:e87aa4c49e95 934 tmpcfgr |= hlptim->Init.UltraLowPowerClock.Polarity;
phungductung 0:e87aa4c49e95 935
phungductung 0:e87aa4c49e95 936 /* Write to LPTIMx CFGR */
phungductung 0:e87aa4c49e95 937 hlptim->Instance->CFGR = tmpcfgr;
phungductung 0:e87aa4c49e95 938
phungductung 0:e87aa4c49e95 939 /* Set ENC bit to enable the encoder interface */
phungductung 0:e87aa4c49e95 940 hlptim->Instance->CFGR |= LPTIM_CFGR_ENC;
phungductung 0:e87aa4c49e95 941
phungductung 0:e87aa4c49e95 942 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 943 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 944
phungductung 0:e87aa4c49e95 945 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 946 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 947
phungductung 0:e87aa4c49e95 948 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 949 __HAL_LPTIM_START_CONTINUOUS(hlptim);
phungductung 0:e87aa4c49e95 950
phungductung 0:e87aa4c49e95 951 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 952 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 953
phungductung 0:e87aa4c49e95 954 /* Return function status */
phungductung 0:e87aa4c49e95 955 return HAL_OK;
phungductung 0:e87aa4c49e95 956 }
phungductung 0:e87aa4c49e95 957
phungductung 0:e87aa4c49e95 958 /**
phungductung 0:e87aa4c49e95 959 * @brief Stops the Encoder interface.
phungductung 0:e87aa4c49e95 960 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 961 * @retval HAL status
phungductung 0:e87aa4c49e95 962 */
phungductung 0:e87aa4c49e95 963 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 964 {
phungductung 0:e87aa4c49e95 965 /* Check the parameters */
phungductung 0:e87aa4c49e95 966 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 967
phungductung 0:e87aa4c49e95 968 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 969 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 970
phungductung 0:e87aa4c49e95 971 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 972 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 973
phungductung 0:e87aa4c49e95 974 /* Reset ENC bit to disable the encoder interface */
phungductung 0:e87aa4c49e95 975 hlptim->Instance->CFGR &= ~LPTIM_CFGR_ENC;
phungductung 0:e87aa4c49e95 976
phungductung 0:e87aa4c49e95 977 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 978 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 979
phungductung 0:e87aa4c49e95 980 /* Return function status */
phungductung 0:e87aa4c49e95 981 return HAL_OK;
phungductung 0:e87aa4c49e95 982 }
phungductung 0:e87aa4c49e95 983
phungductung 0:e87aa4c49e95 984 /**
phungductung 0:e87aa4c49e95 985 * @brief Starts the Encoder interface in interrupt mode.
phungductung 0:e87aa4c49e95 986 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 987 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 988 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 989 * @retval HAL status
phungductung 0:e87aa4c49e95 990 */
phungductung 0:e87aa4c49e95 991 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period)
phungductung 0:e87aa4c49e95 992 {
phungductung 0:e87aa4c49e95 993 uint32_t tmpcfgr = 0;
phungductung 0:e87aa4c49e95 994
phungductung 0:e87aa4c49e95 995 /* Check the parameters */
phungductung 0:e87aa4c49e95 996 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 997 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 998 assert_param(hlptim->Init.Clock.Source == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC);
phungductung 0:e87aa4c49e95 999 assert_param(hlptim->Init.Clock.Prescaler == LPTIM_PRESCALER_DIV1);
phungductung 0:e87aa4c49e95 1000 assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));
phungductung 0:e87aa4c49e95 1001
phungductung 0:e87aa4c49e95 1002 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1003 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1004
phungductung 0:e87aa4c49e95 1005 /* Configure edge sensitivity for encoder mode */
phungductung 0:e87aa4c49e95 1006 /* Get the LPTIMx CFGR value */
phungductung 0:e87aa4c49e95 1007 tmpcfgr = hlptim->Instance->CFGR;
phungductung 0:e87aa4c49e95 1008
phungductung 0:e87aa4c49e95 1009 /* Clear CKPOL bits */
phungductung 0:e87aa4c49e95 1010 tmpcfgr &= (uint32_t)(~LPTIM_CFGR_CKPOL);
phungductung 0:e87aa4c49e95 1011
phungductung 0:e87aa4c49e95 1012 /* Set Input polarity */
phungductung 0:e87aa4c49e95 1013 tmpcfgr |= hlptim->Init.UltraLowPowerClock.Polarity;
phungductung 0:e87aa4c49e95 1014
phungductung 0:e87aa4c49e95 1015 /* Write to LPTIMx CFGR */
phungductung 0:e87aa4c49e95 1016 hlptim->Instance->CFGR = tmpcfgr;
phungductung 0:e87aa4c49e95 1017
phungductung 0:e87aa4c49e95 1018 /* Set ENC bit to enable the encoder interface */
phungductung 0:e87aa4c49e95 1019 hlptim->Instance->CFGR |= LPTIM_CFGR_ENC;
phungductung 0:e87aa4c49e95 1020
phungductung 0:e87aa4c49e95 1021 /* Enable "switch to down direction" interrupt */
phungductung 0:e87aa4c49e95 1022 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_DOWN);
phungductung 0:e87aa4c49e95 1023
phungductung 0:e87aa4c49e95 1024 /* Enable "switch to up direction" interrupt */
phungductung 0:e87aa4c49e95 1025 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_UP);
phungductung 0:e87aa4c49e95 1026
phungductung 0:e87aa4c49e95 1027 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 1028 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 1029
phungductung 0:e87aa4c49e95 1030 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 1031 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 1032
phungductung 0:e87aa4c49e95 1033 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 1034 __HAL_LPTIM_START_CONTINUOUS(hlptim);
phungductung 0:e87aa4c49e95 1035
phungductung 0:e87aa4c49e95 1036 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1037 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1038
phungductung 0:e87aa4c49e95 1039 /* Return function status */
phungductung 0:e87aa4c49e95 1040 return HAL_OK;
phungductung 0:e87aa4c49e95 1041 }
phungductung 0:e87aa4c49e95 1042
phungductung 0:e87aa4c49e95 1043 /**
phungductung 0:e87aa4c49e95 1044 * @brief Stops the Encoder interface in interrupt mode.
phungductung 0:e87aa4c49e95 1045 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1046 * @retval HAL status
phungductung 0:e87aa4c49e95 1047 */
phungductung 0:e87aa4c49e95 1048 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1049 {
phungductung 0:e87aa4c49e95 1050 /* Check the parameters */
phungductung 0:e87aa4c49e95 1051 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1052
phungductung 0:e87aa4c49e95 1053 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1054 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1055
phungductung 0:e87aa4c49e95 1056 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 1057 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 1058
phungductung 0:e87aa4c49e95 1059 /* Reset ENC bit to disable the encoder interface */
phungductung 0:e87aa4c49e95 1060 hlptim->Instance->CFGR &= ~LPTIM_CFGR_ENC;
phungductung 0:e87aa4c49e95 1061
phungductung 0:e87aa4c49e95 1062 /* Disable "switch to down direction" interrupt */
phungductung 0:e87aa4c49e95 1063 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_DOWN);
phungductung 0:e87aa4c49e95 1064
phungductung 0:e87aa4c49e95 1065 /* Disable "switch to up direction" interrupt */
phungductung 0:e87aa4c49e95 1066 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_UP);
phungductung 0:e87aa4c49e95 1067
phungductung 0:e87aa4c49e95 1068 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1069 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1070
phungductung 0:e87aa4c49e95 1071 /* Return function status */
phungductung 0:e87aa4c49e95 1072 return HAL_OK;
phungductung 0:e87aa4c49e95 1073 }
phungductung 0:e87aa4c49e95 1074
phungductung 0:e87aa4c49e95 1075 /**
phungductung 0:e87aa4c49e95 1076 * @brief Starts the Timeout function. The first trigger event will start the
phungductung 0:e87aa4c49e95 1077 * timer, any successive trigger event will reset the counter and
phungductung 0:e87aa4c49e95 1078 * the timer restarts.
phungductung 0:e87aa4c49e95 1079 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1080 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 1081 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 1082 * @param Timeout : Specifies the TimeOut value to rest the counter.
phungductung 0:e87aa4c49e95 1083 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 1084 * @retval HAL status
phungductung 0:e87aa4c49e95 1085 */
phungductung 0:e87aa4c49e95 1086 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout)
phungductung 0:e87aa4c49e95 1087 {
phungductung 0:e87aa4c49e95 1088 /* Check the parameters */
phungductung 0:e87aa4c49e95 1089 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1090 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 1091 assert_param(IS_LPTIM_PULSE(Timeout));
phungductung 0:e87aa4c49e95 1092
phungductung 0:e87aa4c49e95 1093 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1094 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1095
phungductung 0:e87aa4c49e95 1096 /* Set TIMOUT bit to enable the timeout function */
phungductung 0:e87aa4c49e95 1097 hlptim->Instance->CFGR |= LPTIM_CFGR_TIMOUT;
phungductung 0:e87aa4c49e95 1098
phungductung 0:e87aa4c49e95 1099 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 1100 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 1101
phungductung 0:e87aa4c49e95 1102 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 1103 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 1104
phungductung 0:e87aa4c49e95 1105 /* Load the Timeout value in the compare register */
phungductung 0:e87aa4c49e95 1106 __HAL_LPTIM_COMPARE_SET(hlptim, Timeout);
phungductung 0:e87aa4c49e95 1107
phungductung 0:e87aa4c49e95 1108 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 1109 __HAL_LPTIM_START_CONTINUOUS(hlptim);
phungductung 0:e87aa4c49e95 1110
phungductung 0:e87aa4c49e95 1111 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1112 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1113
phungductung 0:e87aa4c49e95 1114 /* Return function status */
phungductung 0:e87aa4c49e95 1115 return HAL_OK;
phungductung 0:e87aa4c49e95 1116 }
phungductung 0:e87aa4c49e95 1117
phungductung 0:e87aa4c49e95 1118 /**
phungductung 0:e87aa4c49e95 1119 * @brief Stops the Timeout function.
phungductung 0:e87aa4c49e95 1120 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1121 * @retval HAL status
phungductung 0:e87aa4c49e95 1122 */
phungductung 0:e87aa4c49e95 1123 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1124 {
phungductung 0:e87aa4c49e95 1125 /* Check the parameters */
phungductung 0:e87aa4c49e95 1126 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1127
phungductung 0:e87aa4c49e95 1128 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1129 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1130
phungductung 0:e87aa4c49e95 1131 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 1132 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 1133
phungductung 0:e87aa4c49e95 1134 /* Reset TIMOUT bit to enable the timeout function */
phungductung 0:e87aa4c49e95 1135 hlptim->Instance->CFGR &= ~LPTIM_CFGR_TIMOUT;
phungductung 0:e87aa4c49e95 1136
phungductung 0:e87aa4c49e95 1137 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1138 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1139
phungductung 0:e87aa4c49e95 1140 /* Return function status */
phungductung 0:e87aa4c49e95 1141 return HAL_OK;
phungductung 0:e87aa4c49e95 1142 }
phungductung 0:e87aa4c49e95 1143
phungductung 0:e87aa4c49e95 1144 /**
phungductung 0:e87aa4c49e95 1145 * @brief Starts the Timeout function in interrupt mode. The first trigger
phungductung 0:e87aa4c49e95 1146 * event will start the timer, any successive trigger event will reset
phungductung 0:e87aa4c49e95 1147 * the counter and the timer restarts.
phungductung 0:e87aa4c49e95 1148 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1149 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 1150 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 1151 * @param Timeout : Specifies the TimeOut value to rest the counter.
phungductung 0:e87aa4c49e95 1152 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 1153 * @retval HAL status
phungductung 0:e87aa4c49e95 1154 */
phungductung 0:e87aa4c49e95 1155 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout)
phungductung 0:e87aa4c49e95 1156 {
phungductung 0:e87aa4c49e95 1157 /* Check the parameters */
phungductung 0:e87aa4c49e95 1158 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1159 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 1160 assert_param(IS_LPTIM_PULSE(Timeout));
phungductung 0:e87aa4c49e95 1161
phungductung 0:e87aa4c49e95 1162 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1163 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1164
phungductung 0:e87aa4c49e95 1165 /* Set TIMOUT bit to enable the timeout function */
phungductung 0:e87aa4c49e95 1166 hlptim->Instance->CFGR |= LPTIM_CFGR_TIMOUT;
phungductung 0:e87aa4c49e95 1167
phungductung 0:e87aa4c49e95 1168 /* Enable Compare match interrupt */
phungductung 0:e87aa4c49e95 1169 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_CMPM);
phungductung 0:e87aa4c49e95 1170
phungductung 0:e87aa4c49e95 1171 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 1172 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 1173
phungductung 0:e87aa4c49e95 1174 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 1175 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 1176
phungductung 0:e87aa4c49e95 1177 /* Load the Timeout value in the compare register */
phungductung 0:e87aa4c49e95 1178 __HAL_LPTIM_COMPARE_SET(hlptim, Timeout);
phungductung 0:e87aa4c49e95 1179
phungductung 0:e87aa4c49e95 1180 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 1181 __HAL_LPTIM_START_CONTINUOUS(hlptim);
phungductung 0:e87aa4c49e95 1182
phungductung 0:e87aa4c49e95 1183 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1184 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1185
phungductung 0:e87aa4c49e95 1186 /* Return function status */
phungductung 0:e87aa4c49e95 1187 return HAL_OK;
phungductung 0:e87aa4c49e95 1188 }
phungductung 0:e87aa4c49e95 1189
phungductung 0:e87aa4c49e95 1190 /**
phungductung 0:e87aa4c49e95 1191 * @brief Stops the Timeout function in interrupt mode.
phungductung 0:e87aa4c49e95 1192 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1193 * @retval HAL status
phungductung 0:e87aa4c49e95 1194 */
phungductung 0:e87aa4c49e95 1195 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1196 {
phungductung 0:e87aa4c49e95 1197 /* Check the parameters */
phungductung 0:e87aa4c49e95 1198 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1199
phungductung 0:e87aa4c49e95 1200 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1201 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1202
phungductung 0:e87aa4c49e95 1203 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 1204 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 1205
phungductung 0:e87aa4c49e95 1206 /* Reset TIMOUT bit to enable the timeout function */
phungductung 0:e87aa4c49e95 1207 hlptim->Instance->CFGR &= ~LPTIM_CFGR_TIMOUT;
phungductung 0:e87aa4c49e95 1208
phungductung 0:e87aa4c49e95 1209 /* Disable Compare match interrupt */
phungductung 0:e87aa4c49e95 1210 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_CMPM);
phungductung 0:e87aa4c49e95 1211
phungductung 0:e87aa4c49e95 1212 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1213 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1214
phungductung 0:e87aa4c49e95 1215 /* Return function status */
phungductung 0:e87aa4c49e95 1216 return HAL_OK;
phungductung 0:e87aa4c49e95 1217 }
phungductung 0:e87aa4c49e95 1218
phungductung 0:e87aa4c49e95 1219 /**
phungductung 0:e87aa4c49e95 1220 * @brief Starts the Counter mode.
phungductung 0:e87aa4c49e95 1221 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1222 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 1223 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 1224 * @retval HAL status
phungductung 0:e87aa4c49e95 1225 */
phungductung 0:e87aa4c49e95 1226 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period)
phungductung 0:e87aa4c49e95 1227 {
phungductung 0:e87aa4c49e95 1228 /* Check the parameters */
phungductung 0:e87aa4c49e95 1229 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1230 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 1231
phungductung 0:e87aa4c49e95 1232 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1233 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1234
phungductung 0:e87aa4c49e95 1235 /* If clock source is not ULPTIM clock and counter source is external, then it must not be prescaled */
phungductung 0:e87aa4c49e95 1236 if((hlptim->Init.Clock.Source != LPTIM_CLOCKSOURCE_ULPTIM) && (hlptim->Init.CounterSource == LPTIM_COUNTERSOURCE_EXTERNAL))
phungductung 0:e87aa4c49e95 1237 {
phungductung 0:e87aa4c49e95 1238 /* Check if clock is prescaled */
phungductung 0:e87aa4c49e95 1239 assert_param(IS_LPTIM_CLOCK_PRESCALERDIV1(hlptim->Init.Clock.Prescaler));
phungductung 0:e87aa4c49e95 1240 /* Set clock prescaler to 0 */
phungductung 0:e87aa4c49e95 1241 hlptim->Instance->CFGR &= ~LPTIM_CFGR_PRESC;
phungductung 0:e87aa4c49e95 1242 }
phungductung 0:e87aa4c49e95 1243
phungductung 0:e87aa4c49e95 1244 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 1245 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 1246
phungductung 0:e87aa4c49e95 1247 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 1248 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 1249
phungductung 0:e87aa4c49e95 1250 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 1251 __HAL_LPTIM_START_CONTINUOUS(hlptim);
phungductung 0:e87aa4c49e95 1252
phungductung 0:e87aa4c49e95 1253 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1254 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1255
phungductung 0:e87aa4c49e95 1256 /* Return function status */
phungductung 0:e87aa4c49e95 1257 return HAL_OK;
phungductung 0:e87aa4c49e95 1258 }
phungductung 0:e87aa4c49e95 1259
phungductung 0:e87aa4c49e95 1260 /**
phungductung 0:e87aa4c49e95 1261 * @brief Stops the Counter mode.
phungductung 0:e87aa4c49e95 1262 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1263 * @retval HAL status
phungductung 0:e87aa4c49e95 1264 */
phungductung 0:e87aa4c49e95 1265 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1266 {
phungductung 0:e87aa4c49e95 1267 /* Check the parameters */
phungductung 0:e87aa4c49e95 1268 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1269
phungductung 0:e87aa4c49e95 1270 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1271 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1272
phungductung 0:e87aa4c49e95 1273 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 1274 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 1275
phungductung 0:e87aa4c49e95 1276 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1277 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1278
phungductung 0:e87aa4c49e95 1279 /* Return function status */
phungductung 0:e87aa4c49e95 1280 return HAL_OK;
phungductung 0:e87aa4c49e95 1281 }
phungductung 0:e87aa4c49e95 1282
phungductung 0:e87aa4c49e95 1283 /**
phungductung 0:e87aa4c49e95 1284 * @brief Starts the Counter mode in interrupt mode.
phungductung 0:e87aa4c49e95 1285 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1286 * @param Period : Specifies the Autoreload value.
phungductung 0:e87aa4c49e95 1287 * This parameter must be a value between 0x0000 and 0xFFFF.
phungductung 0:e87aa4c49e95 1288 * @retval HAL status
phungductung 0:e87aa4c49e95 1289 */
phungductung 0:e87aa4c49e95 1290 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period)
phungductung 0:e87aa4c49e95 1291 {
phungductung 0:e87aa4c49e95 1292 /* Check the parameters */
phungductung 0:e87aa4c49e95 1293 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1294 assert_param(IS_LPTIM_PERIOD(Period));
phungductung 0:e87aa4c49e95 1295
phungductung 0:e87aa4c49e95 1296 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1297 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1298
phungductung 0:e87aa4c49e95 1299 /* If clock source is not ULPTIM clock and counter source is external, then it must not be prescaled */
phungductung 0:e87aa4c49e95 1300 if((hlptim->Init.Clock.Source != LPTIM_CLOCKSOURCE_ULPTIM) && (hlptim->Init.CounterSource == LPTIM_COUNTERSOURCE_EXTERNAL))
phungductung 0:e87aa4c49e95 1301 {
phungductung 0:e87aa4c49e95 1302 /* Check if clock is prescaled */
phungductung 0:e87aa4c49e95 1303 assert_param(IS_LPTIM_CLOCK_PRESCALERDIV1(hlptim->Init.Clock.Prescaler));
phungductung 0:e87aa4c49e95 1304 /* Set clock prescaler to 0 */
phungductung 0:e87aa4c49e95 1305 hlptim->Instance->CFGR &= ~LPTIM_CFGR_PRESC;
phungductung 0:e87aa4c49e95 1306 }
phungductung 0:e87aa4c49e95 1307
phungductung 0:e87aa4c49e95 1308 /* Enable Autoreload write complete interrupt */
phungductung 0:e87aa4c49e95 1309 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARROK);
phungductung 0:e87aa4c49e95 1310
phungductung 0:e87aa4c49e95 1311 /* Enable Autoreload match interrupt */
phungductung 0:e87aa4c49e95 1312 __HAL_LPTIM_ENABLE_IT(hlptim, LPTIM_IT_ARRM);
phungductung 0:e87aa4c49e95 1313
phungductung 0:e87aa4c49e95 1314 /* Enable the Peripheral */
phungductung 0:e87aa4c49e95 1315 __HAL_LPTIM_ENABLE(hlptim);
phungductung 0:e87aa4c49e95 1316
phungductung 0:e87aa4c49e95 1317 /* Load the period value in the autoreload register */
phungductung 0:e87aa4c49e95 1318 __HAL_LPTIM_AUTORELOAD_SET(hlptim, Period);
phungductung 0:e87aa4c49e95 1319
phungductung 0:e87aa4c49e95 1320 /* Start timer in continuous mode */
phungductung 0:e87aa4c49e95 1321 __HAL_LPTIM_START_CONTINUOUS(hlptim);
phungductung 0:e87aa4c49e95 1322
phungductung 0:e87aa4c49e95 1323 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1324 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1325
phungductung 0:e87aa4c49e95 1326 /* Return function status */
phungductung 0:e87aa4c49e95 1327 return HAL_OK;
phungductung 0:e87aa4c49e95 1328 }
phungductung 0:e87aa4c49e95 1329
phungductung 0:e87aa4c49e95 1330 /**
phungductung 0:e87aa4c49e95 1331 * @brief Stops the Counter mode in interrupt mode.
phungductung 0:e87aa4c49e95 1332 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1333 * @retval HAL status
phungductung 0:e87aa4c49e95 1334 */
phungductung 0:e87aa4c49e95 1335 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1336 {
phungductung 0:e87aa4c49e95 1337 /* Check the parameters */
phungductung 0:e87aa4c49e95 1338 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1339
phungductung 0:e87aa4c49e95 1340 /* Set the LPTIM state */
phungductung 0:e87aa4c49e95 1341 hlptim->State= HAL_LPTIM_STATE_BUSY;
phungductung 0:e87aa4c49e95 1342
phungductung 0:e87aa4c49e95 1343 /* Disable the Peripheral */
phungductung 0:e87aa4c49e95 1344 __HAL_LPTIM_DISABLE(hlptim);
phungductung 0:e87aa4c49e95 1345
phungductung 0:e87aa4c49e95 1346 /* Disable Autoreload write complete interrupt */
phungductung 0:e87aa4c49e95 1347 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARROK);
phungductung 0:e87aa4c49e95 1348
phungductung 0:e87aa4c49e95 1349 /* Disable Autoreload match interrupt */
phungductung 0:e87aa4c49e95 1350 __HAL_LPTIM_DISABLE_IT(hlptim, LPTIM_IT_ARRM);
phungductung 0:e87aa4c49e95 1351
phungductung 0:e87aa4c49e95 1352 /* Change the TIM state*/
phungductung 0:e87aa4c49e95 1353 hlptim->State= HAL_LPTIM_STATE_READY;
phungductung 0:e87aa4c49e95 1354
phungductung 0:e87aa4c49e95 1355 /* Return function status */
phungductung 0:e87aa4c49e95 1356 return HAL_OK;
phungductung 0:e87aa4c49e95 1357 }
phungductung 0:e87aa4c49e95 1358
phungductung 0:e87aa4c49e95 1359 /**
phungductung 0:e87aa4c49e95 1360 * @}
phungductung 0:e87aa4c49e95 1361 */
phungductung 0:e87aa4c49e95 1362
phungductung 0:e87aa4c49e95 1363 /** @defgroup LPTIM_Group3 LPTIM Read operation functions
phungductung 0:e87aa4c49e95 1364 * @brief Read operation functions.
phungductung 0:e87aa4c49e95 1365 *
phungductung 0:e87aa4c49e95 1366 @verbatim
phungductung 0:e87aa4c49e95 1367 ==============================================================================
phungductung 0:e87aa4c49e95 1368 ##### LPTIM Read operation functions #####
phungductung 0:e87aa4c49e95 1369 ==============================================================================
phungductung 0:e87aa4c49e95 1370 [..] This section provides LPTIM Reading functions.
phungductung 0:e87aa4c49e95 1371 (+) Read the counter value.
phungductung 0:e87aa4c49e95 1372 (+) Read the period (Auto-reload) value.
phungductung 0:e87aa4c49e95 1373 (+) Read the pulse (Compare)value.
phungductung 0:e87aa4c49e95 1374 @endverbatim
phungductung 0:e87aa4c49e95 1375 * @{
phungductung 0:e87aa4c49e95 1376 */
phungductung 0:e87aa4c49e95 1377
phungductung 0:e87aa4c49e95 1378 /**
phungductung 0:e87aa4c49e95 1379 * @brief This function returns the current counter value.
phungductung 0:e87aa4c49e95 1380 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 1381 * @retval Counter value.
phungductung 0:e87aa4c49e95 1382 */
phungductung 0:e87aa4c49e95 1383 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1384 {
phungductung 0:e87aa4c49e95 1385 /* Check the parameters */
phungductung 0:e87aa4c49e95 1386 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1387
phungductung 0:e87aa4c49e95 1388 return (hlptim->Instance->CNT);
phungductung 0:e87aa4c49e95 1389 }
phungductung 0:e87aa4c49e95 1390
phungductung 0:e87aa4c49e95 1391 /**
phungductung 0:e87aa4c49e95 1392 * @brief This function return the current Autoreload (Period) value.
phungductung 0:e87aa4c49e95 1393 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 1394 * @retval Autoreload value.
phungductung 0:e87aa4c49e95 1395 */
phungductung 0:e87aa4c49e95 1396 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1397 {
phungductung 0:e87aa4c49e95 1398 /* Check the parameters */
phungductung 0:e87aa4c49e95 1399 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1400
phungductung 0:e87aa4c49e95 1401 return (hlptim->Instance->ARR);
phungductung 0:e87aa4c49e95 1402 }
phungductung 0:e87aa4c49e95 1403
phungductung 0:e87aa4c49e95 1404 /**
phungductung 0:e87aa4c49e95 1405 * @brief This function return the current Compare (Pulse) value.
phungductung 0:e87aa4c49e95 1406 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 1407 * @retval Compare value.
phungductung 0:e87aa4c49e95 1408 */
phungductung 0:e87aa4c49e95 1409 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1410 {
phungductung 0:e87aa4c49e95 1411 /* Check the parameters */
phungductung 0:e87aa4c49e95 1412 assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
phungductung 0:e87aa4c49e95 1413
phungductung 0:e87aa4c49e95 1414 return (hlptim->Instance->CMP);
phungductung 0:e87aa4c49e95 1415 }
phungductung 0:e87aa4c49e95 1416
phungductung 0:e87aa4c49e95 1417 /**
phungductung 0:e87aa4c49e95 1418 * @}
phungductung 0:e87aa4c49e95 1419 */
phungductung 0:e87aa4c49e95 1420
phungductung 0:e87aa4c49e95 1421
phungductung 0:e87aa4c49e95 1422
phungductung 0:e87aa4c49e95 1423 /** @defgroup LPTIM_Group4 LPTIM IRQ handler
phungductung 0:e87aa4c49e95 1424 * @brief LPTIM IRQ handler.
phungductung 0:e87aa4c49e95 1425 *
phungductung 0:e87aa4c49e95 1426 @verbatim
phungductung 0:e87aa4c49e95 1427 ==============================================================================
phungductung 0:e87aa4c49e95 1428 ##### LPTIM IRQ handler #####
phungductung 0:e87aa4c49e95 1429 ==============================================================================
phungductung 0:e87aa4c49e95 1430 [..] This section provides LPTIM IRQ handler function.
phungductung 0:e87aa4c49e95 1431
phungductung 0:e87aa4c49e95 1432 @endverbatim
phungductung 0:e87aa4c49e95 1433 * @{
phungductung 0:e87aa4c49e95 1434 */
phungductung 0:e87aa4c49e95 1435
phungductung 0:e87aa4c49e95 1436 /**
phungductung 0:e87aa4c49e95 1437 * @brief This function handles LPTIM interrupt request.
phungductung 0:e87aa4c49e95 1438 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 1439 * @retval None
phungductung 0:e87aa4c49e95 1440 */
phungductung 0:e87aa4c49e95 1441 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1442 {
phungductung 0:e87aa4c49e95 1443 /* Compare match interrupt */
phungductung 0:e87aa4c49e95 1444 if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_CMPM) != RESET)
phungductung 0:e87aa4c49e95 1445 {
phungductung 0:e87aa4c49e95 1446 if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_CMPM) !=RESET)
phungductung 0:e87aa4c49e95 1447 {
phungductung 0:e87aa4c49e95 1448 /* Clear Compare match flag */
phungductung 0:e87aa4c49e95 1449 __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_CMPM);
phungductung 0:e87aa4c49e95 1450 /* Compare match Callback */
phungductung 0:e87aa4c49e95 1451 HAL_LPTIM_CompareMatchCallback(hlptim);
phungductung 0:e87aa4c49e95 1452 }
phungductung 0:e87aa4c49e95 1453 }
phungductung 0:e87aa4c49e95 1454
phungductung 0:e87aa4c49e95 1455 /* Autoreload match interrupt */
phungductung 0:e87aa4c49e95 1456 if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_ARRM) != RESET)
phungductung 0:e87aa4c49e95 1457 {
phungductung 0:e87aa4c49e95 1458 if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_ARRM) !=RESET)
phungductung 0:e87aa4c49e95 1459 {
phungductung 0:e87aa4c49e95 1460 /* Clear Autoreload match flag */
phungductung 0:e87aa4c49e95 1461 __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_ARRM);
phungductung 0:e87aa4c49e95 1462 /* Autoreload match Callback */
phungductung 0:e87aa4c49e95 1463 HAL_LPTIM_AutoReloadMatchCallback(hlptim);
phungductung 0:e87aa4c49e95 1464 }
phungductung 0:e87aa4c49e95 1465 }
phungductung 0:e87aa4c49e95 1466
phungductung 0:e87aa4c49e95 1467 /* Trigger detected interrupt */
phungductung 0:e87aa4c49e95 1468 if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_EXTTRIG) != RESET)
phungductung 0:e87aa4c49e95 1469 {
phungductung 0:e87aa4c49e95 1470 if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_EXTTRIG) !=RESET)
phungductung 0:e87aa4c49e95 1471 {
phungductung 0:e87aa4c49e95 1472 /* Clear Trigger detected flag */
phungductung 0:e87aa4c49e95 1473 __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_EXTTRIG);
phungductung 0:e87aa4c49e95 1474 /* Trigger detected callback */
phungductung 0:e87aa4c49e95 1475 HAL_LPTIM_TriggerCallback(hlptim);
phungductung 0:e87aa4c49e95 1476 }
phungductung 0:e87aa4c49e95 1477 }
phungductung 0:e87aa4c49e95 1478
phungductung 0:e87aa4c49e95 1479 /* Compare write interrupt */
phungductung 0:e87aa4c49e95 1480 if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_CMPOK) != RESET)
phungductung 0:e87aa4c49e95 1481 {
phungductung 0:e87aa4c49e95 1482 if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_FLAG_CMPM) !=RESET)
phungductung 0:e87aa4c49e95 1483 {
phungductung 0:e87aa4c49e95 1484 /* Clear Compare write flag */
phungductung 0:e87aa4c49e95 1485 __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_CMPOK);
phungductung 0:e87aa4c49e95 1486 /* Compare write Callback */
phungductung 0:e87aa4c49e95 1487 HAL_LPTIM_CompareWriteCallback(hlptim);
phungductung 0:e87aa4c49e95 1488 }
phungductung 0:e87aa4c49e95 1489 }
phungductung 0:e87aa4c49e95 1490
phungductung 0:e87aa4c49e95 1491 /* Autoreload write interrupt */
phungductung 0:e87aa4c49e95 1492 if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_ARROK) != RESET)
phungductung 0:e87aa4c49e95 1493 {
phungductung 0:e87aa4c49e95 1494 if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_ARROK) !=RESET)
phungductung 0:e87aa4c49e95 1495 {
phungductung 0:e87aa4c49e95 1496 /* Clear Autoreload write flag */
phungductung 0:e87aa4c49e95 1497 __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_ARROK);
phungductung 0:e87aa4c49e95 1498 /* Autoreload write Callback */
phungductung 0:e87aa4c49e95 1499 HAL_LPTIM_AutoReloadWriteCallback(hlptim);
phungductung 0:e87aa4c49e95 1500 }
phungductung 0:e87aa4c49e95 1501 }
phungductung 0:e87aa4c49e95 1502
phungductung 0:e87aa4c49e95 1503 /* Direction counter changed from Down to Up interrupt */
phungductung 0:e87aa4c49e95 1504 if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_UP) != RESET)
phungductung 0:e87aa4c49e95 1505 {
phungductung 0:e87aa4c49e95 1506 if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_UP) !=RESET)
phungductung 0:e87aa4c49e95 1507 {
phungductung 0:e87aa4c49e95 1508 /* Clear Direction counter changed from Down to Up flag */
phungductung 0:e87aa4c49e95 1509 __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_UP);
phungductung 0:e87aa4c49e95 1510 /* Direction counter changed from Down to Up Callback */
phungductung 0:e87aa4c49e95 1511 HAL_LPTIM_DirectionUpCallback(hlptim);
phungductung 0:e87aa4c49e95 1512 }
phungductung 0:e87aa4c49e95 1513 }
phungductung 0:e87aa4c49e95 1514
phungductung 0:e87aa4c49e95 1515 /* Direction counter changed from Up to Down interrupt */
phungductung 0:e87aa4c49e95 1516 if(__HAL_LPTIM_GET_FLAG(hlptim, LPTIM_FLAG_DOWN) != RESET)
phungductung 0:e87aa4c49e95 1517 {
phungductung 0:e87aa4c49e95 1518 if(__HAL_LPTIM_GET_IT_SOURCE(hlptim, LPTIM_IT_DOWN) !=RESET)
phungductung 0:e87aa4c49e95 1519 {
phungductung 0:e87aa4c49e95 1520 /* Clear Direction counter changed from Up to Down flag */
phungductung 0:e87aa4c49e95 1521 __HAL_LPTIM_CLEAR_FLAG(hlptim, LPTIM_FLAG_DOWN);
phungductung 0:e87aa4c49e95 1522 /* Direction counter changed from Up to Down Callback */
phungductung 0:e87aa4c49e95 1523 HAL_LPTIM_DirectionDownCallback(hlptim);
phungductung 0:e87aa4c49e95 1524 }
phungductung 0:e87aa4c49e95 1525 }
phungductung 0:e87aa4c49e95 1526 }
phungductung 0:e87aa4c49e95 1527
phungductung 0:e87aa4c49e95 1528 /**
phungductung 0:e87aa4c49e95 1529 * @brief Compare match callback in non blocking mode
phungductung 0:e87aa4c49e95 1530 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1531 * @retval None
phungductung 0:e87aa4c49e95 1532 */
phungductung 0:e87aa4c49e95 1533 __weak void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1534 {
phungductung 0:e87aa4c49e95 1535 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 1536 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 1537
phungductung 0:e87aa4c49e95 1538 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 1539 the HAL_LPTIM_CompareMatchCallback could be implemented in the user file
phungductung 0:e87aa4c49e95 1540 */
phungductung 0:e87aa4c49e95 1541 }
phungductung 0:e87aa4c49e95 1542
phungductung 0:e87aa4c49e95 1543 /**
phungductung 0:e87aa4c49e95 1544 * @brief Autoreload match callback in non blocking mode
phungductung 0:e87aa4c49e95 1545 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1546 * @retval None
phungductung 0:e87aa4c49e95 1547 */
phungductung 0:e87aa4c49e95 1548 __weak void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1549 {
phungductung 0:e87aa4c49e95 1550 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 1551 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 1552
phungductung 0:e87aa4c49e95 1553 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 1554 the HAL_LPTIM_AutoReloadMatchCallback could be implemented in the user file
phungductung 0:e87aa4c49e95 1555 */
phungductung 0:e87aa4c49e95 1556 }
phungductung 0:e87aa4c49e95 1557
phungductung 0:e87aa4c49e95 1558 /**
phungductung 0:e87aa4c49e95 1559 * @brief Trigger detected callback in non blocking mode
phungductung 0:e87aa4c49e95 1560 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1561 * @retval None
phungductung 0:e87aa4c49e95 1562 */
phungductung 0:e87aa4c49e95 1563 __weak void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1564 {
phungductung 0:e87aa4c49e95 1565 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 1566 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 1567
phungductung 0:e87aa4c49e95 1568 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 1569 the HAL_LPTIM_TriggerCallback could be implemented in the user file
phungductung 0:e87aa4c49e95 1570 */
phungductung 0:e87aa4c49e95 1571 }
phungductung 0:e87aa4c49e95 1572
phungductung 0:e87aa4c49e95 1573 /**
phungductung 0:e87aa4c49e95 1574 * @brief Compare write callback in non blocking mode
phungductung 0:e87aa4c49e95 1575 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1576 * @retval None
phungductung 0:e87aa4c49e95 1577 */
phungductung 0:e87aa4c49e95 1578 __weak void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1579 {
phungductung 0:e87aa4c49e95 1580 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 1581 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 1582
phungductung 0:e87aa4c49e95 1583 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 1584 the HAL_LPTIM_CompareWriteCallback could be implemented in the user file
phungductung 0:e87aa4c49e95 1585 */
phungductung 0:e87aa4c49e95 1586 }
phungductung 0:e87aa4c49e95 1587
phungductung 0:e87aa4c49e95 1588 /**
phungductung 0:e87aa4c49e95 1589 * @brief Autoreload write callback in non blocking mode
phungductung 0:e87aa4c49e95 1590 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1591 * @retval None
phungductung 0:e87aa4c49e95 1592 */
phungductung 0:e87aa4c49e95 1593 __weak void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1594 {
phungductung 0:e87aa4c49e95 1595 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 1596 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 1597
phungductung 0:e87aa4c49e95 1598 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 1599 the HAL_LPTIM_AutoReloadWriteCallback could be implemented in the user file
phungductung 0:e87aa4c49e95 1600 */
phungductung 0:e87aa4c49e95 1601 }
phungductung 0:e87aa4c49e95 1602
phungductung 0:e87aa4c49e95 1603 /**
phungductung 0:e87aa4c49e95 1604 * @brief Direction counter changed from Down to Up callback in non blocking mode
phungductung 0:e87aa4c49e95 1605 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1606 * @retval None
phungductung 0:e87aa4c49e95 1607 */
phungductung 0:e87aa4c49e95 1608 __weak void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1609 {
phungductung 0:e87aa4c49e95 1610 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 1611 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 1612
phungductung 0:e87aa4c49e95 1613 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 1614 the HAL_LPTIM_DirectionUpCallback could be implemented in the user file
phungductung 0:e87aa4c49e95 1615 */
phungductung 0:e87aa4c49e95 1616 }
phungductung 0:e87aa4c49e95 1617
phungductung 0:e87aa4c49e95 1618 /**
phungductung 0:e87aa4c49e95 1619 * @brief Direction counter changed from Up to Down callback in non blocking mode
phungductung 0:e87aa4c49e95 1620 * @param hlptim : LPTIM handle
phungductung 0:e87aa4c49e95 1621 * @retval None
phungductung 0:e87aa4c49e95 1622 */
phungductung 0:e87aa4c49e95 1623 __weak void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1624 {
phungductung 0:e87aa4c49e95 1625 /* Prevent unused argument(s) compilation warning */
phungductung 0:e87aa4c49e95 1626 UNUSED(hlptim);
phungductung 0:e87aa4c49e95 1627
phungductung 0:e87aa4c49e95 1628 /* NOTE : This function Should not be modified, when the callback is needed,
phungductung 0:e87aa4c49e95 1629 the HAL_LPTIM_DirectionDownCallback could be implemented in the user file
phungductung 0:e87aa4c49e95 1630 */
phungductung 0:e87aa4c49e95 1631 }
phungductung 0:e87aa4c49e95 1632
phungductung 0:e87aa4c49e95 1633 /**
phungductung 0:e87aa4c49e95 1634 * @}
phungductung 0:e87aa4c49e95 1635 */
phungductung 0:e87aa4c49e95 1636
phungductung 0:e87aa4c49e95 1637 /** @defgroup LPTIM_Group5 Peripheral State functions
phungductung 0:e87aa4c49e95 1638 * @brief Peripheral State functions.
phungductung 0:e87aa4c49e95 1639 *
phungductung 0:e87aa4c49e95 1640 @verbatim
phungductung 0:e87aa4c49e95 1641 ==============================================================================
phungductung 0:e87aa4c49e95 1642 ##### Peripheral State functions #####
phungductung 0:e87aa4c49e95 1643 ==============================================================================
phungductung 0:e87aa4c49e95 1644 [..]
phungductung 0:e87aa4c49e95 1645 This subsection permits to get in run-time the status of the peripheral.
phungductung 0:e87aa4c49e95 1646
phungductung 0:e87aa4c49e95 1647 @endverbatim
phungductung 0:e87aa4c49e95 1648 * @{
phungductung 0:e87aa4c49e95 1649 */
phungductung 0:e87aa4c49e95 1650
phungductung 0:e87aa4c49e95 1651 /**
phungductung 0:e87aa4c49e95 1652 * @brief Returns the LPTIM state.
phungductung 0:e87aa4c49e95 1653 * @param hlptim: LPTIM handle
phungductung 0:e87aa4c49e95 1654 * @retval HAL state
phungductung 0:e87aa4c49e95 1655 */
phungductung 0:e87aa4c49e95 1656 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim)
phungductung 0:e87aa4c49e95 1657 {
phungductung 0:e87aa4c49e95 1658 return hlptim->State;
phungductung 0:e87aa4c49e95 1659 }
phungductung 0:e87aa4c49e95 1660
phungductung 0:e87aa4c49e95 1661 /**
phungductung 0:e87aa4c49e95 1662 * @}
phungductung 0:e87aa4c49e95 1663 */
phungductung 0:e87aa4c49e95 1664
phungductung 0:e87aa4c49e95 1665
phungductung 0:e87aa4c49e95 1666 /**
phungductung 0:e87aa4c49e95 1667 * @}
phungductung 0:e87aa4c49e95 1668 */
phungductung 0:e87aa4c49e95 1669
phungductung 0:e87aa4c49e95 1670 #endif /* HAL_LPTIM_MODULE_ENABLED */
phungductung 0:e87aa4c49e95 1671 /**
phungductung 0:e87aa4c49e95 1672 * @}
phungductung 0:e87aa4c49e95 1673 */
phungductung 0:e87aa4c49e95 1674
phungductung 0:e87aa4c49e95 1675 /**
phungductung 0:e87aa4c49e95 1676 * @}
phungductung 0:e87aa4c49e95 1677 */
phungductung 0:e87aa4c49e95 1678
phungductung 0:e87aa4c49e95 1679 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/