Broken spark implementation

This commit is contained in:
2026-06-03 17:45:48 +02:00
parent 1e8d3b766f
commit f8b73ea1bc
6 changed files with 90 additions and 29 deletions

View File

@@ -3,10 +3,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <ring_buffer.h>
#include <stdbool.h>
#include <stdint.h>
#define MAX_CAM_MISS 2
#define SPARK_ADVANCE 20
#define INJECTION_PHASE 0
typedef enum { SYNC_OK = 0, SYNC_PENDING = 1, SYNC_NOT_OK = 2 } sync_state_t;
@@ -20,6 +22,12 @@ typedef enum {
typedef enum { CAM_IDLE = 0, CAM_TRIGD = 1 } cam_state_t;
typedef enum {
SPARK_IDLE = 0,
SPARK_CHARGING = 1,
SPARK_NONE = 2
} spark_state_t;
typedef struct {
crank_state_t crank_state;
cam_state_t cam_state;
@@ -27,4 +35,6 @@ typedef struct {
sync_state_t sync_state;
ring_buffer_t crank_RB;
ring_buffer_t cam_RB;
spark_state_t next_spark_state;
spark_state_t current_spark_state;
} global_state_t;

View File

@@ -5,7 +5,6 @@
#include "global_state.h"
#ifdef DEBUG
#include "SEGGER_RTT.h"
#define INJECTION_PHASE 0
#define DEBUG_LOG(fmt, ...) SEGGER_RTT_printf(0, fmt "\n", ##__VA_ARGS__)
#else
#define DEBUG_LOG(fmt, ...) \
@@ -14,5 +13,3 @@
#endif
#define CRANK(num) ringBufferRead(&state_g.crank_RB, num)
#define CAM(num) ringBufferRead(&state_g.cam_RB, num)
#define D1A CRANK(0)-CRANK(1)
#define D1B CRANK(1)-CRANK(2)