Skip to content

Commit

Permalink
Create bootup task which runs bootup procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
Makiv1 committed Nov 30, 2024
1 parent 807c120 commit d4d1f8b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions firmware/Core/Inc/rtos_tasks/rtos_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ void TASK_handle_uart_telecommands(void *argument);

void TASK_execute_telecommands(void *argument);

void TASK_bootup(void *argument);

#endif // __INCLUDE_GUARD__RTOS_TASKS_H__
10 changes: 9 additions & 1 deletion firmware/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ const osThreadAttr_t TASK_sync_eps_time_to_mcu_time_Attributes = {
.priority = (osPriority_t) osPriorityNormal, //TODO: Figure out which priority makes sense for this task
};

osThreadId_t TASK_bootup_Handle;
const osThreadAttr_t TASK_bootup_Attributes = {
.name = "TASK_bootup",
.stack_size = 1024, //in bytes. 512 is tool small and will cause crashes when lfs_close() is called!
.priority = (osPriority_t) osPriorityNormal, //TODO: Figure out which priority makes sense for this task
};


/* USER CODE END PV */

Expand Down Expand Up @@ -212,7 +219,6 @@ int main(void)
// Initialise the ADCS CRC8 checksum (required for ADCS operation).
ADCS_initialise_crc8_checksum();

START_antenna_deploy();
/* USER CODE END 2 */

/* Init scheduler */
Expand Down Expand Up @@ -250,6 +256,8 @@ int main(void)
TASK_service_eps_watchdog_Handle = osThreadNew(TASK_service_eps_watchdog, NULL, &TASK_service_eps_watchdog_Attributes);

TASK_sync_eps_time_to_mcu_time_Handle = osThreadNew(TASK_sync_eps_time_to_mcu_time, NULL, &TASK_sync_eps_time_to_mcu_time_Attributes);

TASK_bootup_Handle = osThreadNew(TASK_bootup, NULL, &TASK_bootup_Attributes);
/* USER CODE END RTOS_THREADS */

/* USER CODE BEGIN RTOS_EVENTS */
Expand Down
20 changes: 20 additions & 0 deletions firmware/Core/Src/rtos_tasks/rtos_tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "log/log.h"
#include "config/configuration.h"
#include "eps_drivers/eps_commands.h"
#include "startup_sequence/antenna_deploy_startup.h"

#include "cmsis_os.h"

Expand Down Expand Up @@ -177,3 +178,22 @@ void TASK_execute_telecommands(void *argument) {
} /* End Task's Main Loop */
}

/// @brief Completes all tasks which are nesssary after the obc is powered on(or rebooted)
/// @param argument
void TASK_bootup(void *argument) {
TASK_HELP_start_of_task();

uint8_t ant_deploy_complete = 0;
//TODO: Unsure of how to properly terminate this task. Should it be a forever loop?
while (1) {
//TODO: What should the delay be here? I suspect it should be smaller.
osDelay(2000);
if (!ant_deploy_complete) {
START_antenna_deploy();
//TODO: This should be changed to the commeted out code
if (/*START_antenna_deploy() == 0*/ 1) {
ant_deploy_complete = 1;
}
}
} /* End Task's Main Loop */
}

0 comments on commit d4d1f8b

Please sign in to comment.