73 lines
2.1 KiB
C
73 lines
2.1 KiB
C
/*
|
|
* @file rsense.h
|
|
* @brief Radiation sensor subsystem: counters, spectrum, drift compensation,
|
|
* and HV/detector power control.
|
|
*
|
|
* Created: 21.09.2025
|
|
* Author: ThePetrovich
|
|
*
|
|
* Copyright YKSA - Sakha Aerospace Systems, LLC.
|
|
* See the LICENSE file for details.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef RSENSE_H
|
|
#define RSENSE_H
|
|
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @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 Periodic housekeeping: CPM accumulation window and drift
|
|
* compensation tick. Should be called from the main loop.
|
|
*/
|
|
void rsense_periodic(void);
|
|
|
|
/** @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 */
|