GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 32.4% 12 / 0 / 37
Functions: 25.0% 1 / 0 / 4
Branches: 37.5% 3 / 0 / 8

driver/led/led.c
Line Branch Exec Source
1 /*******************************************************************************
2 *
3 * FILE:
4 * led.c
5 *
6 * DESCRIPTION:
7 * Contains API functions to set the behavior of the on-board rgb led
8 *
9 * COPYRIGHT:
10 * Copyright (c) 2025 Sun Devil Rocketry.
11 * All rights reserved.
12 *
13 * This software is licensed under terms that can be found in the LICENSE
14 * file in the root directory of this software component.
15 * If no LICENSE file comes with this software, it is covered under the
16 * BSD-3-Clause.
17 *
18 * https://opensource.org/license/bsd-3-clause
19 *
20 *******************************************************************************/
21
22
23 /*------------------------------------------------------------------------------
24 MCU Pins
25 ------------------------------------------------------------------------------*/
26 #if defined( A0002_REV2 ) /* FC rev2 */
27 #include "sdr_pin_defines_A0002.h"
28 #elif defined( A0010 ) /* FC rev3 */
29 #include "sdr_pin_defines_A0010.h"
30 #elif defined( ENGINE_CONTROLLER )
31 #include "sdr_pin_defines_L0002.h"
32 #elif defined( GROUND_STATION )
33 #include "sdr_pin_defines_A0005.h"
34 #elif defined( FLIGHT_COMPUTER_LITE )
35 #include "sdr_pin_defines_A0007.h"
36 #elif defined( VALVE_CONTROLLER )
37 #include "sdr_pin_defines_L0005.h"
38 #endif
39
40
41 /*------------------------------------------------------------------------------
42 Project Includes
43 ------------------------------------------------------------------------------*/
44 #include "main.h"
45 #include "led.h"
46
47
48 /*------------------------------------------------------------------------------
49 Procedures
50 ------------------------------------------------------------------------------*/
51
52
53 /*******************************************************************************
54 * *
55 * PROCEDURE: *
56 * led_error_assert *
57 * *
58 * DESCRIPTION: *
59 * Sets the RGB LED to red to indicate a software exception *
60 * *
61 *******************************************************************************/
62 ✗ void led_error_assert
63 (
64 void
65 )
66 {
67 /* Reset RGB LED */
68 ✗ led_reset();
69
70 /* Set the RGB LED to red */
71 ✗ HAL_GPIO_WritePin(STATUS_GPIO_PORT, STATUS_R_PIN, GPIO_PIN_RESET);
72
73 ✗ } /* led_error_assert */
74
75
76 /*******************************************************************************
77 * *
78 * PROCEDURE: *
79 * led_reset *
80 * *
81 * DESCRIPTION: *
82 * Resets the RGB led *
83 * *
84 *******************************************************************************/
85 ✗ void led_reset
86 (
87 void
88 )
89 {
90
91 /* Set all MCU RGB led pins to high */
92 ✗ HAL_GPIO_WritePin(
93 STATUS_GPIO_PORT,
94 STATUS_R_PIN |
95 STATUS_G_PIN |
96 STATUS_B_PIN,
97 GPIO_PIN_SET
98 );
99
100 ✗ } /* led_reset */
101
102
103 /*******************************************************************************
104 * *
105 * PROCEDURE: *
106 * led_error_flash *
107 * *
108 * DESCRIPTION: *
109 * Flashes the RGB led red to indicate the code hit a block of code not *
110 * intended to be hit under normal conditions *
111 * *
112 *******************************************************************************/
113 ✗ void led_error_flash
114 (
115 void
116 )
117 {
118
119 /* Flash led red */
120 ✗ led_reset();
121 ✗ HAL_GPIO_WritePin(STATUS_GPIO_PORT, STATUS_R_PIN, GPIO_PIN_RESET);
122 ✗ HAL_Delay(100);
123 ✗ HAL_GPIO_WritePin(STATUS_GPIO_PORT, STATUS_R_PIN, GPIO_PIN_SET);
124
125 ✗ } /* led_error_flash */
126
127
128 /*******************************************************************************
129 * *
130 * PROCEDURE: *
131 * led_set_color *
132 * *
133 * DESCRIPTION: *
134 * Sets the LED to a color from the LED_COLOR_CODES enum *
135 * *
136 *******************************************************************************/
137 2714 void led_set_color
138 (
139 LED_COLOR_CODES color
140 )
141 {
142
143 /* Reset LED */
144 #ifndef EMULATOR
145 led_reset(); /* The call to reset every time makes the emulator GUI flash */
146 #endif
147
148 /* Check Colors */
149
3/8
✓ Branch 0 taken 1553 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1160 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2714 switch ( color )
150 {
151 1553 case LED_GREEN:
152 {
153 1553 HAL_GPIO_WritePin( STATUS_GPIO_PORT, STATUS_G_PIN, GPIO_PIN_RESET );
154 1553 break;
155 }
156
157 ✗ case LED_RED:
158 {
159 ✗ HAL_GPIO_WritePin( STATUS_GPIO_PORT, STATUS_R_PIN, GPIO_PIN_RESET );
160 ✗ break;
161 }
162
163 ✗ case LED_BLUE:
164 {
165 ✗ HAL_GPIO_WritePin( STATUS_GPIO_PORT, STATUS_B_PIN, GPIO_PIN_RESET );
166 ✗ break;
167 }
168
169 1160 case LED_CYAN:
170 {
171 1160 HAL_GPIO_WritePin( STATUS_GPIO_PORT,
172 STATUS_B_PIN |
173 STATUS_G_PIN,
174 GPIO_PIN_RESET);
175 1160 break;
176 }
177
178 ✗ case LED_PURPLE:
179 {
180 ✗ HAL_GPIO_WritePin( STATUS_GPIO_PORT,
181 STATUS_B_PIN |
182 STATUS_R_PIN ,
183 GPIO_PIN_RESET );
184 ✗ break;
185 }
186
187 1 case LED_YELLOW:
188 {
189 1 HAL_GPIO_WritePin( STATUS_GPIO_PORT,
190 STATUS_G_PIN |
191 STATUS_R_PIN ,
192 GPIO_PIN_RESET );
193 1 break;
194 }
195
196 ✗ case LED_WHITE:
197 {
198 ✗ HAL_GPIO_WritePin( STATUS_GPIO_PORT,
199 STATUS_G_PIN |
200 STATUS_R_PIN |
201 STATUS_B_PIN ,
202 GPIO_PIN_RESET );
203 ✗ break;
204 }
205 } /* switch ( color ) */
206 2714 } /* led_set_color */
207
208
209 /*******************************************************************************
210 * END OF FILE *
211 *******************************************************************************/
212