73 lines
2.8 KiB
C
73 lines
2.8 KiB
C
/*
|
|
* @file config.h
|
|
* @brief System configuration and constants
|
|
*
|
|
* 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 CONFIG_H
|
|
#define CONFIG_H
|
|
|
|
// Firmware version
|
|
#define FIRMWARE_VERSION_MAJOR 2
|
|
#define FIRMWARE_VERSION_MINOR 03
|
|
|
|
// Serial communication
|
|
#define SERIAL_BAUD_RATE 38400
|
|
#define SERIAL_BUFFER_CLEAR() \
|
|
do { \
|
|
while (Serial.available()) { \
|
|
Serial.read(); \
|
|
} \
|
|
} while (0)
|
|
#define SERIAL_SEND_OK() \
|
|
do { \
|
|
Serial.print("ok\n"); \
|
|
Serial.flush(); \
|
|
SERIAL_BUFFER_CLEAR(); \
|
|
} while (0)
|
|
|
|
// Timing constants
|
|
#define STATUS_LED_BLINK_PERIOD 500U
|
|
#define MAIN_LOOP_DELAY 10
|
|
#define CPM_UPDATE_PERIOD 10000U
|
|
|
|
// ADC and detector settings
|
|
#define ADC_OVERSAMPLING_BITS 2 // 16x oversampling -> 2 extra bits
|
|
#define ADC_CHANNEL_16_MASK 0x7FFU // 11-bit channel mask
|
|
#define ADC_CHANNEL_32_MASK 0x3FFU // 10-bit channel mask
|
|
#define DETECTOR_CHANNEL_COUNT 2048
|
|
#define DETECTOR_CHANNEL_32_COUNT 1024
|
|
|
|
// Temperature sensor constants (MCP9700)
|
|
#define TEMP_SENSOR_OFFSET_MV 500L // 500 mV at 0°C
|
|
#define TEMP_SENSOR_SCALE_MV 10L // 10 mV per degree
|
|
#define ADC_VREF_MV 3000L // 3.0V reference
|
|
#define ADC_RESOLUTION 4096L // 12-bit effective resolution
|
|
|
|
// Voltage divider constants
|
|
#define VOLTAGE_DIVIDER_RATIO 20.0f // 200k and 10k resistors
|
|
#define VOLTAGE_MV_PER_STEP 14.6484375f // (3.0 * 20) / 4096
|
|
|
|
// EEPROM addresses for potentiometer settings
|
|
#define EEPROM_POT_HV_ADDR 0
|
|
#define EEPROM_POT_AMP_ADDR 1
|
|
#define EEPROM_POT_DET_ADDR 2
|
|
#define EEPROM_MAGIC_ADDR 3
|
|
#define EEPROM_MAGIC_VALUE 0xA5 // Magic value to check if EEPROM is initialized
|
|
|
|
// Default potentiometer values
|
|
#define DEFAULT_POT_VALUE 127
|
|
|
|
// Light sensor constants
|
|
#define LSENSE_I2C_BASE_ADDR 0x38
|
|
#define LSENSE_EXPECTED_ID 0xE0
|
|
#define LSENSE_DATA_SIZE 12
|
|
|
|
#endif // CONFIG_H
|