TTS/Software/Core/Inc/HTPA_32x32d.h

83 lines
2.7 KiB
C

/**
* @file HTPA_32x32d.h
* @brief Header for HTPA 32x32d infrared array sensor library
* @author Tim-Erik Düntzsch t.duentzsch@fasttube.de
*
* @date 25.03.2023 - first implementation (untested)
*
* @todo finish HTPA_ReadBlock function
* @todo add calibration function
* @todo add temperature conversion function
*
* @test communication and readout
*
* @version 0.1
*/
#include <stdbool.h>
#ifndef INC_HTPA_32X32D_H_
#define INC_HTPA_32X32D_H_
#define ReadToFromTable
// ToDo: Sensor selection / add shortened lookup tables for selection:
#define HTPA32x32dL2_1HiSiF5_0_Gain3k3
//#define HTPA32x32dR1L2_1HiSiF5_0_Gain3k3_Extended
#ifdef HTPA32x32dL2_1HiSiF5_0_Gain3k3
#define TABLENUMBER 114
#define PCSCALEVAL 100000000 //327000000000 //PixelConst scale value for table... lower 'L' for (long)
#define NROFTAELEMENTS 7
#define NROFADELEMENTS 180 //because of shortened lookup table (capped at 300°C) //1595 default (~930°C)
#define TAEQUIDISTANCE 100 //dK
#define ADEQUIDISTANCE 64 //dig
#define ADEXPBITS 6 //2^ADEXPBITS=ADEQUIDISTANCE
#define TABLEOFFSET 1024
#define EQUIADTABLE //if defined, ADELEMENTS have to be 2^N quantizied! else more CPU Power is needed
#ifdef EQUIADTABLE
#undef FLOATTABLE
#endif
#define MBITTRIMDefault 0x2C //use REF_CAL=2 here. Table does not match, so GlobalGain ist set to 50 % to compensate this.
#define SensRv 1 //Sensor Revision is set to 1 (Redesign)
#endif
#ifdef HTPA32x32dR1L2_1HiSiF5_0_Gain3k3_Extended
#define TABLENUMBER 114
#define PCSCALEVAL 100000000 //327000000000 //PixelConst scale value for table... lower 'L' for (long)
#define NROFTAELEMENTS 12
#define NROFADELEMENTS 1595 //130 possible due to Program memory, higher values possible if NROFTAELEMENTS is decreased
#define TAEQUIDISTANCE 100 //dK
#define ADEQUIDISTANCE 64 //dig
#define ADEXPBITS 6 //2^ADEXPBITS=ADEQUIDISTANCE
#define TABLEOFFSET 1792
#define EQUIADTABLE //if defined, ADELEMENTS have to be 2^N quantizied! else more CPU Power is needed
#ifdef EQUIADTABLE
#undef FLOATTABLE
#endif
#define MBITTRIMDefault 0x2C
#define SensRv 1
#endif
/// @brief HTPA status register struct
typedef struct {
uint8_t block; // currently selected block
bool vdd_meas; // selection whether first two bytes are VDD or PTA
bool blind;
bool eoc; // end of conversion flag
} HTPA_Status;
void HTPA_Init(I2C_HandleTypeDef *hi2c);
void HTPA_ReadSensor(uint32_t dataArray[32]);
uint8_t HTPA_ReadEEPROM_byte(uint16_t address);
void HTPA_WriteRegister(uint8_t address, uint8_t byte);
void HTPA_ReadRegister(uint8_t address, uint8_t* pData, uint16_t length);
void HTPA_GetStatus(void);
uint32_t HTPA_calcPowerTwo(uint8_t power);
#endif /* INC_HTPA_32X32D_H_ */