mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
181:a4cbdfbbd2f4
test with CLOCK_SETUP = 0

Who changed what in which revision?

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