/*
 * psg_prop.h
 * PSG device properties dictionary.
 *
 * All K-Line ROM and EEPROM read responses are defined here.
 * Edit the values in this file to configure what the master sees.
 *
 *  Created on: Aug 19, 2025
 *      Author: herli
 */

#ifndef INC_PSG_PROP_H_
#define INC_PSG_PROP_H_

#include <stdint.h>
#include <stddef.h>
#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           "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"
#elif defined(_004002)
#define PSG_IDENT_STR           "0470004002"
#define PSG_KUNDENNUMMER_STR "139031      "
#define PSG_KUNDENNUMMER1_STR "139031    "
#define PSG_KUNDENNUMMER2_STR "  "
#define PSG_MOD_INDEX_STR       "000000"
#elif defined(_504012)
#define PSG_IDENT_STR           "0470504012"
#define PSG_KUNDENNUMMER_STR "167005M321  "
#define PSG_KUNDENNUMMER1_STR "167005M321"
#define PSG_KUNDENNUMMER2_STR "  "
#define PSG_MOD_INDEX_STR       "000001"
#elif defined(_424026)
#define PSG_IDENT_STR           "1093424026"
#define PSG_KUNDENNUMMER_STR "167002X900  "
#define PSG_KUNDENNUMMER1_STR "167002X900"
#define PSG_KUNDENNUMMER2_STR "  "
#define PSG_MOD_INDEX_STR       "000001"
#elif defined(_504042)
#define PSG_IDENT_STR           "0470504042"
#define PSG_KUNDENNUMMER_STR "1093412080  "
#define PSG_KUNDENNUMMER1_STR "1093412080"
#define PSG_KUNDENNUMMER2_STR "  "
#define PSG_MOD_INDEX_STR       "000001"
#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"


/* Software version — 10 ASCII chars, ROM 0x9F80 */
//#define PSG_SOFTWARE_VER_STR    "C063_2.V61"
#define PSG_SOFTWARE_VER_STR    "HCPS_G2.04"


#define PSG_SOFTWARE_VER2_STR    "C062_0.P64" //no la lee directamente, solo al principio

/* Steuergeraet (controller unit number) — 10 ASCII chars, ROM 0x9F94 */
#define PSG_STEUERGERAET_STR    "0281010888"

/* Fahrsoftware (driving software code) — 10 ASCII chars, ROM 0x9F76 */
#define PSG_FAHRSOFTWARE_STR    "1469946013"

/* Datensatz (dataset code) — 10 ASCII chars, ROM 0x9C1C */
#define PSG_DATENSATZ_STR       "2469947023"

/* Referenz-Kennfeld (reference map code) — 10 ASCII chars, ROM 0x93B0 */
#define PSG_REFERENZ_STR        "2469948008"

/* Fertigungsdatum (manufacturing date) — 3 ASCII chars, EEPROM 0x0086 */
//#define FERTIGUNGSDATUM_STR "489"
#define FERTIGUNGSDATUM_STR "420"

/* Fertigungswerk (manufacturing plant) — 3 ASCII chars, ROM 0x93A4 */
//#define PSG_FERTIGUNGSWERK_STR  "015"
#define PSG_FERTIGUNGSWERK_STR  "069"

#define PSG_ANDERUNGSINDEX_STR  "000"






#define PSG_UNKNOWN_STR       "\xFF\xFF\xFF\xFF\xFF\xFF"


// ================================================================
// Key address constants
// ================================================================

/*
 * Address returned by the ReadIdentAdress (0x01) command.
 * The ROM ident string lives at (PSG_IDENT_ADDR - 10) = 0x93BA.
 */
#define PSG_IDENT_ADDR          0x93C4U

#define PSG_FAHRSOFTWARE_ADDR   0x9C28U

#define PSG_START55_ADDR   0x60U
#define PSG_CALVALUE_ADDR   0x166CU

/*
 * Customer change address — returned at ROM 0x9FFE (little-endian).
 * The mod-index string lives at (PSG_CUST_CHANGE_ADDR + 3) = 0x93A7.
 */
#define PSG_CUST_CHANGE_ADDR    0x93A4U

// ================================================================
// ROM lookup interface  (implemented in psg_prop.c)
// ================================================================

/*
 * PSG_ROM_GetData — fill 'out' with 'len' bytes for the given ROM address.
 * Returns 1 if the address is known, 0 if unhandled.
 * Access-control (lock checks) is the caller's responsibility.
 */
uint8_t PSG_ROM_GetData(uint16_t addr, uint8_t len, uint8_t *out);

/*
 * PSG_EEPROM_GetData — fill 'out' with 'len' bytes for the given EEPROM address.
 * Returns 1 if the address is known, 0 if unhandled.
 * Access-control (lock checks) is the caller's responsibility.
 */
uint8_t PSG_EEPROM_GetData(uint16_t addr, uint8_t len, uint8_t *out);

#endif /* INC_PSG_PROP_H_ */
