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.
168 lines
3.5 KiB
168 lines
3.5 KiB
4 months ago
|
/**
|
||
|
******************************************************************************
|
||
|
* @copyright Copyright (C), 2016-2022, ConvenientPower. Co., Ltd.
|
||
|
* @file app_spec.h
|
||
|
* @version 1.0
|
||
|
* @author CPS SW Team
|
||
|
* @date 2022-10-24
|
||
|
* @brief Header file of APP_SPEC_H module.
|
||
|
******************************************************************************
|
||
|
*/
|
||
|
#ifndef _APP_SPEC_H_
|
||
|
#define _APP_SPEC_H_
|
||
|
#include "customized.h"
|
||
|
#include "config.h"
|
||
|
|
||
|
#include "pd_protocol.h"
|
||
|
#include "dpdn_protocol.h"
|
||
|
|
||
|
#define MTP_TRIM_MAGIC_WORD 0xAA55AA55
|
||
|
typedef union
|
||
|
{
|
||
|
uint8_t byte;
|
||
|
struct
|
||
|
{
|
||
|
uint8_t read_not_support: 1;
|
||
|
uint8_t write_not_support: 1;
|
||
|
uint8_t mtp_not_check: 1;
|
||
|
uint8_t erase_not_all: 1;
|
||
|
uint8_t resverd0: 4;
|
||
|
} bits;
|
||
|
} mtp_trim_flag_u;
|
||
|
typedef struct mtp_trim_callback_s
|
||
|
{
|
||
|
void(*rom_dpdn_init)(void);
|
||
|
void(*rom_callback_deal)(uint8_t port, pd_param_s* pd_param);
|
||
|
void(*rom_errase_sector_deal)(uint32_t addr, uint32_t len);
|
||
|
} mtp_trim_callback_s;
|
||
|
|
||
|
typedef union support_protocol_u
|
||
|
{
|
||
|
uint8_t byte;
|
||
|
struct
|
||
|
{
|
||
|
//byte
|
||
|
uint8_t scp_support: 1;
|
||
|
uint8_t qc_support: 1;
|
||
|
uint8_t pd_support: 1;
|
||
|
uint8_t ufcs_support: 1;
|
||
|
uint8_t tfcp_support: 1;
|
||
|
uint8_t vfcp_support: 1;
|
||
|
uint8_t reserved: 2;
|
||
|
};
|
||
|
} support_protocol_u;
|
||
|
|
||
|
typedef enum
|
||
|
{
|
||
|
PROTOCOL_DISABLE_ALL = 0x00,
|
||
|
PROTOCOL_ONLY_ENABLE_SCP = 0x01,
|
||
|
PROTOCOL_ONLY_ENABLE_QC = 0x02,
|
||
|
PROTOCOL_ONLY_ENABLE_PD = 0x04,
|
||
|
PROTOCOL_DISABLE_QC_UFCS = 0X05,
|
||
|
PROTOCOL_DISABLE_UFCS = 0x07,
|
||
|
PROTOCOL_ONLY_ENABLE_UFCS = 0x08,
|
||
|
PROTOCOL_ONLY_ENABLE_TFCP = 0x10,
|
||
|
PROTOCOL_DISABLE_PD = 0x0B,
|
||
|
PROTOCOL_DISABLE_QC = 0x0D,
|
||
|
PROTOCOL_DISABLE_SCP = 0x0E,
|
||
|
PROTOCOL_ALL_ENABLE = 0xFF
|
||
|
} PROTOCOL_SELECT_e;
|
||
|
typedef enum
|
||
|
{
|
||
|
PROTOCOL_PD = 0,
|
||
|
PROTOCOL_QC,
|
||
|
PROTOCOL_FCP,
|
||
|
PROTOCOL_SCP,
|
||
|
PROTOCOL_UFCS,
|
||
|
PROTOCOL_TFCP,
|
||
|
PROTOCOL_AFC,
|
||
|
PROTOCOL_UNKNOWN,
|
||
|
|
||
|
} PROTOCOL_TYPE_e;
|
||
|
typedef struct fw_footprint_s
|
||
|
{
|
||
|
uint8_t custom_id;
|
||
|
uint8_t project_id;
|
||
|
uint8_t fw_ver_major;
|
||
|
uint8_t fw_ver_minor;
|
||
|
uint8_t hw_ver_minor;
|
||
|
uint8_t hw_ver_major;
|
||
|
uint8_t fw_len[4];
|
||
|
uint8_t fw_magic[2];
|
||
|
mtp_trim_flag_u mtp_trim_flag;
|
||
|
uint16_t boot_to_mtp_delay;
|
||
|
uint8_t resverd1;
|
||
|
|
||
|
const mtp_trim_callback_s *mtp_trim_callback;
|
||
|
uint32_t magic_word;
|
||
|
} __attribute__((packed)) fw_footprint_s;
|
||
|
|
||
|
typedef struct app_protocol_param_s
|
||
|
{
|
||
|
#if PD_SUPPORT | TYPEC_SUPPORT
|
||
|
pd_param_s pd_param;
|
||
|
#endif
|
||
|
|
||
|
#if HVDCP_SUPPORT | QC_SCP_SUPPORT | UFCS_SUPPORT
|
||
|
dpdn_param_s dpdn_param;
|
||
|
#endif
|
||
|
uint8_t protocol_type;
|
||
|
support_protocol_u support_protocol;
|
||
|
} app_protocol_param_s;
|
||
|
|
||
|
extern app_protocol_param_s g_app_protocol_param[TYPEC_PORT_MAX];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
#define DN_TRIGGER_COMP_ENABLE()\
|
||
|
do{\
|
||
|
drv_analog_gp_mask_set(0x08);\
|
||
|
}while(0)
|
||
|
|
||
|
|
||
|
#define MAX_LOOP_TASK_NUM ARRY_LEN(loop_task_action)
|
||
|
|
||
|
|
||
|
typedef void (*task_action_t)(uint8_t port);
|
||
|
|
||
|
|
||
|
#define LOOP_TASK_RUN(x)\
|
||
|
loop_task_run(x)
|
||
|
|
||
|
/*
|
||
|
* @brief rom_dpdn_init_patch
|
||
|
* @param NULL
|
||
|
* @note
|
||
|
* @retval
|
||
|
*/
|
||
|
void rom_dpdn_init_patch(void);
|
||
|
|
||
|
/*
|
||
|
* @brief app_protocol_reset
|
||
|
* @param null
|
||
|
* @note
|
||
|
* @retval null
|
||
|
*/
|
||
|
void app_protocol_reset(uint8_t port);
|
||
|
|
||
|
/*
|
||
|
* @brief app_spec_run
|
||
|
* @param null
|
||
|
* @note
|
||
|
* @retval null
|
||
|
*/
|
||
|
void app_spec_run(uint8_t port);
|
||
|
|
||
|
|
||
|
/*
|
||
|
* @brief periodic_work
|
||
|
* @param port
|
||
|
* @note
|
||
|
* @retval null
|
||
|
*/
|
||
|
void periodic_work(uint8_t port);
|
||
|
|
||
|
|
||
|
#endif
|