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