Skip to content

Commit 1cbfebc

Browse files
committed
rename some functions
1 parent 2d77371 commit 1cbfebc

File tree

7 files changed

+78
-78
lines changed

7 files changed

+78
-78
lines changed

source/a_box/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ void HardFault_Handler() {
9595
while (1) {
9696
__asm__("NOP"); // Halt forever
9797
}
98-
}
98+
}

source/dashboard/lcd/lcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ void updatePage() {
489489
page_handlers[curr_page].update();
490490
}
491491

492-
lcdTxUpdate();
492+
lcd_tx_cmd();
493493
}
494494

495495
void moveUp() {

source/dashboard/main.c

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,12 @@ extern page_t curr_page;
124124
volatile dashboard_input_state_t input_state = {0}; // Clear all input states
125125

126126
/* Function Prototypes */
127-
void preflightAnimation(void);
128-
void heartBeatLED();
129-
void lcdTxUpdate();
130-
void enableInterrupts();
131-
void encoderISR();
132-
void handleDashboardInputs();
133-
void sendBrakeStatus();
134-
void sendVersion();
127+
void preflight_animation(void);
128+
void heartbeat_led();
129+
void lcd_tx_cmd();
130+
void config_button_irqs();
131+
void service_button_inputs();
132+
void send_version();
135133
extern void HardFault_Handler();
136134

137135
// Communication queues
@@ -140,59 +138,21 @@ q_handle_t q_tx_usart;
140138
void preflight_task();
141139
void can_worker_task();
142140

143-
// The preflight thread must not be interrupted, give highest priority
141+
// The preflight thread must not be interrupted, give highest priority (will self exit when finished)
144142
defineThreadStack(preflight_task, 10, osPriorityRealtime, 1024);
145143

144+
// System critical threads
146145
defineThreadStack(pedalsPeriodic, FILT_THROTTLE_BRAKE_PERIOD_MS, osPriorityHigh, 512);
147146
defineThreadStack(can_worker_task, 20, osPriorityNormal, 512);
148147

148+
// Auxilary threads
149149
defineThreadStack(updateFaultDisplay, 500, osPriorityLow, 256);
150-
defineThreadStack(heartBeatLED, 500, osPriorityLow, 128);
151-
defineThreadStack(handleDashboardInputs, 50, osPriorityLow, 1024);
152-
defineThreadStack(sendVersion, DASH_VERSION_PERIOD_MS, osPriorityLow, 256);
150+
defineThreadStack(heartbeat_led, 500, osPriorityLow, 128);
151+
defineThreadStack(service_button_inputs, 50, osPriorityLow, 1024);
152+
defineThreadStack(send_version, DASH_VERSION_PERIOD_MS, osPriorityLow, 256);
153153
defineThreadStack(updateTelemetryPages, 200, osPriorityLow, 1024);
154154
defineThreadStack(sendTVParameters, DASHBOARD_VCU_PARAMETERS_PERIOD_MS, osPriorityLow, 256);
155155

156-
void preflight_task() {
157-
static uint8_t counter = 0;
158-
159-
// run animation until for at least 1.5 seconds
160-
if (counter >= 150) {
161-
PHAL_writeGPIO(HEART_LED_GPIO_Port, HEART_LED_Pin, 0);
162-
PHAL_writeGPIO(CONN_LED_GPIO_Port, CONN_LED_Pin, 0);
163-
PHAL_writeGPIO(ERROR_LED_GPIO_Port, ERROR_LED_Pin, 0);
164-
165-
// spawn the other threads
166-
createThread(pedalsPeriodic);
167-
createThread(can_worker_task);
168-
169-
createThread(updateFaultDisplay)
170-
createThread(heartBeatLED)
171-
createThread(handleDashboardInputs)
172-
createThread(sendVersion)
173-
createThread(updateTelemetryPages)
174-
createThread(sendTVParameters)
175-
osThreadExit(); // Self delete
176-
return;
177-
}
178-
179-
if (counter % 10 == 0) { // Run every 100ms
180-
preflightAnimation();
181-
}
182-
183-
counter++;
184-
}
185-
186-
void can_worker_task() {
187-
// Process all received CAN messages
188-
CAN_rx_update();
189-
190-
// Drain all CAN transmit queues
191-
CAN_tx_update();
192-
193-
lcdTxUpdate();
194-
}
195-
196156
int main(void) {
197157
// Hardware Initialization
198158
if (0 != PHAL_configureClockRates(&clock_config)) {
@@ -216,13 +176,13 @@ int main(void) {
216176
PHAL_startTxfer(&adc_dma_config);
217177
PHAL_startADC(&adc_config);
218178

219-
// Begin Software Init tasks
179+
// Software Initialization
220180
osKernelInitialize();
221181

222182
CAN_library_init();
223183
initLCD();
224184
NVIC_EnableIRQ(FDCAN2_IT0_IRQn);
225-
enableInterrupts();
185+
config_button_irqs();
226186

227187
// show signs of life
228188
PHAL_writeGPIO(BMS_LED_GPIO_Port, BMS_LED_Pin, 1);
@@ -242,7 +202,47 @@ int main(void) {
242202
return 0;
243203
}
244204

245-
void preflightAnimation(void) {
205+
void preflight_task() {
206+
static uint8_t counter = 0;
207+
208+
// run animation until for at least 1.5 seconds
209+
if (counter >= 150) {
210+
PHAL_writeGPIO(HEART_LED_GPIO_Port, HEART_LED_Pin, 0);
211+
PHAL_writeGPIO(CONN_LED_GPIO_Port, CONN_LED_Pin, 0);
212+
PHAL_writeGPIO(ERROR_LED_GPIO_Port, ERROR_LED_Pin, 0);
213+
214+
// spawn the other threads
215+
createThread(pedalsPeriodic);
216+
createThread(can_worker_task);
217+
218+
createThread(updateFaultDisplay)
219+
createThread(heartbeat_led)
220+
createThread(service_button_inputs)
221+
createThread(send_version)
222+
createThread(updateTelemetryPages)
223+
createThread(sendTVParameters)
224+
osThreadExit(); // Self delete
225+
return;
226+
}
227+
228+
if (counter % 10 == 0) { // Run every 100ms
229+
preflight_animation();
230+
}
231+
232+
counter++;
233+
}
234+
235+
void can_worker_task() {
236+
// Process all received CAN messages
237+
CAN_rx_update();
238+
239+
// Drain all CAN transmit queues
240+
CAN_tx_update();
241+
242+
lcd_tx_cmd();
243+
}
244+
245+
void preflight_animation(void) {
246246
// Controls external LEDs since they are more visible when dash is in car
247247
static uint32_t external_index;
248248
static uint32_t sweep_index;
@@ -279,7 +279,7 @@ void preflightAnimation(void) {
279279
}
280280
}
281281

282-
void sendVersion() {
282+
void send_version() {
283283
CAN_SEND_dash_version(GIT_HASH);
284284
}
285285

@@ -291,7 +291,7 @@ void sendVersion() {
291291
* Controls heartbeat, connection, precharge, IMD and BMS status LEDs.
292292
* Handles periodic CAN statistics transmission.
293293
*/
294-
void heartBeatLED() {
294+
void heartbeat_led() {
295295
static uint8_t imd_prev_latched;
296296
static uint8_t bms_prev_latched;
297297

@@ -371,7 +371,7 @@ void EXTI15_10_IRQHandler() {
371371
*
372372
* Meant to be called periodically.
373373
*/
374-
void handleDashboardInputs() {
374+
void service_button_inputs() {
375375
if (input_state.up_button) {
376376
input_state.up_button = 0;
377377
moveUp();
@@ -408,7 +408,7 @@ void handleDashboardInputs() {
408408
}
409409
}
410410

411-
void enableInterrupts() {
411+
void config_button_irqs() {
412412
// Enable the SYSCFG clock for interrupts
413413
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
414414

@@ -441,7 +441,7 @@ void enableInterrupts() {
441441
* @note The queue holds a max of 10 commands. Design your LCD page updates with this in mind.
442442
*/
443443
char cmd[NXT_STR_SIZE] = {'\0'}; // Buffer for Nextion LCD commands
444-
void lcdTxUpdate() {
444+
void lcd_tx_cmd() {
445445
if ((false == PHAL_usartTxBusy(&lcd)) && (SUCCESS_G == qReceive(&q_tx_usart, cmd))) {
446446
PHAL_usartTxDma(&lcd, (uint8_t *)cmd, strlen(cmd));
447447
}

source/dashboard/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,6 @@ typedef struct {
121121
#define LCD_UART_RX_GPIO_Port (GPIOA)
122122
#define LCD_UART_RX_Pin (10)
123123

124-
void lcdTxUpdate();
124+
void lcd_tx_cmd();
125125

126126
#endif

source/main_module/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ dma_init_t adc_dma_config = ADC1_DMA_CONT_CONFIG((uint32_t)&adc_readings,
154154
/* -------------------------------------------------------
155155
Procedures
156156
-------------------------------------------------------- */
157-
void preflightAnimation(void);
157+
void preflight_animation(void);
158158
void preflightChecks(void);
159-
void heartBeatLED();
159+
void heartbeat_led();
160160
void send_fault(uint16_t, bool);
161161
extern void HardFault_Handler();
162162
void interpretLoadSensor(void);
@@ -179,11 +179,11 @@ int main(void) {
179179
schedInit(APB1ClockRateHz);
180180

181181
/* Preflight */
182-
configureAnim(preflightAnimation, preflightChecks, 60, 750);
182+
configureAnim(preflight_animation, preflightChecks, 60, 750);
183183

184184
/* Periodic Tasks */
185185
taskCreate(coolingPeriodic, 50);
186-
taskCreate(heartBeatLED, 500);
186+
taskCreate(heartbeat_led, 500);
187187
taskCreate(monitorSDCPeriodic, 20);
188188
taskCreate(carHeartbeat, 500);
189189
taskCreate(carPeriodic, 15);
@@ -282,7 +282,7 @@ void preflightChecks(void) {
282282
}
283283
}
284284

285-
void preflightAnimation(void) {
285+
void preflight_animation(void) {
286286
static uint32_t time;
287287

288288
PHAL_writeGPIO(HEARTBEAT_GPIO_Port, HEARTBEAT_Pin, 0);
@@ -305,7 +305,7 @@ void preflightAnimation(void) {
305305
}
306306
}
307307

308-
void heartBeatLED(void) {
308+
void heartbeat_led(void) {
309309
static uint8_t trig;
310310
PHAL_toggleGPIO(HEARTBEAT_GPIO_Port, HEARTBEAT_Pin);
311311
if ((sched.os_ticks - last_can_rx_time_ms) >= CONN_LED_MS_THRESH) {

source/pdu/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ extern uint32_t AHBClockRateHz;
161161
extern uint32_t PLLClockRateHz;
162162

163163
void HardFault_Handler();
164-
void preflightAnimation();
164+
void preflight_animation();
165165
void preflightChecks(void);
166166
void heatBeatLED();
167167
void send_iv_readings();
@@ -192,7 +192,7 @@ int main() {
192192

193193
/* Task Creation */
194194
schedInit(APB1ClockRateHz);
195-
configureAnim(preflightAnimation, preflightChecks, 20, 750);
195+
configureAnim(preflight_animation, preflightChecks, 20, 750);
196196

197197
/* Schedule Periodic tasks here */
198198
taskCreate(heatBeatLED, 500);
@@ -255,7 +255,7 @@ void preflightChecks(void) {
255255
}
256256
}
257257

258-
void preflightAnimation(void) {
258+
void preflight_animation(void) {
259259
static uint32_t time;
260260
static int led_number;
261261
static bool led_decrement = false;

source/torque_vector/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ static uint16_t rxbuffer[(sizeof(rxmsg) + 1) / 2];
142142
static uint8_t txbuffer[2 + sizeof(txmsg)] = {0xAA, 0x55};
143143

144144
/* Function Prototypes */
145-
void heartBeatLED(void);
146-
void preflightAnimation(void);
145+
void heartbeat_led(void);
146+
void preflight_animation(void);
147147
void preflightChecks(void);
148148
void reportIMU(void);
149149
void reportGPS(void);
@@ -174,12 +174,12 @@ int main(void) {
174174

175175
/* Task Creation */
176176
schedInit(APB1ClockRateHz);
177-
configureAnim(preflightAnimation, preflightChecks, 74, 1000);
177+
configureAnim(preflight_animation, preflightChecks, 74, 1000);
178178

179179
taskCreateBackground(CAN_tx_update);
180180
taskCreateBackground(CAN_rx_update);
181181

182-
taskCreate(heartBeatLED, 500);
182+
taskCreate(heartbeat_led, 500);
183183
taskCreate(parseIMU, 20);
184184
taskCreate(VCU_MAIN, 20);
185185
taskCreate(reportIMU, IMU_ACCEL_PERIOD_MS);
@@ -312,7 +312,7 @@ void preflightChecks(void) {
312312
}
313313
}
314314

315-
void preflightAnimation(void) {
315+
void preflight_animation(void) {
316316
static uint32_t time;
317317

318318
PHAL_writeGPIO(HEARTBEAT_GPIO_Port, HEARTBEAT_Pin, 0);
@@ -335,7 +335,7 @@ void preflightAnimation(void) {
335335
}
336336
}
337337

338-
void heartBeatLED(void) {
338+
void heartbeat_led(void) {
339339
PHAL_toggleGPIO(HEARTBEAT_GPIO_Port, HEARTBEAT_Pin);
340340

341341
if ((sched.os_ticks - can_data.main_hb.last_rx) >= CONN_LED_MS_THRESH)

0 commit comments

Comments
 (0)