Skip to content

Commit

Permalink
Deinit sequences (#1369)
Browse files Browse the repository at this point in the history
### Changelist 

De-initialized peripherals & interrupts for all boards (except VC).
Changes only on quadruna.

- task_deinit


<!-- Give a list of the changes covered in this PR. This will help both
you and the reviewer keep this PR within scope. -->

### Testing Done

- no testing done yet
<!-- Outline the testing that was done to demonstrate the changes are
solid. This could be unit tests, integration tests, testing on the car,
etc. Include relevant code snippets, screenshots, etc as needed. -->

### Resolved Tickets

-  [FIRM-151](https://ubcformulaelectric.atlassian.net/browse/FIRM-151)

<!-- Link any tickets that this PR resolves. -->


[FIRM-151]:
https://ubcformulaelectric.atlassian.net/browse/FIRM-151?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
kryptoish authored Jan 20, 2025
1 parent 6e3a0ac commit 332a806
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
27 changes: 27 additions & 0 deletions firmware/quadruna/BMS/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,33 @@ void tasks_init(void)
app_globals_init();
}

void tasks_deinit(void)
{
HAL_TIM_Base_Stop_IT(&htim1);
HAL_TIM_Base_Stop_IT(&htim3);
HAL_TIM_Base_Stop_IT(&htim15);
HAL_TIM_Base_DeInit(&htim1);
HAL_TIM_Base_DeInit(&htim3);
HAL_TIM_Base_DeInit(&htim15);

HAL_SD_Abort_IT(&hsd1);
HAL_SD_DeInit(&hsd1);

HAL_DMA_Abort_IT(&hdma_adc1);
HAL_DMA_DeInit(&hdma_adc1);

HAL_UART_Abort_IT(&huart1);
HAL_UART_DeInit(&huart1);

HAL_ADC_Stop_IT(&hadc1);
HAL_ADC_DeInit(&hadc1);

HAL_SPI_Abort_IT(&hspi2);
HAL_SPI_DeInit(&hspi2);

HAL_CRC_DeInit(&hcrc);
}

_Noreturn void tasks_run1Hz(void)
{
io_chimera_sleepTaskIfEnabled();
Expand Down
15 changes: 15 additions & 0 deletions firmware/quadruna/CRIT/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,21 @@ void tasks_init(void)
app_canTx_CRIT_Clean_set(GIT_COMMIT_CLEAN);
}

void tasks_deinit(void)
{
HAL_TIM_Base_Stop_IT(&htim3);
HAL_TIM_Base_DeInit(&htim3);

HAL_UART_Abort_IT(&huart2);
HAL_UART_DeInit(&huart2);

HAL_DMA_Abort_IT(&hdma_adc1);
HAL_DMA_DeInit(&hdma_adc1);

HAL_ADC_Stop_IT(&hadc1);
HAL_ADC_DeInit(&hadc1);
}

_Noreturn void tasks_run100Hz(void)
{
io_chimera_sleepTaskIfEnabled();
Expand Down
17 changes: 17 additions & 0 deletions firmware/quadruna/FSM/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ void tasks_init(void)
app_canTx_FSM_Clean_set(GIT_COMMIT_CLEAN);
}

void tasks_deinit(void)
{
HAL_TIM_Base_Stop_IT(&htim3);
HAL_TIM_Base_DeInit(&htim3);
HAL_TIM_Base_Stop_IT(&htim12);
HAL_TIM_Base_DeInit(&htim12);

HAL_UART_Abort_IT(&huart1);
HAL_UART_DeInit(&huart1);

HAL_DMA_Abort_IT(&hdma_adc1);
HAL_DMA_DeInit(&hdma_adc1);

HAL_ADC_Stop_IT(&hadc1);
HAL_ADC_DeInit(&hadc1);
}

_Noreturn void tasks_run1Hz(void)
{
io_chimera_sleepTaskIfEnabled();
Expand Down
15 changes: 15 additions & 0 deletions firmware/quadruna/RSM/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ void tasks_init(void)
app_canTx_RSM_Clean_set(GIT_COMMIT_CLEAN);
}

void tasks_deinit(void)
{
HAL_TIM_Base_Stop_IT(&htim3);
HAL_TIM_Base_DeInit(&htim3);

HAL_UART_Abort_IT(&huart1);
HAL_UART_DeInit(&huart1);

HAL_ADC_Stop_IT(&hadc1);
HAL_ADC_DeInit(&hadc1);

HAL_DMA_Abort_IT(&hdma_adc1);
HAL_DMA_DeInit(&hdma_adc1);
}

_Noreturn void tasks_run1Hz(void)
{
io_chimera_sleepTaskIfEnabled();
Expand Down

0 comments on commit 332a806

Please sign in to comment.