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