|
1 | 1 | /** |
2 | | - ****************************************************************************** |
3 | | - * @file at32f4xx_comp.c |
4 | | - * @author Artery |
5 | | - * @version V1.0.1 |
6 | | - * @date 20-April-2012 |
7 | | - * @brief This file provides firmware functions to manage the following |
8 | | - * functionalities of the comparators (COMP1 and COMP2) peripheral: |
9 | | - * + Comparators configuration |
10 | | - * + Window mode control |
11 | | - * |
12 | | - * @verbatim |
13 | | - * |
14 | | - =============================================================================== |
15 | | - ##### How to use this driver ##### |
16 | | - =============================================================================== |
17 | | - [..] |
18 | | - |
19 | | - The device integrates two analog comparators COMP1 and COMP2: |
20 | | - (+) The non inverting input is set to PA1 for COMP1 and to PA3 |
21 | | - for COMP2. |
22 | | - |
23 | | - (+) The inverting input can be selected among: DAC_OUT1, |
24 | | - 1/4 VREFINT, 1/2 VERFINT, 3/4 VREFINT, VREFINT, |
25 | | - I/O (PA0 for COMP1 and PA2 for COMP2) |
26 | | - |
27 | | - (+) The COMP output is internally is available using COMP_GetOutputState() |
28 | | - and can be set on GPIO pins: PA0, PA6, PA11 for COMP1 |
29 | | - and PA2, PA7, PA12 for COMP2 |
30 | | - |
31 | | - (+) The COMP output can be redirected to embedded timers (TIM1, TIM2 |
32 | | - and TIM3) |
33 | | - |
34 | | - (+) The two comparators COMP1 and COMP2 can be combined in window |
35 | | - mode and only COMP1 non inverting (PA1) can be used as non- |
36 | | - inverting input. |
37 | | - |
38 | | - (+) The two comparators COMP1 and COMP2 have interrupt capability |
39 | | - with wake-up from Sleep and Stop modes (through the EXTI controller). |
40 | | - COMP1 and COMP2 outputs are internally connected to EXTI Line 21 |
41 | | - and EXTI Line 22 respectively. |
42 | | - |
43 | | -
|
44 | | - ##### How to configure the comparator ##### |
45 | | - =============================================================================== |
46 | | - [..] |
47 | | - This driver provides functions to configure and program the Comparators |
48 | | - of all AT32F4xx devices. |
49 | | - |
50 | | - [..] To use the comparator, perform the following steps: |
51 | | - |
52 | | - (#) Enable the SYSCFG APB clock to get write access to comparator |
53 | | - register using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); |
54 | | - |
55 | | - (#) Configure the comparator input in analog mode using GPIO_Init() |
56 | | - |
57 | | - (#) Configure the comparator output in alternate function mode |
58 | | - using GPIO_Init() and use GPIO_PinAFConfig() function to map the |
59 | | - comparator output to the GPIO pin |
60 | | - |
61 | | - (#) Configure the comparator using COMP_Init() function: |
62 | | - (++) Select the inverting input |
63 | | - (++) Select the output polarity |
64 | | - (++) Select the output redirection |
65 | | - (++) Select the hysteresis level |
66 | | - (++) Select the power mode |
67 | | - |
68 | | - (#) Enable the comparator using COMP_Cmd() function |
69 | | - |
70 | | - (#) If required enable the COMP interrupt by configuring and enabling |
71 | | - EXTI line in Interrupt mode and selecting the desired sensitivity |
72 | | - level using EXTI_Init() function. After that enable the comparator |
73 | | - interrupt vector using NVIC_Init() function. |
74 | | - |
75 | | - @endverbatim |
76 | | - * |
77 | | - ****************************************************************************** |
78 | | - * @attention |
79 | | - * |
80 | | - * <h2><center>© COPYRIGHT 2012 Artery</center></h2> |
81 | | - * |
82 | | - * Licensed under Artery Liberty SW License Agreement V2, (the "License"); |
83 | | - * You may not use this file except in compliance with the License. |
84 | | - * |
85 | | - * Unless required by applicable law or agreed to in writing, software |
86 | | - * distributed under the License is distributed on an "AS IS" BASIS, |
87 | | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
88 | | - * See the License for the specific language governing permissions and |
89 | | - * limitations under the License. |
90 | | - * |
91 | | - ****************************************************************************** |
92 | | - */ |
| 2 | + ************************************************************************** |
| 3 | + * File Name : at32f4xx_comp.c |
| 4 | + * Description : at32f4xx COMP source file |
| 5 | + * Date : 2018-02-26 |
| 6 | + * Version : V1.0.4 |
| 7 | + ************************************************************************** |
| 8 | + */ |
93 | 9 |
|
94 | 10 | /* Includes ------------------------------------------------------------------*/ |
95 | 11 | #include "at32f4xx_comp.h" |
|
0 commit comments