1 /*!
2     \file    gd32l23x_vref.h
3     \brief   definitions for the VREF
4 
5     \version 2021-08-04, V1.0.0, firmware for GD32L23x
6 */
7 
8 /*
9     Copyright (c) 2021, GigaDevice Semiconductor Inc.
10 
11     Redistribution and use in source and binary forms, with or without modification,
12 are permitted provided that the following conditions are met:
13 
14     1. Redistributions of source code must retain the above copyright notice, this
15        list of conditions and the following disclaimer.
16     2. Redistributions in binary form must reproduce the above copyright notice,
17        this list of conditions and the following disclaimer in the documentation
18        and/or other materials provided with the distribution.
19     3. Neither the name of the copyright holder nor the names of its contributors
20        may be used to endorse or promote products derived from this software without
21        specific prior written permission.
22 
23     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 OF SUCH DAMAGE.
33 */
34 
35 #ifndef GD32L23X_VREF_H
36 #define GD32L23X_VREF_H
37 
38 #include "gd32l23x.h"
39 
40 /* VREF definitions */
41 #define VREF                      VREF_BASE                      /*!< VREF base address */
42 
43 /* registers definitions */
44 #define VREF_CS                   REG32(VREF + 0x00000000U)      /*!< VREF Control and status register */
45 #define VREF_CALIB                REG32(VREF + 0x00000004U)      /*!< VREF Calibration register */
46 
47 /* bits definitions */
48 /* VREF_CS */
49 #define VREF_CS_VREFEN            BIT(0)                         /*!< VREF enable */
50 #define VREF_CS_HIPM              BIT(1)                         /*!< High impedance mode */
51 #define VREF_CS_VREFRDY           BIT(3)                         /*!< VREF ready */
52 
53 /* VREF_CALIB */
54 #define VREF_CALIB_VREFCAL        BITS(0,5)                      /*!< VREF calibration */
55 
56 /* VREF bit devinitions */
57 #define VREF_EN                      VREF_CS_VREFEN              /*!< VREF enable */
58 #define VREF_HIGH_IMPEDANCE_MODE     VREF_CS_HIPM                /*!< High impedance mode */
59 #define VREF_RDY                     VREF_CS_VREFRDY             /*!< VREF ready */
60 
61 /* function declarations */
62 /* deinitialize the VREF */
63 void vref_deinit(void);
64 /* enable VREF */
65 void vref_enable(void);
66 /* disable VREF */
67 void vref_disable(void);
68 /* enable VREF high impendance mode */
69 void vref_high_impedance_mode_enable(void);
70 /* disable VREF high impendance mode */
71 void vref_high_impedance_mode_disable(void);
72 /* get the status of VREF */
73 FlagStatus vref_status_get(void);
74 /* set the calibration value of VREF */
75 void syscfg_vref_calib_value_set(uint8_t value);
76 /* get the calibration value of VREF */
77 uint8_t syscfg_vref_calib_value_get(void);
78 
79 #endif /* GD32L23X_VREF_H */
80