The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
<>
Date:
Wed Apr 12 16:07:08 2017 +0100
Revision:
140:97feb9bacc10
Parent:
128:9bcdf88f62b0
Child:
145:64910690c574
Release 140 of the mbed library

Ports for Upcoming Targets

3841: Add nRf52840 target https://github.com/ARMmbed/mbed-os/pull/3841
3992: Introducing UBLOX_C030 platform. https://github.com/ARMmbed/mbed-os/pull/3992

Fixes and Changes

3951: [NUCLEO_F303ZE] Correct ARDUINO pin https://github.com/ARMmbed/mbed-os/pull/3951
4021: Fixing a macro to detect when RTOS was in use for the NRF52840_DK https://github.com/ARMmbed/mbed-os/pull/4021
3979: KW24D: Add missing SPI defines and Arduino connector definitions https://github.com/ARMmbed/mbed-os/pull/3979
3990: UBLOX_C027: construct a ticker-based wait, rather than calling wait_ms(), in the https://github.com/ARMmbed/mbed-os/pull/3990
4003: Fixed OBOE in async serial tx for NRF52 target, fixes #4002 https://github.com/ARMmbed/mbed-os/pull/4003
4012: STM32: Correct I2C master error handling https://github.com/ARMmbed/mbed-os/pull/4012
4020: NUCLEO_L011K4 remove unsupported tool chain files https://github.com/ARMmbed/mbed-os/pull/4020
4065: K66F: Move bss section to m_data_2 Section https://github.com/ARMmbed/mbed-os/pull/4065
4014: Issue 3763: Reduce heap allocation in the GCC linker file https://github.com/ARMmbed/mbed-os/pull/4014
4030: [STM32L0] reduce IAR heap and stack size for small targets https://github.com/ARMmbed/mbed-os/pull/4030
4109: NUCLEO_L476RG : minor serial pin update https://github.com/ARMmbed/mbed-os/pull/4109
3982: Ticker - kl25z bugfix for handling events in the past https://github.com/ARMmbed/mbed-os/pull/3982

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 122:f9eeca106725 1 /**
Kojto 122:f9eeca106725 2 ******************************************************************************
Kojto 122:f9eeca106725 3 * @file stm32l4xx_hal_lptim.h
Kojto 122:f9eeca106725 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.1
Kojto 122:f9eeca106725 6 * @date 31-May-2016
Kojto 122:f9eeca106725 7 * @brief Header file of LPTIM HAL module.
Kojto 122:f9eeca106725 8 ******************************************************************************
Kojto 122:f9eeca106725 9 * @attention
Kojto 122:f9eeca106725 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 122:f9eeca106725 12 *
Kojto 122:f9eeca106725 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 122:f9eeca106725 14 * are permitted provided that the following conditions are met:
Kojto 122:f9eeca106725 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 122:f9eeca106725 16 * this list of conditions and the following disclaimer.
Kojto 122:f9eeca106725 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 122:f9eeca106725 18 * this list of conditions and the following disclaimer in the documentation
Kojto 122:f9eeca106725 19 * and/or other materials provided with the distribution.
Kojto 122:f9eeca106725 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 122:f9eeca106725 21 * may be used to endorse or promote products derived from this software
Kojto 122:f9eeca106725 22 * without specific prior written permission.
Kojto 122:f9eeca106725 23 *
Kojto 122:f9eeca106725 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 122:f9eeca106725 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 122:f9eeca106725 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 122:f9eeca106725 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 122:f9eeca106725 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 122:f9eeca106725 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 122:f9eeca106725 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 122:f9eeca106725 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 122:f9eeca106725 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 122:f9eeca106725 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 122:f9eeca106725 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
Kojto 122:f9eeca106725 37
Kojto 122:f9eeca106725 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 122:f9eeca106725 39 #ifndef __STM32L4xx_HAL_LPTIM_H
Kojto 122:f9eeca106725 40 #define __STM32L4xx_HAL_LPTIM_H
Kojto 122:f9eeca106725 41
Kojto 122:f9eeca106725 42 #ifdef __cplusplus
Kojto 122:f9eeca106725 43 extern "C" {
Kojto 122:f9eeca106725 44 #endif
Kojto 122:f9eeca106725 45
Kojto 122:f9eeca106725 46 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 47 #include "stm32l4xx_hal_def.h"
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /** @addtogroup STM32L4xx_HAL_Driver
Kojto 122:f9eeca106725 50 * @{
Kojto 122:f9eeca106725 51 */
Kojto 122:f9eeca106725 52
Kojto 122:f9eeca106725 53 /** @addtogroup LPTIM
Kojto 122:f9eeca106725 54 * @{
Kojto 122:f9eeca106725 55 */
Kojto 122:f9eeca106725 56
Kojto 122:f9eeca106725 57 /* Exported types ------------------------------------------------------------*/
Kojto 122:f9eeca106725 58 /** @defgroup LPTIM_Exported_Types LPTIM Exported Types
Kojto 122:f9eeca106725 59 * @{
Kojto 122:f9eeca106725 60 */
Kojto 122:f9eeca106725 61
Kojto 122:f9eeca106725 62 /**
Kojto 122:f9eeca106725 63 * @brief LPTIM Clock configuration definition
Kojto 122:f9eeca106725 64 */
Kojto 122:f9eeca106725 65 typedef struct
Kojto 122:f9eeca106725 66 {
Kojto 122:f9eeca106725 67 uint32_t Source; /*!< Selects the clock source.
Kojto 122:f9eeca106725 68 This parameter can be a value of @ref LPTIM_Clock_Source */
Kojto 122:f9eeca106725 69
Kojto 122:f9eeca106725 70 uint32_t Prescaler; /*!< Specifies the counter clock Prescaler.
Kojto 122:f9eeca106725 71 This parameter can be a value of @ref LPTIM_Clock_Prescaler */
Kojto 122:f9eeca106725 72
Kojto 122:f9eeca106725 73 }LPTIM_ClockConfigTypeDef;
Kojto 122:f9eeca106725 74
Kojto 122:f9eeca106725 75 /**
Kojto 122:f9eeca106725 76 * @brief LPTIM Clock configuration definition
Kojto 122:f9eeca106725 77 */
Kojto 122:f9eeca106725 78 typedef struct
Kojto 122:f9eeca106725 79 {
Kojto 122:f9eeca106725 80 uint32_t Polarity; /*!< Selects the polarity of the active edge for the counter unit
Kojto 122:f9eeca106725 81 if the ULPTIM input is selected.
Kojto 122:f9eeca106725 82 Note: This parameter is used only when Ultra low power clock source is used.
Kojto 122:f9eeca106725 83 Note: If the polarity is configured on 'both edges', an auxiliary clock
Kojto 122:f9eeca106725 84 (one of the Low power oscillator) must be active.
Kojto 122:f9eeca106725 85 This parameter can be a value of @ref LPTIM_Clock_Polarity */
Kojto 122:f9eeca106725 86
Kojto 122:f9eeca106725 87 uint32_t SampleTime; /*!< Selects the clock sampling time to configure the clock glitch filter.
Kojto 122:f9eeca106725 88 Note: This parameter is used only when Ultra low power clock source is used.
Kojto 122:f9eeca106725 89 This parameter can be a value of @ref LPTIM_Clock_Sample_Time */
Kojto 122:f9eeca106725 90
Kojto 122:f9eeca106725 91 }LPTIM_ULPClockConfigTypeDef;
Kojto 122:f9eeca106725 92
Kojto 122:f9eeca106725 93 /**
Kojto 122:f9eeca106725 94 * @brief LPTIM Trigger configuration definition
Kojto 122:f9eeca106725 95 */
Kojto 122:f9eeca106725 96 typedef struct
Kojto 122:f9eeca106725 97 {
Kojto 122:f9eeca106725 98 uint32_t Source; /*!< Selects the Trigger source.
Kojto 122:f9eeca106725 99 This parameter can be a value of @ref LPTIM_Trigger_Source */
Kojto 122:f9eeca106725 100
Kojto 122:f9eeca106725 101 uint32_t ActiveEdge; /*!< Selects the Trigger active edge.
Kojto 122:f9eeca106725 102 Note: This parameter is used only when an external trigger is used.
Kojto 122:f9eeca106725 103 This parameter can be a value of @ref LPTIM_External_Trigger_Polarity */
Kojto 122:f9eeca106725 104
Kojto 122:f9eeca106725 105 uint32_t SampleTime; /*!< Selects the trigger sampling time to configure the clock glitch filter.
Kojto 122:f9eeca106725 106 Note: This parameter is used only when an external trigger is used.
Kojto 122:f9eeca106725 107 This parameter can be a value of @ref LPTIM_Trigger_Sample_Time */
Kojto 122:f9eeca106725 108 }LPTIM_TriggerConfigTypeDef;
Kojto 122:f9eeca106725 109
Kojto 122:f9eeca106725 110 /**
Kojto 122:f9eeca106725 111 * @brief LPTIM Initialization Structure definition
Kojto 122:f9eeca106725 112 */
Kojto 122:f9eeca106725 113 typedef struct
Kojto 122:f9eeca106725 114 {
Kojto 122:f9eeca106725 115 LPTIM_ClockConfigTypeDef Clock; /*!< Specifies the clock parameters */
Kojto 122:f9eeca106725 116
Kojto 122:f9eeca106725 117 LPTIM_ULPClockConfigTypeDef UltraLowPowerClock; /*!< Specifies the Ultra Low Power clock parameters */
Kojto 122:f9eeca106725 118
Kojto 122:f9eeca106725 119 LPTIM_TriggerConfigTypeDef Trigger; /*!< Specifies the Trigger parameters */
Kojto 122:f9eeca106725 120
Kojto 122:f9eeca106725 121 uint32_t OutputPolarity; /*!< Specifies the Output polarity.
Kojto 122:f9eeca106725 122 This parameter can be a value of @ref LPTIM_Output_Polarity */
Kojto 122:f9eeca106725 123
Kojto 122:f9eeca106725 124 uint32_t UpdateMode; /*!< Specifies whether the update of the autoreload and the compare
Kojto 122:f9eeca106725 125 values is done immediately or after the end of current period.
Kojto 122:f9eeca106725 126 This parameter can be a value of @ref LPTIM_Updating_Mode */
Kojto 122:f9eeca106725 127
Kojto 122:f9eeca106725 128 uint32_t CounterSource; /*!< Specifies whether the counter is incremented each internal event
Kojto 122:f9eeca106725 129 or each external event.
Kojto 122:f9eeca106725 130 This parameter can be a value of @ref LPTIM_Counter_Source */
Kojto 122:f9eeca106725 131
Kojto 122:f9eeca106725 132 uint32_t Input1Source; /*!< Specifies source selected for input1 (GPIO or comparator output).
Kojto 122:f9eeca106725 133 This parameter can be a value of @ref LPTIM_Input1_Source */
Kojto 122:f9eeca106725 134
Kojto 122:f9eeca106725 135 uint32_t Input2Source; /*!< Specifies source selected for input2 (GPIO or comparator output).
Kojto 122:f9eeca106725 136 Note: This parameter is used only for encoder feature so is used only
Kojto 122:f9eeca106725 137 for LPTIM1 instance.
Kojto 122:f9eeca106725 138 This parameter can be a value of @ref LPTIM_Input2_Source */
Kojto 122:f9eeca106725 139
Kojto 122:f9eeca106725 140 }LPTIM_InitTypeDef;
Kojto 122:f9eeca106725 141
Kojto 122:f9eeca106725 142 /**
Kojto 122:f9eeca106725 143 * @brief HAL LPTIM State structure definition
Kojto 122:f9eeca106725 144 */
Kojto 122:f9eeca106725 145 typedef enum __HAL_LPTIM_StateTypeDef
Kojto 122:f9eeca106725 146 {
Kojto 122:f9eeca106725 147 HAL_LPTIM_STATE_RESET = 0x00, /*!< Peripheral not yet initialized or disabled */
Kojto 122:f9eeca106725 148 HAL_LPTIM_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
Kojto 122:f9eeca106725 149 HAL_LPTIM_STATE_BUSY = 0x02, /*!< An internal process is ongoing */
Kojto 122:f9eeca106725 150 HAL_LPTIM_STATE_TIMEOUT = 0x03, /*!< Timeout state */
Kojto 122:f9eeca106725 151 HAL_LPTIM_STATE_ERROR = 0x04 /*!< Internal Process is ongoing */
Kojto 122:f9eeca106725 152 }HAL_LPTIM_StateTypeDef;
Kojto 122:f9eeca106725 153
Kojto 122:f9eeca106725 154 /**
Kojto 122:f9eeca106725 155 * @brief LPTIM handle Structure definition
Kojto 122:f9eeca106725 156 */
Kojto 122:f9eeca106725 157 typedef struct
Kojto 122:f9eeca106725 158 {
Kojto 122:f9eeca106725 159 LPTIM_TypeDef *Instance; /*!< Register base address */
Kojto 122:f9eeca106725 160
Kojto 122:f9eeca106725 161 LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */
Kojto 122:f9eeca106725 162
Kojto 122:f9eeca106725 163 HAL_StatusTypeDef Status; /*!< LPTIM peripheral status */
Kojto 122:f9eeca106725 164
Kojto 122:f9eeca106725 165 HAL_LockTypeDef Lock; /*!< LPTIM locking object */
Kojto 122:f9eeca106725 166
Kojto 122:f9eeca106725 167 __IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */
Kojto 122:f9eeca106725 168
Kojto 122:f9eeca106725 169 }LPTIM_HandleTypeDef;
Kojto 122:f9eeca106725 170
Kojto 122:f9eeca106725 171 /**
Kojto 122:f9eeca106725 172 * @}
Kojto 122:f9eeca106725 173 */
Kojto 122:f9eeca106725 174
Kojto 122:f9eeca106725 175 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 176 /** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
Kojto 122:f9eeca106725 177 * @{
Kojto 122:f9eeca106725 178 */
Kojto 122:f9eeca106725 179
Kojto 122:f9eeca106725 180 /** @defgroup LPTIM_Clock_Source LPTIM Clock Source
Kojto 122:f9eeca106725 181 * @{
Kojto 122:f9eeca106725 182 */
Kojto 122:f9eeca106725 183 #define LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC ((uint32_t)0x00)
Kojto 122:f9eeca106725 184 #define LPTIM_CLOCKSOURCE_ULPTIM LPTIM_CFGR_CKSEL
Kojto 122:f9eeca106725 185 /**
Kojto 122:f9eeca106725 186 * @}
Kojto 122:f9eeca106725 187 */
Kojto 122:f9eeca106725 188
Kojto 122:f9eeca106725 189 /** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
Kojto 122:f9eeca106725 190 * @{
Kojto 122:f9eeca106725 191 */
Kojto 122:f9eeca106725 192 #define LPTIM_PRESCALER_DIV1 ((uint32_t)0x000000)
Kojto 122:f9eeca106725 193 #define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0
Kojto 122:f9eeca106725 194 #define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1
Kojto 122:f9eeca106725 195 #define LPTIM_PRESCALER_DIV8 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1))
Kojto 122:f9eeca106725 196 #define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2
Kojto 122:f9eeca106725 197 #define LPTIM_PRESCALER_DIV32 ((uint32_t)(LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2))
Kojto 122:f9eeca106725 198 #define LPTIM_PRESCALER_DIV64 ((uint32_t)(LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2))
Kojto 122:f9eeca106725 199 #define LPTIM_PRESCALER_DIV128 ((uint32_t)LPTIM_CFGR_PRESC)
Kojto 122:f9eeca106725 200 /**
Kojto 122:f9eeca106725 201 * @}
Kojto 122:f9eeca106725 202 */
Kojto 122:f9eeca106725 203
Kojto 122:f9eeca106725 204 /** @defgroup LPTIM_Output_Polarity LPTIM Output Polarity
Kojto 122:f9eeca106725 205 * @{
Kojto 122:f9eeca106725 206 */
Kojto 122:f9eeca106725 207
Kojto 122:f9eeca106725 208 #define LPTIM_OUTPUTPOLARITY_HIGH ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 209 #define LPTIM_OUTPUTPOLARITY_LOW (LPTIM_CFGR_WAVPOL)
Kojto 122:f9eeca106725 210 /**
Kojto 122:f9eeca106725 211 * @}
Kojto 122:f9eeca106725 212 */
Kojto 122:f9eeca106725 213
Kojto 122:f9eeca106725 214 /** @defgroup LPTIM_Clock_Sample_Time LPTIM Clock Sample Time
Kojto 122:f9eeca106725 215 * @{
Kojto 122:f9eeca106725 216 */
Kojto 122:f9eeca106725 217 #define LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 218 #define LPTIM_CLOCKSAMPLETIME_2TRANSITIONS LPTIM_CFGR_CKFLT_0
Kojto 122:f9eeca106725 219 #define LPTIM_CLOCKSAMPLETIME_4TRANSITIONS LPTIM_CFGR_CKFLT_1
Kojto 122:f9eeca106725 220 #define LPTIM_CLOCKSAMPLETIME_8TRANSITIONS LPTIM_CFGR_CKFLT
Kojto 122:f9eeca106725 221 /**
Kojto 122:f9eeca106725 222 * @}
Kojto 122:f9eeca106725 223 */
Kojto 122:f9eeca106725 224
Kojto 122:f9eeca106725 225 /** @defgroup LPTIM_Clock_Polarity LPTIM Clock Polarity
Kojto 122:f9eeca106725 226 * @{
Kojto 122:f9eeca106725 227 */
Kojto 122:f9eeca106725 228 #define LPTIM_CLOCKPOLARITY_RISING ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 229 #define LPTIM_CLOCKPOLARITY_FALLING LPTIM_CFGR_CKPOL_0
Kojto 122:f9eeca106725 230 #define LPTIM_CLOCKPOLARITY_RISING_FALLING LPTIM_CFGR_CKPOL_1
Kojto 122:f9eeca106725 231 /**
Kojto 122:f9eeca106725 232 * @}
Kojto 122:f9eeca106725 233 */
Kojto 122:f9eeca106725 234
Kojto 122:f9eeca106725 235 /** @defgroup LPTIM_Trigger_Source LPTIM Trigger Source
Kojto 122:f9eeca106725 236 * @{
Kojto 122:f9eeca106725 237 */
Kojto 122:f9eeca106725 238 #define LPTIM_TRIGSOURCE_SOFTWARE ((uint32_t)0x0000FFFF)
Kojto 122:f9eeca106725 239 #define LPTIM_TRIGSOURCE_0 ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 240 #define LPTIM_TRIGSOURCE_1 ((uint32_t)LPTIM_CFGR_TRIGSEL_0)
Kojto 122:f9eeca106725 241 #define LPTIM_TRIGSOURCE_2 LPTIM_CFGR_TRIGSEL_1
Kojto 122:f9eeca106725 242 #define LPTIM_TRIGSOURCE_3 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_1)
Kojto 122:f9eeca106725 243 #define LPTIM_TRIGSOURCE_4 LPTIM_CFGR_TRIGSEL_2
Kojto 122:f9eeca106725 244 #define LPTIM_TRIGSOURCE_5 ((uint32_t)LPTIM_CFGR_TRIGSEL_0 | LPTIM_CFGR_TRIGSEL_2)
Kojto 122:f9eeca106725 245 #define LPTIM_TRIGSOURCE_6 ((uint32_t)LPTIM_CFGR_TRIGSEL_1 | LPTIM_CFGR_TRIGSEL_2)
Kojto 122:f9eeca106725 246 #define LPTIM_TRIGSOURCE_7 LPTIM_CFGR_TRIGSEL
Kojto 122:f9eeca106725 247 /**
Kojto 122:f9eeca106725 248 * @}
Kojto 122:f9eeca106725 249 */
Kojto 122:f9eeca106725 250
Kojto 122:f9eeca106725 251 /** @defgroup LPTIM_External_Trigger_Polarity LPTIM External Trigger Polarity
Kojto 122:f9eeca106725 252 * @{
Kojto 122:f9eeca106725 253 */
Kojto 122:f9eeca106725 254 #define LPTIM_ACTIVEEDGE_RISING LPTIM_CFGR_TRIGEN_0
Kojto 122:f9eeca106725 255 #define LPTIM_ACTIVEEDGE_FALLING LPTIM_CFGR_TRIGEN_1
Kojto 122:f9eeca106725 256 #define LPTIM_ACTIVEEDGE_RISING_FALLING LPTIM_CFGR_TRIGEN
Kojto 122:f9eeca106725 257 /**
Kojto 122:f9eeca106725 258 * @}
Kojto 122:f9eeca106725 259 */
Kojto 122:f9eeca106725 260
Kojto 122:f9eeca106725 261 /** @defgroup LPTIM_Trigger_Sample_Time LPTIM Trigger Sample Time
Kojto 122:f9eeca106725 262 * @{
Kojto 122:f9eeca106725 263 */
Kojto 122:f9eeca106725 264 #define LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 265 #define LPTIM_TRIGSAMPLETIME_2TRANSITIONS LPTIM_CFGR_TRGFLT_0
Kojto 122:f9eeca106725 266 #define LPTIM_TRIGSAMPLETIME_4TRANSITIONS LPTIM_CFGR_TRGFLT_1
Kojto 122:f9eeca106725 267 #define LPTIM_TRIGSAMPLETIME_8TRANSITIONS LPTIM_CFGR_TRGFLT
Kojto 122:f9eeca106725 268 /**
Kojto 122:f9eeca106725 269 * @}
Kojto 122:f9eeca106725 270 */
Kojto 122:f9eeca106725 271
Kojto 122:f9eeca106725 272 /** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
Kojto 122:f9eeca106725 273 * @{
Kojto 122:f9eeca106725 274 */
Kojto 122:f9eeca106725 275
Kojto 122:f9eeca106725 276 #define LPTIM_UPDATE_IMMEDIATE ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 277 #define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD
Kojto 122:f9eeca106725 278 /**
Kojto 122:f9eeca106725 279 * @}
Kojto 122:f9eeca106725 280 */
Kojto 122:f9eeca106725 281
Kojto 122:f9eeca106725 282 /** @defgroup LPTIM_Counter_Source LPTIM Counter Source
Kojto 122:f9eeca106725 283 * @{
Kojto 122:f9eeca106725 284 */
Kojto 122:f9eeca106725 285
Kojto 122:f9eeca106725 286 #define LPTIM_COUNTERSOURCE_INTERNAL ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 287 #define LPTIM_COUNTERSOURCE_EXTERNAL LPTIM_CFGR_COUNTMODE
Kojto 122:f9eeca106725 288 /**
Kojto 122:f9eeca106725 289 * @}
Kojto 122:f9eeca106725 290 */
Kojto 122:f9eeca106725 291
Kojto 122:f9eeca106725 292 /** @defgroup LPTIM_Input1_Source LPTIM Input1 Source
Kojto 122:f9eeca106725 293 * @{
Kojto 122:f9eeca106725 294 */
Kojto 122:f9eeca106725 295
Kojto 122:f9eeca106725 296 #define LPTIM_INPUT1SOURCE_GPIO ((uint32_t)0x00000000) /*!< For LPTIM1 and LPTIM2 */
Kojto 122:f9eeca106725 297 #define LPTIM_INPUT1SOURCE_COMP1 LPTIM_OR_OR_0 /*!< For LPTIM1 and LPTIM2 */
Kojto 122:f9eeca106725 298 #define LPTIM_INPUT1SOURCE_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM2 */
Kojto 122:f9eeca106725 299 #define LPTIM_INPUT1SOURCE_COMP1_COMP2 LPTIM_OR_OR /*!< For LPTIM2 */
Kojto 122:f9eeca106725 300 /**
Kojto 122:f9eeca106725 301 * @}
Kojto 122:f9eeca106725 302 */
Kojto 122:f9eeca106725 303
Kojto 122:f9eeca106725 304 /** @defgroup LPTIM_Input2_Source LPTIM Input2 Source
Kojto 122:f9eeca106725 305 * @{
Kojto 122:f9eeca106725 306 */
Kojto 122:f9eeca106725 307
Kojto 122:f9eeca106725 308 #define LPTIM_INPUT2SOURCE_GPIO ((uint32_t)0x00000000) /*!< For LPTIM1 */
Kojto 122:f9eeca106725 309 #define LPTIM_INPUT2SOURCE_COMP2 LPTIM_OR_OR_1 /*!< For LPTIM1 */
Kojto 122:f9eeca106725 310 /**
Kojto 122:f9eeca106725 311 * @}
Kojto 122:f9eeca106725 312 */
Kojto 122:f9eeca106725 313
Kojto 122:f9eeca106725 314 /** @defgroup LPTIM_Flag_Definition LPTIM Flags Definition
Kojto 122:f9eeca106725 315 * @{
Kojto 122:f9eeca106725 316 */
Kojto 122:f9eeca106725 317
Kojto 122:f9eeca106725 318 #define LPTIM_FLAG_DOWN LPTIM_ISR_DOWN
Kojto 122:f9eeca106725 319 #define LPTIM_FLAG_UP LPTIM_ISR_UP
Kojto 122:f9eeca106725 320 #define LPTIM_FLAG_ARROK LPTIM_ISR_ARROK
Kojto 122:f9eeca106725 321 #define LPTIM_FLAG_CMPOK LPTIM_ISR_CMPOK
Kojto 122:f9eeca106725 322 #define LPTIM_FLAG_EXTTRIG LPTIM_ISR_EXTTRIG
Kojto 122:f9eeca106725 323 #define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
Kojto 122:f9eeca106725 324 #define LPTIM_FLAG_CMPM LPTIM_ISR_CMPM
Kojto 122:f9eeca106725 325 /**
Kojto 122:f9eeca106725 326 * @}
Kojto 122:f9eeca106725 327 */
Kojto 122:f9eeca106725 328
Kojto 122:f9eeca106725 329 /** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
Kojto 122:f9eeca106725 330 * @{
Kojto 122:f9eeca106725 331 */
Kojto 122:f9eeca106725 332
Kojto 122:f9eeca106725 333 #define LPTIM_IT_DOWN LPTIM_IER_DOWNIE
Kojto 122:f9eeca106725 334 #define LPTIM_IT_UP LPTIM_IER_UPIE
Kojto 122:f9eeca106725 335 #define LPTIM_IT_ARROK LPTIM_IER_ARROKIE
Kojto 122:f9eeca106725 336 #define LPTIM_IT_CMPOK LPTIM_IER_CMPOKIE
Kojto 122:f9eeca106725 337 #define LPTIM_IT_EXTTRIG LPTIM_IER_EXTTRIGIE
Kojto 122:f9eeca106725 338 #define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
Kojto 122:f9eeca106725 339 #define LPTIM_IT_CMPM LPTIM_IER_CMPMIE
Kojto 122:f9eeca106725 340 /**
Kojto 122:f9eeca106725 341 * @}
Kojto 122:f9eeca106725 342 */
Kojto 122:f9eeca106725 343
Kojto 122:f9eeca106725 344 /**
Kojto 122:f9eeca106725 345 * @}
Kojto 122:f9eeca106725 346 */
Kojto 122:f9eeca106725 347
Kojto 122:f9eeca106725 348 /* Exported macros -----------------------------------------------------------*/
Kojto 122:f9eeca106725 349 /** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
Kojto 122:f9eeca106725 350 * @{
Kojto 122:f9eeca106725 351 */
Kojto 122:f9eeca106725 352
Kojto 122:f9eeca106725 353 /** @brief Reset LPTIM handle state.
Kojto 122:f9eeca106725 354 * @param __HANDLE__: LPTIM handle
Kojto 122:f9eeca106725 355 * @retval None
Kojto 122:f9eeca106725 356 */
Kojto 122:f9eeca106725 357 #define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
Kojto 122:f9eeca106725 358
Kojto 122:f9eeca106725 359 /**
Kojto 122:f9eeca106725 360 * @brief Enable the LPTIM peripheral.
Kojto 122:f9eeca106725 361 * @param __HANDLE__: LPTIM handle
Kojto 122:f9eeca106725 362 * @retval None
Kojto 122:f9eeca106725 363 */
Kojto 122:f9eeca106725 364 #define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
Kojto 122:f9eeca106725 365
Kojto 122:f9eeca106725 366 /**
Kojto 122:f9eeca106725 367 * @brief Disable the LPTIM peripheral.
Kojto 122:f9eeca106725 368 * @param __HANDLE__: LPTIM handle
Kojto 122:f9eeca106725 369 * @retval None
Kojto 122:f9eeca106725 370 */
Kojto 122:f9eeca106725 371 #define __HAL_LPTIM_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(LPTIM_CR_ENABLE))
Kojto 122:f9eeca106725 372
Kojto 122:f9eeca106725 373 /**
Kojto 122:f9eeca106725 374 * @brief Start the LPTIM peripheral in Continuous or in single mode.
Kojto 122:f9eeca106725 375 * @param __HANDLE__: DMA handle
Kojto 122:f9eeca106725 376 * @retval None
Kojto 122:f9eeca106725 377 */
Kojto 122:f9eeca106725 378 #define __HAL_LPTIM_START_CONTINUOUS(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_CNTSTRT)
Kojto 122:f9eeca106725 379 #define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT)
Kojto 122:f9eeca106725 380
Kojto 122:f9eeca106725 381
Kojto 122:f9eeca106725 382 /**
Kojto 122:f9eeca106725 383 * @brief Write the passed parameter in the Autoreload register.
Kojto 122:f9eeca106725 384 * @param __HANDLE__: LPTIM handle
Kojto 122:f9eeca106725 385 * @param __VALUE__: Autoreload value
Kojto 122:f9eeca106725 386 * @retval None
Kojto 122:f9eeca106725 387 */
Kojto 122:f9eeca106725 388 #define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__))
Kojto 122:f9eeca106725 389
Kojto 122:f9eeca106725 390 /**
Kojto 122:f9eeca106725 391 * @brief Write the passed parameter in the Compare register.
Kojto 122:f9eeca106725 392 * @param __HANDLE__: LPTIM handle
Kojto 122:f9eeca106725 393 * @param __VALUE__: Compare value
Kojto 122:f9eeca106725 394 * @retval None
Kojto 122:f9eeca106725 395 */
Kojto 122:f9eeca106725 396 #define __HAL_LPTIM_COMPARE_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->CMP = (__VALUE__))
Kojto 122:f9eeca106725 397
Kojto 122:f9eeca106725 398 /**
Kojto 122:f9eeca106725 399 * @brief Check whether the specified LPTIM flag is set or not.
Kojto 122:f9eeca106725 400 * @param __HANDLE__: LPTIM handle
Kojto 122:f9eeca106725 401 * @param __FLAG__: LPTIM flag to check
Kojto 122:f9eeca106725 402 * This parameter can be a value of:
Kojto 122:f9eeca106725 403 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
Kojto 122:f9eeca106725 404 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
Kojto 122:f9eeca106725 405 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
Kojto 122:f9eeca106725 406 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
Kojto 122:f9eeca106725 407 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
Kojto 122:f9eeca106725 408 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
Kojto 122:f9eeca106725 409 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
Kojto 122:f9eeca106725 410 * @retval The state of the specified flag (SET or RESET).
Kojto 122:f9eeca106725 411 */
Kojto 122:f9eeca106725 412 #define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
Kojto 122:f9eeca106725 413
Kojto 122:f9eeca106725 414 /**
Kojto 122:f9eeca106725 415 * @brief Clear the specified LPTIM flag.
Kojto 122:f9eeca106725 416 * @param __HANDLE__: LPTIM handle.
Kojto 122:f9eeca106725 417 * @param __FLAG__: LPTIM flag to clear.
Kojto 122:f9eeca106725 418 * This parameter can be a value of:
Kojto 122:f9eeca106725 419 * @arg LPTIM_FLAG_DOWN : Counter direction change up Flag.
Kojto 122:f9eeca106725 420 * @arg LPTIM_FLAG_UP : Counter direction change down to up Flag.
Kojto 122:f9eeca106725 421 * @arg LPTIM_FLAG_ARROK : Autoreload register update OK Flag.
Kojto 122:f9eeca106725 422 * @arg LPTIM_FLAG_CMPOK : Compare register update OK Flag.
Kojto 122:f9eeca106725 423 * @arg LPTIM_FLAG_EXTTRIG : External trigger edge event Flag.
Kojto 122:f9eeca106725 424 * @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
Kojto 122:f9eeca106725 425 * @arg LPTIM_FLAG_CMPM : Compare match Flag.
Kojto 122:f9eeca106725 426 * @retval None
Kojto 122:f9eeca106725 427 */
Kojto 122:f9eeca106725 428 #define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
Kojto 122:f9eeca106725 429
Kojto 122:f9eeca106725 430 /**
Kojto 122:f9eeca106725 431 * @brief Enable the specified LPTIM interrupt.
Kojto 122:f9eeca106725 432 * @param __HANDLE__: LPTIM handle.
Kojto 122:f9eeca106725 433 * @param __INTERRUPT__: LPTIM interrupt to set.
Kojto 122:f9eeca106725 434 * This parameter can be a value of:
Kojto 122:f9eeca106725 435 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
Kojto 122:f9eeca106725 436 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
Kojto 122:f9eeca106725 437 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
Kojto 122:f9eeca106725 438 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
Kojto 122:f9eeca106725 439 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
Kojto 122:f9eeca106725 440 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
Kojto 122:f9eeca106725 441 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
Kojto 122:f9eeca106725 442 * @retval None
Kojto 122:f9eeca106725 443 */
Kojto 122:f9eeca106725 444 #define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
Kojto 122:f9eeca106725 445
Kojto 122:f9eeca106725 446 /**
Kojto 122:f9eeca106725 447 * @brief Disable the specified LPTIM interrupt.
Kojto 122:f9eeca106725 448 * @param __HANDLE__: LPTIM handle.
Kojto 122:f9eeca106725 449 * @param __INTERRUPT__: LPTIM interrupt to set.
Kojto 122:f9eeca106725 450 * This parameter can be a value of:
Kojto 122:f9eeca106725 451 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
Kojto 122:f9eeca106725 452 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
Kojto 122:f9eeca106725 453 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
Kojto 122:f9eeca106725 454 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
Kojto 122:f9eeca106725 455 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
Kojto 122:f9eeca106725 456 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
Kojto 122:f9eeca106725 457 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
Kojto 122:f9eeca106725 458 * @retval None
Kojto 122:f9eeca106725 459 */
Kojto 122:f9eeca106725 460 #define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
Kojto 122:f9eeca106725 461
Kojto 122:f9eeca106725 462 /**
Kojto 122:f9eeca106725 463 * @brief Check whether the specified LPTIM interrupt source is enabled or not.
Kojto 122:f9eeca106725 464 * @param __HANDLE__: LPTIM handle.
Kojto 122:f9eeca106725 465 * @param __INTERRUPT__: LPTIM interrupt to check.
Kojto 122:f9eeca106725 466 * This parameter can be a value of:
Kojto 122:f9eeca106725 467 * @arg LPTIM_IT_DOWN : Counter direction change up Interrupt.
Kojto 122:f9eeca106725 468 * @arg LPTIM_IT_UP : Counter direction change down to up Interrupt.
Kojto 122:f9eeca106725 469 * @arg LPTIM_IT_ARROK : Autoreload register update OK Interrupt.
Kojto 122:f9eeca106725 470 * @arg LPTIM_IT_CMPOK : Compare register update OK Interrupt.
Kojto 122:f9eeca106725 471 * @arg LPTIM_IT_EXTTRIG : External trigger edge event Interrupt.
Kojto 122:f9eeca106725 472 * @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
Kojto 122:f9eeca106725 473 * @arg LPTIM_IT_CMPM : Compare match Interrupt.
Kojto 122:f9eeca106725 474 * @retval Interrupt status.
Kojto 122:f9eeca106725 475 */
Kojto 122:f9eeca106725 476
Kojto 122:f9eeca106725 477 #define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
Kojto 122:f9eeca106725 478
Kojto 122:f9eeca106725 479 /**
Kojto 122:f9eeca106725 480 * @}
Kojto 122:f9eeca106725 481 */
Kojto 122:f9eeca106725 482
Kojto 122:f9eeca106725 483 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 484 /** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
Kojto 122:f9eeca106725 485 * @{
Kojto 122:f9eeca106725 486 */
Kojto 122:f9eeca106725 487
Kojto 122:f9eeca106725 488 /* Initialization/de-initialization functions ********************************/
Kojto 122:f9eeca106725 489 HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 490 HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 491
Kojto 122:f9eeca106725 492 /* MSP functions *************************************************************/
Kojto 122:f9eeca106725 493 void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 494 void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 495
Kojto 122:f9eeca106725 496 /* Start/Stop operation functions *********************************************/
Kojto 122:f9eeca106725 497 /* ################################# PWM Mode ################################*/
Kojto 122:f9eeca106725 498 /* Blocking mode: Polling */
Kojto 122:f9eeca106725 499 HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
Kojto 122:f9eeca106725 500 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 501 /* Non-Blocking mode: Interrupt */
Kojto 122:f9eeca106725 502 HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
Kojto 122:f9eeca106725 503 HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 504
Kojto 122:f9eeca106725 505 /* ############################# One Pulse Mode ##############################*/
Kojto 122:f9eeca106725 506 /* Blocking mode: Polling */
Kojto 122:f9eeca106725 507 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
Kojto 122:f9eeca106725 508 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 509 /* Non-Blocking mode: Interrupt */
Kojto 122:f9eeca106725 510 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
Kojto 122:f9eeca106725 511 HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 512
Kojto 122:f9eeca106725 513 /* ############################## Set once Mode ##############################*/
Kojto 122:f9eeca106725 514 /* Blocking mode: Polling */
Kojto 122:f9eeca106725 515 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
Kojto 122:f9eeca106725 516 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 517 /* Non-Blocking mode: Interrupt */
Kojto 122:f9eeca106725 518 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Pulse);
Kojto 122:f9eeca106725 519 HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 520
Kojto 122:f9eeca106725 521 /* ############################### Encoder Mode ##############################*/
Kojto 122:f9eeca106725 522 /* Blocking mode: Polling */
Kojto 122:f9eeca106725 523 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
Kojto 122:f9eeca106725 524 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 525 /* Non-Blocking mode: Interrupt */
Kojto 122:f9eeca106725 526 HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
Kojto 122:f9eeca106725 527 HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 528
Kojto 122:f9eeca106725 529 /* ############################# Time out Mode ##############################*/
Kojto 122:f9eeca106725 530 /* Blocking mode: Polling */
Kojto 122:f9eeca106725 531 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
Kojto 122:f9eeca106725 532 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 533 /* Non-Blocking mode: Interrupt */
Kojto 122:f9eeca106725 534 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period, uint32_t Timeout);
Kojto 122:f9eeca106725 535 HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 536
Kojto 122:f9eeca106725 537 /* ############################## Counter Mode ###############################*/
Kojto 122:f9eeca106725 538 /* Blocking mode: Polling */
Kojto 122:f9eeca106725 539 HAL_StatusTypeDef HAL_LPTIM_Counter_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
Kojto 122:f9eeca106725 540 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 541 /* Non-Blocking mode: Interrupt */
Kojto 122:f9eeca106725 542 HAL_StatusTypeDef HAL_LPTIM_Counter_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
Kojto 122:f9eeca106725 543 HAL_StatusTypeDef HAL_LPTIM_Counter_Stop_IT(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 544
Kojto 122:f9eeca106725 545 /* Reading operation functions ************************************************/
Kojto 122:f9eeca106725 546 uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 547 uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 548 uint32_t HAL_LPTIM_ReadCompare(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 549
Kojto 122:f9eeca106725 550 /* LPTIM IRQ functions *******************************************************/
Kojto 122:f9eeca106725 551 void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 552
Kojto 122:f9eeca106725 553 /* CallBack functions ********************************************************/
Kojto 122:f9eeca106725 554 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 555 void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 556 void HAL_LPTIM_TriggerCallback(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 557 void HAL_LPTIM_CompareWriteCallback(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 558 void HAL_LPTIM_AutoReloadWriteCallback(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 559 void HAL_LPTIM_DirectionUpCallback(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 560 void HAL_LPTIM_DirectionDownCallback(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 561
Kojto 122:f9eeca106725 562 /* Peripheral State functions ************************************************/
Kojto 122:f9eeca106725 563 HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
Kojto 122:f9eeca106725 564
Kojto 122:f9eeca106725 565 /**
Kojto 122:f9eeca106725 566 * @}
Kojto 122:f9eeca106725 567 */
Kojto 122:f9eeca106725 568
Kojto 122:f9eeca106725 569 /* Private types -------------------------------------------------------------*/
Kojto 122:f9eeca106725 570 /** @defgroup LPTIM_Private_Types LPTIM Private Types
Kojto 122:f9eeca106725 571 * @{
Kojto 122:f9eeca106725 572 */
Kojto 122:f9eeca106725 573
Kojto 122:f9eeca106725 574 /**
Kojto 122:f9eeca106725 575 * @}
Kojto 122:f9eeca106725 576 */
Kojto 122:f9eeca106725 577
Kojto 122:f9eeca106725 578 /* Private variables ---------------------------------------------------------*/
Kojto 122:f9eeca106725 579 /** @defgroup LPTIM_Private_Variables LPTIM Private Variables
Kojto 122:f9eeca106725 580 * @{
Kojto 122:f9eeca106725 581 */
Kojto 122:f9eeca106725 582
Kojto 122:f9eeca106725 583 /**
Kojto 122:f9eeca106725 584 * @}
Kojto 122:f9eeca106725 585 */
Kojto 122:f9eeca106725 586
Kojto 122:f9eeca106725 587 /* Private constants ---------------------------------------------------------*/
Kojto 122:f9eeca106725 588 /** @defgroup LPTIM_Private_Constants LPTIM Private Constants
Kojto 122:f9eeca106725 589 * @{
Kojto 122:f9eeca106725 590 */
Kojto 122:f9eeca106725 591
Kojto 122:f9eeca106725 592 /**
Kojto 122:f9eeca106725 593 * @}
Kojto 122:f9eeca106725 594 */
Kojto 122:f9eeca106725 595
Kojto 122:f9eeca106725 596 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 597 /** @defgroup LPTIM_Private_Macros LPTIM Private Macros
Kojto 122:f9eeca106725 598 * @{
Kojto 122:f9eeca106725 599 */
Kojto 122:f9eeca106725 600
Kojto 122:f9eeca106725 601 #define IS_LPTIM_CLOCK_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_CLOCKSOURCE_ULPTIM) || \
Kojto 122:f9eeca106725 602 ((__SOURCE__) == LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC))
Kojto 122:f9eeca106725 603
Kojto 122:f9eeca106725 604
Kojto 122:f9eeca106725 605 #define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \
Kojto 122:f9eeca106725 606 ((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \
Kojto 122:f9eeca106725 607 ((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \
Kojto 122:f9eeca106725 608 ((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \
Kojto 122:f9eeca106725 609 ((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \
Kojto 122:f9eeca106725 610 ((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \
Kojto 122:f9eeca106725 611 ((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \
Kojto 122:f9eeca106725 612 ((__PRESCALER__) == LPTIM_PRESCALER_DIV128))
Kojto 122:f9eeca106725 613
Kojto 122:f9eeca106725 614 #define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1)
Kojto 122:f9eeca106725 615
Kojto 122:f9eeca106725 616 #define IS_LPTIM_OUTPUT_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_OUTPUTPOLARITY_LOW ) || \
Kojto 122:f9eeca106725 617 ((__POLARITY__) == LPTIM_OUTPUTPOLARITY_HIGH))
Kojto 122:f9eeca106725 618
Kojto 122:f9eeca106725 619 #define IS_LPTIM_CLOCK_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION) || \
Kojto 122:f9eeca106725 620 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_2TRANSITIONS) || \
Kojto 122:f9eeca106725 621 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_4TRANSITIONS) || \
Kojto 122:f9eeca106725 622 ((__SAMPLETIME__) == LPTIM_CLOCKSAMPLETIME_8TRANSITIONS))
Kojto 122:f9eeca106725 623
Kojto 122:f9eeca106725 624 #define IS_LPTIM_CLOCK_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING) || \
Kojto 122:f9eeca106725 625 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_FALLING) || \
Kojto 122:f9eeca106725 626 ((__POLARITY__) == LPTIM_CLOCKPOLARITY_RISING_FALLING))
Kojto 122:f9eeca106725 627
Kojto 122:f9eeca106725 628 #define IS_LPTIM_TRG_SOURCE(__TRIG__) (((__TRIG__) == LPTIM_TRIGSOURCE_SOFTWARE) || \
Kojto 122:f9eeca106725 629 ((__TRIG__) == LPTIM_TRIGSOURCE_0) || \
Kojto 122:f9eeca106725 630 ((__TRIG__) == LPTIM_TRIGSOURCE_1) || \
Kojto 122:f9eeca106725 631 ((__TRIG__) == LPTIM_TRIGSOURCE_2) || \
Kojto 122:f9eeca106725 632 ((__TRIG__) == LPTIM_TRIGSOURCE_3) || \
Kojto 122:f9eeca106725 633 ((__TRIG__) == LPTIM_TRIGSOURCE_4) || \
Kojto 122:f9eeca106725 634 ((__TRIG__) == LPTIM_TRIGSOURCE_5) || \
Kojto 122:f9eeca106725 635 ((__TRIG__) == LPTIM_TRIGSOURCE_6) || \
Kojto 122:f9eeca106725 636 ((__TRIG__) == LPTIM_TRIGSOURCE_7))
Kojto 122:f9eeca106725 637
Kojto 122:f9eeca106725 638 #define IS_LPTIM_EXT_TRG_POLARITY(__POLARITY__) (((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING ) || \
Kojto 122:f9eeca106725 639 ((__POLARITY__) == LPTIM_ACTIVEEDGE_FALLING ) || \
Kojto 122:f9eeca106725 640 ((__POLARITY__) == LPTIM_ACTIVEEDGE_RISING_FALLING ))
Kojto 122:f9eeca106725 641
Kojto 122:f9eeca106725 642 #define IS_LPTIM_TRIG_SAMPLE_TIME(__SAMPLETIME__) (((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION) || \
Kojto 122:f9eeca106725 643 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_2TRANSITIONS ) || \
Kojto 122:f9eeca106725 644 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_4TRANSITIONS ) || \
Kojto 122:f9eeca106725 645 ((__SAMPLETIME__) == LPTIM_TRIGSAMPLETIME_8TRANSITIONS ))
Kojto 122:f9eeca106725 646
Kojto 122:f9eeca106725 647 #define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
Kojto 122:f9eeca106725 648 ((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
Kojto 122:f9eeca106725 649
Kojto 122:f9eeca106725 650 #define IS_LPTIM_COUNTER_SOURCE(__SOURCE__) (((__SOURCE__) == LPTIM_COUNTERSOURCE_INTERNAL) || \
Kojto 122:f9eeca106725 651 ((__SOURCE__) == LPTIM_COUNTERSOURCE_EXTERNAL))
Kojto 122:f9eeca106725 652
Kojto 122:f9eeca106725 653 #define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFF)
Kojto 122:f9eeca106725 654
Kojto 122:f9eeca106725 655 #define IS_LPTIM_COMPARE(__COMPARE__) ((__COMPARE__) <= 0x0000FFFF)
Kojto 122:f9eeca106725 656
Kojto 122:f9eeca106725 657 #define IS_LPTIM_PERIOD(__PERIOD__) ((__PERIOD__) <= 0x0000FFFF)
Kojto 122:f9eeca106725 658
Kojto 122:f9eeca106725 659 #define IS_LPTIM_PULSE(__PULSE__) ((__PULSE__) <= 0x0000FFFF)
Kojto 122:f9eeca106725 660
Kojto 122:f9eeca106725 661 #define IS_LPTIM_INPUT1_SOURCE(__INSTANCE__, __SOURCE__) \
Kojto 122:f9eeca106725 662 ((((__INSTANCE__) == LPTIM1) && \
Kojto 122:f9eeca106725 663 (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \
Kojto 122:f9eeca106725 664 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1))) \
Kojto 122:f9eeca106725 665 || \
Kojto 122:f9eeca106725 666 (((__INSTANCE__) == LPTIM2) && \
Kojto 122:f9eeca106725 667 (((__SOURCE__) == LPTIM_INPUT1SOURCE_GPIO) || \
Kojto 122:f9eeca106725 668 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1) || \
Kojto 122:f9eeca106725 669 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP2) || \
Kojto 122:f9eeca106725 670 ((__SOURCE__) == LPTIM_INPUT1SOURCE_COMP1_COMP2))))
Kojto 122:f9eeca106725 671
Kojto 122:f9eeca106725 672 #define IS_LPTIM_INPUT2_SOURCE(__INSTANCE__, __SOURCE__) \
Kojto 122:f9eeca106725 673 (((__INSTANCE__) == LPTIM1) && \
Kojto 122:f9eeca106725 674 (((__SOURCE__) == LPTIM_INPUT2SOURCE_GPIO) || \
Kojto 122:f9eeca106725 675 ((__SOURCE__) == LPTIM_INPUT2SOURCE_COMP2)))
Kojto 122:f9eeca106725 676
Kojto 122:f9eeca106725 677 /**
Kojto 122:f9eeca106725 678 * @}
Kojto 122:f9eeca106725 679 */
Kojto 122:f9eeca106725 680
Kojto 122:f9eeca106725 681 /* Private functions ---------------------------------------------------------*/
Kojto 122:f9eeca106725 682 /** @defgroup LPTIM_Private_Functions LPTIM Private Functions
Kojto 122:f9eeca106725 683 * @{
Kojto 122:f9eeca106725 684 */
Kojto 122:f9eeca106725 685
Kojto 122:f9eeca106725 686 /**
Kojto 122:f9eeca106725 687 * @}
Kojto 122:f9eeca106725 688 */
Kojto 122:f9eeca106725 689
Kojto 122:f9eeca106725 690 /**
Kojto 122:f9eeca106725 691 * @}
Kojto 122:f9eeca106725 692 */
Kojto 122:f9eeca106725 693
Kojto 122:f9eeca106725 694 /**
Kojto 122:f9eeca106725 695 * @}
Kojto 122:f9eeca106725 696 */
Kojto 122:f9eeca106725 697
Kojto 122:f9eeca106725 698 #ifdef __cplusplus
Kojto 122:f9eeca106725 699 }
Kojto 122:f9eeca106725 700 #endif
Kojto 122:f9eeca106725 701
Kojto 122:f9eeca106725 702 #endif /* __STM32L4xx_HAL_LPTIM_H */
Kojto 122:f9eeca106725 703
Kojto 122:f9eeca106725 704 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/