mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Jun 19 09:15:11 2015 +0100
Revision:
573:ad23fe03a082
Child:
610:813dcc80987e
Synchronized with git revision d47834cd4d729e5b36b4c1ad4650f8b8f6a9ab86

Full URL: https://github.com/mbedmicro/mbed/commit/d47834cd4d729e5b36b4c1ad4650f8b8f6a9ab86/

DISCO_F746NG - Add new target

Who changed what in which revision?

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