STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1#pragma once
2
3#include <Adafruit_LIS3DH.h>
4#include <Arduino.h>
5#include <STAR_ISM330DH.h>
6
7// -----------------------------------------------------------------------------
8// MCP3201 — ratiometric pressure transducer
9// -----------------------------------------------------------------------------
10static constexpr float VREF = 3.3f;
11static constexpr float ADC_COUNTS = 4095.0f;
12static constexpr float PT_FULL_SCALE_PSI = 1000.0f;
13
14// -----------------------------------------------------------------------------
15// LPS28DFW
16// -----------------------------------------------------------------------------
17static constexpr float LPS28DFW_SEA_LEVEL_HPA = 1013.25f;
18static constexpr uint8_t LPS28DFW_I2C_ADDR = 0x5C;
19
20// Apogee — windowed barometric derivative
21static constexpr unsigned ALT_BUF_N = 24;
22static constexpr float ALT_TREND_THRESHOLD_M = 2.0f;
23static constexpr unsigned ALT_TREND_CONFIRM_COUNT = 6;
24
25// -----------------------------------------------------------------------------
26// LIS3DH — launch / high-G (see IC_Testing/LIS3DH/main.h)
27// -----------------------------------------------------------------------------
29static constexpr float INTERRUPT_THRESHOLD_G = 2.5f;
30static constexpr uint8_t INTERRUPT_DURATION_COUNTS = 10;
32
33static constexpr float lis3dh_lsb_mg(lis3dh_range_t range) {
34 switch (range) {
36 return 16.0f;
38 return 32.0f;
40 return 62.0f;
42 return 186.0f;
43 default:
44 return 16.0f;
45 }
46}
47
48static constexpr uint8_t INT1_THS_VALUE = []() -> uint8_t {
49 float lsb = lis3dh_lsb_mg(ACCEL_RANGE);
50 float raw = (INTERRUPT_THRESHOLD_G * 1000.0f) / lsb;
51 uint8_t val = (raw > 127.0f) ? 127 : (uint8_t)raw;
52 return (val == 0) ? 1 : val;
53}();
54
55static constexpr uint8_t INT1_DUR_VALUE =
56 (INTERRUPT_DURATION_COUNTS > 127) ? 127
58
59// -----------------------------------------------------------------------------
60// ISM330DHCX — match IC_Testing/ISM330DH main.h
61// -----------------------------------------------------------------------------
62static constexpr uint8_t ISM330_ACCEL_FS = ISM_16g;
63static constexpr float ISM330_ACCEL_FS_G = 16.0f;
64static constexpr float ISM330_WAKEUP_THRESHOLD_G = 2.5f;
65static constexpr uint8_t ISM330_WAKEUP_DUR = 2;
66static constexpr bool ISM330_ROUTE_DRDY_TO_INT1 = false;
67
68static constexpr uint8_t ISM330_WKUP_THS = []() -> uint8_t {
69 constexpr float mgPerLsb = (ISM330_ACCEL_FS_G * 1000.0f) / 64.0f;
70 float raw = (ISM330_WAKEUP_THRESHOLD_G * 1000.0f) / mgPerLsb;
71 uint8_t v = (raw > 63.0f) ? 63 : static_cast<uint8_t>(raw);
72 return (v < 1) ? 1 : v;
73}();
74
75// -----------------------------------------------------------------------------
76// Flight state machine
77// -----------------------------------------------------------------------------
78static constexpr uint32_t ACTIVE_DURATION_MS = 120000UL;
79
80// -----------------------------------------------------------------------------
81// MX25 flight log region (bytes reserved from end of flash)
82// -----------------------------------------------------------------------------
83static constexpr uint32_t FLIGHT_LOG_REGION_BYTES = 512UL * 1024UL;
84
85// -----------------------------------------------------------------------------
86// Debug
87// -----------------------------------------------------------------------------
88#ifndef DEBUG_TELEMETRY
89#define DEBUG_TELEMETRY 0
90#endif
91
92#ifndef FLIGHT_LOG_ENABLE
93#define FLIGHT_LOG_ENABLE 1
94#endif
This is a library for the Adafruit LIS3DH Accel breakout board.
lis3dh_range_t
A structure to represent scales.
@ LIS3DH_RANGE_16_G
@ LIS3DH_RANGE_8_G
@ LIS3DH_RANGE_2_G
@ LIS3DH_RANGE_4_G
lis3dh_dataRate_t
Data rate selection Used with register 0x2A (LIS3DH_REG_CTRL_REG1) to set bandwidth.
@ LIS3DH_DATARATE_400_HZ
#define ISM330_WAKEUP_DUR
Definition main.h:28
#define ISM330_ROUTE_DRDY_TO_INT1
Definition main.h:31
#define ISM330_ACCEL_FS_G
Definition main.h:22
#define ISM330_ACCEL_FS
Definition main.h:21
#define ISM330_WAKEUP_THRESHOLD_G
Definition main.h:25
#define ACCEL_RANGE
Definition main.h:11
#define ACCEL_ODR
Definition main.h:21
#define INTERRUPT_DURATION_COUNTS
Definition main.h:18
#define INTERRUPT_THRESHOLD_G
Definition main.h:14
#define LPS28DFW_I2C_ADDR
Definition main.h:9
#define LPS28DFW_SEA_LEVEL_HPA
Definition main.h:13
#define ADC_COUNTS
Definition main.h:17
#define VREF
Definition main.h:14
static constexpr unsigned ALT_TREND_CONFIRM_COUNT
Definition config.h:23
static constexpr uint32_t ACTIVE_DURATION_MS
Definition config.h:78
static constexpr uint8_t INT1_THS_VALUE
Definition config.h:48
static constexpr uint8_t ISM330_WKUP_THS
Definition config.h:68
static constexpr float PT_FULL_SCALE_PSI
Definition config.h:12
static constexpr uint32_t FLIGHT_LOG_REGION_BYTES
Definition config.h:83
static constexpr float ALT_TREND_THRESHOLD_M
Definition config.h:22
static constexpr uint8_t INT1_DUR_VALUE
Definition config.h:55
static constexpr float lis3dh_lsb_mg(lis3dh_range_t range)
Definition config.h:33
static constexpr unsigned ALT_BUF_N
Definition config.h:21
#define ISM_16g