mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

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

Who changed what in which revision?

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