Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature op modes #354

Merged
merged 38 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a9c7a82
firmware: Update payload structs
c-porto Aug 5, 2024
041832d
firmware: app: Add tasks to manage operation modes
c-porto Aug 5, 2024
29ea3d7
firmware: app: tasks: Update payload tasks to use the state functiona…
c-porto Aug 5, 2024
07ad629
firmware: Update payloads ID values and struct field names
c-porto Aug 6, 2024
62fb380
firmware: app: tasks: Refactor operation control task to use direct t…
c-porto Aug 6, 2024
78964d9
firmware: app: tasks: Refactor payload tasks to support task notifica…
c-porto Aug 6, 2024
12cb95e
firmware: app: tasks: Fix Misra-C 2012 violations
c-porto Aug 6, 2024
bfa79a9
firmware: app: tasks: Add position notification logic
c-porto Aug 6, 2024
a364166
firmware: app: tasks: read_px: Change vTaskDelay call to vTaskDelayUntil
c-porto Aug 6, 2024
1ce0d10
firmware: app: tasks: op_ctrl: Fix satellite_change_mode macro
c-porto Aug 6, 2024
d106cfb
firmware: app: tasks: housekeeping: Fix obdh data save functionality
c-porto Aug 6, 2024
6f51a23
firmware: config: Add operation control task enabled flag to config
c-porto Aug 6, 2024
3f349a5
firmware: app: tasks: Add operation control task creation
c-porto Aug 6, 2024
f8c5bee
firmware: app: tasks: antenna_deployment: Fix hibernation period check
c-porto Aug 9, 2024
4a35ff9
firmware: app: tasks: housekeeping: Remove operation mode logic from …
c-porto Aug 9, 2024
45e9bdf
firmware: app: tasks: Add hibernation mode logic to operation control
c-porto Aug 9, 2024
8ced47e
firmware: system: system: Add critical session on sys_time increment
c-porto Aug 9, 2024
f063ad9
firmware: Add Health Check Operation Mode
c-porto Aug 9, 2024
42815ec
firmware: app: tasks: process_tc: Add hibernation awareness for trans…
c-porto Aug 10, 2024
9577981
firmware: app: tasks: process_tc: Add NOR memory die 1 erase to TC
c-porto Aug 10, 2024
32cb3bf
firmware: app: utils: mem_mng: Add flash erase helper functions
c-porto Aug 11, 2024
23be923
firmware: app: tasks: process_tc: Update memory erase TC to use mem_m…
c-porto Aug 11, 2024
a7d8d43
firmware: app: tasks: process_tc: Finish implementation of data reque…
c-porto Aug 11, 2024
e12e93c
firmware: drivers: sl_ttc2: Fix packet max lenght check
c-porto Aug 11, 2024
4a00af1
firmware: app: tasks: process_tc: Fix memcpy calls
c-porto Aug 11, 2024
dd1dc4a
firmware: app: tasks: data_log: Update edc logging to use the current…
c-porto Aug 11, 2024
1698b05
firmware: app: tasks: process_tc: Add check for hibernation on data r…
c-porto Aug 11, 2024
39f775d
firmware: app: tasks: op_ctrl: Fix hibernation time check
c-porto Aug 12, 2024
1694920
firmware: config: Add payload tasks for health check
c-porto Aug 12, 2024
413ccb1
firmware: app: tasks: mode_check: Fix mode check task to test expecte…
c-porto Aug 12, 2024
e85e8b7
firmware: devices: payload: Fix EDC 0 raw hk error case
c-porto Aug 12, 2024
7eeb9c9
firmware: drivers: px: Add enable/disable for px driver
c-porto Aug 14, 2024
32ec644
firmware: devices: payload: Change payloads ID
c-porto Aug 14, 2024
19cdc80
firmware: devices: payload: Add enable/disable implementations for px
c-porto Aug 14, 2024
149c463
firmware: app: tasks: Fix MISRA-C 2012 violations
c-porto Aug 17, 2024
1c056d3
firmware: tests: mockups: drivers: Update px driver mockups
c-porto Aug 17, 2024
bb5fe26
firmware: tests: devices: Update Payload X tests
c-porto Aug 17, 2024
8f385bc
firmware: Update version of modified files
c-porto Aug 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion firmware/app/structs/obdh_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* \author Gabriel Mariano Marcelino <[email protected]>
* \author Carlos Augusto Porto Freitas <[email protected]>
*
* \version 0.10.18
* \version 0.10.19
*
* \date 2020/07/16
*
Expand Down Expand Up @@ -115,6 +115,7 @@
/* Operation modes */
#define OBDH_MODE_NORMAL 0
#define OBDH_MODE_HIBERNATION 1
#define OBDH_MODE_STAND_BY 2

