You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

279 lines
5.9 KiB

/*
* @Copyright (C),: 2020-2030, ConvenientPower Inc.
* @File:
* @Author: your name
* @Date: 2023-01-05 10:16:59
* @LastEditTime: 2023-01-05 18:19:22
* @LastEditors: your name
* @Description: Used to specify the main functions accomplished by this program file
*/
/**
******************************************************************************
* @copyright Copyright (C), 2016-2022, ConvenientPower. Co., Ltd.
* @file config.h
* @version 1.0
* @author qing.cheng
* @date 2023-01-04
* @brief Header file of CONFIG_H module.
******************************************************************************
*/
#ifndef _CONFIG_H_
#define _CONFIG_H_
#include "comp_config.h"
#define BUCK_FOLLOW_TYPEC_VOLTAGE 1
/******************log debug***************************/
#define UART_DEUG 0
#if UART_DEUG
#define SIM_UART_DEBUG 0
#if SIM_UART_DEBUG
#define log_info comp_sim_uart_sync_print
#else
#define log_info comp_uart2_sync_print
#endif
#else
#define log_info(...)
#endif
#define FB_FUNC_ENABLE 0
#if !UART_DEUG
#define NTC_ENABLE 0
#endif
#if FB_FUNC_ENABLE
//1:100 0:50
#define FB_CV_GAIN_CHOICE 1
#endif/**FB_FUNC_ENABLE**/
#define I2C_DC_SUPPORT 0
#define I2C_POWER_CONSULT 0
/****************CPS8841H MTP project info*******************/
#define SOFT_WARE_VERISION_H 0x00
#define SOFT_WARE_VERISION_L 0x04
#define CUSTOM_ID 0xc0
#define PROJECT_ID 0x41
/**********************param************************************/
/*The voltage is adjusted to a percentage of ps rdy*/
#define PERCENT_OF_VOL_REGULA 5
/*Do not look at the voltage adjustment completed current difference */
#define PS_RDY_CHECK_CURRENT 150
/*Cable impedance SNS R*/
#define CABLE_IMPEDANCE_R 100
/*Cable large compensation voltage*/
#define CABLE_COMP_MAX_VOL 300
#define FIX_CC_OFFEST 400
/*sample resistor*/
#define HS_SINS_R 5
#define LS_SINS_R 5
#define QC30_MAX_VOL VOLTAGE_12V
#define QC30_MIN_VOL VOLTAGE_3P3V
#define USBA_PORT_DETECT_SUPPORT 1
/***********protocol support***********************/
#define TYPEC_SUPPORT 1
#define PD_SUPPORT 1
#if PD_SUPPORT
#define PD_EMARK_SUPPORT 0
#define PD_DERATE_SUPPORT 0
#define PD_HW_UVDM_POWER_SUPPORT 0
#endif/**PD_SUPPORT**/
#define DCP_SUPPORT 1
#define HVDCP_SUPPORT 1
#define QC_SCP_SUPPORT 1
#if QC_SCP_SUPPORT & HVDCP_SUPPORT
#define SCP_SUPPORT 1
#if SCP_SUPPORT
#define SCP_DERATE_SUPPORT 0
#endif/*SCP_SUPPORT*/
#define QC_SUPPORT 1
#if QC_SUPPORT
#define QC3P0_SUPPORT 1
#endif/**QC_SUPPORT**/
#endif/**QC_SCP_SUPPORT**/
#define UFCS_SUPPORT 0
#if UFCS_SUPPORT
#define UFCS_DERATE_SUPPORT 1
#endif/**UFCS_SUPPORT**/
#define APPLE_MODE_SUPPORT 0
#define TFCP_SUPPORT 0
#define AFC_SUPPORT 0
#define VFCP_SUPPORT 0
#define PROTECTION_SUPPORT 1
#if PROTECTION_SUPPORT
#define VIN_OVP_SUPPORT 1
#define CHIP_OTP_SUPPORT 0
#define DNDP_OVP_SUPPORT 1
#define GATE_UVP_SUPPORT 0
#define V2_OCP_SUPPORT 0
#define VBUS_OCP_SUPPORT 0
#define CCx_OVP_SUPPORT 0
#define VCONN_OCP_SUPPORT 0
#endif/**PROTECTION_SUPPORT**/
#define ADC_ENABLE 1
#if ADC_ENABLE
#define ADC_VIN_SAMPLE_EN 1
#define ADC_VBUS_SAMPLE_EN 1
#define ADC_HS_CUR_SAMPLE_EN 1
#define ADC_CC1_SAMPLE_EN 0
#define ADC_CC2_SAMPLE_EN 0
#define ADC_DP_SAMPLE_EN 1
#if ADC_DP_SAMPLE_EN
//1:1/3 0:1/1
#define DP_SCAL_EN 1
#endif /**ADC_DP_SAMPLE_EN**/
#define ADC_DN_SAMPLE_EN 1
#if ADC_DN_SAMPLE_EN
//1:1/3 0:1/1
#define DN_SCAL_EN 1
#endif /**ADC_DP_SAMPLE_EN**/
#define ADC_RT1_SAMPLE_EN 1
#define ADC_RT2_SAMPLE_EN 0
#if ADC_RT2_SAMPLE_EN
//00:vfb
//01:rt2 即FB
//10:rt3
#define RT2_SEL_PIN_MUX RT2
//1:1/2 0:1/1
#define RT2_SCAL_EN 0
#endif /**ADC_RT2_SAMPLE_EN*/
#define ADC_RT3_SAMPLE_EN 0
#if ADC_RT3_SAMPLE_EN
//1:1/2 0:1/1
#define RT3_SCAL_EN 0
#endif /**ADC_RT3_SAMPLE_EN*/
//00:RT4
//01:VD
//10:GP2
#define RT4_SEL_PIN_MUX RT4
#define ADC_RT4_SAMPLE_EN 0
#define ADC_CHIP_TEMP_SAMPLE_EN 1
#define ADC_VD_SAMPLE_EN 0
#define ADC_LS_CUR_SAMPLE_EN 1
#define ADC_GP1_SAMPLE_EN 1
#define ADC_GP2_SAMPLE_EN 1
#endif/**ADC_ENABLE**/
#define CHECK_CC_MODE_SUPPORT 1
#define CABLE_COMP_SUPPORT 1
#define POWEROUT_SUPPORT 1
#define WATCHDOG_ENABLE 1
#define DISCHARGE_ENABLE 1
#define POWER_ON_DISCHARGE 1
#define IFB_BUFFER_ENABLE 1
#define VD_ENABLE 0
#if VD_ENABLE
#define VD_PEAK_DETECT 1
#define VD_FREQ_DETECT 1
#endif/**VD_ENABLE**/
#define ADC_UPDATE_SUPPORT 1
#define DAC_TRIM_WAY_ENABLE 1
#define LOOP_TASK_ENABLE 0
#if LOOP_TASK_ENABLE
#define TEMP_REPORT_SUPPORT 1
#define GREEN_MODE_SUPPORT 0
#define SLEEP_MODE_SUPPORT 1
#define LPS_PROTE_ENABLE 0
#define AUTO_ZERO_SUPPORT 0
#endif
extern volatile uint32_t g_systick_cnt;
#define GET_SYSTICK16_TIME()\
g_systick_cnt
typedef enum
{
PORT_TYPE_USBA = 0,
PORT_TYPE_TYPEC,
PORT_TYPE_DUAL_PORT
} adp_port_type_e;
typedef enum
{
ADP_PORT0 = 0,
ADP_PORT1,
ADP_PORT_NUM_MAX
} adp_port_num_e;
typedef struct user_app_s
{
// uint16_t interrupt_event_1;
// uint16_t interrupt_event_2;
bool buck_state;
// uint16_t test_c_ocp_current;
uint16_t usba_high_current_vol;
uint16_t current_src_cap_idx; // 当前的src_cap档位
#if UFCS_SUPPORT
// rx收到包时间计数, 用于做发power_change间隔, 协议规定收到其他包12ms后才发power_change
volatile uint16_t ufcs_rx_package_cnt;
uint16_t ufcs_need_send_power_change;
#endif
#if NTC_ENABLE
bool ntc_triggered_dera;
bool last_ntc_triggered_dera;
#endif
// 上电后, 需要隔一段时间才能把5.5A电流设回去3.3A, 直接设3.3A的话,满载起机不行
volatile uint16_t first_power_cnt;
} user_app_s;
extern user_app_s user_app;
#endif