Skip to content

Commit 1f46cec

Browse files
Jude MerrittJude Merritt
authored andcommitted
merge to push ADC
2 parents b5900fa + 301d6be commit 1f46cec

12 files changed

Lines changed: 503 additions & 16 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,5 @@ build_logs/
253253
# Doxygen output
254254
html/
255255
docs/
256-
# End of https://www.toptal.com/developers/gitignore/api/cmake,c,c++,clion,macos
256+
# End of https://www.toptal.com/developers/gitignore/api/cmake,c,c++,clion,macos
257+
*.bin

.vscode/launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "openocd dev debug CM7",
66
"cwd": "${workspaceRoot}",
7-
"executable": "/Users/mahiremran/Desktop/GitHub/titan/build/test_spi.elf",
7+
"executable": "/Users/mahiremran/Desktop/GitHub/titan/build/test_errc.elf",
88
"armToolchainPath": "/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin",
99
"request": "launch",
1010
"type": "cortex-debug",
@@ -21,7 +21,7 @@
2121
{
2222
"name": "openocd test debug CM7",
2323
"cwd": "${workspaceRoot}",
24-
"executable": "/Users/mahiremran/Desktop/GitHub/titan/build/test_spi.elf",
24+
"executable": "/Users/mahiremran/Desktop/GitHub/titan/build/test_errc.elf",
2525
"armToolchainPath": "/Applications/ArmGNUToolchain/14.3.rel1/arm-none-eabi/bin",
2626
"request": "attach",
2727
"type": "cortex-debug",
@@ -42,5 +42,5 @@
4242
]
4343
}
4444
],
45-
"project.debugTarget": "/Users/mahiremran/Desktop/GitHub/titan/build/test_pwm.elf"
45+
"project.debugTarget": "/Users/mahiremran/Desktop/GitHub/titan/build/test_errc.elf"
4646
}

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ add_firmware_target(test_pwm ${CMAKE_SOURCE_DIR}/test/test_pwm.c)
101101
add_firmware_target(test_spi ${CMAKE_SOURCE_DIR}/test/test_spi.c)
102102
add_firmware_target(test_usart ${CMAKE_SOURCE_DIR}/test/test_usart.c)
103103
add_firmware_target(test_oscilloscope ${CMAKE_SOURCE_DIR}/test/test_oscilloscope.c)
104+
add_firmware_target(test_errc ${CMAKE_SOURCE_DIR}/test/test_errc.c)
104105

105106
# Native host unit test: test_alloc (compiled with system gcc, not the ARM cross-compiler)
106107
add_custom_command(

build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LOG_FILE="$LOG_DIR/build_$(date +%Y%m%d_%H%M%S).log"
1212
exec > >(tee -a "$LOG_FILE") 2>&1
1313

1414
FW_TARGET="${1:-${FW_TARGET:-titan}}"
15-
FW_TARGETS=(titan test_pwm test_spi test_usart test_oscilloscope)
15+
FW_TARGETS=(titan test_pwm test_spi test_usart test_oscilloscope test_errc)
1616
MAX_ATTEMPTS=3
1717
UPDATE_DEBUG_TARGET=false
1818

@@ -24,11 +24,11 @@ done
2424

2525
# ── Target validation ──────────────────────────────────────────────────────────
2626
case "$FW_TARGET" in
27-
titan|test_pwm|test_spi|test_usart|test_oscilloscope|commit_check|all|clean|docs)
27+
titan|test_pwm|test_spi|test_usart|test_oscilloscope|test_errc|commit_check|all|clean|docs)
2828
;;
2929
*)
3030
echo "Unknown target: $FW_TARGET"
31-
echo "Valid targets: titan, test_pwm, test_spi, test_usart, test_oscilloscope, commit_check, all, clean, docs"
31+
echo "Valid targets: titan, test_pwm, test_spi, test_usart, test_oscilloscope, test_errc, commit_check, all, clean, docs"
3232
exit 4
3333
;;
3434
esac

