1 /**
2   ******************************************************************************
3   * @file    lib_LoadNVR.h
4   * @author  Application Team
5   * @version V4.7.0
6   * @date    2019-12-12
7   * @brief   Load information from NVR.
8   ******************************************************************************
9   * @attention
10   *
11   ******************************************************************************
12   */
13 
14 #ifndef __LIB_LOADNVR_H
15 #define __LIB_LOADNVR_H
16 
17 #ifdef __cplusplus
18  extern "C" {
19 #endif
20 
21 /* Includes ------------------------------------------------------------------*/
22 #include "target.h"
23 
24 /* BAT measure result */
25 typedef struct
26 {
27   float  BATRESResult;  // BAT Resistor division Measure Result
28   float  BATCAPResult;  // BATRTC Cap division Measure Result
29 } NVR_BATMEARES;
30 
31 /* Power Measure Result */
32 typedef struct
33 {
34   uint32_t  AVCCMEAResult;  // LDO33 Measure Result
35   uint32_t  DVCCMEAResult;  // LDO15 Measure Result
36   uint32_t  BGPMEAResult;    // BGP Measure Result
37   uint32_t  RCLMEAResult;    // RCL Measure Result
38   uint32_t  RCHMEAResult;    // RCH Measure Result
39 } NVR_MISCGain;
40 
41 /* Chip ID */
42 typedef struct
43 {
44   uint32_t  ChipID0;        // ID word 0
45   uint32_t  ChipID1;        // ID word 1
46 } NVR_CHIPID;
47 
48 /* Temperature information */
49 typedef struct
50 {
51   float  TempOffset;
52 } NVR_TEMPINFO;
53 
54 /* LCD information */
55 typedef struct
56 {
57   uint32_t  MEALCDLDO;     // Measure LCD LDO pre trim value
58   uint32_t  MEALCDVol;     // VLCD setting
59 } NVR_LCDINFO;
60 
61 /* RTC(temp) information */
62 typedef struct
63 {
64   int16_t RTCTempP0; //P0
65   int16_t RTCTempP1; //P1
66   int32_t RTCTempP2; //P2
67   int16_t RTCTempP4; //P4
68   int16_t RTCTempP5; //P5
69   int16_t RTCTempP6; //P6
70   int16_t RTCTempP7; //P7
71   int16_t RTCTempK1; //K1
72   int16_t RTCTempK2; //K2
73   int16_t RTCTempK3; //K3
74   int16_t RTCTempK4; //K4
75   int16_t RTCTempK5; //K5
76   int16_t RTCACTI;      //Center temperature
77   uint32_t RTCACKTemp;  //section X temperature
78   int16_t RTCTempDelta; //Temperature delta
79   uint32_t RTCACF200;   //RTC_ACF200
80   uint32_t APBClock;    //APB clock
81 } NVR_RTCINFO;
82 
83 /* ADC Voltage Parameters */
84 typedef struct
85 {
86   float aParameter;
87   float bParameter;
88 } NVR_ADCVOLPARA;
89 //Mode
90 #define NVR_3V_EXTERNAL_NODIV    (0x000UL)    // Power supply: 3.3V;    Channel: External;    Divider modeL: None
91 #define NVR_3V_EXTERNAL_RESDIV   (0x001UL)    // Power supply: 3.3V;    Channel: External;    Divider modeL: Resistive
92 #define NVR_3V_EXTERNAL_CAPDIV   (0x002UL)    // Power supply: 3.3V;    Channel: External;    Divider modeL: Capacitive
93 #define NVR_3V_VDD_RESDIV        (0x003UL)    // Power supply: 3.3V;    Channel: VDD;         Divider modeL: Resistive
94 #define NVR_3V_VDD_CAPDIV        (0x004UL)    // Power supply: 3.3V;    Channel: VDD;         Divider modeL: Capacitive
95 #define NVR_3V_BATRTC_RESDIV     (0x005UL)    // Power supply: 3.3V;    Channel: BATRTC;      Divider modeL: Resistive
96 #define NVR_3V_BATRTC_CAPDIV     (0x006UL)    // Power supply: 3.3V;    Channel: BATRTC;      Divider modeL: Capacitive
97 #define NVR_5V_EXTERNAL_NODIV    (0x100UL)    // Power supply: 5V;      Channel: External;    Divider modeL: None
98 #define NVR_5V_EXTERNAL_RESDIV   (0x101UL)    // Power supply: 5V;      Channel: External;    Divider modeL: Resistive
99 #define NVR_5V_EXTERNAL_CAPDIV   (0x102UL)    // Power supply: 5V;      Channel: External;    Divider modeL: Capacitive
100 #define NVR_5V_VDD_RESDIV        (0x103UL)    // Power supply: 5V;      Channel: VDD;         Divider modeL: Resistive
101 #define NVR_5V_VDD_CAPDIV        (0x104UL)    // Power supply: 5V;      Channel: VDD;         Divider modeL: Capacitive
102 #define NVR_5V_BATRTC_RESDIV     (0x105UL)    // Power supply: 5V;      Channel: BATRTC;      Divider modeL: Resistive
103 #define NVR_5V_BATRTC_CAPDIV     (0x106UL)    // Power supply: 5V;      Channel: BATRTC;      Divider modeL: Capacitive
104 #define IS_NVR_ADCVOL_MODE(__MODE__)  (((__MODE__) == NVR_3V_EXTERNAL_NODIV)   ||\
105                                        ((__MODE__) == NVR_3V_EXTERNAL_RESDIV)  ||\
106                                        ((__MODE__) == NVR_3V_EXTERNAL_CAPDIV)  ||\
107                                        ((__MODE__) == NVR_3V_VDD_RESDIV)       ||\
108                                        ((__MODE__) == NVR_3V_VDD_CAPDIV)       ||\
109                                        ((__MODE__) == NVR_3V_BATRTC_RESDIV)    ||\
110                                        ((__MODE__) == NVR_3V_BATRTC_CAPDIV)    ||\
111                                        ((__MODE__) == NVR_5V_EXTERNAL_NODIV)   ||\
112                                        ((__MODE__) == NVR_5V_EXTERNAL_RESDIV)  ||\
113                                        ((__MODE__) == NVR_5V_EXTERNAL_CAPDIV)  ||\
114                                        ((__MODE__) == NVR_5V_VDD_RESDIV)       ||\
115                                        ((__MODE__) == NVR_5V_VDD_CAPDIV)       ||\
116                                        ((__MODE__) == NVR_5V_BATRTC_RESDIV)    ||\
117                                        ((__MODE__) == NVR_5V_BATRTC_CAPDIV))
118 
119 /********** NVR Address **********/
120 //ADC Voltage Parameters
121 #define NVR_3VPARA_BASEADDR1          (__IO uint32_t *)(0x40400)
122 #define NVR_3VPARA_BASEADDR2          (__IO uint32_t *)(0x40440)
123 #define NVR_5VPARA_BASEADDR1          (__IO uint32_t *)(0x40480)
124 #define NVR_5VPARA_BASEADDR2          (__IO uint32_t *)(0x404C0)
125 //RTC DATA
126 //P4
127 #define NVR_RTC1_P4                   (__IO uint32_t *)(0x40800)
128 #define NVR_RTC1_P4_CHKSUM            (__IO uint32_t *)(0x40804)
129 #define NVR_RTC2_P4                   (__IO uint32_t *)(0x40808)
130 #define NVR_RTC2_P4_CHKSUM            (__IO uint32_t *)(0x4080C)
131 //ACK1~ACK5
132 #define NVR_RTC1_ACK1                 (__IO uint32_t *)(0x40810)
133 #define NVR_RTC1_ACK2                 (__IO uint32_t *)(0x40814)
134 #define NVR_RTC1_ACK3                 (__IO uint32_t *)(0x40818)
135 #define NVR_RTC1_ACK4                 (__IO uint32_t *)(0x4081C)
136 #define NVR_RTC1_ACK5                 (__IO uint32_t *)(0x40820)
137 #define NVR_RTC1_ACK_CHKSUM           (__IO uint32_t *)(0x40824)
138 #define NVR_RTC2_ACK1                 (__IO uint32_t *)(0x40828)
139 #define NVR_RTC2_ACK2                 (__IO uint32_t *)(0x4082C)
140 #define NVR_RTC2_ACK3                 (__IO uint32_t *)(0x40830)
141 #define NVR_RTC2_ACK4                 (__IO uint32_t *)(0x40834)
142 #define NVR_RTC2_ACK5                 (__IO uint32_t *)(0x40838)
143 #define NVR_RTC2_ACK_CHKSUM           (__IO uint32_t *)(0x4083C)
144 //ACTI
145 #define NVR_RTC1_ACTI                 (__IO uint32_t *)(0x40840)
146 #define NVR_RTC1_ACTI_CHKSUM          (__IO uint32_t *)(0x40844)
147 #define NVR_RTC2_ACTI                 (__IO uint32_t *)(0x40848)
148 #define NVR_RTC2_ACTI_CHKSUM          (__IO uint32_t *)(0x4084C)
149 //ACKTEMP
150 #define NVR_RTC1_ACKTEMP              (__IO uint32_t *)(0x40850)
151 #define NVR_RTC1_ACKTEMP_CHKSUM       (__IO uint32_t *)(0x40854)
152 #define NVR_RTC2_ACKTEMP              (__IO uint32_t *)(0x40858)
153 #define NVR_RTC2_ACKTEMP_CHKSUM       (__IO uint32_t *)(0x4085C)
154 //Analog trim data
155 #define NVR_ANA_TRIMDATA1             (__IO uint32_t *)(0x40DC0)
156 #define NVR_ANA_OPREG1                (__IO uint32_t *)(0x40DC4)
157 #define NVR_ANA_KEYREG1               (__IO uint32_t *)(0x40DC8)
158 #define NVR_ANA_CHECKSUM1             (__IO uint32_t *)(0x40DCC)
159 #define NVR_ANA_TRIMDATA2             (__IO uint32_t *)(0x40DD0)
160 #define NVR_ANA_OPREG2                (__IO uint32_t *)(0x40DD4)
161 #define NVR_ANA_KEYREG2               (__IO uint32_t *)(0x40DD8)
162 #define NVR_ANA_CHECKSUM2             (__IO uint32_t *)(0x40DDC)
163 //BAT Measure Result
164 #define NVR_BAT_R1                    (__IO uint32_t *)(0x40CE0)
165 #define NVR_BAT_C1                    (__IO uint32_t *)(0x40CE4)
166 #define NVR_BATMEA_CHECHSUM1          (__IO uint32_t *)(0x40CE8)
167 #define NVR_BAT_R2                    (__IO uint32_t *)(0x40CF0)
168 #define NVR_BAT_C2                    (__IO uint32_t *)(0x40CF4)
169 #define NVR_BATMEA_CHECHSUM2          (__IO uint32_t *)(0x40CF8)
170 //RTC AutoCal Px pramameters
171 #define NVR_RTC1_P1_P0                (__IO uint32_t *)(0x40D00)
172 #define NVR_RTC1_P2                   (__IO uint32_t *)(0x40D04)
173 #define NVR_RTC1_P5_P4                (__IO uint32_t *)(0x40D08)
174 #define NVR_RTC1_P7_P6                (__IO uint32_t *)(0x40D0C)
175 #define NVR_RTC1_PCHECHSUM            (__IO uint32_t *)(0x40D10)
176 #define NVR_RTC2_P1_P0                (__IO uint32_t *)(0x40D14)
177 #define NVR_RTC2_P2                   (__IO uint32_t *)(0x40D18)
178 #define NVR_RTC2_P5_P4                (__IO uint32_t *)(0x40D1C)
179 #define NVR_RTC2_P7_P6                (__IO uint32_t *)(0x40D20)
180 #define NVR_RTC2_PCHECHSUM            (__IO uint32_t *)(0x40D24)
181 //Power Measure Result
182 #define NVR_DVCC_MEA1                 (__IO uint32_t *)(0x40D28)
183 #define NVR_AVCC_MEA1                 (__IO uint32_t *)(0x40D2C)
184 #define NVR_BGP_MEA1                  (__IO uint32_t *)(0x40D30)
185 #define NVR_RCL_MEA1                  (__IO uint32_t *)(0x40D34)
186 #define NVR_RCH_MEA1                  (__IO uint32_t *)(0x40D38)
187 #define NVR_PWR_CHECKSUM1             (__IO uint32_t *)(0x40D3C)
188 #define NVR_DVCC_MEA2                 (__IO uint32_t *)(0x40D40)
189 #define NVR_AVCC_MEA2                 (__IO uint32_t *)(0x40D44)
190 #define NVR_BGP_MEA2                  (__IO uint32_t *)(0x40D48)
191 #define NVR_RCL_MEA2                  (__IO uint32_t *)(0x40D4C)
192 #define NVR_RCH_MEA2                  (__IO uint32_t *)(0x40D50)
193 #define NVR_PWR_CHECKSUM2             (__IO uint32_t *)(0x40D54)
194 //Chip ID
195 #define NVR_CHIP1_ID0                 (__IO uint32_t *)(0x40D58)
196 #define NVR_CHIP1_ID1                 (__IO uint32_t *)(0x40D5C)
197 #define NVR_CHIP1_CHECKSUM            (__IO uint32_t *)(0x40D60)
198 #define NVR_CHIP2_ID0                 (__IO uint32_t *)(0x40D64)
199 #define NVR_CHIP2_ID1                 (__IO uint32_t *)(0x40D68)
200 #define NVR_CHIP2_CHECKSUM            (__IO uint32_t *)(0x40D6C)
201 //Temperature information
202 #define NVR_REALTEMP1                 (__IO uint32_t *)(0x40D70)
203 #define NVR_MEATEMP1                  (__IO uint32_t *)(0x40D74)
204 #define NVR_TEMP_CHECKSUM1            (__IO uint32_t *)(0x40D78)
205 #define NVR_REALTEMP2                 (__IO uint32_t *)(0x40D7C)
206 #define NVR_MEATEMP2                  (__IO uint32_t *)(0x40D80)
207 #define NVR_TEMP_CHECKSUM2            (__IO uint32_t *)(0x40D84)
208 //LCD Information
209 #define NVR_LCD_LDO1                  (__IO uint32_t *)(0x40D90)
210 #define NVR_LCD_VOL1                  (__IO uint32_t *)(0x40D94)
211 #define NVR_LCD_CHECKSUM1             (__IO uint32_t *)(0x40D98)
212 #define NVR_LCD_LDO2                  (__IO uint32_t *)(0x40D9C)
213 #define NVR_LCD_VOL2                  (__IO uint32_t *)(0x40DA0)
214 #define NVR_LCD_CHECKSUM2             (__IO uint32_t *)(0x40DA4)
215 
216 
217 uint32_t NVR_LoadANADataManual(void);
218 uint32_t NVR_GetADCVoltageParameter(uint32_t Mode, NVR_ADCVOLPARA *Parameter);
219 uint32_t NVR_GetBATOffset(NVR_BATMEARES *MEAResult);
220 uint32_t NVR_GetInfo_LoadRTCData(NVR_RTCINFO *RTCTempData);
221 uint32_t NVR_GetMISCGain(NVR_MISCGain *MEAResult);
222 uint32_t NVR_GetChipID(NVR_CHIPID *ChipID);
223 uint32_t NVR_GetLCDInfo(NVR_LCDINFO *LCDInfo);
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif /* __LIB_LOADNVR_H */
230 
231 /*********************************** END OF FILE ******************************/
232