/**
* \brief Position data.
Expand Down
17 changes: 15 additions & 2 deletions firmware/app/structs/satellite.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
* \brief Satellite data structure definition.
*
* \author Gabriel Mariano Marcelino <[email protected]>
* \author Carlos Augusto Porto Freitas <[email protected]>
*
* \version 0.10.9
* \version 0.10.19
*
* \date 2020/07/16
*
Expand All @@ -45,6 +46,7 @@
#include <devices/eps/eps_data.h>
#include <devices/ttc/ttc_data.h>
#include <devices/antenna/antenna_data.h>
#include <devices/payload/payload.h>

#include "obdh_data.h"

Expand Down Expand Up @@ -90,10 +92,20 @@ typedef struct
typedef struct
{
sys_time_t timestamp; /**< Timestamp of the Payload data. */
bool enabled; /**< Payload enable flag. */
uint8_t id; /**< Payload id [Ex: PAYLOAD_EDC_0_ID] */
uint8_t data[220]; /**< Payload data. */
} payload_telemetry_t;

/**
* \brief Payloads state type.
*/
typedef struct
{
payload_t active_payload; /**< Active payload. */
payload_t main_edc; /**< Main EDC. */
payload_telemetry_t *c_edc; /**< Pointer to the active EDC telemetry data. */
} payload_state_t;

/**
* \brief Satellite data.
*/
Expand All @@ -107,6 +119,7 @@ typedef struct
payload_telemetry_t edc_0; /**< EDC 0 telemetry. */
payload_telemetry_t edc_1; /**< EDC 1 telemetry. */
payload_telemetry_t payload_x; /**< Payload-X telemetry. */
payload_state_t state; /**< Payload state. */
} sat_data_t;

/**
Expand Down
5 changes: 3 additions & 2 deletions firmware/app/tasks/antenna_deployment.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
* \brief Antenna deployment task implementation.
*
* \author Gabriel Mariano Marcelino <[email protected]>
* \author Carlos Augusto Porto Freitas <[email protected]>
*
* \version 0.10.7
* \version 0.10.19
*
* \date 2021/11/17
*
Expand Down Expand Up @@ -53,7 +54,7 @@ void vTaskAntennaDeployment(void)

uint8_t i = 0;

for(i = initial_hib_time_counter; i < CONFIG_ANTENNA_DEPLOYMENT_HIBERNATION_MIN; i++)
for(i = initial_hib_time_counter; (i < CONFIG_ANTENNA_DEPLOYMENT_HIBERNATION_MIN) && (!sat_data_buf.obdh.data.initial_hib_executed); i++)
{
vTaskDelay(pdMS_TO_TICKS(60000U));

Expand Down
24 changes: 4 additions & 20 deletions firmware/app/tasks/beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
* \brief Beacon task implementation.
*
* \author Gabriel Mariano Marcelino <[email protected]>
* \author Carlos Augusto Porto Freitas <[email protected]>
*
* \version 0.10.9
* \version 0.10.19
*
* \date 2019/10/27
*
Expand Down Expand Up @@ -137,25 +138,8 @@ void vTaskBeacon(void)
beacon_pl.payload[63] = sat_data_buf.eps.data.battery_monitor_temperature & 0xFF;
beacon_pl.payload[64] = sat_data_buf.eps.data.battery_heater_1_duty_cycle;
beacon_pl.payload[65] = sat_data_buf.eps.data.battery_heater_2_duty_cycle;

if (!sat_data_buf.edc_0.enabled && !sat_data_buf.edc_0.enabled)
{
beacon_pl.payload[66] = 0x00U;
}
else if (sat_data_buf.edc_0.enabled && !sat_data_buf.edc_0.enabled)
{
beacon_pl.payload[66] = 0x01U;
}
else if (!sat_data_buf.edc_0.enabled && sat_data_buf.edc_0.enabled)
{
beacon_pl.payload[66] = 0x02U;
}
else
{
beacon_pl.payload[66] = 0x03U;
}

beacon_pl.payload[67] = sat_data_buf.payload_x.enabled ? 0x01U : 0x00U;
beacon_pl.payload[66] = sat_data_buf.state.main_edc;
beacon_pl.payload[67] = sat_data_buf.state.active_payload;

beacon_pl.length = 68U;

Expand Down
6 changes: 3 additions & 3 deletions firmware/app/tasks/data_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
* \author Carlos Augusto Porto Freitas <[email protected]>
*
* \version 0.10.18
*
* \version 0.10.19
*
* \date 2021/05/24
*
Expand Down Expand Up @@ -114,7 +114,7 @@ void vTaskDataLog(void)
(void)memset(&page_buf[0], 0, 256);

/* EDC data */
(void)memcpy(&page_buf[0], &sat_data_buf.edc_0, sizeof(payload_telemetry_t));
(void)memcpy(&page_buf[0], sat_data_buf.state.c_edc, sizeof(payload_telemetry_t));
if (mem_mng_write_data_to_flash_page(page_buf, &sat_data_buf.obdh.data.media.last_page_edc_data, nor_info.page_size, CONFIG_MEM_EDC_DATA_START_PAGE, CONFIG_MEM_EDC_DATA_END_PAGE) != 0)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_DATA_LOG_NAME, "Error writing the EDC data to the flash memory!");
Expand Down
30 changes: 9 additions & 21 deletions firmware/app/tasks/housekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* \author Gabriel Mariano Marcelino <[email protected]>
* \author Carlos Augusto Porto Freitas <[email protected]>
*
* \version 0.10.18
* \version 0.10.19
*
* \date 2021/04/27
*
Expand All @@ -39,6 +39,7 @@
#include <devices/current_sensor/current_sensor.h>
#include <devices/voltage_sensor/voltage_sensor.h>
#include <devices/temp_sensor/temp_sensor.h>
#include <utils/mem_mng.h>

