/*
 * tein_detection.h
 *
 *  Created on: May 17, 2025
 *      Author: herli
 */

#ifndef INC_TEIN_DETECTION_H_
#define INC_TEIN_DETECTION_H_

#include <stdint.h>

#define DMA_BUFFER_SIZE_TEIN 127
#define ADC_MID         128

#define AcquisitionTime 2048 //2000us at 20us the sample goes to 100 length

#define samplePeriod 16 //50khz -> 20us 62.5khz ->16

extern uint8_t dma_buffer_tein[DMA_BUFFER_SIZE_TEIN]; // Buffer to hold results
extern float T_ein_filtered;
extern float T_ein_in;
extern float T_ein;
extern int CompensateTein;
extern int ProcessTein;
extern uint32_t TeinProcessedTime;
extern uint32_t lastTeinProcessedTime;
extern uint8_t T_ein_status;

extern uint32_t diff_ConvCallback;

extern volatile uint8_t hasTeinDetEnded;
extern volatile uint8_t hasTeinDetEndedFlag;

extern void ProcessAdcSignal(uint32_t IC_INJ, uint16_t PeakEndIndex, uint16_t T_on);
extern void TEIN_STATUS_ONFAULT(void);
#endif /* INC_TEIN_DETECTION_H_ */