communication_protocol.txt

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Data from flight comptuer:
2+
# Flight computer sensor data
3+
# Flight computer status
4+
# Flight computer valve/servo states
5+
6+
# Data from CC:
7+
# CC passthrough sensor data
8+
# CC passthrough valve states
9+
# CC status data
10+
11+
# Loggers:
12+
# Status Logger
13+
# Flight computer sensor logger
14+
# Flight computer valve/servo state logger
15+
16+
# Flight Computer Sensors
17+
# 2x IMU - [accel x (2 bytes), accel y (2 bytes), accel z (2 bytes), gyro x (2 bytes), gyro y (2 bytes), gyro z (2 bytes)] - 12 bytes each
18+
# 2x Magnetometer - [mag x (2 bytes), mag y (2 bytes), mag z (2 bytes)] - 6 bytes each
19+
# 2x barometer - 3 bytes each (reads pressure)
20+
# 2x Temperature sensor - temperature (2 bytes) (one is on power board, one is on sensor board)
21+
# GPS - [latitude (4 bytes), longitude (4 bytes), altitude (4 bytes), velocity x (2 bytes), velocity y (2 bytes), velocity z (2 bytes), time (4 bytes)] - 22 bytes
22+
# ADC - 3 bytes per data point (max of 24 pressure sensors, 24 RTDs, 3 strain guages)
23+
24+
# 3x current sensors - 2 bytes each
25+
26+
# Flight computer valves/servos
27+
# 12 actuator outputs
28+
# 8 servo outputs
29+
30+
# Downlink Packets (from FC to CC):
31+
32+
# Sensor data packet:
33+
# 0x01
34+
# <IMU 1 accel x (2 bytes)>
35+
# <IMU 1 accel y (2 bytes)>
36+
# <IMU 1 accel z (2 bytes)>
37+
# <IMU 1 gyro x (2 bytes)>
38+
# <IMU 1 gyro y (2 bytes)>
39+
# <IMU 1 gyro z (2 bytes)>
40+
# <IMU 2 accel x (2 bytes)>
41+
# <IMU 2 accel y (2 bytes)>
42+
# <IMU 2 accel z (2 bytes)>
43+
# <IMU 2 gyro x (2 bytes)>
44+
# <IMU 2 gyro y (2 bytes)>
45+
# <IMU 2 gyro z (2 bytes)>
46+
# <Magnetometer 1 mag x (2 bytes)>
47+
# <Magnetometer 1 mag y (2 bytes)>
48+
# <Magnetometer 1 mag z (2 bytes)>
49+
# <Magnetometer 2 mag x (2 bytes)>
50+
# <Magnetometer 2 mag y (2 bytes)>
51+
# <Magnetometer 2 mag z (2 bytes)>
52+
# <Barometer 1 pressure (3 bytes)>
53+
# <Barometer 2 pressure (3 bytes)>
54+
# <Temperature sensor 1 temperature (2 bytes)>
55+
# <Temperature sensor 2 temperature (2 bytes)>
56+
# <Current sensor 1 current (2 bytes)>
57+
# <Current sensor 2 current (2 bytes)>
58+
# <Current sensor 3 current (2 bytes)>
59+
60+
# GPS data packet
61+
# 0x02
62+
# <Latitude (4 bytes)>
63+
# <Longitude (4 bytes)>
64+
# <Altitude (4 bytes)>
65+
# <Velocity x (2 bytes)>
66+
# <Velocity y (2 bytes)>
67+
# <Velocity z (2 bytes)>
68+
# <Time (4 bytes)>
69+
70+
# ADC data packet
71+
# 0x03
72+
# <packet index (1 byte)>
73+
# <data point (3 bytes)> (repeat for each sensor in adc config for this packet index)
74+
75+
# State packet
76+
# 0x04
77+
# <valve state (1 bit)> (repeat for each valve in status protocol, pad to byte boundary)
78+
# <servo state (2 bytes)> (repeat for each servo in status protocol)
79+
80+
# comm packet:
81+
# 0x05
82+
# <ping id (2 bytes)>
83+
# <system mode (1 byte)>
84+
# <processor time (4 bytes)> (ms since startup)
85+
# <last command id (2 bytes)>
86+
# <last command status (1 byte)>
87+
# <message count (1 byte)>
88+
# <message 1 tag (1 byte)> (optional) (repeat for each desired message)
89+
90+
# NOTE: After comm packet is sent over radio, FC is expected
91+
# The comm packet is expected every 100 ms, with 10 ms given for a response.
92+
93+
# Command status values
94+
# 0x00 Command waiting
95+
# 0x01 Command in progress
96+
# 0x02 Command completed successfully
97+
# 0x03 Command failed due to invalid tag
98+
# 0x04 Command failed due to invalid arguments
99+
# 0x05 Command failed due to out of range arguments
100+
# 0x06 Command failed due to hardware error
101+
# 0x07 Command failed due to timeout
102+
# 0x08 Command failed due to invalid system state
103+
# 0x09 Command aborted by flight computer
104+
# 0x0A Command awaiting confirmation
105+
106+
# Uplink Packets (from CC to FC):
107+
108+
# comm packet:
109+
# 0x01
110+
# <ping id (2 bytes)>
111+
# <system time (4 bytes)> (unix timestamp)
112+
# <command valid (1 byte)> (0 = invalid, 1 = valid)
113+
# <command id (2 bytes)> (optional, only if command valid = 1)
114+
# <command type (1 byte)> (optional, only if command valid = 1)
115+
# <command tag (1 byte)> (optional, only if command valid = 1)
116+
# <command arguments (pre-determined variable length)> (optional, only if command valid = 1)
117+
118+
# Command types
119+
# 0x00 Static command
120+
# 0x01 Custom command
121+
122+
# Static command tags and args
123+
124+
# Change valve state
125+
# 0x00
126+
# <valve id (1 byte)>
127+
# <new state (1 byte)> (0 = closed, 1 = open)
128+
129+
# Pulse valve
130+
# 0x01
131+
# <valve id (1 byte)>
132+
# <pulse duration (2 bytes)> (in milliseconds)
133+
134+
# Change servo state
135+
# 0x02
136+
# <servo id (1 byte)>
137+
# <new position (2 bytes)>
138+
139+
# Pulse servo
140+
#0x03
141+
# <servo id (1 byte)>
142+
# <new position (2 bytes)>
143+
# <pulse duration (2 bytes)> (in milliseconds)
144+
145+
# Set sys mode
146+
# 0x04
147+
# <new mode (1 byte)>
148+
149+
# Set comm link
150+
# 0x05
151+
# <new link (1 byte)> (0 = RS485, 1 = radio)
152+
153+
# Sleep
154+
#0x04
155+
156+
# Wake
157+
# 0x05
158+
159+
# Restart (2 commands to confirm)
160+
#0x06