#include <structs/satellite.h>

Expand All @@ -56,29 +57,16 @@ void vTaskHousekeeping(void)
{
TickType_t last_cycle = xTaskGetTickCount();

/* Hibernation mode check */
if (sat_data_buf.obdh.data.mode == OBDH_MODE_HIBERNATION)
/* Save the last available OBDH data at every minute */
if (mem_mng_save_obdh_data_to_fram(&sat_data_buf.obdh) != 0)
{
if ((sat_data_buf.obdh.data.ts_last_mode_change + sat_data_buf.obdh.data.mode_duration) >= system_get_time())
{
sat_data_buf.obdh.data.mode = OBDH_MODE_NORMAL;
sat_data_buf.obdh.data.ts_last_mode_change = system_get_time();
}
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_HOUSEKEEPING_NAME, "Error writing data to the FRAM memory!");
sys_log_new_line();
}

/* Save the last available OBDH data at every minute */
if ((system_get_time() % 60U) == 0U)
else
{
if (mem_mng_save_obdh_data_to_fram(&sat_data_buf.obdh) != 0)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_HOUSEKEEPING_NAME, "Error writing data to the FRAM memory!");
sys_log_new_line();
}
else
{
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_HOUSEKEEPING_NAME, "Saving obdh data to fram...");
sys_log_new_line();
}
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_HOUSEKEEPING_NAME, "Saving obdh data to fram...");
sys_log_new_line();
}

vTaskDelayUntil(&last_cycle, pdMS_TO_TICKS(TASK_HOUSEKEEPING_PERIOD_MS));
Expand Down
5 changes: 3 additions & 2 deletions firmware/app/tasks/housekeeping.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
* \brief Housekeeping task definition.
*
* \author Gabriel Mariano Marcelino <[email protected]>
* \author Carlos Augusto Porto Freitas <[email protected]>
*
* \version 0.10.17
* \version 0.10.19
*
* \date 2021/04/27
*
Expand All @@ -43,7 +44,7 @@
#define TASK_HOUSEKEEPING_NAME "Housekeeping" /**< Task name. */
#define TASK_HOUSEKEEPING_STACK_SIZE 225 /**< Stack size in bytes. */
#define TASK_HOUSEKEEPING_PRIORITY 3 /**< Task priority. */
#define TASK_HOUSEKEEPING_PERIOD_MS (10000) /**< Task period in milliseconds. */
#define TASK_HOUSEKEEPING_PERIOD_MS (60000) /**< Task period in milliseconds. */
#define TASK_HOUSEKEEPING_INIT_TIMEOUT_MS 2000 /**< Wait time to initialize the task in milliseconds. */

/**
Expand Down
8 changes: 6 additions & 2 deletions firmware/app/tasks/mem_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Carlos Augusto Porto Freitas <[email protected]>
*
* \version 0.10.18
* \version 0.10.19
*
* \date 2024/07/24
*
Expand All @@ -47,11 +47,12 @@

#include "mem_check.h"
#include "startup.h"
#include "mode_check.h"

#define PAGE_SIZE ((uint32_t)256UL)
#define SEG_SIZE ((uint32_t)128UL)
#define PAGE_TO_ADDR(page) ((page) * PAGE_SIZE)
#define PAGE_CHECK_DEPTH ((uint32_t)10UL)
#define PAGE_CHECK_DEPTH ((uint32_t)CONFIG_HEALTH_CHECK_PAGES_TO_VALIDATE)
#define ARR_SIZE(arr) (sizeof((arr))/sizeof((arr)[0]))
#define ADDR_TO_PAGE(addr) ((uint32_t)(addr) / PAGE_SIZE)

Expand Down Expand Up @@ -207,6 +208,9 @@ void vTaskHealthCheckMem(void)
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_HEALTH_CHECK_MEM_NAME, "Health Check finished!!");
sys_log_new_line();

/* Notify Next Health Check */
xTaskNotify(xTaskHealthCheckModeHandle, 0U, eNoAction);

vTaskSuspend(NULL);
}
}
Expand Down
Loading
Loading