/*
 * id.h
 *
 *  Created on: Jul 28, 2025
 *      Author: herli
 */

#ifndef INC_ID_H_
#define INC_ID_H_

/* 504 012 */

/* DEBUG PARAMETERS*/
//#define T06301				//ford 			004 -> 002 004 006	||	504 -> 010 018
//#define T06215   			//bmw rover  	004 -> 005 014 015 016 017	||	504 -> 005 007 017	||	006 -> 001 002 003 004 007 008
//#define T15021   			//audi 			506 -> 030 033
//#define T31804   			//audi 			506 -> 037 038
//#define T06209	//eq: T06216
#define T06211

#define _504012

/* FORD  */
#define FORD_SYNC_PULSE_OUT 0

#define ENABLE_AUDI_IMMO 0
#define HAS_PREINJECTION 0

#define CYLINDERS 4

/* TIMING COMPENSATIONS */
#define PHI1 41.004

#define TEIN_NOMINAL 1556
//(phiad - injangle with fault tein)*totime = teinnom
#define TEIN_FAULT 950

/* ALL FBKW */

#define FBKW_FEEDBACK_ZERO 53.719

#define FBKW_FEEDBACK_MIN -5.367
#define FBKW_FEEDBACK_MAX 21.27

#define FBKW_FEEDBACK_IC_DT 14

/* CAN DEFINITIONS */
#define CAN_BAUDRATE 500
#define CAN_RPM_SEND_ASYNC 250
#define CAN_EMPF2_INSTANT 0

/* ALL FUELMAP */
#define FM_N_RPM 6
#define FM_N_ME 11
#define FM_N_T 5


/* PEAK AND HOLD */
#define PH_PEAK_DEF 600

/* ANALOG CALIBRATION PARAMETERS */
// MOSFET
#define V_PEAK 2.94
#define V_HOLD 1.94

#define INJ_CLOSING_MARGIN 0 //o cero, o 20

// TOOTHED WHEEL
#define TW_MT_THRESHOLD 2.4
#define TW_THEETHS 120
#define TW_TOOTH_ALPHA 3
#define TW_STARTED_RPM 400

#define MIN_RPM 20

#define USTODEG 0.000006
// TIMINGS
#define TEIN_READING_OFFSET 8

/* ifdef things */

#if CYLINDERS == 4
    #define TW_PERCYL_TEETH 26
#elif CYLINDERS == 6
    #define TW_PERCYL_TEETH 16
#else
	#define TW_PERCYL_TEETH 26
    #error "Unsupported number of cylinders"
#endif


#endif /* INC_ID_H_ */
