GCC Code Coverage Report


Directory: ../../../../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 33 / 3 / 36
Functions: 100.0% 2 / 0 / 2
Branches: 85.7% 6 / 0 / 7

app/rev2/error_contract.c
Line Branch Exec Source
1 /*******************************************************************************
2 * *
3 * FILE: *
4 * error_contract.c *
5 * *
6 * DESCRIPTION: *
7 * Contains error callback table definitions for APPA. *
8 * *
9 * CRITICALITY: *
10 * FQ - Flight Qualified *
11 * *
12 * COPYRIGHT: *
13 * Copyright (c) 2025 Sun Devil Rocketry. *
14 * All rights reserved. *
15 * *
16 * This software is licensed under terms that can be found in the LICENSE *
17 * file in the root directory of this software component. *
18 * If no LICENSE file comes with this software, it is covered under the *
19 * BSD-3-Clause. *
20 * *
21 * https://opensource.org/license/bsd-3-clause *
22 * *
23 *******************************************************************************/
24
25 /*------------------------------------------------------------------------------
26 Standard Includes
27 ------------------------------------------------------------------------------*/
28 #include <stdlib.h>
29 #include "main.h"
30 #include "led.h"
31 #include "math_sdr.h"
32 #include "timer.h"
33 #include "error_sdr.h"
34 #include "buzzer.h"
35
36
37 /*------------------------------------------------------------------------------
38 Callback Function Prototypes
39 ------------------------------------------------------------------------------*/
40 static void error_callback_i2c_init
41 (
42 volatile ERROR_CODE error_code
43 );
44
45 static void error_callback_lora
46 (
47 volatile ERROR_CODE error_code
48 );
49
50 /*------------------------------------------------------------------------------
51 Callback Table
52 ------------------------------------------------------------------------------*/
53 volatile ERROR_CALLBACK error_callback_table[] =
54 {
55 { ERROR_BARO_INIT_ERROR , error_callback_i2c_init },
56 { ERROR_IMU_INIT_ERROR , error_callback_i2c_init },
57 { ERROR_BARO_I2C_INIT_ERROR , error_callback_i2c_init },
58 { ERROR_IMU_I2C_INIT_ERROR , error_callback_i2c_init },
59 { ERROR_I2C_HAL_MSP_ERROR , error_callback_i2c_init },
60 { ERROR_BARO_CAL_ERROR , error_callback_i2c_init },
61 { ERROR_LORA_INIT_ERROR , error_callback_lora },
62 { ERROR_LORA_CMD_ERROR , error_callback_lora }
63 };
64 uint16_t error_callback_table_size = array_size(error_callback_table);
65
66
67 /*------------------------------------------------------------------------------
68 Callback Implementations
69 ------------------------------------------------------------------------------*/
70
71 /*******************************************************************************
72 * *
73 * PROCEDURE: *
74 * error_callback_i2c_init *
75 * *
76 * DESCRIPTION: *
77 * Provides a slightly different error handler for different i2c init *
78 * errors. Temporary function for debugging *
79 * debugging of SunDevilRocketry/Flight-Computer-Firmware#192 *
80 * *
81 *******************************************************************************/
82 6 void error_callback_i2c_init
83 (
84 volatile ERROR_CODE error_code
85 )
86 {
87 // ETS TEMP: This callback is temporary while we debug an issue. If you hit this,
88 // please document it in #avionics-firmware and tell us the number of beeps.
89 // We'll match it to our key and record what may have happened.
90 6 led_set_color( LED_RED ); /* set LED to red */
91
92
6/7
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
6 switch ( error_code )
93 {
94 /* seq: 1 beep */
95 1 case ERROR_BARO_INIT_ERROR:
96 2 while(1)
97 {
98 1 buzzer_multi_beeps(200, 200, 1);
99 1 delay_ms(1000);
100 }
101 /* seq: 2 beeps */
102 1 case ERROR_IMU_INIT_ERROR:
103 2 while(1)
104 {
105 1 buzzer_multi_beeps(200, 200, 2);
106 1 delay_ms(1000);
107 }
108 /* seq: 3 beeps */
109 1 case ERROR_BARO_I2C_INIT_ERROR:
110 2 while(1)
111 {
112 1 buzzer_multi_beeps(200, 200, 3);
113 1 delay_ms(1000);
114 }
115 /* seq: 4 beeps */
116 1 case ERROR_IMU_I2C_INIT_ERROR:
117 2 while(1)
118 {
119 1 buzzer_multi_beeps(200, 200, 4);
120 1 delay_ms(1000);
121 }
122 /* seq: 5 beeps */
123 1 case ERROR_I2C_HAL_MSP_ERROR:
124 2 while(1)
125 {
126 1 buzzer_multi_beeps(200, 200, 5);
127 1 delay_ms(1000);
128 }
129 /* seq: 6 beeps */
130 1 case ERROR_BARO_CAL_ERROR:
131 2 while(1)
132 {
133 1 buzzer_multi_beeps(200, 200, 6);
134 1 delay_ms(1000);
135 }
136 /**
137 * GCOVR_EXCL_START
138 *
139 * Protective default case to prevent programmer error. Called by one function that will fall into one
140 * of the above cases.
141 */
142 − default:
143 − while(1)
144 {
145 /* Constant blinking beep */
146 − buzzer_multi_beeps(200, 200, 1);
147 }
148 }
149 /**
150 * GCOVR_EXCL_STOP
151 */
152
153 } /* store_frame */
154
155
156 2 void error_callback_lora
157 (
158 volatile ERROR_CODE error_code
159 )
160 {
161 4 while(1) {
162 2 led_set_color( LED_RED );
163 2 buzzer_beep(150);
164 2 led_set_color( LED_CYAN );
165 2 delay_ms(150);
166 }
167
168 } /* error_callback_lora */
169