Mbed for VNG board

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Nov 05 14:30:08 2014 +0000
Revision:
387:643a59b3dbac
Parent:
382:ee426a420dbb
Synchronized with git revision cfeccf154f8f92c3ea9c0c881c577c154537aecc

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

Exporters: STM32L053R8 - IAR exporter

Who changed what in which revision?

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