src/app/states/fill_state.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ bool fill_state_init(){
1212
}
1313

1414
int fill_state_run(){
15+
16+
1517
return 3;
1618
}
1719

src/app/utils/pinout.h

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
* This file is part of the Titan Flight Computer Project
3+
* Copyright (c) 2025 UW SARP
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, version 3.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* @file app/utils/pinout.h
18+
* @authors Joshua Beard
19+
* @brief Physical pinout of flight computer board
20+
*/
21+
22+
#include <stdint.h>
23+
24+
25+
const uint32_t GNSS_SPI_CS = 126;
26+
// SPI 3, same as sensor board SPI
27+
const uint32_t GNSS_SPI_MOSI = 111;
28+
const uint32_t GNSS_SPI_MISO = 110;
29+
const uint32_t GNSS_SPI_SCLK = 109;
30+
//-------------------------------
31+
32+
const uint32_t EXT_FLASH_QSPI_CS = 66;
33+
const uint32_t EXT_FLASH_QSPI_SCLK = 24;
34+
const uint32_t EXT_FLASH_QSPI_IO_0 = 22;
35+
const uint32_t EXT_FLASH_QSPI_IO_1 = 23;
36+
const uint32_t EXT_FLASH_QSPI_IO_2 = 21;
37+
const uint32_t EXT_FLASH_QSPI_IO_3 = 20;
38+
//-------------------------------
39+
40+
const uint32_t RADIO_SPI_CS = 84;
41+
// SPI 2
42+
const uint32_t RADIO_SPI_MOSI = 75;
43+
const uint32_t RADIO_SPI_MISO = 74;
44+
const uint32_t RADIO_SPI_SCLK = 73;
45+
46+
const uint32_t RADIO_IRQ = 85;
47+
const uint32_t RADIO_SHDN = 49;
48+
//-------------------------------
49+
50+
// UART 2
51+
const uint32_t RS485_UART_TX = 39;
52+
const uint32_t RS485_UART_RX = 40;
53+
54+
const uint32_t RS485_RE = 44;
55+
const uint32_t RS485_DE = 43;
56+
//-------------------------------
57+
//CAN could be here, but I omit since we are not using it in the minimal version
58+
59+
const uint32_t USB_DATA_plus = 101;
60+
const uint32_t USB_DATA_minus = 100;
61+
const uint32_t USB_ID = 99;
62+
//-------------------------------
63+
64+
const uint32_t SWD_CLK = 107;
65+
const uint32_t SWD_IO = 102;
66+
const uint32_t SWD_OUT = 130;
67+
const uint32_t RST = 27;
68+
//-------------------------------
69+
70+
const uint32_t ACTUATOR_SPI_MOSI = 5;
71+
const uint32_t ACTUATOR_SPI_MISO = 4;
72+
const uint32_t ACTUATOR_CS_1 = 63;
73+
const uint32_t ACTUATOR_CS_2 = 62;
74+
const uint32_t ACTUATOR_CS_3 = 61;
75+
const uint32_t POWER_TMP_CS = 58; // power board temperature
76+
77+
const uint32_t PWM_1 = 38;
78+
const uint32_t PWM_2 = 93;
79+
const uint32_t PWM_3 = 82;
80+
const uint32_t PWM_4 = 37;
81+
const uint32_t PWM_5 = 45;
82+
const uint32_t PWM_6 = 46;
83+
const uint32_t PWM_7 = 136;
84+
const uint32_t PWM_8 = 137;
85+
86+
//-------------------------------
87+
88+
const uint32_t IGNITE_IO = 51;
89+
const uint32_t IGNITE_CONT = 52; // ADC in
90+
const uint32_t BATT_EN = 60;
91+
92+
//-------------------------------
93+
94+
// SPI 3, same as GNSS spi
95+
// NOTE: EVERYTHING IN THIS BLOCK IS ON SPI 3
96+
const uint32_t SENSOR_SPI_MOSI = 111; // ANA_SPI on diagram
97+
const uint32_t SENSOR_SPI_MISO = 110;
98+
const uint32_t SENSOR_SPI_SCLK = 109;
99+
100+
// ADC CS
101+
const uint32_t SENSOR_CS_1 = 76;
102+
const uint32_t SENSOR_CS_2 = 77;
103+
const uint32_t SENSOR_CS_3 = 114;
104+
const uint32_t SENSOR_CS_4 = 115;
105+
const uint32_t SENSOR_CS_5 = 116;
106+
const uint32_t SENSOR_CS_6 = 117;
107+
108+
// Regular sensor CS
109+
const uint32_t IMU_1_CS = 120;
110+
const uint32_t IMU_2_CS = 121;
111+
const uint32_t BARO_1_CS = 122;
112+
const uint32_t BARO_2_CS = 123;
113+
const uint32_t ANALOG_TMP_CS = 124; // analog (sensor) board temperature
114+
const uint32_t MAGNOTOMETER_CS = 125;
115+
//-------------------------------

0 commit comments

Comments
 (0)