Initial sync implementation
Implemented system sync with crank and cam state and simple error handling
This commit is contained in:
@@ -3,21 +3,27 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <ring_buffer.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MAX_CAM_MISS 2
|
||||
|
||||
typedef enum { SYNC_OK = 0, SYNC_PENDING = 1, SYNC_NOT_OK = 2 } sync_state_t;
|
||||
|
||||
typedef enum {
|
||||
SYNC_OK = 0,
|
||||
SYNC_PENDING = 1,
|
||||
SYNC_NOT_OK = 2
|
||||
} sync_state;
|
||||
typedef enum {
|
||||
CYCLE_EXHAUST = 0,
|
||||
CYCLE_INTAKE = 1,
|
||||
CYCLE_COMPRESSION = 2,
|
||||
CYCLE_COMBUSTION = 3,
|
||||
CYCLE_COMBUSTION = 0,
|
||||
CYCLE_EXHAUST = 1,
|
||||
CYCLE_INTAKE = 2,
|
||||
CYCLE_COMPRESSION = 3,
|
||||
CYCLE_UNKNOWN = 4
|
||||
} crank_state;
|
||||
} crank_state_t;
|
||||
|
||||
typedef enum { CAM_IDLE = 0, CAM_TRIGD = 1 } cam_state_t;
|
||||
|
||||
typedef struct {
|
||||
crank_state cycle;
|
||||
sync_state sync;
|
||||
ring_buffer_t crank_RB;
|
||||
ring_buffer_t cam_RB;
|
||||
crank_state_t crank_state;
|
||||
cam_state_t cam_state;
|
||||
uint8_t cam_miss_ctr;
|
||||
sync_state_t sync_state;
|
||||
ring_buffer_t crank_RB;
|
||||
ring_buffer_t cam_RB;
|
||||
} global_state_t;
|
||||
|
||||
13
STM32/CM7/Core/Inc/macros.h
Normal file
13
STM32/CM7/Core/Inc/macros.h
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
|
||||
// Copyright (C) 2026 Pierre Barbier <pierrebarbier741@gmail.com>
|
||||
// Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "SEGGER_RTT.h"
|
||||
#define DEBUG_LOG(fmt, ...) SEGGER_RTT_printf(0, fmt "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_LOG(fmt, ...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
Reference in New Issue
Block a user