/*********************************************************
*Copyright (C), 2024-2030
*文件名:	USER.h
*版  本:	Ver1.00
*日  期:	2024/08/15
*描  述:	main.c的函数配置
*备  注:	
**********************************************************/
#ifndef   __USER_H__
#define   __USER_H__
#include "common.h"

#define SECTOR_SIZE 512

#define NVR4_START_ADC_ADDR 0x620 //ADC
#define NVR1_START_ADDR 0X00		//NVR1扇区首地址
#define NVR2_START_ADDR 0X200		//NVR2扇区首地址
#define NVR3_START_ADDR 0X400		//NVR3扇区首地址
#define NVR4_START_ADDR 0X600		//NVR4扇区首地址
#define NVR5_START_ADDR 0X800		//NVR1扇区首地址
#define NVR6_START_ADDR 0XA00		//NVR2扇区首地址
#define NVR7_START_ADDR 0XC00		//NVR3扇区首地址
#define NVR8_START_ADDR 0XE00		//NVR4扇区首地址
#define NVR9_START_ADDR 0X1000	//NVR1扇区首地址
#define NVR10_START_ADDR 0X1200	//NVR2扇区首地址
#define NVR11_START_ADDR 0X1400	//NVR3扇区首地址
#define NVR12_START_ADDR 0X1600	//NVR4扇区首地址
#define NVR13_START_ADDR 0X1800	//NVR1扇区首地址
#define NVR14_START_ADDR 0X1A00	//NVR2扇区首地址
#define NVR15_START_ADDR 0X1C00	//NVR3扇区首地址
#define NVR16_START_ADDR 0X1E00	//NVR4扇区首地址


void write_nvr(unsigned char *buf, unsigned int SectorAddr, unsigned int len);
void erase_nvr(unsigned int SectorAddr);
void read_nvr(unsigned char *buf,unsigned int SectorAddr,unsigned int len);
typedef enum
{
	ADC_CHN_00 = 0x00,
	ADC_CHN_01 = 0x01,
	ADC_CHN_02 = 0x02,
	ADC_CHN_03 = 0x03,
	ADC_CHN_04 = 0x04,
	ADC_CHN_05 = 0x05,
	ADC_CHN_06 = 0x06,
	ADC_CHN_07 = 0x07,
	ADC_CHN_08 = 0x08,
	ADC_CHN_09 = 0x09,
	ADC_CHN_10 = 0x0A,
	ADC_CHN_11 = 0x0B,
	ADC_CHN_12 = 0x0C,
	ADC_CHN_13 = 0x0D,
	ADC_CHN_14 = 0x0E,
	ADC_CHN_15 = 0x0F,
	ADC_CHN_16 = 0x10,
	ADC_CHN_17 = 0x11,
	ADC_CHN_AVRF = 0x1C, 	/* 1/4 AVRF */
	ADC_CHN_VSS = 0x1D,		/* VSS */
	ADC_CHN_VDD = 0x1E, 	/* 1/4 VDD */
	ADC_CHN_INNER = 0x1F, /* 1/2 基准 */
}ADC_CHN_ENUM;

/**********************************************/
int read_trimed_adc(char sign, int k);
void adc_read_test();
bit ADC_CHECK();
int read_adc();
void ADC_INIT(INT8U i_model);
void adc_set_channel(ADC_CHN_ENUM chn);
void ADC_SCAN(void);

#endif