55 lines
2.2 KiB
C
55 lines
2.2 KiB
C
/*
|
|
* ckp_acquisition.h (variant/T06215/compact_src)
|
|
*
|
|
* CKP-zero acquisition chain for T06215. Mirrors ROM
|
|
* FUN_624a-class Stage-1 caller @ 0x6330 (LCALL FUN_70d8) → FUN_70d8 @ 0x70d8.
|
|
*
|
|
* Body copied verbatim from variant/T06235 per the pillar-port copy gate
|
|
* (docs/pillar-functions.md). Only cal-field bindings change.
|
|
*
|
|
* See docs/algorithm-ckp-zero-acquisition.md for the data-flow summary.
|
|
*/
|
|
#ifndef PWM_T06215_CKP_ACQUISITION_H
|
|
#define PWM_T06215_CKP_ACQUISITION_H
|
|
|
|
#include <stdint.h>
|
|
|
|
/* Inputs */
|
|
extern int16_t B_CKP_OFFSET; /* RW134 / DAT_0134 — CAN raw input */
|
|
extern uint8_t commitCKP_offset; /* unused for now (commit gate hook) */
|
|
|
|
/* Internal RAM trims (DAT_0430 word, DAT_0404 signed byte). No runtime
|
|
* writer was found in this ROM/car; sit at 0 unless a future step wires
|
|
* them up. Exposed for diagnostic poking. */
|
|
extern int16_t CKP_RAM_TRIM_0430;
|
|
extern int8_t CKP_RAM_TRIM_0404;
|
|
|
|
/* Outputs */
|
|
extern int16_t dCKP_OFFSET; /* DAT_0434 — output of Stage 1 */
|
|
extern int16_t CKP_ZERO_OFFSET; /* DAT_0152 — output of Stage 2 (FUN_70d8) */
|
|
|
|
int16_t get_ckp_zero(void);
|
|
|
|
/* Get the next process-tooth index — mirrors the byte stored to R90
|
|
* in ROM FUN_7293 @ 0x7293 (analog of default-family FUN_87ea @ 0x87ea).
|
|
*
|
|
* The ROM routine advances the CKP zero-crossing accumulator by a fixed
|
|
* per-tick angular increment, then renormalizes the high byte (segment-
|
|
* tooth view) into the valid tooth range with two wrap branches:
|
|
*
|
|
* advanced = CKP_ZERO_OFFSET + ckp_advance_per_tick (16-bit ADD)
|
|
* tooth = (advanced >> 8) + 1 (byte INC of high)
|
|
* if (tooth > ckp_seg_wrap_threshold) (T06215: 29)
|
|
* tooth -= (ckp_modulus >> 8) (= 30 — angular wrap)
|
|
* else if (tooth > ckp_teeth_per_seg) (T06215: 26)
|
|
* tooth = 0 (hard reset)
|
|
* return tooth;
|
|
*
|
|
* No side-effects on CKP_ZERO_OFFSET or dCKP_OFFSET — the ROM SUB on
|
|
* RW1C is local to the function frame; only the byte (R90) escapes via
|
|
* the store at 0x72d1.
|
|
*/
|
|
uint8_t get_ckp_process_tooth(void);
|
|
|
|
#endif /* PWM_T06215_CKP_ACQUISITION_H */
|