Skip to content

Commit 2c4a021

Browse files
committed
Yay packets + other minor changes :)
1 parent 4cee561 commit 2c4a021

10 files changed

Lines changed: 824 additions & 376 deletions

File tree

src/app/states/fire_state.c

Lines changed: 163 additions & 276 deletions
Large diffs are not rendered by default.

src/app/utils/devices.h

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
#include "app/utils/pinout.h"
6+
#include "devices/adc.h"
7+
#include "devices/actuator.h"
8+
#include "devices/barometer.h"
9+
#include "devices/gnss.h"
10+
#include "devices/imu.h"
11+
#include "devices/magnetometer.h"
12+
#include "devices/radio.h"
13+
#include "devices/temperature.h"
14+
15+
#define VALVE_COUNT 12U
16+
#define SERVO_COUNT 8U
17+
18+
static radio_t radio_dev;
19+
static radio_spi_dev radio_spi_config = {
20+
.spi_inst = (uint8_t)RADIO_SPI_INST,
21+
.ss_pin = (uint8_t)RADIO_SPI_CS
22+
};
23+
24+
static radio_config_t radio_config = {
25+
.reset_pin = (uint8_t)RADIO_SHDN,
26+
.nirq_pin = (uint8_t)RADIO_IRQ,
27+
.reset_active_high = 0,
28+
.channel = 0
29+
};
30+
31+
static gnss_t gnss_dev = {
32+
.spi_config = {
33+
.spi_inst = (uint8_t)GNSS_SPI_INST,
34+
.ss_pin = (uint8_t)GNSS_SPI_CS
35+
},
36+
.config = {
37+
.meas_rate_ms = 200,
38+
.constellation_mask = GNSS_CONSTELLATION_GPS | GNSS_CONSTELLATION_GLONASS | GNSS_CONSTELLATION_BEIDOU,
39+
.dyn_model = GNSS_DYN_AIRBORNE_4G,
40+
.power_mode = GNSS_POWER_CONTINUOUS
41+
},
42+
.initialized = 0
43+
};
44+
45+
static struct imu_spi_dev imu_dev1 = {
46+
.inst = (uint8_t)SENSOR_SPI_INST,
47+
.ss_pin = (uint8_t)IMU_1_CS
48+
};
49+
50+
static struct imu_spi_dev imu_dev2 = {
51+
.inst = (uint8_t)SENSOR_SPI_INST,
52+
.ss_pin = (uint8_t)IMU_2_CS
53+
};
54+
55+
static barometer_t barometer_dev1 = {
56+
.spi_dev = {
57+
.inst = (uint8_t)SENSOR_SPI_INST,
58+
.ss_pin = (uint8_t)BARO_1_CS
59+
},
60+
.osr = OSR_4096,
61+
.calibration_data = {0},
62+
.result = {0}
63+
};
64+
65+
static barometer_t barometer_dev2 = {
66+
.spi_dev = {
67+
.inst = (uint8_t)SENSOR_SPI_INST,
68+
.ss_pin = (uint8_t)BARO_2_CS
69+
},
70+
.osr = OSR_4096,
71+
.calibration_data = {0},
72+
.result = {0}
73+
};
74+
75+
static struct magnetometer_spi_dev magnetometer_dev1 = {
76+
.inst = (uint8_t)SENSOR_SPI_INST,
77+
.ss_pin = (uint8_t)MAGNOTOMETER_CS
78+
};
79+
80+
static struct magnetometer_spi_dev magnetometer_dev2 = {
81+
.inst = (uint8_t)SENSOR_SPI_INST,
82+
.ss_pin = (uint8_t)MAGNOTOMETER_CS
83+
};
84+
85+
static temperature_t temperature_dev1 = {
86+
.spi_config = {
87+
.spi_inst = (uint8_t)SENSOR_SPI_INST,
88+
.ss_pin = (uint8_t)POWER_TMP_CS
89+
},
90+
.config = {
91+
.mode = temperature_MODE_CONTINUOUS,
92+
.resolution = temperature_RES_16_BIT
93+
}
94+
};
95+
96+
static temperature_t temperature_dev2 = {
97+
.spi_config = {
98+
.spi_inst = (uint8_t)SENSOR_SPI_INST,
99+
.ss_pin = (uint8_t)ANALOG_TMP_CS
100+
},
101+
.config = {
102+
.mode = temperature_MODE_CONTINUOUS,
103+
.resolution = temperature_RES_16_BIT
104+
}
105+
};
106+
107+
static struct adc_spi_dev adc_dev = {
108+
.inst = (uint8_t)SENSOR_SPI_INST,
109+
.ss_pin = (uint8_t)SENSOR_CS_1
110+
};
111+
112+
static const struct adc_channel adc_channels[] = {
113+
{
114+
.pos_pin = AIN0,
115+
.neg_pin = AINCOM,
116+
.gain = GAIN_1,
117+
.source = REF_INTERNAL,
118+
.ref_voltage = 25,
119+
.name = "adc0"
120+
}
121+
};
122+
123+
static const uint8_t adc_channel_count = (uint8_t)(sizeof(adc_channels) / sizeof(adc_channels[0]));
124+
125+
static uint8_t valve_states[VALVE_COUNT];
126+
static uint16_t servo_states[SERVO_COUNT];

0 commit comments

Comments
 (0)