177 lines
4.3 KiB
C
177 lines
4.3 KiB
C
|
|
/*
|
|||
|
|
*Copyright ,2023 , NANOCHAP
|
|||
|
|
*File name: ENS1_ANAC.H
|
|||
|
|
*Author:
|
|||
|
|
*Version: V1.0
|
|||
|
|
*Date: 2023-11-
|
|||
|
|
*Description:
|
|||
|
|
*Function List:
|
|||
|
|
|
|||
|
|
History:
|
|||
|
|
1.V1.0
|
|||
|
|
Date:
|
|||
|
|
Author:
|
|||
|
|
Modification: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#ifndef ENS1_ANAC_H
|
|||
|
|
#define ENS1_ANAC_H
|
|||
|
|
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include "CMSDK_CM0.h"
|
|||
|
|
#include "my_header.h"
|
|||
|
|
#include "ENS1_GPIO.h"
|
|||
|
|
/*-------------------boost------------------------*/
|
|||
|
|
extern uint8_t Boost_Voltage_Sel(uint8_t VOLTAGE_XV);
|
|||
|
|
#define VOLTAGE_11V 0x0
|
|||
|
|
#define VOLTAGE_15V 0x1
|
|||
|
|
#define VOLTAGE_26V 0x2
|
|||
|
|
#define VOLTAGE_45V 0x3
|
|||
|
|
#define VOLTAGE_55V 0x4
|
|||
|
|
|
|||
|
|
|
|||
|
|
/*-------------------<2D>Ƚ<EFBFBD><C8BD><EFBFBD>------------------------*/
|
|||
|
|
/*
|
|||
|
|
<EFBFBD>Ƚ<EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
GPIO12 -- COMP1_VIP0
|
|||
|
|
GPIO13 -- COMP1_VIP1
|
|||
|
|
GPIO14 -- COMP1_VIN0
|
|||
|
|
GPIO15 -- COMP1_VIN1
|
|||
|
|
GPIO21 -- COMP1_OUT
|
|||
|
|
|
|||
|
|
GPIO8 -- COMP0_VIP0
|
|||
|
|
GPIO9 -- COMP0_VIP1
|
|||
|
|
GPIO10 -- COMP0_VIN0
|
|||
|
|
GPIO11 -- COMP0_VIN1
|
|||
|
|
GPIO20 -- COMP0_OUT
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#define COMP_VREF_VOLTAGE_0_3v (uint8_t)(0x0)
|
|||
|
|
#define COMP_VREF_VOLTAGE_0_6v (uint8_t)(0x1)
|
|||
|
|
#define COMP_VREF_VOLTAGE_0_9v (uint8_t)(0x2)
|
|||
|
|
#define COMP_VREF_VOLTAGE_1_2v (uint8_t)(0x3)
|
|||
|
|
#define COMP_VREF_VOLTAGE_1_5v (uint8_t)(0x4)
|
|||
|
|
#define COMP_VREF_VOLTAGE_1_8v (uint8_t)(0x5)
|
|||
|
|
#define COMP_VREF_VOLTAGE_2_1v (uint8_t)(0x6)
|
|||
|
|
#define COMP_VREF_VOLTAGE_2_4v (uint8_t)(0x7)
|
|||
|
|
|
|||
|
|
#define COMP_NEG_INPUT_VIN0 (uint8_t)(0x0)
|
|||
|
|
#define COMP_NEG_INPUT_VIN1 (uint8_t)(0x1)
|
|||
|
|
#define COMP_NEG_INPUT_VREF (uint8_t)(0x2)
|
|||
|
|
|
|||
|
|
#define COMP_POS_INPUT_VIP0 (uint8_t)(0x1)
|
|||
|
|
#define COMP_POS_INPUT_VIP1 (uint8_t)(0x2)
|
|||
|
|
|
|||
|
|
typedef enum{COMP0=0, COMP1}COMP_NUM;
|
|||
|
|
typedef struct COMPConfig
|
|||
|
|
{
|
|||
|
|
COMP_NUM COMPARATOR_NUM;
|
|||
|
|
uint8_t COMP_VREF_SEL;
|
|||
|
|
uint8_t COMP_SIGSEL_NEGATIVE_INPUT_SEL;
|
|||
|
|
uint8_t COMP_SIGSEL_POSITIVE_INPUT_SEL;
|
|||
|
|
}COMP_ConfigStructure;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/*<2A>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
|
extern void CompInitSet(COMP_ConfigStructure* COMPCONFIG);
|
|||
|
|
|
|||
|
|
/*<2A><><EFBFBD>ȽϽ<C8BD><CFBD><EFBFBD>*/
|
|||
|
|
extern uint8_t Read_Comp_Output(COMP_NUM NUM);
|
|||
|
|
|
|||
|
|
/*<2A><><EFBFBD><EFBFBD>/<2F>رձȽ<D5B1><C8BD><EFBFBD>*/
|
|||
|
|
extern void CompControl(COMP_NUM NUM ,FunctionalState Newstate);
|
|||
|
|
|
|||
|
|
|
|||
|
|
/*-----------------------------PGA------------------------------*/
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
PGA IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>
|
|||
|
|
GPIO16 -- PGA_VIP0 //<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>ֱ<EFBFBD><D6B1>
|
|||
|
|
GPIO18 -- PGA_VIN0 //<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
GPIO17 -- PGA_VIP1 //<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>ֱ<EFBFBD><D6B1>
|
|||
|
|
GPIO19 -- PGA_VIN1 //<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
GPIO20 -- PGA_EXVCM
|
|||
|
|
|
|||
|
|
GPIO4 -- PGA_OUT
|
|||
|
|
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
//#define PGA_POSITIVE_INPUT_VBAT (uint8_t)(0x3)
|
|||
|
|
//#define PGA_POSITIVE_INPUT_AVDD1P8 (uint8_t)(0x4)
|
|||
|
|
//#define PGA_POSITIVE_INPUT_VLCD0 (uint8_t)(0x5)
|
|||
|
|
//#define PGA_POSITIVE_INPUT_V_TEMP (uint8_t)(0x7)
|
|||
|
|
|
|||
|
|
|
|||
|
|
//PGA<47>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1> <20><><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>ģʽ<C4A3><CABD> 1-8 <20><><EFBFBD><EFBFBD> ͬ<><CDAC>ģʽ2-9<><39>
|
|||
|
|
#define PGA_GAIN_1X_2X (uint8_t)(0x0)
|
|||
|
|
#define PGA_GAIN_2X_3X (uint8_t)(0x1)
|
|||
|
|
#define PGA_GAIN_3X_4X (uint8_t)(0x2)
|
|||
|
|
#define PGA_GAIN_4X_5X (uint8_t)(0x3)
|
|||
|
|
#define PGA_GAIN_5X_6X (uint8_t)(0x4)
|
|||
|
|
#define PGA_GAIN_6X_7X (uint8_t)(0x5)
|
|||
|
|
#define PGA_GAIN_7X_8X (uint8_t)(0x6)
|
|||
|
|
#define PGA_GAIN_8X_9X (uint8_t)(0x7)
|
|||
|
|
|
|||
|
|
|
|||
|
|
typedef enum{PGA_NEGATIVE_INPUT_PGA_VIN0 = 0,PGA_NEGATIVE_INPUT_PGA_VIN1, PGA_NEGATIVE_INPUT_INTERNAL_VCM,PGA_NEGATIVE_INPUT_EXTERNAL_VCM}PGA_NEG_SEL;
|
|||
|
|
typedef enum{PGA_POSITIVE_INPUT_PGA_VIP0 = 0,PGA_POSITIVE_INPUT_PGA_VIP1=1,PGA_POSITIVE_INPUT_INTERNAL_VCM=2,PGA_POSITIVE_INPUT_VREF1_2V=6}PGA_POS_SEL;
|
|||
|
|
typedef enum{PGA_TO_GPIO4=0 , PGA_TO_ADC=1}PGA_OUTPUT_SEL;
|
|||
|
|
typedef struct PGAConfig
|
|||
|
|
{
|
|||
|
|
PGA_NEG_SEL PGA_NEG_SELx ;
|
|||
|
|
PGA_POS_SEL PGA_POS_SELx ;
|
|||
|
|
uint8_t PGA_GAIN_SEL ;
|
|||
|
|
PGA_OUTPUT_SEL PGA_OUT ;
|
|||
|
|
}PGA_ConfigStructure;
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD><CABC>
|
|||
|
|
extern void PGAInitSet(PGA_ConfigStructure* PGACONFIG );
|
|||
|
|
|
|||
|
|
//PGA<47><41><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>
|
|||
|
|
extern void PGAControl(FunctionalState Newstate);
|
|||
|
|
|
|||
|
|
|
|||
|
|
/*--------------------------<2D>͵<EFBFBD>ѹ<EFBFBD><D1B9>оƬ<D0BE><C6AC><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>-------------------------*/
|
|||
|
|
void PMU_TEMP150C_TRIGControl(FunctionalState Newstate); //<2F><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><C2B6>Ƿ<C7B7>150<35>ȵ<EFBFBD>״ֵ̬
|
|||
|
|
int8_t TEMP_150C_TRIG_SIGNAL(void);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#define LVD_4P2V (uint8_t)(0x0)
|
|||
|
|
#define LVD_3P9V (uint8_t)(0x1)
|
|||
|
|
#define LVD_3P6V (uint8_t)(0x2)
|
|||
|
|
#define LVD_3P3V (uint8_t)(0x3)
|
|||
|
|
#define LVD_3P0V (uint8_t)(0x4)
|
|||
|
|
#define LVD_2P7V (uint8_t)(0x5)
|
|||
|
|
#define LVD_2P4V (uint8_t)(0x6)
|
|||
|
|
#define LVD_2P1V (uint8_t)(0x7)
|
|||
|
|
//<2F>͵<EFBFBD>ѹ<EFBFBD>澯
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ѹ
|
|||
|
|
void LVD_InitSet(uint8_t Threshold_voltage);
|
|||
|
|
//<2F><EFBFBD><F2BFAABB>رմ˹<D5B4><CBB9><EFBFBD>
|
|||
|
|
void PMU_LVD_Control(FunctionalState Newstate);
|
|||
|
|
//<2F><>ȡ<EFBFBD>͵<EFBFBD>ѹ״̬
|
|||
|
|
uint8_t Read_LVD_Signal(void);
|
|||
|
|
|
|||
|
|
/*-------------------------<2D><>϶BUFFER<45><52><EFBFBD>û<EFBFBD><C3BB>ر<EFBFBD>-------------------------*/
|
|||
|
|
void PMU_BANDGAP_CONTROL(FunctionalState Newstate);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|