54 temp_uint8[0] = reg_data >> 24;
55 temp_uint8[1] = reg_data >> 16;
56 temp_uint8[2] = reg_data >> 8;
57 temp_uint8[3] = reg_data;
73#ifdef __DEBUG_GP22_OPCODE_ATY
74 printf(
"\r\nRead opcode %02X: 0x%02X%02X%02X%02X",
75 opcode_address, data_t[0], data_t[1], data_t[2], data_t[3]);
102 if(errTimeCount > 12000)
105#ifdef __DEBUG_GP22_ATY
106 printf(
"\r\nERR - INT timeout %d", step);
119 for(
i = 0;
i < 5;
i++)
126#ifdef __DEBUG_GP22_ATY
127 printf(
"\r\nSPIT - 0x%08X", temp_uint32);
129 if((temp_uint32 >> 24) == data_t)
132#ifdef __DEBUG_GP22_ATY
133 printf(
"\r\nERR - SPI Commucate Err!");
147#ifdef __DEBUG_GP22_ATY
148 printf(
"\r\nRID - Read id: 0x%02X%02X%02X%02X%02X%02X%02X%02X",
149 id[0],
id[1],
id[2],
id[3],
id[4],
id[5],
id[6],
id[7]);
163#ifdef __DEBUG_GP22_ATY
164 printf(
"\r\nERR - Read wrong id number!");
177#ifdef __DEBUG_GP22_ATY
178 printf(
"\r\nSTAT - Code: 0x%04X | ALU - %d | HIT1 - %d | HIT2 - %d",
181 (statusCode >> 3) & 0x0007,
182 (statusCode >> 6) & 0x0007);
184 if((statusCode & 0x0200) == 0x0200)
185 printf(
"\r\nERR - Indicates an overflow of the TDC unit");
187 if((statusCode & 0x0400) == 0x0400)
188 printf(
"\r\nERR - Indicates an overflow of the 14 bit precounter in MR 2");
190 if((statusCode & 0x0800) == 0x0800)
191 printf(
"\r\nERR - Indicates an open sensor at temperature measurement");
193 if((statusCode & 0x1000) == 0x1000)
194 printf(
"\r\nERR - Indicates a shorted sensor at temperature measurement");
196 if((statusCode & 0x2000) != 0x2000)
197 printf(
"\r\nERR - The content of the configuration registers not equals the EEPROM");
199 if((statusCode & 0x4000) == 0x4000)
200 printf(
"\r\nERR - Double error detection. A multiple error has been detected whcich can not be corrected");
202 if((statusCode & 0x8000) == 0x8000)
203 printf(
"\r\nERR - Single error in EEPROM which has been corrected");
220 if((statusCode & 0x2000) != 0x2000)
226#ifdef __DEBUG_GP22_ATY
227 printf(
"\r\nERR - Write E2 timeout");
234#ifdef __DEBUG_GP22_ATY
235 printf(
"\r\nCE2 - Compare E2 success");
240#ifdef __DEBUG_GP22_ATY
241 printf(
"\r\nERR - Compare E2 failed");
250 float correctionFactor;
270#ifdef __DEBUG_GP22_ATY
271 printf(
"\r\nCHSC - Theoretical value: 0x%08X - %1.6f",
272 hscReadValue, (
float)hscReadValue / 65536);
273 printf(
"\r\nCHSC - Correction factor for clock: %.6f", correctionFactor);
274 printf(
"\r\nCHSC - Calibrated internal clock frequency: %.6fMHz - %.6fns",
287 float tempRefResFactor = 0.0;
288 float tempRealRes[2] = {0.0};
303 (float)(temp_uint32[2] + temp_uint32[3]) / 2
316#ifdef __DEBUG_GP22_ATY
317 printf(
"\r\nSTEMP - Temp reg: 0x%08X - 0x%08X - 0x%08X - 0x%08X",
318 temp_uint32[0], temp_uint32[1], temp_uint32[2], temp_uint32[3]);
319 printf(
"\r\nSTEMP - Temp reg: %d - %d - %d - %d",
320 temp_uint32[0], temp_uint32[1], temp_uint32[2], temp_uint32[3]);
359#define GP22_MEASURE_UsWave1MHz
363#if defined(GP22_MEASURE_UsWave1MHz)
448#ifdef __DEBUG_GP22_ATY
449 printf(
"\r\nREGI - 0: %08X\r\nREGI - 1: %08X\r\nREGI - 2: %08X\
450 \r\nREGI - 3: %08X\r\nREGI - 4: %08X\r\nREGI - 5: %08X\r\nREGI - 6: %08X",
458 float wavePeriod = 0.0;
459 float waveFreq = 0.0;
477 waveFreq = 1 / wavePeriod;
485#ifdef __DEBUG_GP22_ATY
487 printf(
"\r\nSTOF - PW1ST value: 0x%02X - %f",
489 printf(
"\r\nSTOF - TOF reg: 0x%08X - 0x%08X - 0x%08X - 0x%08X",
491 printf(
"\r\nSTOF - TOF reg: %d - %d - %d - %d",
494 printf(
"\r\nSTOF - TOF reg: %f - %f - %f - %f",
499 printf(
"\r\nSTOF - Wave: %f us - %f MHz", wavePeriod, waveFreq);
501 printf(
"\r\nStep %02d-A done! ----------------------------------------------",
538#ifdef __DEBUG_GP22_ATY
544#ifdef __DEBUG_GP22_ATY
545 printf(
"\r\nStep %02d done! ------------------------------------------------", errCode);
556#elif defined(GP22_MEASURE_US_DIGITAL)
557void GP22_RegInitUs_Digital(
void)
603 | GP22_CFG5_CON_FIRE_0 * 1
619#ifdef __DEBUG_GP22_ATY
620 printf(
"\r\nREGI - 0: %08X\r\nREGI - 1: %08X\r\nREGI - 2: %08X\
621 \r\nREGI - 3: %08X\r\nREGI - 4: %08X\r\nREGI - 5: %08X\r\nREGI - 6: %08X",
637uint8_t GP22_StartTofUs_Digital(
void)
642 gp22StartTofFlag = 1;
647 gp22StartTofFlag = 0;
658 PW1ST_Value = PW1ST_Value * 1;
659#ifdef __DEBUG_GP22_ATY
660 printf(
"\r\nSTOF - TOF reg: 0x%08X - 0x%08X - 0x%08X - 0x%08X",
661 tofReadValue[0], tofReadValue[1], tofReadValue[2], tofReadValue[3]);
662 printf(
"\r\nSTOF - TOF reg: %d - %d - %d - %d",
663 tofReadValue[0], tofReadValue[1], tofReadValue[2], tofReadValue[3]);
664 printf(
"\r\nSTOF - TOF reg: %.2f - %.2f - %.2f - %.2f",
665 (
float)tofReadValue[0] / 65536, (
float)tofReadValue[1] / 65536,
666 (
float)tofReadValue[2] / 65536, (
float)tofReadValue[3] / 65536);
667 printf(
"\r\nSTOF - PW1ST value: 0x%02X - %f",
668 PW1ST_Value, (
float)(PW1ST_Value >> 24) / 128);
677#elif defined(GP22_MEASURE_UsWave1MHz1)
684uint8_t GP22_StartTofLaserCal(
void)
697#ifdef __DEBUG_GP22_ATY
698 printf(
"\r\nTOF - Laser: Cal over");
714#ifdef __DEBUG_GP22_ATY
729#ifdef __DEBUG_GP22_ATY
730 printf(
"\r\nTOF - Laser: 0x%08X - %d", calValue, calValue / 65536);
731 printf(
"\r\nTOF - Laser: %f ns - %f m",
732 (
float)
tofValue / ((
float)calValue / 65536) * 16,
733 (
float)
tofValue / ((
float)calValue / 65536) * 16 * 0.23);
739void GP22_Process(
uint32_t* gp22ProcessValue)
757#ifdef __DEBUG_GP22_ATY
float ALGO_ResToKelvinTemp(float Rntc, float R25, float B)
Calculate temperature from ntc resistance.
void GP22_WriteData(uint8_t data_t)
write data with spi
void GP22_WriteReg(uint8_t opcode_address, uint32_t reg_data)
uint16_t GP22_AnalyseErrCode(void)
uint8_t GP22_SpiTest(uint8_t data_t)
uint8_t GP22_Process_UsWave1MHz(uint8_t cmdCode)
uint8_t GP22_StartTof_UsWave1MHz(void)
uint8_t GP22_CompareE2(void)
uint8_t GP22_WaitInt(uint8_t step)
uint32_t GP22_ReadReg(uint8_t opcode_address)
float GP22_CALC_CLKHS_FREQ
uint8_t GP22_ReadId(void)
void GP22_RegInit_UsWave1MHz(void)
uint8_t GP22_CalcHSC(void)
uint8_t GP22_Process_Run(uint8_t cmdCode)
uint8_t GP22_StartTemp(void)
Base functions of GP22 for all embedded device.
#define GP22_CFG3FW_SEL_TIMO_MB2_0
#define GP22_STEP_START_TEMP
#define GP22_CFG1_SEL_START_FIRE
#define GP22_CFG3FW_DELREL2_0
#define GP22_CFG5_DIS_PHASESHIFT
#define GP22_CFG1_SEL_TSTO2_0
#define GP22_CFG4FW_EDGE_FW
#define GP22_CFG3FW_EN_FIRST_WAVE
#define GP22_CFG3FW_DELREL3_0
#define GP22_OPCODE_COMPARE_E2
#define GP22_CFG2_RFEDGE1
#define GP22_CFG6_DA_KORR_0
#define GP22_CFG3FW_EN_AUTOCALC_MB2
#define GP22_CFG_KEEP_DEFAULT4
#define GP22_CFG4FW_DIS_PW
#define GP22_CLKHS_PERIOD
#define GP22_OPCODE_START_TOF
#define GP22_OPCODE_WRITE_E2
#define GP22_CFG6_EN_INT_END
#define GP22_CFG6_NEG_STOP_TEMP
#define GP22_REGADDR_STATUS
#define GP22_STEP_START_TOF
#define GP22_CFG4FW_OFFSRNG1
#define GP22_STEP_SPI_TEST
#define GP22_CFG4FW_OFFS_0
#define GP22_OPCODE_READ_REG
#define GP22_CFG4FW_OFFSRNG2
#define GP22_STEP_COMPARE_E2
#define GP22_CFG1_SEL_TSTO1_0
#define GP22_CFG1_HITIN2_0
#define GP22_CFG_KEEP_DEFAULT5
#define GP22_CFG2_DELVAL1_0
#define GP22_CFG6_EN_ANALOG
#define GP22_CFG1_HITIN1_0
#define GP22_CFG0_ANZ_PORT
#define GP22_CFG_KEEP_DEFAULT2
#define GP22_REGADDR_TEST
#define GP22_CFG6_ANZ_FIRE_END_0
#define GP22_OPCODE_RESET
#define GP22_CFG6_QUAD_RES
#define GP22_CFG0_ANZ_FIRE_0
#define GP22_CFG0_DIV_FIRE_0
#define GP22_CFG_KEEP_DEFAULT0
#define GP22_OPCODE_CALC_HSC
#define GP22_STEP_READ_ID
#define GP22_CFG3FW_EN_ERR_VAL
#define GP22_CFG_KEEP_DEFAULT3
#define GP22_CFG2_EN_INT_TDC_TIMEOUT
#define GP22_OPCODE_START_CAL_TOF
#define GP22_OPCODE_WRITE_REG
#define GP22_OPCODE_READ_ID
#define GP22_CFG0_SEL_ECLK_TEMP
#define GP22_TEMP_REF_RES
#define GP22_CFG3FW_DELREL1_0
#define GP22_CFG0_ANZ_FAKE
#define GP22_CFG0_CALIBRATE
#define GP22_CFG0_ANZ_PER_CALRES_0
#define GP22_CFG5_PHFIRE_0
#define GP22_CFG_KEEP_DEFAULT6
#define GP22_CFG2_EN_INT_HITS
#define GP22_CFG0_START_CLKHS_0
#define GP22_CFG2_EN_INT_ALU
#define GP22_CFG5_CON_FIRE_DOWN
#define GP22_CFG5_EN_STARTNOISE
#define GP22_STEP_CALC_HSC
#define GP22_STEP_REG_INIT
#define GP22_CFG0_DIV_CLKHS_0
#define GP22_CFG_KEEP_DEFAULT1
#define GP22_OPCODE_START_TEMP
uint8_t SPI_Write(uint8_t *data_t, uint16_t len)
uint8_t SPI_Read(uint8_t *data_t, uint16_t len)
void DelayMs(uint32_t ms)
__WEAK_ATY void printf(uint8_t *,...)