Protocol rework

This commit is contained in:
ThePetrovich 2026-05-10 15:33:08 +08:00
parent 3e77d34ccc
commit 2b713a3e3a
15 changed files with 1347 additions and 1155 deletions

View file

@ -1,8 +1,9 @@
/*
* @file rsense.h
* @brief Radiation sensor management and command handling
* @brief Radiation sensor subsystem: counters, spectrum, drift compensation,
* and HV/detector power control.
*
* Created: 21.09.2025 06:01:56
* Created: 21.09.2025
* Author: ThePetrovich
*
* Copyright YKSA - Sakha Aerospace Systems, LLC.
@ -14,58 +15,59 @@
#ifndef RSENSE_H
#define RSENSE_H
#include <Arduino.h>
#include <stdint.h>
/**
* @brief Initialize radiation sensor subsystem
* @brief Configure GPIO, SPI digital potentiometers, and the event system
* used by the detector trigger pin to start ADC conversions.
*/
void rsense_init(void);
/**
* @brief Send telemetry data via serial
*/
void rsense_cmd_telemetry(void);
/**
* @brief Dump channel data via serial
*/
void rsense_cmd_dump_channels(void);
/**
* @brief Flush detector counters
*/
void rsense_cmd_flush(void);
/**
* @brief Enable radiation detection
*/
void rsense_cmd_enable(void);
/**
* @brief Disable radiation detection
*/
void rsense_cmd_disable(void);
/**
* @brief Set potentiometer values
*/
void rsense_cmd_set_potentiometers(void);
/**
* @brief Send counts per minute data
*/
void rsense_cmd_get_cpm(void);
/**
* @brief Set spectrum mode (16-bit or 32-bit)
*/
void rsense_cmd_set_configuration(void);
/**
* @brief Periodic tasks for radiation sensor
* Updates CPM calculation every 10 seconds
* Call from main loop
* @brief Periodic housekeeping: CPM accumulation window and drift
* compensation tick. Should be called from the main loop.
*/
void rsense_periodic(void);
#endif // RSENSE_H
/** @brief Reset all CPM/CP10S/total/delta count accumulators. */
void rsense_flush_counters(void);
/** @brief Zero the spectrum histogram and reset all counters. */
void rsense_flush_spectrum(void);
/** @brief Total counts since the last #rsense_flush_counters call. */
uint32_t rsense_get_total_counts(void);
/** @brief Last computed counts-per-minute value. */
uint16_t rsense_get_cps(void);
/**
* @brief Returns the count delta since the previous call and resets it.
* Used to service CMD_GET_COUNTS without losing pulses.
*/
uint32_t rsense_get_counts_since_last(void);
/** @brief Counts in the current 10 s window. */
uint32_t rsense_get_cp10s(void);
/**
* @brief Apply @c config.pots to the AD5160s.
* When the radiation sensor is powered, performs a freeze
* disable set enable unfreeze sequence to avoid spurious
* counts during the wiper update.
*/
void rsense_apply_potentiometers(void);
/** @brief Current spectrum binning mode (0 = 16-bit channels, 1 = 32-bit). */
uint8_t rsense_get_spectrum_mode(void);
/** @brief Pointer to the spectrum histogram, for read-only chunked transfer. */
const volatile void *rsense_get_spectrum_ptr(void);
/** @brief Power on the high-voltage and detector rails. */
void rsense_enable(void);
/** @brief Power off the high-voltage and detector rails. */
void rsense_disable(void);
#endif /* RSENSE_H */