fix LPC812 PWM

Dependents:   IR_LED_Send

Fork of mbed-dev by mbed official

Committer:
bogdanm
Date:
Thu Oct 01 15:25:22 2015 +0300
Revision:
0:9b334a45a8ff
Initial commit on mbed-dev

Replaces mbed-src (now inactive)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:9b334a45a8ff 1 /**
bogdanm 0:9b334a45a8ff 2 ******************************************************************************
bogdanm 0:9b334a45a8ff 3 * @file stm32f3xx_hal_comp.h
bogdanm 0:9b334a45a8ff 4 * @author MCD Application Team
bogdanm 0:9b334a45a8ff 5 * @version V1.1.0
bogdanm 0:9b334a45a8ff 6 * @date 12-Sept-2014
bogdanm 0:9b334a45a8ff 7 * @brief Header file of COMP HAL module.
bogdanm 0:9b334a45a8ff 8 ******************************************************************************
bogdanm 0:9b334a45a8ff 9 * @attention
bogdanm 0:9b334a45a8ff 10 *
bogdanm 0:9b334a45a8ff 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bogdanm 0:9b334a45a8ff 12 *
bogdanm 0:9b334a45a8ff 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 0:9b334a45a8ff 14 * are permitted provided that the following conditions are met:
bogdanm 0:9b334a45a8ff 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 0:9b334a45a8ff 16 * this list of conditions and the following disclaimer.
bogdanm 0:9b334a45a8ff 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 0:9b334a45a8ff 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 0:9b334a45a8ff 19 * and/or other materials provided with the distribution.
bogdanm 0:9b334a45a8ff 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 0:9b334a45a8ff 21 * may be used to endorse or promote products derived from this software
bogdanm 0:9b334a45a8ff 22 * without specific prior written permission.
bogdanm 0:9b334a45a8ff 23 *
bogdanm 0:9b334a45a8ff 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 0:9b334a45a8ff 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 0:9b334a45a8ff 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 0:9b334a45a8ff 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 0:9b334a45a8ff 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 0:9b334a45a8ff 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 0:9b334a45a8ff 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 0:9b334a45a8ff 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 0:9b334a45a8ff 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 0:9b334a45a8ff 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 0:9b334a45a8ff 34 *
bogdanm 0:9b334a45a8ff 35 ******************************************************************************
bogdanm 0:9b334a45a8ff 36 */
bogdanm 0:9b334a45a8ff 37
bogdanm 0:9b334a45a8ff 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 0:9b334a45a8ff 39 #ifndef __STM32F3xx_HAL_COMP_H
bogdanm 0:9b334a45a8ff 40 #define __STM32F3xx_HAL_COMP_H
bogdanm 0:9b334a45a8ff 41
bogdanm 0:9b334a45a8ff 42 #ifdef __cplusplus
bogdanm 0:9b334a45a8ff 43 extern "C" {
bogdanm 0:9b334a45a8ff 44 #endif
bogdanm 0:9b334a45a8ff 45
bogdanm 0:9b334a45a8ff 46 /* Includes ------------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 47 #include "stm32f3xx_hal_def.h"
bogdanm 0:9b334a45a8ff 48
bogdanm 0:9b334a45a8ff 49 /** @addtogroup STM32F3xx_HAL_Driver
bogdanm 0:9b334a45a8ff 50 * @{
bogdanm 0:9b334a45a8ff 51 */
bogdanm 0:9b334a45a8ff 52
bogdanm 0:9b334a45a8ff 53 /** @addtogroup COMP
bogdanm 0:9b334a45a8ff 54 * @{
bogdanm 0:9b334a45a8ff 55 */
bogdanm 0:9b334a45a8ff 56
bogdanm 0:9b334a45a8ff 57 /* Exported types ------------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 58 /** @defgroup COMP_Exported_Types COMP Exported Types
bogdanm 0:9b334a45a8ff 59 * @{
bogdanm 0:9b334a45a8ff 60 */
bogdanm 0:9b334a45a8ff 61 /**
bogdanm 0:9b334a45a8ff 62 * @brief COMP Init structure definition
bogdanm 0:9b334a45a8ff 63 */
bogdanm 0:9b334a45a8ff 64
bogdanm 0:9b334a45a8ff 65 typedef struct
bogdanm 0:9b334a45a8ff 66 {
bogdanm 0:9b334a45a8ff 67
bogdanm 0:9b334a45a8ff 68 uint32_t InvertingInput; /*!< Selects the inverting input of the comparator.
bogdanm 0:9b334a45a8ff 69 This parameter can be a value of @ref COMPEx_InvertingInput */
bogdanm 0:9b334a45a8ff 70
bogdanm 0:9b334a45a8ff 71 uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator.
bogdanm 0:9b334a45a8ff 72 This parameter can be a value of @ref COMPEx_NonInvertingInput
bogdanm 0:9b334a45a8ff 73 Note: Only available on STM32F302xB/xC, STM32F303xB/xC and STM32F358xx devices */
bogdanm 0:9b334a45a8ff 74
bogdanm 0:9b334a45a8ff 75 uint32_t Output; /*!< Selects the output redirection of the comparator.
bogdanm 0:9b334a45a8ff 76 This parameter can be a value of @ref COMPEx_Output */
bogdanm 0:9b334a45a8ff 77
bogdanm 0:9b334a45a8ff 78 uint32_t OutputPol; /*!< Selects the output polarity of the comparator.
bogdanm 0:9b334a45a8ff 79 This parameter can be a value of @ref COMP_OutputPolarity */
bogdanm 0:9b334a45a8ff 80
bogdanm 0:9b334a45a8ff 81 uint32_t Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
bogdanm 0:9b334a45a8ff 82 This parameter can be a value of @ref COMPEx_Hysteresis
bogdanm 0:9b334a45a8ff 83 Note: Only available on STM32F302xB/xC, STM32F303xB/xC, STM32F373xB/xC, STM32F358xx and STM32F378xx devices */
bogdanm 0:9b334a45a8ff 84
bogdanm 0:9b334a45a8ff 85 uint32_t BlankingSrce; /*!< Selects the output blanking source of the comparator.
bogdanm 0:9b334a45a8ff 86 This parameter can be a value of @ref COMPEx_BlankingSrce
bogdanm 0:9b334a45a8ff 87 Note: Not available on STM32F373xB/C and STM32F378xx devices */
bogdanm 0:9b334a45a8ff 88
bogdanm 0:9b334a45a8ff 89 uint32_t Mode; /*!< Selects the operating comsumption mode of the comparator
bogdanm 0:9b334a45a8ff 90 to adjust the speed/consumption.
bogdanm 0:9b334a45a8ff 91 This parameter can be a value of @ref COMPEx_Mode
bogdanm 0:9b334a45a8ff 92 Note: Not available on STM32F301x6/x8, STM32F302x6/x8, STM32F334x6/x8, STM32F318xx and STM32F328xx devices */
bogdanm 0:9b334a45a8ff 93
bogdanm 0:9b334a45a8ff 94 uint32_t WindowMode; /*!< Selects the window mode of the comparator X (X=2, 4 or 6 if available).
bogdanm 0:9b334a45a8ff 95 This parameter can be a value of @ref COMPEx_WindowMode */
bogdanm 0:9b334a45a8ff 96
bogdanm 0:9b334a45a8ff 97 uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode).
bogdanm 0:9b334a45a8ff 98 This parameter can be a value of @ref COMP_TriggerMode */
bogdanm 0:9b334a45a8ff 99
bogdanm 0:9b334a45a8ff 100 }COMP_InitTypeDef;
bogdanm 0:9b334a45a8ff 101
bogdanm 0:9b334a45a8ff 102 /**
bogdanm 0:9b334a45a8ff 103 * @brief HAL State structures definition
bogdanm 0:9b334a45a8ff 104 */
bogdanm 0:9b334a45a8ff 105 typedef enum
bogdanm 0:9b334a45a8ff 106 {
bogdanm 0:9b334a45a8ff 107 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized or disabled */
bogdanm 0:9b334a45a8ff 108 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
bogdanm 0:9b334a45a8ff 109 HAL_COMP_STATE_READY_LOCKED = 0x11, /*!< COMP initialized but the configuration is locked */
bogdanm 0:9b334a45a8ff 110 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
bogdanm 0:9b334a45a8ff 111 HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */
bogdanm 0:9b334a45a8ff 112 }HAL_COMP_StateTypeDef;
bogdanm 0:9b334a45a8ff 113
bogdanm 0:9b334a45a8ff 114
bogdanm 0:9b334a45a8ff 115 /**
bogdanm 0:9b334a45a8ff 116 * @brief PPP Handle Structure definition
bogdanm 0:9b334a45a8ff 117 */
bogdanm 0:9b334a45a8ff 118 typedef struct
bogdanm 0:9b334a45a8ff 119 {
bogdanm 0:9b334a45a8ff 120 COMP_TypeDef *Instance; /*!< Register base address */
bogdanm 0:9b334a45a8ff 121 COMP_InitTypeDef Init; /*!< COMP required parameters */
bogdanm 0:9b334a45a8ff 122 HAL_LockTypeDef Lock; /*!< Locking object */
bogdanm 0:9b334a45a8ff 123 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
bogdanm 0:9b334a45a8ff 124
bogdanm 0:9b334a45a8ff 125 }COMP_HandleTypeDef;
bogdanm 0:9b334a45a8ff 126
bogdanm 0:9b334a45a8ff 127 /**
bogdanm 0:9b334a45a8ff 128 * @}
bogdanm 0:9b334a45a8ff 129 */
bogdanm 0:9b334a45a8ff 130
bogdanm 0:9b334a45a8ff 131 /* Exported constants --------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 132 /** @defgroup COMP_Exported_Constants COMP Exported Constants
bogdanm 0:9b334a45a8ff 133 * @{
bogdanm 0:9b334a45a8ff 134 */
bogdanm 0:9b334a45a8ff 135
bogdanm 0:9b334a45a8ff 136 /** @defgroup COMP_OutputPolarity COMP Output Polarity
bogdanm 0:9b334a45a8ff 137 * @{
bogdanm 0:9b334a45a8ff 138 */
bogdanm 0:9b334a45a8ff 139 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
bogdanm 0:9b334a45a8ff 140 #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMPxPOL /*!< COMP output on GPIO is inverted */
bogdanm 0:9b334a45a8ff 141 #define IS_COMP_OUTPUTPOL(POL) (((POL) == COMP_OUTPUTPOL_NONINVERTED) || \
bogdanm 0:9b334a45a8ff 142 ((POL) == COMP_OUTPUTPOL_INVERTED))
bogdanm 0:9b334a45a8ff 143 /**
bogdanm 0:9b334a45a8ff 144 * @}
bogdanm 0:9b334a45a8ff 145 */
bogdanm 0:9b334a45a8ff 146
bogdanm 0:9b334a45a8ff 147 /** @defgroup COMP_OutputLevel COMP Output Level
bogdanm 0:9b334a45a8ff 148 * @{
bogdanm 0:9b334a45a8ff 149 */
bogdanm 0:9b334a45a8ff 150 /* When output polarity is not inverted, comparator output is low when
bogdanm 0:9b334a45a8ff 151 the non-inverting input is at a lower voltage than the inverting input*/
bogdanm 0:9b334a45a8ff 152 #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000)
bogdanm 0:9b334a45a8ff 153 /* When output polarity is not inverted, comparator output is high when
bogdanm 0:9b334a45a8ff 154 the non-inverting input is at a higher voltage than the inverting input */
bogdanm 0:9b334a45a8ff 155 #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMPxOUT
bogdanm 0:9b334a45a8ff 156 /**
bogdanm 0:9b334a45a8ff 157 * @}
bogdanm 0:9b334a45a8ff 158 */
bogdanm 0:9b334a45a8ff 159
bogdanm 0:9b334a45a8ff 160 /** @defgroup COMP_TriggerMode COMP Trigger Mode
bogdanm 0:9b334a45a8ff 161 * @{
bogdanm 0:9b334a45a8ff 162 */
bogdanm 0:9b334a45a8ff 163 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */
bogdanm 0:9b334a45a8ff 164 #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */
bogdanm 0:9b334a45a8ff 165 #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */
bogdanm 0:9b334a45a8ff 166 #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
bogdanm 0:9b334a45a8ff 167 #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \
bogdanm 0:9b334a45a8ff 168 ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \
bogdanm 0:9b334a45a8ff 169 ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
bogdanm 0:9b334a45a8ff 170 ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING))
bogdanm 0:9b334a45a8ff 171 /**
bogdanm 0:9b334a45a8ff 172 * @}
bogdanm 0:9b334a45a8ff 173 */
bogdanm 0:9b334a45a8ff 174
bogdanm 0:9b334a45a8ff 175 #define COMP_LOCK_DISABLE ((uint32_t)0x00000000)
bogdanm 0:9b334a45a8ff 176 #define COMP_LOCK_ENABLE COMP_CSR_COMPxLOCK
bogdanm 0:9b334a45a8ff 177
bogdanm 0:9b334a45a8ff 178 #define COMP_STATE_BIT_LOCK ((uint32_t)0x10)
bogdanm 0:9b334a45a8ff 179
bogdanm 0:9b334a45a8ff 180 /**
bogdanm 0:9b334a45a8ff 181 * @}
bogdanm 0:9b334a45a8ff 182 */
bogdanm 0:9b334a45a8ff 183
bogdanm 0:9b334a45a8ff 184 /* Exported macros -----------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 185 /** @defgroup COMP_Exported_Macros COMP Exported Macros
bogdanm 0:9b334a45a8ff 186 * @{
bogdanm 0:9b334a45a8ff 187 */
bogdanm 0:9b334a45a8ff 188
bogdanm 0:9b334a45a8ff 189 /** @brief Reset COMP handle state
bogdanm 0:9b334a45a8ff 190 * @param __HANDLE__: COMP handle.
bogdanm 0:9b334a45a8ff 191 * @retval None
bogdanm 0:9b334a45a8ff 192 */
bogdanm 0:9b334a45a8ff 193 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
bogdanm 0:9b334a45a8ff 194 /**
bogdanm 0:9b334a45a8ff 195 * @}
bogdanm 0:9b334a45a8ff 196 */
bogdanm 0:9b334a45a8ff 197
bogdanm 0:9b334a45a8ff 198 /* Include COMP HAL Extended module */
bogdanm 0:9b334a45a8ff 199 #include "stm32f3xx_hal_comp_ex.h"
bogdanm 0:9b334a45a8ff 200
bogdanm 0:9b334a45a8ff 201 /* Exported functions --------------------------------------------------------*/
bogdanm 0:9b334a45a8ff 202 /** @addtogroup COMP_Exported_Functions COMP Exported Functions
bogdanm 0:9b334a45a8ff 203 * @{
bogdanm 0:9b334a45a8ff 204 */
bogdanm 0:9b334a45a8ff 205
bogdanm 0:9b334a45a8ff 206 /** @addtogroup COMP_Exported_Functions_Group1 Initialization and de-initialization functions
bogdanm 0:9b334a45a8ff 207 * @brief Initialization and Configuration functions
bogdanm 0:9b334a45a8ff 208 * @{
bogdanm 0:9b334a45a8ff 209 */
bogdanm 0:9b334a45a8ff 210 /* Initialization and de-initialization functions ****************************/
bogdanm 0:9b334a45a8ff 211 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 212 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 213 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 214 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 215 /**
bogdanm 0:9b334a45a8ff 216 * @}
bogdanm 0:9b334a45a8ff 217 */
bogdanm 0:9b334a45a8ff 218
bogdanm 0:9b334a45a8ff 219 /** @addtogroup COMP_Exported_Functions_Group2 Input and Output operation functions
bogdanm 0:9b334a45a8ff 220 * @brief Data transfers functions
bogdanm 0:9b334a45a8ff 221 * @{
bogdanm 0:9b334a45a8ff 222 */
bogdanm 0:9b334a45a8ff 223 /* IO operation functions *****************************************************/
bogdanm 0:9b334a45a8ff 224 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 225 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 226 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 227 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 228 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 229 /**
bogdanm 0:9b334a45a8ff 230 * @}
bogdanm 0:9b334a45a8ff 231 */
bogdanm 0:9b334a45a8ff 232
bogdanm 0:9b334a45a8ff 233 /** @addtogroup COMP_Exported_Functions_Group3 Peripheral Control functions
bogdanm 0:9b334a45a8ff 234 * @brief management functions
bogdanm 0:9b334a45a8ff 235 * @{
bogdanm 0:9b334a45a8ff 236 */
bogdanm 0:9b334a45a8ff 237 /* Peripheral Control functions ***********************************************/
bogdanm 0:9b334a45a8ff 238 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 239 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 240
bogdanm 0:9b334a45a8ff 241 /* Callback in Interrupt mode */
bogdanm 0:9b334a45a8ff 242 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 243 /**
bogdanm 0:9b334a45a8ff 244 * @}
bogdanm 0:9b334a45a8ff 245 */
bogdanm 0:9b334a45a8ff 246
bogdanm 0:9b334a45a8ff 247 /** @addtogroup COMP_Exported_Functions_Group4 Peripheral State functions
bogdanm 0:9b334a45a8ff 248 * @brief Peripheral State functions
bogdanm 0:9b334a45a8ff 249 * @{
bogdanm 0:9b334a45a8ff 250 */
bogdanm 0:9b334a45a8ff 251 /* Peripheral State and Error functions ***************************************/
bogdanm 0:9b334a45a8ff 252 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
bogdanm 0:9b334a45a8ff 253 /**
bogdanm 0:9b334a45a8ff 254 * @}
bogdanm 0:9b334a45a8ff 255 */
bogdanm 0:9b334a45a8ff 256
bogdanm 0:9b334a45a8ff 257 /**
bogdanm 0:9b334a45a8ff 258 * @}
bogdanm 0:9b334a45a8ff 259 */
bogdanm 0:9b334a45a8ff 260
bogdanm 0:9b334a45a8ff 261 /**
bogdanm 0:9b334a45a8ff 262 * @}
bogdanm 0:9b334a45a8ff 263 */
bogdanm 0:9b334a45a8ff 264
bogdanm 0:9b334a45a8ff 265 /**
bogdanm 0:9b334a45a8ff 266 * @}
bogdanm 0:9b334a45a8ff 267 */
bogdanm 0:9b334a45a8ff 268
bogdanm 0:9b334a45a8ff 269 #ifdef __cplusplus
bogdanm 0:9b334a45a8ff 270 }
bogdanm 0:9b334a45a8ff 271 #endif
bogdanm 0:9b334a45a8ff 272
bogdanm 0:9b334a45a8ff 273 #endif /* __STM32F3xx_HAL_COMP_H */
bogdanm 0:9b334a45a8ff 274
bogdanm 0:9b334a45a8ff 275 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/