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