A simple 128x32 graphical LCD program to quickstart with LCD on ARM mbed IoT Starter Kit. This requires mbed Applciation Shield with FRDM-K64F platform.

Dependencies:   C12832

Committer:
tushki7
Date:
Sun Apr 12 15:45:52 2015 +0000
Revision:
1:eb68c94a8ee5
Parent:
0:60d829a0353a
A simple 128x32 LCD program with ARM mbed IoT Starter Kit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tushki7 0:60d829a0353a 1 /**
tushki7 0:60d829a0353a 2 ******************************************************************************
tushki7 0:60d829a0353a 3 * @file stm32f0xx_hal_comp.h
tushki7 0:60d829a0353a 4 * @author MCD Application Team
tushki7 0:60d829a0353a 5 * @version V1.2.0
tushki7 0:60d829a0353a 6 * @date 11-December-2014
tushki7 0:60d829a0353a 7 * @brief Header file of COMP HAL module.
tushki7 0:60d829a0353a 8 ******************************************************************************
tushki7 0:60d829a0353a 9 * @attention
tushki7 0:60d829a0353a 10 *
tushki7 0:60d829a0353a 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
tushki7 0:60d829a0353a 12 *
tushki7 0:60d829a0353a 13 * Redistribution and use in source and binary forms, with or without modification,
tushki7 0:60d829a0353a 14 * are permitted provided that the following conditions are met:
tushki7 0:60d829a0353a 15 * 1. Redistributions of source code must retain the above copyright notice,
tushki7 0:60d829a0353a 16 * this list of conditions and the following disclaimer.
tushki7 0:60d829a0353a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
tushki7 0:60d829a0353a 18 * this list of conditions and the following disclaimer in the documentation
tushki7 0:60d829a0353a 19 * and/or other materials provided with the distribution.
tushki7 0:60d829a0353a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
tushki7 0:60d829a0353a 21 * may be used to endorse or promote products derived from this software
tushki7 0:60d829a0353a 22 * without specific prior written permission.
tushki7 0:60d829a0353a 23 *
tushki7 0:60d829a0353a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
tushki7 0:60d829a0353a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
tushki7 0:60d829a0353a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
tushki7 0:60d829a0353a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
tushki7 0:60d829a0353a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
tushki7 0:60d829a0353a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
tushki7 0:60d829a0353a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
tushki7 0:60d829a0353a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
tushki7 0:60d829a0353a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
tushki7 0:60d829a0353a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
tushki7 0:60d829a0353a 34 *
tushki7 0:60d829a0353a 35 ******************************************************************************
tushki7 0:60d829a0353a 36 */
tushki7 0:60d829a0353a 37
tushki7 0:60d829a0353a 38 /* Define to prevent recursive inclusion -------------------------------------*/
tushki7 0:60d829a0353a 39 #ifndef __STM32F0xx_HAL_COMP_H
tushki7 0:60d829a0353a 40 #define __STM32F0xx_HAL_COMP_H
tushki7 0:60d829a0353a 41
tushki7 0:60d829a0353a 42 #ifdef __cplusplus
tushki7 0:60d829a0353a 43 extern "C" {
tushki7 0:60d829a0353a 44 #endif
tushki7 0:60d829a0353a 45
tushki7 0:60d829a0353a 46 #if defined(STM32F051x8) || defined(STM32F058xx) || \
tushki7 0:60d829a0353a 47 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
tushki7 0:60d829a0353a 48 defined(STM32F091xC) || defined(STM32F098xx)
tushki7 0:60d829a0353a 49
tushki7 0:60d829a0353a 50 /* Includes ------------------------------------------------------------------*/
tushki7 0:60d829a0353a 51 #include "stm32f0xx_hal_def.h"
tushki7 0:60d829a0353a 52
tushki7 0:60d829a0353a 53 /** @addtogroup STM32F0xx_HAL_Driver
tushki7 0:60d829a0353a 54 * @{
tushki7 0:60d829a0353a 55 */
tushki7 0:60d829a0353a 56
tushki7 0:60d829a0353a 57 /** @addtogroup COMP COMP HAL Module Driver
tushki7 0:60d829a0353a 58 * @{
tushki7 0:60d829a0353a 59 */
tushki7 0:60d829a0353a 60
tushki7 0:60d829a0353a 61 /* Exported types ------------------------------------------------------------*/
tushki7 0:60d829a0353a 62 /** @defgroup COMP_Exported_Types COMP Exported Types
tushki7 0:60d829a0353a 63 * @{
tushki7 0:60d829a0353a 64 */
tushki7 0:60d829a0353a 65
tushki7 0:60d829a0353a 66 /**
tushki7 0:60d829a0353a 67 * @brief COMP Init structure definition
tushki7 0:60d829a0353a 68 */
tushki7 0:60d829a0353a 69 typedef struct
tushki7 0:60d829a0353a 70 {
tushki7 0:60d829a0353a 71
tushki7 0:60d829a0353a 72 uint32_t InvertingInput; /*!< Selects the inverting input of the comparator.
tushki7 0:60d829a0353a 73 This parameter can be a value of @ref COMP_InvertingInput */
tushki7 0:60d829a0353a 74
tushki7 0:60d829a0353a 75 uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator.
tushki7 0:60d829a0353a 76 This parameter can be a value of @ref COMP_NonInvertingInput */
tushki7 0:60d829a0353a 77
tushki7 0:60d829a0353a 78 uint32_t Output; /*!< Selects the output redirection of the comparator.
tushki7 0:60d829a0353a 79 This parameter can be a value of @ref COMP_Output */
tushki7 0:60d829a0353a 80
tushki7 0:60d829a0353a 81 uint32_t OutputPol; /*!< Selects the output polarity of the comparator.
tushki7 0:60d829a0353a 82 This parameter can be a value of @ref COMP_OutputPolarity */
tushki7 0:60d829a0353a 83
tushki7 0:60d829a0353a 84 uint32_t Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
tushki7 0:60d829a0353a 85 This parameter can be a value of @ref COMP_Hysteresis */
tushki7 0:60d829a0353a 86
tushki7 0:60d829a0353a 87 uint32_t Mode; /*!< Selects the operating comsumption mode of the comparator
tushki7 0:60d829a0353a 88 to adjust the speed/consumption.
tushki7 0:60d829a0353a 89 This parameter can be a value of @ref COMP_Mode */
tushki7 0:60d829a0353a 90
tushki7 0:60d829a0353a 91 uint32_t WindowMode; /*!< Selects the window mode of the comparator 1 & 2.
tushki7 0:60d829a0353a 92 This parameter can be a value of @ref COMP_WindowMode */
tushki7 0:60d829a0353a 93
tushki7 0:60d829a0353a 94 uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode).
tushki7 0:60d829a0353a 95 This parameter can be a value of @ref COMP_TriggerMode */
tushki7 0:60d829a0353a 96
tushki7 0:60d829a0353a 97 }COMP_InitTypeDef;
tushki7 0:60d829a0353a 98
tushki7 0:60d829a0353a 99 /**
tushki7 0:60d829a0353a 100 * @brief COMP Handle Structure definition
tushki7 0:60d829a0353a 101 */
tushki7 0:60d829a0353a 102 typedef struct
tushki7 0:60d829a0353a 103 {
tushki7 0:60d829a0353a 104 COMP_TypeDef *Instance; /*!< Register base address */
tushki7 0:60d829a0353a 105 COMP_InitTypeDef Init; /*!< COMP required parameters */
tushki7 0:60d829a0353a 106 HAL_LockTypeDef Lock; /*!< Locking object */
tushki7 0:60d829a0353a 107 __IO uint32_t State; /*!< COMP communication state
tushki7 0:60d829a0353a 108 This parameter can be a value of @ref COMP_State */
tushki7 0:60d829a0353a 109 }COMP_HandleTypeDef;
tushki7 0:60d829a0353a 110
tushki7 0:60d829a0353a 111 /**
tushki7 0:60d829a0353a 112 * @}
tushki7 0:60d829a0353a 113 */
tushki7 0:60d829a0353a 114
tushki7 0:60d829a0353a 115 /* Exported constants --------------------------------------------------------*/
tushki7 0:60d829a0353a 116 /** @defgroup COMP_Exported_Constants COMP Exported Constants
tushki7 0:60d829a0353a 117 * @{
tushki7 0:60d829a0353a 118 */
tushki7 0:60d829a0353a 119
tushki7 0:60d829a0353a 120 /** @defgroup COMP_State COMP State
tushki7 0:60d829a0353a 121 * @{
tushki7 0:60d829a0353a 122 */
tushki7 0:60d829a0353a 123 #define HAL_COMP_STATE_RESET ((uint32_t)0x00000000) /*!< COMP not yet initialized or disabled */
tushki7 0:60d829a0353a 124 #define HAL_COMP_STATE_READY ((uint32_t)0x00000001) /*!< COMP initialized and ready for use */
tushki7 0:60d829a0353a 125 #define HAL_COMP_STATE_READY_LOCKED ((uint32_t)0x00000011) /*!< COMP initialized but the configuration is locked */
tushki7 0:60d829a0353a 126 #define HAL_COMP_STATE_BUSY ((uint32_t)0x00000002) /*!< COMP is running */
tushki7 0:60d829a0353a 127 #define HAL_COMP_STATE_BUSY_LOCKED ((uint32_t)0x00000012) /*!< COMP is running and the configuration is locked */
tushki7 0:60d829a0353a 128 /**
tushki7 0:60d829a0353a 129 * @}
tushki7 0:60d829a0353a 130 */
tushki7 0:60d829a0353a 131
tushki7 0:60d829a0353a 132 /** @defgroup COMP_OutputPolarity COMP OutputPolarity
tushki7 0:60d829a0353a 133 * @{
tushki7 0:60d829a0353a 134 */
tushki7 0:60d829a0353a 135 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
tushki7 0:60d829a0353a 136 #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMP1POL /*!< COMP output on GPIO is inverted */
tushki7 0:60d829a0353a 137
tushki7 0:60d829a0353a 138 #define IS_COMP_OUTPUTPOL(POL) (((POL) == COMP_OUTPUTPOL_NONINVERTED) || \
tushki7 0:60d829a0353a 139 ((POL) == COMP_OUTPUTPOL_INVERTED))
tushki7 0:60d829a0353a 140 /**
tushki7 0:60d829a0353a 141 * @}
tushki7 0:60d829a0353a 142 */
tushki7 0:60d829a0353a 143
tushki7 0:60d829a0353a 144 /** @defgroup COMP_Hysteresis COMP Hysteresis
tushki7 0:60d829a0353a 145 * @{
tushki7 0:60d829a0353a 146 */
tushki7 0:60d829a0353a 147 #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */
tushki7 0:60d829a0353a 148 #define COMP_HYSTERESIS_LOW COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */
tushki7 0:60d829a0353a 149 #define COMP_HYSTERESIS_MEDIUM COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */
tushki7 0:60d829a0353a 150 #define COMP_HYSTERESIS_HIGH COMP_CSR_COMP1HYST /*!< Hysteresis level high */
tushki7 0:60d829a0353a 151
tushki7 0:60d829a0353a 152 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_HYSTERESIS_NONE) || \
tushki7 0:60d829a0353a 153 ((HYSTERESIS) == COMP_HYSTERESIS_LOW) || \
tushki7 0:60d829a0353a 154 ((HYSTERESIS) == COMP_HYSTERESIS_MEDIUM) || \
tushki7 0:60d829a0353a 155 ((HYSTERESIS) == COMP_HYSTERESIS_HIGH))
tushki7 0:60d829a0353a 156 /**
tushki7 0:60d829a0353a 157 * @}
tushki7 0:60d829a0353a 158 */
tushki7 0:60d829a0353a 159
tushki7 0:60d829a0353a 160 /** @defgroup COMP_Mode COMP Mode
tushki7 0:60d829a0353a 161 * @{
tushki7 0:60d829a0353a 162 */
tushki7 0:60d829a0353a 163 /* Please refer to the electrical characteristics in the device datasheet for
tushki7 0:60d829a0353a 164 the power consumption values */
tushki7 0:60d829a0353a 165 #define COMP_MODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */
tushki7 0:60d829a0353a 166 #define COMP_MODE_MEDIUMSPEED COMP_CSR_COMP1MODE_0 /*!< Medium Speed */
tushki7 0:60d829a0353a 167 #define COMP_MODE_LOWPOWER COMP_CSR_COMP1MODE_1 /*!< Low power mode */
tushki7 0:60d829a0353a 168 #define COMP_MODE_ULTRALOWPOWER COMP_CSR_COMP1MODE /*!< Ultra-low power mode */
tushki7 0:60d829a0353a 169
tushki7 0:60d829a0353a 170 #define IS_COMP_MODE(MODE) (((MODE) == COMP_MODE_HIGHSPEED) || \
tushki7 0:60d829a0353a 171 ((MODE) == COMP_MODE_MEDIUMSPEED) || \
tushki7 0:60d829a0353a 172 ((MODE) == COMP_MODE_LOWPOWER) || \
tushki7 0:60d829a0353a 173 ((MODE) == COMP_MODE_ULTRALOWPOWER))
tushki7 0:60d829a0353a 174
tushki7 0:60d829a0353a 175 /**
tushki7 0:60d829a0353a 176 * @}
tushki7 0:60d829a0353a 177 */
tushki7 0:60d829a0353a 178
tushki7 0:60d829a0353a 179 /** @defgroup COMP_InvertingInput COMP InvertingInput
tushki7 0:60d829a0353a 180 * @{
tushki7 0:60d829a0353a 181 */
tushki7 0:60d829a0353a 182
tushki7 0:60d829a0353a 183 #define COMP_INVERTINGINPUT_1_4VREFINT ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */
tushki7 0:60d829a0353a 184 #define COMP_INVERTINGINPUT_1_2VREFINT COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */
tushki7 0:60d829a0353a 185 #define COMP_INVERTINGINPUT_3_4VREFINT COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */
tushki7 0:60d829a0353a 186 #define COMP_INVERTINGINPUT_VREFINT (COMP_CSR_COMP1INSEL_1|COMP_CSR_COMP1INSEL_0) /*!< VREFINT connected to comparator inverting input */
tushki7 0:60d829a0353a 187 #define COMP_INVERTINGINPUT_DAC1 COMP_CSR_COMP1INSEL_2 /*!< DAC_OUT1 (PA4) connected to comparator inverting input */
tushki7 0:60d829a0353a 188 #define COMP_INVERTINGINPUT_DAC1SWITCHCLOSED (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1SW1) /*!< DAC_OUT1 (PA4) connected to comparator inverting input
tushki7 0:60d829a0353a 189 and close switch (PA0 for COMP1 only) */
tushki7 0:60d829a0353a 190 #define COMP_INVERTINGINPUT_DAC2 (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1INSEL_0) /*!< DAC_OUT2 (PA5) connected to comparator inverting input */
tushki7 0:60d829a0353a 191 #define COMP_INVERTINGINPUT_IO1 (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1INSEL_1) /*!< IO (PA0 for COMP1 and PA2 for COMP2) connected to comparator inverting input */
tushki7 0:60d829a0353a 192
tushki7 0:60d829a0353a 193 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
tushki7 0:60d829a0353a 194 ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
tushki7 0:60d829a0353a 195 ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
tushki7 0:60d829a0353a 196 ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
tushki7 0:60d829a0353a 197 ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \
tushki7 0:60d829a0353a 198 ((INPUT) == COMP_INVERTINGINPUT_DAC1SWITCHCLOSED) || \
tushki7 0:60d829a0353a 199 ((INPUT) == COMP_INVERTINGINPUT_DAC2) || \
tushki7 0:60d829a0353a 200 ((INPUT) == COMP_INVERTINGINPUT_IO1))
tushki7 0:60d829a0353a 201 /**
tushki7 0:60d829a0353a 202 * @}
tushki7 0:60d829a0353a 203 */
tushki7 0:60d829a0353a 204
tushki7 0:60d829a0353a 205 /** @defgroup COMP_NonInvertingInput COMP NonInvertingInput
tushki7 0:60d829a0353a 206 * @{
tushki7 0:60d829a0353a 207 */
tushki7 0:60d829a0353a 208 #define COMP_NONINVERTINGINPUT_IO1 ((uint32_t)0x00000000) /*!< I/O1 (PA1 for COMP1, PA3 for COMP2)
tushki7 0:60d829a0353a 209 connected to comparator non inverting input */
tushki7 0:60d829a0353a 210 #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP_CSR_COMP1SW1 /*!< DAC ouput connected to comparator COMP1 non inverting input */
tushki7 0:60d829a0353a 211
tushki7 0:60d829a0353a 212 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
tushki7 0:60d829a0353a 213 ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
tushki7 0:60d829a0353a 214 /**
tushki7 0:60d829a0353a 215 * @}
tushki7 0:60d829a0353a 216 */
tushki7 0:60d829a0353a 217
tushki7 0:60d829a0353a 218 /** @defgroup COMP_Output COMP Output
tushki7 0:60d829a0353a 219 * @{
tushki7 0:60d829a0353a 220 */
tushki7 0:60d829a0353a 221
tushki7 0:60d829a0353a 222 /* Output Redirection common for COMP1 and COMP2 */
tushki7 0:60d829a0353a 223 #define COMP_OUTPUT_NONE ((uint32_t)0x00000000) /*!< COMP output isn't connected to other peripherals */
tushki7 0:60d829a0353a 224 #define COMP_OUTPUT_TIM1BKIN COMP_CSR_COMP1OUTSEL_0 /*!< COMP output connected to TIM1 Break Input (BKIN) */
tushki7 0:60d829a0353a 225 #define COMP_OUTPUT_TIM1IC1 COMP_CSR_COMP1OUTSEL_1 /*!< COMP output connected to TIM1 Input Capture 1 */
tushki7 0:60d829a0353a 226 #define COMP_OUTPUT_TIM1OCREFCLR (COMP_CSR_COMP1OUTSEL_1|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM1 OCREF Clear */
tushki7 0:60d829a0353a 227 #define COMP_OUTPUT_TIM2IC4 COMP_CSR_COMP1OUTSEL_2 /*!< COMP output connected to TIM2 Input Capture 4 */
tushki7 0:60d829a0353a 228 #define COMP_OUTPUT_TIM2OCREFCLR (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM2 OCREF Clear */
tushki7 0:60d829a0353a 229 #define COMP_OUTPUT_TIM3IC1 (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM3 Input Capture 1 */
tushki7 0:60d829a0353a 230 #define COMP_OUTPUT_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL /*!< COMP output connected to TIM3 OCREF Clear */
tushki7 0:60d829a0353a 231
tushki7 0:60d829a0353a 232 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
tushki7 0:60d829a0353a 233 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
tushki7 0:60d829a0353a 234 ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
tushki7 0:60d829a0353a 235 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
tushki7 0:60d829a0353a 236 ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
tushki7 0:60d829a0353a 237 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
tushki7 0:60d829a0353a 238 ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
tushki7 0:60d829a0353a 239 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))
tushki7 0:60d829a0353a 240
tushki7 0:60d829a0353a 241 /**
tushki7 0:60d829a0353a 242 * @}
tushki7 0:60d829a0353a 243 */
tushki7 0:60d829a0353a 244
tushki7 0:60d829a0353a 245 /** @defgroup COMP_OutputLevel COMP OutputLevel
tushki7 0:60d829a0353a 246 * @{
tushki7 0:60d829a0353a 247 */
tushki7 0:60d829a0353a 248 /* When output polarity is not inverted, comparator output is low when
tushki7 0:60d829a0353a 249 the non-inverting input is at a lower voltage than the inverting input*/
tushki7 0:60d829a0353a 250 #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 251 /* When output polarity is not inverted, comparator output is high when
tushki7 0:60d829a0353a 252 the non-inverting input is at a higher voltage than the inverting input */
tushki7 0:60d829a0353a 253 #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMP1OUT
tushki7 0:60d829a0353a 254 /**
tushki7 0:60d829a0353a 255 * @}
tushki7 0:60d829a0353a 256 */
tushki7 0:60d829a0353a 257
tushki7 0:60d829a0353a 258 /** @defgroup COMP_TriggerMode COMP TriggerMode
tushki7 0:60d829a0353a 259 * @{
tushki7 0:60d829a0353a 260 */
tushki7 0:60d829a0353a 261 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */
tushki7 0:60d829a0353a 262 #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */
tushki7 0:60d829a0353a 263 #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */
tushki7 0:60d829a0353a 264 #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
tushki7 0:60d829a0353a 265
tushki7 0:60d829a0353a 266 #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \
tushki7 0:60d829a0353a 267 ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \
tushki7 0:60d829a0353a 268 ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
tushki7 0:60d829a0353a 269 ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING))
tushki7 0:60d829a0353a 270 /**
tushki7 0:60d829a0353a 271 * @}
tushki7 0:60d829a0353a 272 */
tushki7 0:60d829a0353a 273
tushki7 0:60d829a0353a 274 /** @defgroup COMP_WindowMode COMP WindowMode
tushki7 0:60d829a0353a 275 * @{
tushki7 0:60d829a0353a 276 */
tushki7 0:60d829a0353a 277 #define COMP_WINDOWMODE_DISABLED ((uint32_t)0x00000000) /*!< Window mode disabled */
tushki7 0:60d829a0353a 278 #define COMP_WINDOWMODE_ENABLED COMP_CSR_WNDWEN /*!< Window mode enabled: non inverting input of comparator 2
tushki7 0:60d829a0353a 279 is connected to the non inverting input of comparator 1 (PA1) */
tushki7 0:60d829a0353a 280
tushki7 0:60d829a0353a 281 #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \
tushki7 0:60d829a0353a 282 ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED))
tushki7 0:60d829a0353a 283 /**
tushki7 0:60d829a0353a 284 * @}
tushki7 0:60d829a0353a 285 */
tushki7 0:60d829a0353a 286
tushki7 0:60d829a0353a 287 /** @defgroup COMP_ExtiLineEvent COMP ExtiLineEvent
tushki7 0:60d829a0353a 288 * Elements values convention: XXXX0000
tushki7 0:60d829a0353a 289 * - XXXX : Interrupt mask in the EMR/IMR/RTSR/FTSR register
tushki7 0:60d829a0353a 290 * @{
tushki7 0:60d829a0353a 291 */
tushki7 0:60d829a0353a 292 #define COMP_EXTI_LINE_COMP1_EVENT ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to COMP1 */
tushki7 0:60d829a0353a 293 #define COMP_EXTI_LINE_COMP2_EVENT ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to COMP2 */
tushki7 0:60d829a0353a 294
tushki7 0:60d829a0353a 295 /**
tushki7 0:60d829a0353a 296 * @}
tushki7 0:60d829a0353a 297 */
tushki7 0:60d829a0353a 298
tushki7 0:60d829a0353a 299 /** @defgroup COMP_Lock COMP Lock
tushki7 0:60d829a0353a 300 * @{
tushki7 0:60d829a0353a 301 */
tushki7 0:60d829a0353a 302 #define COMP_LOCK_DISABLE ((uint32_t)0x00000000)
tushki7 0:60d829a0353a 303 #define COMP_LOCK_ENABLE COMP_CSR_COMP1LOCK
tushki7 0:60d829a0353a 304
tushki7 0:60d829a0353a 305 #define COMP_STATE_BIT_LOCK ((uint32_t)0x10)
tushki7 0:60d829a0353a 306 /**
tushki7 0:60d829a0353a 307 * @}
tushki7 0:60d829a0353a 308 */
tushki7 0:60d829a0353a 309
tushki7 0:60d829a0353a 310
tushki7 0:60d829a0353a 311 /**
tushki7 0:60d829a0353a 312 * @}
tushki7 0:60d829a0353a 313 */
tushki7 0:60d829a0353a 314
tushki7 0:60d829a0353a 315 /* Exported macros -----------------------------------------------------------*/
tushki7 0:60d829a0353a 316 /** @defgroup COMP_Exported_Macros COMP Exported Macros
tushki7 0:60d829a0353a 317 * @{
tushki7 0:60d829a0353a 318 */
tushki7 0:60d829a0353a 319
tushki7 0:60d829a0353a 320 /** @brief Reset COMP handle state
tushki7 0:60d829a0353a 321 * @param __HANDLE__: COMP handle.
tushki7 0:60d829a0353a 322 * @retval None
tushki7 0:60d829a0353a 323 */
tushki7 0:60d829a0353a 324 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
tushki7 0:60d829a0353a 325
tushki7 0:60d829a0353a 326 /**
tushki7 0:60d829a0353a 327 * @brief Checks whether the specified EXTI line flag is set or not.
tushki7 0:60d829a0353a 328 * @param __FLAG__: specifies the COMP Exti sources to be checked.
tushki7 0:60d829a0353a 329 * This parameter can be a value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 330 * @retval The state of __FLAG__ (SET or RESET).
tushki7 0:60d829a0353a 331 */
tushki7 0:60d829a0353a 332 #define __HAL_COMP_EXTI_GET_FLAG(__FLAG__) (EXTI->PR & (__FLAG__))
tushki7 0:60d829a0353a 333
tushki7 0:60d829a0353a 334 /**
tushki7 0:60d829a0353a 335 * @brief Clear the COMP Exti flags.
tushki7 0:60d829a0353a 336 * @param __FLAG__: specifies the COMP Exti sources to be cleared.
tushki7 0:60d829a0353a 337 * This parameter can be a value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 338 * @retval None.
tushki7 0:60d829a0353a 339 */
tushki7 0:60d829a0353a 340 #define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__))
tushki7 0:60d829a0353a 341
tushki7 0:60d829a0353a 342 /**
tushki7 0:60d829a0353a 343 * @brief Enable the COMP Exti Line.
tushki7 0:60d829a0353a 344 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
tushki7 0:60d829a0353a 345 * This parameter can be a value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 346 * @retval None.
tushki7 0:60d829a0353a 347 */
tushki7 0:60d829a0353a 348 #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__) (EXTI->IMR |= (__EXTILINE__))
tushki7 0:60d829a0353a 349
tushki7 0:60d829a0353a 350 /**
tushki7 0:60d829a0353a 351 * @brief Disable the COMP Exti Line.
tushki7 0:60d829a0353a 352 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
tushki7 0:60d829a0353a 353 * This parameter can be a value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 354 * @retval None.
tushki7 0:60d829a0353a 355 */
tushki7 0:60d829a0353a 356 #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__) (EXTI->IMR &= ~(__EXTILINE__))
tushki7 0:60d829a0353a 357
tushki7 0:60d829a0353a 358 /**
tushki7 0:60d829a0353a 359 * @brief Enable the Exti Line rising edge trigger.
tushki7 0:60d829a0353a 360 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
tushki7 0:60d829a0353a 361 * This parameter can be a value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 362 * @retval None.
tushki7 0:60d829a0353a 363 */
tushki7 0:60d829a0353a 364 #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (EXTI->RTSR |= (__EXTILINE__))
tushki7 0:60d829a0353a 365
tushki7 0:60d829a0353a 366 /**
tushki7 0:60d829a0353a 367 * @brief Disable the Exti Line rising edge trigger.
tushki7 0:60d829a0353a 368 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
tushki7 0:60d829a0353a 369 * This parameter can be a value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 370 * @retval None.
tushki7 0:60d829a0353a 371 */
tushki7 0:60d829a0353a 372 #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (EXTI->RTSR &= ~(__EXTILINE__))
tushki7 0:60d829a0353a 373
tushki7 0:60d829a0353a 374 /**
tushki7 0:60d829a0353a 375 * @brief Enable the Exti Line falling edge trigger.
tushki7 0:60d829a0353a 376 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
tushki7 0:60d829a0353a 377 * This parameter can be a value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 378 * @retval None.
tushki7 0:60d829a0353a 379 */
tushki7 0:60d829a0353a 380 #define __HAL_COMP_EXTI_FALLING_IT_ENABLE(__EXTILINE__) (EXTI->FTSR |= (__EXTILINE__))
tushki7 0:60d829a0353a 381
tushki7 0:60d829a0353a 382 /**
tushki7 0:60d829a0353a 383 * @brief Disable the Exti Line falling edge trigger.
tushki7 0:60d829a0353a 384 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
tushki7 0:60d829a0353a 385 * This parameter can be a value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 386 * @retval None.
tushki7 0:60d829a0353a 387 */
tushki7 0:60d829a0353a 388 #define __HAL_COMP_EXTI_FALLING_IT_DISABLE(__EXTILINE__) (EXTI->FTSR &= ~(__EXTILINE__))
tushki7 0:60d829a0353a 389
tushki7 0:60d829a0353a 390 /**
tushki7 0:60d829a0353a 391 * @brief Get the specified EXTI line for a comparator instance
tushki7 0:60d829a0353a 392 * @param __INSTANCE__: specifies the COMP instance.
tushki7 0:60d829a0353a 393 * @retval value of @ref COMP_ExtiLineEvent
tushki7 0:60d829a0353a 394 */
tushki7 0:60d829a0353a 395 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1_EVENT : \
tushki7 0:60d829a0353a 396 COMP_EXTI_LINE_COMP2_EVENT)
tushki7 0:60d829a0353a 397 /**
tushki7 0:60d829a0353a 398 * @}
tushki7 0:60d829a0353a 399 */
tushki7 0:60d829a0353a 400
tushki7 0:60d829a0353a 401 /* Exported functions --------------------------------------------------------*/
tushki7 0:60d829a0353a 402 /** @addtogroup COMP_Exported_Functions COMP Exported Functions
tushki7 0:60d829a0353a 403 * @{
tushki7 0:60d829a0353a 404 */
tushki7 0:60d829a0353a 405 /** @addtogroup COMP_Exported_Functions_Group1 Initialization/de-initialization functions
tushki7 0:60d829a0353a 406 * @brief Initialization and Configuration functions
tushki7 0:60d829a0353a 407 * @{
tushki7 0:60d829a0353a 408 */
tushki7 0:60d829a0353a 409 /* Initialization and de-initialization functions ****************************/
tushki7 0:60d829a0353a 410 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 411 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 412 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 413 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 414 /**
tushki7 0:60d829a0353a 415 * @}
tushki7 0:60d829a0353a 416 */
tushki7 0:60d829a0353a 417
tushki7 0:60d829a0353a 418 /** @addtogroup COMP_Exported_Functions_Group2 I/O operation functions
tushki7 0:60d829a0353a 419 * @brief Data transfers functions
tushki7 0:60d829a0353a 420 * @{
tushki7 0:60d829a0353a 421 */
tushki7 0:60d829a0353a 422 /* IO operation functions *****************************************************/
tushki7 0:60d829a0353a 423 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 424 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 425 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 426 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 427 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 428 /**
tushki7 0:60d829a0353a 429 * @}
tushki7 0:60d829a0353a 430 */
tushki7 0:60d829a0353a 431
tushki7 0:60d829a0353a 432 /** @addtogroup COMP_Exported_Functions_Group3 Peripheral Control functions
tushki7 0:60d829a0353a 433 * @brief management functions
tushki7 0:60d829a0353a 434 * @{
tushki7 0:60d829a0353a 435 */
tushki7 0:60d829a0353a 436 /* Peripheral Control functions ***********************************************/
tushki7 0:60d829a0353a 437 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 438 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 439
tushki7 0:60d829a0353a 440 /* Callback in Interrupt mode */
tushki7 0:60d829a0353a 441 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 442 /**
tushki7 0:60d829a0353a 443 * @}
tushki7 0:60d829a0353a 444 */
tushki7 0:60d829a0353a 445
tushki7 0:60d829a0353a 446 /** @addtogroup COMP_Exported_Functions_Group4 Peripheral State functions
tushki7 0:60d829a0353a 447 * @brief Peripheral State functions
tushki7 0:60d829a0353a 448 * @{
tushki7 0:60d829a0353a 449 */
tushki7 0:60d829a0353a 450 /* Peripheral State and Error functions ***************************************/
tushki7 0:60d829a0353a 451 uint32_t HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
tushki7 0:60d829a0353a 452 /**
tushki7 0:60d829a0353a 453 * @}
tushki7 0:60d829a0353a 454 */
tushki7 0:60d829a0353a 455
tushki7 0:60d829a0353a 456 /**
tushki7 0:60d829a0353a 457 * @}
tushki7 0:60d829a0353a 458 */
tushki7 0:60d829a0353a 459
tushki7 0:60d829a0353a 460 /**
tushki7 0:60d829a0353a 461 * @}
tushki7 0:60d829a0353a 462 */
tushki7 0:60d829a0353a 463
tushki7 0:60d829a0353a 464 /**
tushki7 0:60d829a0353a 465 * @}
tushki7 0:60d829a0353a 466 */
tushki7 0:60d829a0353a 467
tushki7 0:60d829a0353a 468 #endif /* STM32F051x8 || STM32F058xx || */
tushki7 0:60d829a0353a 469 /* STM32F071xB || STM32F072xB || STM32F078xx || */
tushki7 0:60d829a0353a 470 /* STM32F091xC || STM32F098xx */
tushki7 0:60d829a0353a 471
tushki7 0:60d829a0353a 472 #ifdef __cplusplus
tushki7 0:60d829a0353a 473 }
tushki7 0:60d829a0353a 474 #endif
tushki7 0:60d829a0353a 475
tushki7 0:60d829a0353a 476 #endif /* __STM32F0xx_HAL_COMP_H */
tushki7 0:60d829a0353a 477
tushki7 0:60d829a0353a 478 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
tushki7 0:60d829a0353a 479