TEST_CODE_ApplyTo2V1_API

Dependencies:   SDFileSystem max32630fthr USBDevice

Committer:
china_sn0w
Date:
Tue Jul 28 01:40:05 2020 +0000
Revision:
4:217334c3a5b2
Parent:
3:35b05d91568d
A

Who changed what in which revision?

UserRevisionLine numberNew contents of line
china_sn0w 1:7530b7eb757a 1 #ifndef _CMD_HANDLER_
china_sn0w 1:7530b7eb757a 2 #define _CMD_HANDLER_
china_sn0w 1:7530b7eb757a 3
china_sn0w 1:7530b7eb757a 4 #include "mbed.h"
china_sn0w 1:7530b7eb757a 5 #include "max32630fthr.h"
china_sn0w 1:7530b7eb757a 6 #include "USBSerial.h"
china_sn0w 1:7530b7eb757a 7
china_sn0w 1:7530b7eb757a 8 #define CMD_QUEUE_LEN 2048
china_sn0w 1:7530b7eb757a 9 #define CMD_BUF_LEN 2048
china_sn0w 1:7530b7eb757a 10
china_sn0w 1:7530b7eb757a 11 typedef struct cmd_global {
china_sn0w 1:7530b7eb757a 12 uint8_t one_package_done;
china_sn0w 1:7530b7eb757a 13 uint8_t valid_flag;
china_sn0w 1:7530b7eb757a 14 uint8_t send_flag;
china_sn0w 1:7530b7eb757a 15 uint16_t package_len;
china_sn0w 1:7530b7eb757a 16 uint8_t buf[CMD_BUF_LEN];
china_sn0w 1:7530b7eb757a 17 //uint8_t
china_sn0w 1:7530b7eb757a 18
china_sn0w 1:7530b7eb757a 19 } GLOBAL_CMD_VAR;
china_sn0w 1:7530b7eb757a 20
china_sn0w 1:7530b7eb757a 21 #define UPDATA_CMD 0x06
china_sn0w 1:7530b7eb757a 22 #define UPDATA_CMD_ACK 0x86
china_sn0w 1:7530b7eb757a 23
china_sn0w 1:7530b7eb757a 24 #define UPDATA_DATA_CMD 0x07
china_sn0w 1:7530b7eb757a 25 #define UPDATA_DATA_CMD_ACK 0x87
china_sn0w 1:7530b7eb757a 26
china_sn0w 1:7530b7eb757a 27 #define WRITE_CMD 0x01 //写
china_sn0w 1:7530b7eb757a 28 #define WRITE_CMD_ACK 0x81
china_sn0w 1:7530b7eb757a 29
china_sn0w 1:7530b7eb757a 30 #define READ_CMD 0x00 //读
china_sn0w 1:7530b7eb757a 31 #define READ_CMD_ACK 0x80
china_sn0w 1:7530b7eb757a 32 #define READ_ERROR_CMD_ACK 0X10
china_sn0w 1:7530b7eb757a 33
china_sn0w 1:7530b7eb757a 34 #define SPI_AUTO_TRANSF_CMD 0x03 //SPI数据主动上传
china_sn0w 1:7530b7eb757a 35 #define MEASURE_AUTO_TRANSF_CMD 0x07
china_sn0w 1:7530b7eb757a 36
china_sn0w 1:7530b7eb757a 37 #define REGISTER_CMD 0x01 //寄存器操作命令
china_sn0w 1:7530b7eb757a 38 #define CHUCHANG_SET_CMD 0x02 //出厂设置
china_sn0w 1:7530b7eb757a 39 #define CHUCHANG_SET_RESET_CMD 0x03 //恢复出厂设置
china_sn0w 1:7530b7eb757a 40 #define DISTANCE_OFFSET_CALIBRATION_CMD 0x04 //距离offset校准命令
china_sn0w 1:7530b7eb757a 41 #define GAOFAN_OFFSET_CALIBRATION_CMD 0x05 //高反offset校准命令
china_sn0w 1:7530b7eb757a 42 #define LSB_REALDISTANCE_CHANGE 0x06 //LSB 真实距离切换
china_sn0w 1:7530b7eb757a 43 #define SINGLE_COLLECT 0x07 //单次采集
china_sn0w 1:7530b7eb757a 44 #define CONTINUE_COLLECT 0x08 //连续采集 开始/停止
china_sn0w 1:7530b7eb757a 45 #define HISTORGRAM_READ 0x09 // Historgram读取
china_sn0w 1:7530b7eb757a 46 #define RAWDATA_READ 0x0A // RawData读取
china_sn0w 1:7530b7eb757a 47 #define SPI_DATA_TRANSF_SHUANGFENG 0x0B //SPI TOF PEAK上传
china_sn0w 1:7530b7eb757a 48 #define SPI_DATA_TRANSF_DANFENG 0x0C //SPI TOF PEAK上传
china_sn0w 1:7530b7eb757a 49 #define REGISTER_CONTROL_CMD 0x0D //寄存器直接读写操作
china_sn0w 1:7530b7eb757a 50 #define HISTOGRAM_READ_CASSATT 0x0E //CASSATT芯片读取Histogram
china_sn0w 1:7530b7eb757a 51 #define SINGLE_PIXEL_CMD 0x0F //单PIXEL模式PEKA值读取
china_sn0w 1:7530b7eb757a 52 #define DELAYLINE_TEST_CMD 0x11 //单PIXEL模式PEKA值读取
china_sn0w 1:7530b7eb757a 53
china_sn0w 1:7530b7eb757a 54 #define SWITCH_CMD 0x40
china_sn0w 1:7530b7eb757a 55 #define MEASURE_CALI_CMD 0x41
china_sn0w 1:7530b7eb757a 56 #define TC_GPIO_CMD 0x42
china_sn0w 1:7530b7eb757a 57 #define MCU_OSC_OUT_CMD 0x43
china_sn0w 1:7530b7eb757a 58 #define INT_ENABLE_CMD 0x44
china_sn0w 1:7530b7eb757a 59 #define CHIP_RST_CMD 0x45
china_sn0w 1:7530b7eb757a 60 #define CHIP_EN_CMD 0x46
china_sn0w 1:7530b7eb757a 61 #define FREQ_REPORT 0x47
china_sn0w 1:7530b7eb757a 62
china_sn0w 1:7530b7eb757a 63 #define VAN_SCRATCH_CMD 0x50
china_sn0w 1:7530b7eb757a 64 #define VAN_RAW_REG_CMD 0x51
china_sn0w 1:7530b7eb757a 65 #define VAN_AVDD_CMD 0x53
china_sn0w 1:7530b7eb757a 66 #define VAN_HISTOGRAM 0x54
china_sn0w 1:7530b7eb757a 67 #define VAN_RANGE_CMD 0x55
china_sn0w 1:7530b7eb757a 68 #define VAN_DOWN_FW_CMD 0x56
china_sn0w 1:7530b7eb757a 69 #define VAN_READ_HIST_CMD 0x57
china_sn0w 1:7530b7eb757a 70 #define VAN_SINGLE_MEAS 0x58
china_sn0w 1:7530b7eb757a 71 #define VAN_CONTIU_MEAS 0x59
china_sn0w 1:7530b7eb757a 72 #define VAN_STEP_HISTOGRAM_CMD 0x5A
china_sn0w 1:7530b7eb757a 73 #define VAN_MOVING_CTL_CMD 0x5B
china_sn0w 1:7530b7eb757a 74 #define VAN_DCR_TEST_CMD 0x5C
china_sn0w 1:7530b7eb757a 75 #define VAN_DELAYLINE_TEST_CMD 0x5D
china_sn0w 1:7530b7eb757a 76 #define VAN_GET_TDC_PHASE_CMD 0x5E
china_sn0w 3:35b05d91568d 77 #define VAN_SET_WINDOW_CMD 0x5F
china_sn0w 3:35b05d91568d 78
china_sn0w 3:35b05d91568d 79 #define VAN_RCO_TRIM_CMD 0x60
china_sn0w 3:35b05d91568d 80 #define VAN_BVD_TRIM_CMD 0x61
china_sn0w 3:35b05d91568d 81 #define VAN_PIXEL_EN_CMD 0x62
china_sn0w 1:7530b7eb757a 82
china_sn0w 4:217334c3a5b2 83 #define VAN_MP_SLECTE_CMD 0x63
china_sn0w 4:217334c3a5b2 84 #define VAN_OTP_WRITE_CMD 0x65
china_sn0w 4:217334c3a5b2 85 #define VAN_OTP_READ_CMD 0x66
china_sn0w 4:217334c3a5b2 86
china_sn0w 1:7530b7eb757a 87
china_sn0w 1:7530b7eb757a 88
china_sn0w 1:7530b7eb757a 89
china_sn0w 1:7530b7eb757a 90
china_sn0w 1:7530b7eb757a 91 void CmdHandleTask(void);
china_sn0w 1:7530b7eb757a 92
china_sn0w 1:7530b7eb757a 93 void DealUart1OnePackage(uint8_t *pd, uint16_t cmdLen);
china_sn0w 1:7530b7eb757a 94
china_sn0w 1:7530b7eb757a 95 uint8_t HandleWriteReg(uint8_t *pd, uint16_t cmdLen);
china_sn0w 1:7530b7eb757a 96 uint8_t HandleReadReg(void);
china_sn0w 1:7530b7eb757a 97 uint8_t HandleOneTimeMeasure(void);
china_sn0w 1:7530b7eb757a 98 uint8_t HandleContinuousMeasure(uint8_t *pd);
china_sn0w 1:7530b7eb757a 99 uint8_t HandleReadHistogram(uint8_t tdc_idx);
china_sn0w 1:7530b7eb757a 100 uint8_t HandleDownloadFW(uint8_t *pd, uint16_t cmdLen);
china_sn0w 4:217334c3a5b2 101 uint8_t HandleContinuousMeasureReport(uint16_t lsb, uint16_t milimeter, uint32_t peak, uint16_t noise_level, uint16_t ref_lsb, uint16_t ref_milimeter);
china_sn0w 1:7530b7eb757a 102
china_sn0w 1:7530b7eb757a 103 uint8_t HandleSwitch(uint8_t *pd, uint16_t cmdLen);
china_sn0w 1:7530b7eb757a 104 void HandleChipReset(void);
china_sn0w 1:7530b7eb757a 105 void HandleChipEnable(uint8_t en);
china_sn0w 1:7530b7eb757a 106 void HandleInterruptEnable(uint8_t en);
china_sn0w 1:7530b7eb757a 107
china_sn0w 1:7530b7eb757a 108 void HandleFreqReport(float* V_I_Value);
china_sn0w 1:7530b7eb757a 109
china_sn0w 1:7530b7eb757a 110 void UART_CmdAckSend(uint8_t ack_cmd, uint8_t register_addr, uint8_t *pbuff, uint16_t pbuff_len);
china_sn0w 1:7530b7eb757a 111
china_sn0w 1:7530b7eb757a 112 #endif
china_sn0w 1:7530b7eb757a 113
china_sn0w 1:7530b7eb757a 114