mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
jaerts
Date:
Tue Dec 22 13:22:16 2015 +0000
Revision:
637:ed69428d4850
Parent:
610:813dcc80987e
Add very shady LPC1768 CAN Filter implementation

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