This is a first implementation of a "full" timing system, with proper handling for cases wher the ignition charge time overlaps with the compression pulse, the spark has a more complex state machine system with the option to defer charge from the intake pulse to the compression pulse, and further defferal of the spark release schedule to the ISR that triggers when the output compare triggers for the charge Preliminary error counters have been put in place, they still require handling error conditions that would force a soft shutdown on the ignition IC. Alongside this the code still needs to be verified so that all non critical errors (ie missed charge schedules) reset the state machine and increment a global spark miss counter to avoid having these errors breaking the state machine as they can easily be recovered from Cases where the coil would already be charging and an error occurs require as stated above a full recovery procedure with soft shutdown of the ignition IC and a clean cycle of the state machine to ensure a full recovery
16 lines
502 B
C
16 lines
502 B
C
// Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
|
|
// Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
#pragma once
|
|
#include <stdint.h>
|
|
typedef struct ring_buffer_t {
|
|
uint32_t buffer[256];
|
|
uint8_t w_head;
|
|
} ring_buffer_t;
|
|
|
|
void ringBufferPush(volatile ring_buffer_t *rb, uint32_t value);
|
|
|
|
uint32_t ringBufferRead(volatile ring_buffer_t *rb, uint8_t neg_idx);
|
|
|
|
void ringBufferRevert(volatile ring_buffer_t *rb, uint8_t val);
|