From 91865ba01d9a48c70d7f72020badd1315e54ad25 Mon Sep 17 00:00:00 2001 From: LucianoDev Date: Wed, 15 Apr 2026 17:54:42 +0200 Subject: [PATCH] Changed pump ident definition into id.h, kline data and fuelmaps should build from there. Updated write ram exception to always print ack, for less errors in custom software. Added read ram data for 815 mid verification test command --- Core/CAN_Libs/can_manager.c | 3 + Core/Immobilisers/ford_immo.c | 42 +++++++++++--- Core/Inc/id.h | 7 +++ Core/Inc/id_004004.h | 7 +++ Core/Inc/id_504010.h | 9 ++- Core/Kline_Libs/kl_app.c | 21 ++++++- Core/Kline_Libs/psg_prop.h | 45 +++++++++++---- Core/Src/fuel_map.c | 103 +++++++++++++++------------------- Core/Src/injection.c | 4 ++ Core/Src/sync_pulse.c | 1 + Core/Src/timeouts.c | 15 +++++ 11 files changed, 175 insertions(+), 82 deletions(-) diff --git a/Core/CAN_Libs/can_manager.c b/Core/CAN_Libs/can_manager.c index 64c28c1..f0290d1 100644 --- a/Core/CAN_Libs/can_manager.c +++ b/Core/CAN_Libs/can_manager.c @@ -143,6 +143,7 @@ uint8_t count = 0; uint8_t startup_finished = 0; #if defined(T06301) uint8_t startup_count = 9; +uint8_t startupiscar = 0; #elif defined(T06209) || defined(T06216) || defined(T06211) uint8_t startup_count = 0; uint8_t startup_sent_count = 0; @@ -156,6 +157,8 @@ void can_manager_rx_boot_reply_always(const CanMessageDef *msg, const uint8_t in if (!tx || !s_startup_reply_msg) return; #if defined(T06301) + startupiscar = 1; + if(!watchdog_started){return;} if(count < 2){ diff --git a/Core/Immobilisers/ford_immo.c b/Core/Immobilisers/ford_immo.c index 697dbe0..6ec00ad 100644 --- a/Core/Immobilisers/ford_immo.c +++ b/Core/Immobilisers/ford_immo.c @@ -8,6 +8,18 @@ #include "timeouts.h" #include "can_port.h" +uint16_t FIEONA_TRANS0 = 0x0507; +uint16_t FIEONA_TRANS1 = 0x381C; +uint16_t FIEONA_TRANS2 = 0xFC1C; +uint16_t FIEONA_TRANS3 = 0x71F5;//0x375B + +uint8_t eps_fieona_override = 0; + +#define FIEONA_UNLOCK_MS 600000 +uint32_t fieona_unlock_end = 0; +uint8_t fieona_unlocked = 0; + + uint16_t FIEONA_FIRSTWORD = 0x2001; uint16_t FIEONA_SECONDWORD = 0x2000; @@ -48,11 +60,31 @@ uint16_t FIEONA_advance() return tx; } +uint8_t isCar = 0; +volatile uint8_t isChecked = 0; +extern uint8_t startupiscar; + +void FIEONA_Check_Car_Startup() +{ + if (isChecked) return; + if(startupiscar){ + isCar = 1; + } + if (isCar){ + fieona_unlocked = 1; + //FIEONA_TRANS3 = 0x71F5;//0x71F5 + Timeout_ResetByIndex(1, TIM16->CNT); + } + isChecked = 1; + +} // --- RX Handler --- static uint16_t last_send4_tick = 0; // last tick for this timeout extern uint8_t count; + + void Fieona_SEND4_Handler( const struct CanMessageDef *msg, const uint8_t in_data[8], @@ -76,18 +108,10 @@ void Fieona_SEND4_Handler( _rx_fresh = 1; } +//Podria hacer que siempre empieze bloqueado, PERO si recibe un 700 antes de haber enviado el primer 312, este bloqueada... no?? -uint16_t FIEONA_TRANS0 = 0x0507; -uint16_t FIEONA_TRANS1 = 0x381C; -uint16_t FIEONA_TRANS2 = 0xFC1C; -uint16_t FIEONA_TRANS3 = 0x375B;//0x71F5 -uint8_t eps_fieona_override = 0; - -#define FIEONA_UNLOCK_MS 600000 -uint32_t fieona_unlock_end = 0; -uint8_t fieona_unlocked = 0; void Fieona_SEND3_Handler(const uint8_t in_data[8]){ uint16_t rx_word = (uint16_t)in_data[0] | ((uint16_t)in_data[1] << 8); diff --git a/Core/Inc/id.h b/Core/Inc/id.h index 4b8108d..10a0112 100644 --- a/Core/Inc/id.h +++ b/Core/Inc/id.h @@ -14,6 +14,13 @@ //#define T15021 //audi 506 -> 030 033 //#define T31804 //audi 506 -> 037 038 +//#define _004006 +#define _004004 +//#define _004002 +//#define _504003 +//#define _504009 +//#define _504010 + /* FORD */ #define FORD_SYNC_PULSE_OUT 1 diff --git a/Core/Inc/id_004004.h b/Core/Inc/id_004004.h index 4b8108d..10a0112 100644 --- a/Core/Inc/id_004004.h +++ b/Core/Inc/id_004004.h @@ -14,6 +14,13 @@ //#define T15021 //audi 506 -> 030 033 //#define T31804 //audi 506 -> 037 038 +//#define _004006 +#define _004004 +//#define _004002 +//#define _504003 +//#define _504009 +//#define _504010 + /* FORD */ #define FORD_SYNC_PULSE_OUT 1 diff --git a/Core/Inc/id_504010.h b/Core/Inc/id_504010.h index 5fe231c..8384e73 100644 --- a/Core/Inc/id_504010.h +++ b/Core/Inc/id_504010.h @@ -15,6 +15,13 @@ //#define T15021 //audi 506 -> 030 033 //#define T31804 //audi 506 -> 037 038 +//#define _004006 +//#define _004004 +//#define _004002 +//#define _504003 +//#define _504009 +#define _504010 + /* FORD */ #define FORD_SYNC_PULSE_OUT 1 @@ -68,7 +75,7 @@ #define CAN_EMPF2_INSTANT 0 /* ALL FUELMAP */ -#define FM_N_RPM 10 +#define FM_N_RPM 8 #define FM_N_ME 12 #define FM_N_T 5 diff --git a/Core/Kline_Libs/kl_app.c b/Core/Kline_Libs/kl_app.c index 2d63af6..70d1217 100644 --- a/Core/Kline_Libs/kl_app.c +++ b/Core/Kline_Libs/kl_app.c @@ -71,6 +71,7 @@ static const uint8_t kLoginBody_OEM_1[] = { 0x9F, 0xD0, 0x9F, 0xFF, 0xFF, 0xFF static const uint8_t kReadIdentAddrBody[] = { 0x02, 0x00, 0xC6 }; static const uint8_t kReadFahrSoftwareAddress[] = { 0x02, 0x00, 0xA4 }; static const uint8_t kReadStart55Address[] = { 0x01, 0x00, 0xAE }; +static const uint8_t kReadCompensationValue[] = { 0x02, 0x02, 0xFE }; static const uint8_t kActivateSyncOut[] = { 0x88, 0x01, 0x04, 0x06, 0x01 }; @@ -374,6 +375,22 @@ static void handle_read_ram(const KL_Packet *cmd) start_response(payload, 2); return; } + if (cmd->data_len >= sizeof(kReadCompensationValue) && + memcmp(cmd->data, kReadCompensationValue, sizeof(kReadCompensationValue)) == 0) { + uint8_t payload[3]; + payload[0] = 0xFE; + payload[1] = (uint8_t)(PSG_CALVALUE_ADDR & 0xFF); + payload[2] = (uint8_t)((PSG_CALVALUE_ADDR >> 8) & 0xFF); + start_response(payload, 2); + return; + } + /*else{//fallback + uint8_t payload[cmd->data_len-1]; + payload[0] = 0xFE; + //payload[1] = (uint8_t)(PSG_START55_ADDR); + //fill with + start_response(payload, 2); + }*/ KL_Transport_SendNak(); app.state = KL_APP_SIMPLE_WAIT_TX; @@ -390,7 +407,9 @@ static void handle_write_ram(const KL_Packet *cmd) return; } - KL_Transport_SendNak(); + //KL_Transport_SendNak(); + KL_Transport_SendAck(); + app.state = KL_APP_SIMPLE_WAIT_TX; } diff --git a/Core/Kline_Libs/psg_prop.h b/Core/Kline_Libs/psg_prop.h index 0f0c70a..f135669 100644 --- a/Core/Kline_Libs/psg_prop.h +++ b/Core/Kline_Libs/psg_prop.h @@ -14,21 +14,44 @@ #include #include - +#include "id.h" // ================================================================ // Device identity strings (used in ASCII init stream and ROM reads) // ================================================================ - +#if defined(_004004) /* Part number / ECU identifier — 10 ASCII chars, ROM 0x93BA */ -//#define PSG_IDENT_STR "0470504010" -//#define PSG_IDENT_STR "0470504009" + #define PSG_IDENT_STR "0470004004" +#define PSG_KUNDENNUMMER_STR "YC1Q9A543EF " +#define PSG_KUNDENNUMMER1_STR "YC1Q9A543E" +#define PSG_KUNDENNUMMER2_STR "F " +#define PSG_MOD_INDEX_STR "000000" + +#elif defined(_504009) +#define PSG_IDENT_STR "0470504009" +#define PSG_KUNDENNUMMER_STR "39933 " +#define PSG_KUNDENNUMMER1_STR "39933 " +#define PSG_KUNDENNUMMER2_STR " " + +#elif defined(_504010) +#define PSG_IDENT_STR "0470504010" +#define PSG_KUNDENNUMMER_STR "YC1Q-9A543-D" +#define PSG_KUNDENNUMMER1_STR "YC1Q-9A543" +#define PSG_KUNDENNUMMER2_STR "-D" +#define PSG_MOD_INDEX_STR "000003" + +#else +/* Modification index — 6 ASCII chars, ROM 0x93A7 */ +#define PSG_MOD_INDEX_STR "000000" + +#endif + + + /* Serial number — 6 ASCII chars, EEPROM 0x0080 */ #define PSG_SERIAL_STR "297523" -/* Modification index — 6 ASCII chars, ROM 0x93A7 */ -#define PSG_MOD_INDEX_STR "000000" /* Software version — 10 ASCII chars, ROM 0x9F80 */ //#define PSG_SOFTWARE_VER_STR "C063_2.V61" @@ -59,13 +82,10 @@ #define PSG_ANDERUNGSINDEX_STR "000" -//#define PSG_KUNDENNUMMER_STR "39933 " -//#define PSG_KUNDENNUMMER1_STR "39933 " -//#define PSG_KUNDENNUMMER2_STR " " -#define PSG_KUNDENNUMMER_STR "YC1Q9A543EF " -#define PSG_KUNDENNUMMER1_STR "YC1Q9A543E" -#define PSG_KUNDENNUMMER2_STR "F " + + + #define PSG_UNKNOWN_STR "\xFF\xFF\xFF\xFF\xFF\xFF" @@ -83,6 +103,7 @@ #define PSG_FAHRSOFTWARE_ADDR 0x9C28U #define PSG_START55_ADDR 0x60U +#define PSG_CALVALUE_ADDR 0x166CU /* * Customer change address — returned at ROM 0x9FFE (little-endian). diff --git a/Core/Src/fuel_map.c b/Core/Src/fuel_map.c index 247b46a..f68a5fa 100644 --- a/Core/Src/fuel_map.c +++ b/Core/Src/fuel_map.c @@ -375,12 +375,7 @@ float BoostMultiplier(uint8_t mode, float RPM, float ME){ return m; } -//#define _004006 -//#define _004004 -//#define _004002 -//#define _504003 -#define _504009 -//#define _504010 + #if defined(_004006) struct AlphaStruct fuelmap_m12 = { //probar este mapa @@ -632,79 +627,69 @@ struct fuelMapIndexes fuelMapI = { //probar este mapa #elif defined(_504010) struct AlphaStruct fuelmap_m12 = { //probar este mapa { - { 7.734, 8.520, 8.777, 8.918, 9.246, 9.621, 10.945, 11.227, 11.496, 11.801, 12.680, 13.500}, //RPM = 99 - { 6.750, 7.559, 7.746, 7.875, 8.250, 8.789, 10.547, 10.770, 10.980, 11.203, 11.988, 12.797}, //RPM = 199 - { 4.863, 5.754, 6.000, 6.223, 6.820, 7.605, 9.680, 10.102, 10.500, 10.945, 12.539, 13.758}, //RPM = 424 - { 4.336, 5.273, 5.520, 5.742, 6.352, 7.137, 9.434, 9.949, 10.465, 10.957, 12.691, 13.793}, //RPM = 499 - { 1.547, 2.684, 3.035, 3.293, 3.891, 4.688, 8.227, 9.117, 10.066, 10.898, 13.535, 14.309}, //RPM = 896 - { 0.773, 1.957, 2.355, 2.613, 3.246, 4.043, 7.934, 8.941, 9.973, 10.840, 13.758, 14.590}, //RPM = 999 - { -1.898, -0.480, -0.047, 0.223, 0.891, 1.992, 6.938, 8.156, 9.363, 10.582, 13.898, 14.602}, //RPM = 1399 - { -2.707, -1.230, -0.750, -0.480, 0.223, 1.441, 6.633, 7.887, 9.152, 10.512, 13.770, 14.484}, //RPM = 1499 - { -6.258, -4.547, -4.230, -3.938, -3.117, -1.430, 4.828, 6.363, 8.063, 10.066, 13.020, 13.324}, //RPM = 1999 - { -7.406, -5.602, -5.273, -5.027, -4.266, -2.543, 3.703, 5.320, 7.289, 9.563, 12.363, 12.492}, //RPM = 2199 + { 8.594, 9.368, 9.344, 9.473, 9.801, 10.083, 11.219, 11.747, 12.579, 13.141, 13.961, 15.919}, //RPM = 99 + { 7.841, 8.626, 8.509, 8.638, 9.001, 9.388, 11.087, 11.509, 12.165, 12.716, 13.536, 15.505}, //RPM = 199 + { 6.874, 7.741, 7.659, 7.870, 8.456, 9.065, 10.846, 11.631, 12.862, 13.940, 15.229, 18.182}, //RPM = 399 + { 6.519, 7.444, 7.409, 7.644, 8.230, 8.816, 10.784, 11.792, 13.269, 14.487, 15.601, 17.980}, //RPM = 499 + { 4.721, 5.893, 6.127, 6.397, 7.018, 7.498, 10.604, 12.608, 15.127, 17.272, 18.104, 19.123}, //RPM = 999 + { 2.724, 4.166, 4.646, 4.916, 5.619, 6.369, 10.740, 13.154, 16.986, 18.931, 19.634, 20.419}, //RPM = 1499 + { 1.550, 3.085, 3.694, 3.976, 4.726, 5.675, 10.714, 13.222, 17.968, 19.409, 20.124, 21.237}, //RPM = 1749 + { 0.501, 2.189, 2.411, 2.704, 3.525, 4.661, 10.052, 13.228, 19.228, 19.884, 20.048, 20.048}, //RPM = 2099 } }; struct AlphaStruct fuelmap_m5 = { //probar este mapa { - { 7.840, 8.625, 8.895, 9.035, 9.352, 9.727, 11.063, 11.379, 11.672, 12.000, 12.879, 13.699}, //RPM = 99 - { 6.855, 7.664, 7.852, 7.992, 8.355, 8.895, 10.664, 10.910, 11.156, 11.402, 12.188, 13.008}, //RPM = 199 - { 4.945, 5.871, 6.105, 6.328, 6.914, 7.699, 9.785, 10.254, 10.688, 11.168, 12.750, 13.992}, //RPM = 425 - { 4.430, 5.367, 5.625, 5.859, 6.457, 7.219, 9.574, 10.102, 10.617, 11.156, 12.902, 14.004}, //RPM = 499 - { 1.594, 2.730, 3.070, 3.328, 3.949, 4.746, 8.367, 9.293, 10.254, 11.121, 13.828, 14.590}, //RPM = 896 - { 0.820, 2.004, 2.402, 2.660, 3.293, 4.113, 8.074, 9.105, 10.160, 11.086, 14.086, 14.906}, //RPM = 999 - { -1.805, -0.387, 0.047, 0.316, 0.984, 2.086, 7.137, 8.391, 9.656, 10.934, 14.309, 15.023}, //RPM = 1399 - { -2.566, -1.102, -0.621, -0.352, 0.340, 1.570, 6.855, 8.168, 9.492, 10.910, 14.238, 14.941}, //RPM = 1499 - { -6.082, -4.371, -4.031, -3.762, -2.941, -1.242, 5.215, 6.832, 8.578, 10.652, 13.676, 14.051}, //RPM = 2001 - { -7.266, -5.438, -5.109, -4.863, -4.102, -2.344, 4.172, 5.813, 7.828, 10.207, 13.137, 13.254}, //RPM = 2199 + { 8.594, 9.379, 9.497, 9.626, 9.954, 10.235, 11.348, 11.958, 12.860, 13.422, 14.243, 16.200}, //RPM = 99 + { 7.841, 8.638, 8.650, 8.790, 9.154, 9.540, 11.216, 11.720, 12.458, 13.009, 13.818, 15.786}, //RPM = 199 + { 6.874, 7.752, 7.799, 8.022, 8.608, 9.217, 10.975, 11.842, 13.143, 14.233, 15.522, 18.475}, //RPM = 399 + { 6.519, 7.444, 7.538, 7.761, 8.347, 8.933, 10.925, 11.991, 13.573, 14.804, 15.894, 18.273}, //RPM = 499 + { 4.721, 5.905, 6.198, 6.455, 7.088, 7.580, 10.768, 12.830, 15.549, 17.694, 18.526, 19.510}, //RPM = 999 + { 2.876, 4.330, 4.810, 5.080, 5.783, 6.533, 10.974, 13.541, 17.595, 19.541, 20.255, 21.041}, //RPM = 1499 + { 1.773, 3.343, 3.941, 4.222, 4.972, 5.921, 11.019, 13.737, 18.659, 20.112, 20.827, 21.941}, //RPM = 1749 + { 0.701, 2.411, 2.646, 2.927, 3.759, 4.896, 10.568, 13.872, 20.177, 20.845, 20.986, 21.115}, //RPM = 2099 } }; struct AlphaStruct fuelmap_10 = { //probar este mapa { - { 7.980, 8.766, 9.035, 9.164, 9.492, 9.867, 11.215, 11.566, 11.895, 12.246, 13.148, 13.969}, //RPM = 99 - { 6.996, 7.805, 7.992, 8.133, 8.484, 9.023, 10.816, 11.109, 11.379, 11.648, 12.445, 13.266}, //RPM = 199 - { 5.086, 5.988, 6.258, 6.457, 7.055, 7.816, 9.938, 10.441, 10.910, 11.379, 12.996, 14.250}, //RPM = 424 - { 4.523, 5.473, 5.719, 5.965, 6.551, 7.313, 9.703, 10.277, 10.828, 11.391, 13.137, 14.285}, //RPM = 499 - { 1.641, 2.777, 3.141, 3.387, 3.984, 4.770, 8.496, 9.445, 10.465, 11.379, 14.145, 14.895}, //RPM = 896 - { 0.879, 2.063, 2.461, 2.719, 3.352, 4.160, 8.238, 9.305, 10.371, 11.379, 14.438, 15.270}, //RPM = 999 - { -1.699, -0.281, 0.152, 0.422, 1.102, 2.203, 7.383, 8.684, 9.984, 11.355, 14.836, 15.539}, //RPM = 1399 - { -2.426, -0.961, -0.480, -0.211, 0.480, 1.711, 7.137, 8.496, 9.879, 11.355, 14.754, 15.469}, //RPM = 1499 - { -5.906, -4.172, -3.844, -3.551, -2.742, -1.031, 5.684, 7.359, 9.164, 11.309, 14.449, 14.754}, //RPM = 1999 - { -7.043, -5.309, -4.922, -4.676, -3.902, -2.133, 4.699, 6.398, 8.461, 10.934, 14.004, 14.121}, //RPM = 2199 + { 8.594, 9.391, 9.590, 9.719, 10.047, 10.340, 11.430, 12.086, 13.047, 13.610, 14.430, 16.387}, //RPM = 99 + { 7.841, 8.650, 8.755, 8.896, 9.259, 9.646, 11.310, 11.861, 12.657, 13.208, 14.029, 15.997}, //RPM = 199 + { 6.874, 7.764, 7.916, 8.139, 8.725, 9.334, 11.081, 12.006, 13.366, 14.456, 15.745, 18.698}, //RPM = 399 + { 6.519, 7.433, 7.632, 7.866, 8.452, 9.038, 11.030, 12.155, 13.819, 15.038, 16.151, 18.530}, //RPM = 499 + { 4.721, 5.905, 6.244, 6.502, 7.135, 7.627, 10.909, 13.018, 15.924, 18.069, 18.901, 19.920}, //RPM = 999 + { 3.017, 4.470, 4.951, 5.232, 5.935, 6.685, 11.197, 13.892, 18.169, 20.115, 20.818, 21.615}, //RPM = 1499 + { 1.995, 3.577, 4.175, 4.456, 5.206, 6.155, 11.312, 14.241, 19.327, 20.780, 21.495, 22.620}, //RPM = 1749 + { 0.900, 2.634, 2.857, 3.232, 3.970, 5.130, 11.072, 14.505, 21.126, 21.783, 21.947, 21.935}, //RPM = 2099 } }; struct AlphaStruct fuelmap_25 = { //probar este mapa { - { 8.098, 8.883, 9.152, 9.293, 9.621, 9.996, 11.355, 11.730, 12.105, 12.469, 13.383, 14.203}, //RPM = 99 - { 7.125, 7.934, 8.109, 8.250, 8.613, 9.152, 10.957, 11.273, 11.578, 11.871, 12.691, 13.512}, //RPM = 199 - { 5.227, 6.117, 6.363, 6.586, 7.172, 7.957, 10.102, 10.594, 11.098, 11.637, 13.254, 14.484}, //RPM = 425 - { 4.652, 5.590, 5.836, 6.059, 6.645, 7.430, 9.891, 10.453, 11.016, 11.625, 13.406, 14.520}, //RPM = 499 - { 1.699, 2.836, 3.176, 3.445, 4.055, 4.863, 8.719, 9.668, 10.676, 11.648, 14.496, 15.270}, //RPM = 896 - { 0.926, 2.109, 2.508, 2.766, 3.398, 4.230, 8.402, 9.492, 10.605, 11.660, 14.813, 15.656}, //RPM = 1000 - { -1.582, -0.164, 0.270, 0.539, 1.207, 2.332, 7.617, 8.977, 10.336, 11.766, 15.328, 16.043}, //RPM = 1399 - { -2.285, -0.832, -0.340, -0.070, 0.621, 1.863, 7.418, 8.883, 10.289, 11.824, 15.305, 15.996}, //RPM = 1499 - { -5.672, -3.961, -3.621, -3.352, -2.555, -0.797, 6.152, 7.816, 9.762, 12.000, 15.246, 15.445}, //RPM = 1997 - { -6.867, -5.051, -4.723, -4.465, -3.703, -1.910, 5.250, 6.996, 9.105, 11.707, 14.895, 15.035}, //RPM = 2199 + { 8.583, 9.415, 9.825, 9.965, 10.294, 10.575, 11.641, 12.415, 13.493, 14.055, 14.876, 16.833}, //RPM = 99 + { 7.829, 8.661, 8.978, 9.118, 9.482, 9.868, 11.497, 12.165, 13.079, 13.630, 14.450, 16.419}, //RPM = 199 + { 6.862, 7.776, 8.127, 8.350, 8.936, 9.545, 11.268, 12.288, 13.764, 14.854, 16.143, 19.096}, //RPM = 399 + { 6.507, 7.468, 7.796, 8.030, 8.616, 9.202, 11.218, 12.425, 14.206, 15.425, 16.538, 18.917}, //RPM = 499 + { 4.709, 5.916, 6.326, 6.584, 7.217, 7.709, 11.108, 13.299, 16.451, 18.596, 19.428, 20.448}, //RPM = 999 + { 3.193, 4.669, 5.162, 5.431, 6.134, 6.884, 11.490, 14.349, 18.896, 20.841, 21.544, 22.330}, //RPM = 1499 + { 2.265, 3.870, 4.468, 4.749, 5.499, 6.448, 11.675, 14.839, 20.124, 21.577, 22.292, 23.405}, //RPM = 1749 + { 1.146, 2.892, 3.115, 3.396, 4.228, 5.376, 11.622, 15.267, 22.169, 22.826, 22.978, 22.978}, //RPM = 2099 } }; struct AlphaStruct fuelmap_60 = { //probar este mapa { - { 8.332, 9.117, 9.387, 9.527, 9.855, 10.219, 11.613, 12.047, 12.469, 12.867, 13.816, 14.637}, //RPM = 99 - { 7.348, 8.156, 8.344, 8.484, 8.848, 9.387, 11.215, 11.590, 11.941, 12.270, 13.125, 13.945}, //RPM = 199 - { 5.449, 6.352, 6.586, 6.809, 7.395, 8.180, 10.359, 10.910, 11.461, 12.023, 13.676, 14.918}, //RPM = 425 - { 4.840, 5.777, 6.023, 6.258, 6.844, 7.641, 10.113, 10.758, 11.379, 12.012, 13.863, 14.965}, //RPM = 499 - { 1.770, 2.918, 3.270, 3.527, 4.137, 4.969, 8.953, 9.984, 11.039, 12.129, 15.082, 15.832}, //RPM = 896 - { 1.031, 2.215, 2.613, 2.871, 3.504, 4.336, 8.695, 9.820, 10.969, 12.164, 15.445, 16.277}, //RPM = 999 - { -1.359, 0.023, 0.457, 0.727, 1.395, 2.531, 8.027, 9.516, 10.910, 12.492, 16.207, 16.910}, //RPM = 1399 - { -2.039, -0.574, -0.105, 0.176, 0.879, 2.121, 7.887, 9.422, 10.957, 12.633, 16.207, 16.934}, //RPM = 1499 - { -5.344, -3.609, -3.270, -3.000, -2.191, -0.410, 6.938, 8.801, 10.758, 13.172, 16.523, 16.828}, //RPM = 1999 - { -6.551, -4.699, -4.406, -4.137, -3.375, -1.512, 6.164, 8.004, 10.184, 12.973, 16.418, 16.535}, //RPM = 2199 + { 8.583, 9.426, 10.024, 10.176, 10.504, 10.786, 11.817, 12.262, 13.844, 14.442, 14.676, 17.219}, //RPM = 99 + { 7.829, 8.685, 9.177, 9.329, 9.693, 10.079, 11.685, 12.446, 13.466, 14.017, 14.837, 16.806}, //RPM = 199 + { 6.862, 7.788, 8.327, 8.561, 9.147, 9.756, 11.444, 12.569, 14.151, 15.241, 16.530, 19.483}, //RPM = 399 + { 6.507, 7.480, 7.960, 8.194, 8.792, 9.378, 11.394, 12.706, 14.605, 15.823, 16.937, 19.292}, //RPM = 499 + { 4.709, 5.916, 6.420, 6.678, 7.311, 7.803, 11.319, 13.592, 17.026, 19.170, 20.002, 21.022}, //RPM = 999 + { 3.404, 4.892, 5.373, 5.642, 6.345, 7.095, 11.818, 14.865, 19.716, 21.662, 22.365, 23.162}, //RPM = 1499 + { 2.569, 4.198, 4.796, 5.089, 5.839, 6.788, 12.097, 15.530, 21.073, 22.515, 23.230, 24.343}, //RPM = 1749 + { 1.427, 3.197, 3.431, 3.701, 4.533, 5.681, 12.326, 16.087, 23.447, 24.091, 24.255, 24.267}, //RPM = 2099 } }; struct fuelMapIndexes fuelMapI = { //probar este mapa - { 100, 200, 425, 500, 900, 1000, 1400, 1500, 2000, 2200}, //N_RPM = 17 - { 0.375, 0.500, 1.625, 2.500, 5.000, 10.000, 30.000, 35.000, 40.000, 45.000, 60.000, 72.000}, - { -5, 10.5 , 27, 45.5, 75.3} + { 100, 200, 400, 500, 1000, 1500, 1750, 2100}, //N_RPM = 17 + { 0.375, 0.500, 1.625, 2.500, 5.000, 8.313, 24.938, 35.000, 49.813, 60.000, 72.000, 99.625}, + { -15, 5 , 30, 45.5, 72.5} }; #elif defined(_504003) struct AlphaStruct fuelmap_m12 = { //probar este mapa diff --git a/Core/Src/injection.c b/Core/Src/injection.c index 94b899b..5d42767 100644 --- a/Core/Src/injection.c +++ b/Core/Src/injection.c @@ -460,12 +460,16 @@ static inline void TIM1_OC4_SetSafe(uint16_t ccr4_new) } } +extern uint8_t startupiscar; void SEND1_Handler( const struct CanMessageDef *msg, const uint8_t in_data[8], CanTxFn tx ) { +#if defined(T06301) + startupiscar = 1; +#endif if(!isInjecting && !hasInjectionEnded){ INJ_UPDATE_ALPHA(); } diff --git a/Core/Src/sync_pulse.c b/Core/Src/sync_pulse.c index ee4a33c..847c4d5 100644 --- a/Core/Src/sync_pulse.c +++ b/Core/Src/sync_pulse.c @@ -229,6 +229,7 @@ void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) if (!watchdog_active){ watchdog_active = 1; // ✅ Pulse finished watchdog_started = 1; + FIEONA_Check_Car_Startup(); can_port_send_msg_def(&MSG_ID_EMPF4); Timeout_StartIfStopped(20, TIM16->CNT); // deberia mejorarlo bastante esto, en vez de FIEONA_advance(); diff --git a/Core/Src/timeouts.c b/Core/Src/timeouts.c index cdedf88..af6643b 100644 --- a/Core/Src/timeouts.c +++ b/Core/Src/timeouts.c @@ -248,6 +248,8 @@ void Handle_EMPF4_TimeoutTick(void) #if defined(T06301) static uint16_t last_immo_unlocked_tick = 0; +extern uint8_t fieona_unlocked; +extern uint8_t isCar; void Handle_Immo_Timeout(void) { /*//s_empf4_due = 1; @@ -255,6 +257,14 @@ void Handle_Immo_Timeout(void) uint16_t newtick = last_CAN_msg_empf_4_tick + 500; Timeout_ResetByIndex(20, newtick); // deberia mejorarlo bastante esto, en vez de FIEONA_advance();*/ + if(fieona_unlocked){ + if(isCar){ + Timeout_ResetByIndex(1, TIM16->CNT); + //no xse si poner esto afuera, en el banco si que se tendria que volver a bloquear... + Timeout_SetEnabledByIndex(1,0); + } + } + Timeout_StopByIndex(1); // deberia mejorarlo bastante esto, en vez de } @@ -460,6 +470,11 @@ void Timeout_StopByIndex(uint8_t index){ timeout_list[index].started = 0; } } +void Timeout_SetEnabledByIndex(uint8_t index,uint8_t enabled){ + if (index < timeout_list_size){ + timeout_list[index].enabled = enabled; + } +} void Set_Timeout_Period_ByIndex(uint8_t index, uint16_t period){ if (index < timeout_list_size){ timeout_list[index].timeout_duration = period;