-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #352 from spacelab-ufsc/spi_mutex_feature
- Loading branch information
Showing
39 changed files
with
836 additions
and
446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.10.9 | ||
* \version 0.10.17 | ||
* | ||
* \date 2020/07/16 | ||
* | ||
|
@@ -105,7 +105,7 @@ | |
#define OBDH_PARAM_MEDIA_LAST_OBDH_DATA_DEFAULT_VAL CONFIG_MEM_OBDH_DATA_START_PAGE | ||
#define OBDH_PARAM_MEDIA_LAST_EPS_DATA_DEFAULT_VAL CONFIG_MEM_EPS_DATA_START_PAGE | ||
#define OBDH_PARAM_MEDIA_LAST_TTC_0_DATA_DEFAULT_VAL CONFIG_MEM_TTC_0_DATA_START_PAGE | ||
#define OBDH_PARAM_MEDIA_LAST_TTC_1_DATA_DEFAULT_VAL CONFIG_MEM_TTC_1_DATA_END_PAGE | ||
#define OBDH_PARAM_MEDIA_LAST_TTC_1_DATA_DEFAULT_VAL CONFIG_MEM_TTC_1_DATA_START_PAGE | ||
#define OBDH_PARAM_MEDIA_LAST_ANT_DATA_DEFAULT_VAL CONFIG_MEM_ANT_DATA_START_PAGE | ||
#define OBDH_PARAM_MEDIA_LAST_EDC_DATA_DEFAULT_VAL CONFIG_MEM_EDC_DATA_START_PAGE | ||
#define OBDH_PARAM_MEDIA_LAST_PX_DATA_DEFAULT_VAL CONFIG_MEM_PX_DATA_START_PAGE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.10.9 | ||
* \version 0.10.17 | ||
* | ||
* \date 2021/05/24 | ||
* | ||
|
@@ -170,7 +170,7 @@ int write_data_to_flash_page(uint8_t *data, uint32_t *page, uint32_t page_size, | |
|
||
if (media_write(MEDIA_NOR, (*page) * page_size, data, page_size) == 0) | ||
{ | ||
*page++; // cppcheck-suppress misra-c2012-17.8 | ||
(*page)++; // cppcheck-suppress misra-c2012-17.8 | ||
|
||
if (*page > end_page) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.10.9 | ||
* \version 0.10.17 | ||
* | ||
* \date 2021/04/27 | ||
* | ||
|
@@ -66,7 +66,7 @@ void vTaskHousekeeping(void) | |
} | ||
|
||
/* Save the last available OBDH data at every minute */ | ||
if ((system_get_time() % (60U*1000U)) == 0U) | ||
if ((system_get_time() % 60U) == 0U) | ||
{ | ||
if (mem_mng_save_obdh_data_to_fram(sat_data_buf.obdh) != 0) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.8.33 | ||
* \version 0.10.17 | ||
* | ||
* \date 2021/04/27 | ||
* | ||
|
@@ -41,7 +41,7 @@ | |
#include <task.h> | ||
|
||
#define TASK_HOUSEKEEPING_NAME "Housekeeping" /**< Task name. */ | ||
#define TASK_HOUSEKEEPING_STACK_SIZE 160 /**< Stack size in bytes. */ | ||
#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_INIT_TIMEOUT_MS 2000 /**< Wait time to initialize the task in milliseconds. */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* \author Carlos Augusto Porto Freitas <[email protected]> | ||
* | ||
* \version 0.10.14 | ||
* \version 0.10.17 | ||
* | ||
* \date 2021/07/06 | ||
* | ||
|
@@ -45,7 +45,7 @@ | |
#define TASK_PROCESS_TC_STACK_SIZE 500 /**< Stack size in bytes. */ | ||
#define TASK_PROCESS_TC_PRIORITY 4 /**< Task priority. */ | ||
#define TASK_PROCESS_TC_PERIOD_MS 1000 /**< Task period in milliseconds. */ | ||
#define TASK_PROCESS_TC_INITIAL_DELAY_MS 2000 /**< Delay, in milliseconds, before the first execution. */ | ||
#define TASK_PROCESS_TC_INITIAL_DELAY_MS 6500 /**< Delay, in milliseconds, before the first execution. */ | ||
#define TASK_PROCESS_TC_INIT_TIMEOUT_MS (10*1000) /**< Wait time to initialize the task in milliseconds. */ | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.8.5 | ||
* \version 0.10.17 | ||
* | ||
* \date 2020/07/12 | ||
* | ||
|
@@ -38,6 +38,7 @@ | |
#include <devices/temp_sensor/temp_sensor.h> | ||
|
||
#include <structs/satellite.h> | ||
#include <system/sys_log/sys_log.h> | ||
|
||
#include "read_sensors.h" | ||
#include "startup.h" | ||
|
@@ -59,18 +60,33 @@ void vTaskReadSensors(void) | |
if (current_sensor_read_ma(&buf) == 0) | ||
{ | ||
sat_data_buf.obdh.data.current = buf; | ||
|
||
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_READ_SENSORS_NAME, "Current input current: "); | ||
sys_log_print_uint((uint32_t)buf); | ||
sys_log_print_msg(" mA"); | ||
sys_log_new_line(); | ||
} | ||
|
||
/* OBDH voltage */ | ||
if (voltage_sensor_read_mv(&buf) == 0) | ||
{ | ||
sat_data_buf.obdh.data.voltage = buf; | ||
|
||
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_READ_SENSORS_NAME, "Current input voltage: "); | ||
sys_log_print_uint((uint32_t)buf); | ||
sys_log_print_msg(" mV"); | ||
sys_log_new_line(); | ||
} | ||
|
||
/* OBDH temperature */ | ||
if (temp_sensor_read_raw(&buf) == 0) | ||
if (temp_sensor_read_k(&buf) == 0) | ||
{ | ||
sat_data_buf.obdh.data.temperature = buf; | ||
|
||
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_READ_SENSORS_NAME, "Current uC temperature: "); | ||
sys_log_print_uint((uint32_t)buf); | ||
sys_log_print_msg(" K"); | ||
sys_log_new_line(); | ||
} | ||
|
||
/* Data timestamp */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* \author Carlos Augusto Porto Freitas <[email protected]> | ||
* | ||
* \version 0.10.14 | ||
* \version 0.10.17 | ||
* | ||
* \date 2021/05/14 | ||
* | ||
|
@@ -45,7 +45,7 @@ | |
#define TASK_READ_TTC_STACK_SIZE 384 /**< Stack size in bytes. */ | ||
#define TASK_READ_TTC_PRIORITY 3 /**< Task priority. */ | ||
#define TASK_READ_TTC_PERIOD_MS (60000) /**< Task period in milliseconds. */ | ||
#define TASK_READ_TTC_INITIAL_DELAY_MS 1000 /**< Delay, in milliseconds, before the first execution. */ | ||
#define TASK_READ_TTC_INITIAL_DELAY_MS 5500 /**< Delay, in milliseconds, before the first execution. */ | ||
#define TASK_READ_TTC_INIT_TIMEOUT_MS 2000 /**< Wait time to initialize the task in milliseconds. */ | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.10.9 | ||
* \version 0.10.17 | ||
* | ||
* \date 2019/12/04 | ||
* | ||
|
@@ -114,14 +114,20 @@ void vTaskStartup(void) | |
} | ||
else | ||
{ | ||
sys_log_print_event_from_module(SYS_LOG_WARNING, TASK_STARTUP_NAME, "FRAM was not initialized in previous cycles"); | ||
sys_log_new_line(); | ||
|
||
/* Initialize FRAM */ | ||
if (mem_mng_init_fram() == 0) | ||
{ | ||
/* Load default values to the OBDH data buffer */ | ||
mem_mng_load_obdh_data_from_default_values(&sat_data_buf.obdh); | ||
|
||
sys_log_print_event_from_module(SYS_LOG_WARNING, TASK_STARTUP_NAME, "Loading default values to FRAM..."); | ||
sys_log_new_line(); | ||
|
||
/* Write the OBDH data to the FRAM memory */ | ||
if (mem_mng_save_obdh_data_to_fram(sat_data_buf.obdh) != 0) | ||
if (mem_mng_save_obdh_data_to_fram(&sat_data_buf.obdh) != 0) | ||
{ | ||
error_counter++; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.10.7 | ||
* \version 0.10.17 | ||
* | ||
* \date 2019/11/02 | ||
* | ||
|
@@ -54,6 +54,7 @@ | |
#include "process_tc.h" | ||
#include "pos_det.h" | ||
#include "read_px.h" | ||
#include "housekeeping.h" | ||
|
||
void create_tasks(void) | ||
{ | ||
|
@@ -204,6 +205,15 @@ void create_tasks(void) | |
} | ||
#endif /* CONFIG_TASK_PAYLOAD_X_ENABLED */ | ||
|
||
#if defined(CONFIG_TASK_HOUSEKEEPING_ENABLED) && (CONFIG_TASK_HOUSEKEEPING_ENABLED == 1) | ||
xTaskCreate(vTaskHousekeeping, TASK_HOUSEKEEPING_NAME, TASK_HOUSEKEEPING_STACK_SIZE, NULL, TASK_HOUSEKEEPING_PRIORITY, &xTaskHousekeepingHandle); | ||
|
||
if (xTaskHousekeepingHandle == NULL) | ||
{ | ||
/* Error creating the Housekeeping task */ | ||
} | ||
#endif /* CONFIG_TASK_HOUSEKEEPING_ENABLED */ | ||
|
||
create_event_groups(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.10.9 | ||
* \version 0.10.17 | ||
* | ||
* \date 2024/02/24 | ||
* | ||
|
@@ -37,6 +37,7 @@ | |
#include <string.h> | ||
|
||
#include <config/config.h> | ||
#include <system/sys_log/sys_log.h> | ||
|
||
#include "mem_mng.h" | ||
|
||
|
@@ -45,12 +46,15 @@ int mem_mng_check_fram(void) | |
int err = -1; | ||
|
||
uint8_t mem_word_ref[8] = CONFIG_MEM_INIT_WORD; | ||
uint8_t mem_word[8] = {0}; | ||
uint8_t mem_word[8]; | ||
|
||
if (media_read(MEDIA_FRAM, CONFIG_MEM_ADR_INIT_WORD, mem_word, 8U) == 0) | ||
{ | ||
if (memcmp(&mem_word_ref[0], &mem_word[0], 8U) == 0) | ||
{ | ||
sys_log_print_event_from_module(SYS_LOG_INFO, MEM_MNG_NAME, "FRAM was already initalized"); | ||
sys_log_new_line(); | ||
|
||
err = 0; | ||
} | ||
} | ||
|
@@ -109,9 +113,8 @@ void mem_mng_load_obdh_data_from_default_values(obdh_telemetry_t *tel) | |
uint8_t tle_line1[70] = OBDH_PARAM_POSITION_TLE_LINE1_DEFAULT_VAL; | ||
uint8_t tle_line2[70] = OBDH_PARAM_POSITION_TLE_LINE2_DEFAULT_VAL; | ||
|
||
void *null_ptr; | ||
null_ptr = memcpy(&tel->data.position.tle_line1, &tle_line1[0], 70U); | ||
null_ptr = memcpy(&tel->data.position.tle_line2, &tle_line2[0], 70U); | ||
(void)memcpy(&tel->data.position.tle_line1, &tle_line1[0], 70U); | ||
(void)memcpy(&tel->data.position.tle_line2, &tle_line2[0], 70U); | ||
|
||
tel->data.position.latitude = OBDH_PARAM_POSITION_LATITUDE_DEFAULT_VAL; | ||
tel->data.position.longitude = OBDH_PARAM_POSITION_LONGITUDE_DEFAULT_VAL; | ||
|
@@ -126,18 +129,17 @@ void mem_mng_load_obdh_data_from_default_values(obdh_telemetry_t *tel) | |
tel->data.media.last_page_sbcd_pkts = OBDH_PARAM_MEDIA_LAST_SBCD_PKTS_DEFAULT_VAL; | ||
} | ||
|
||
int mem_mng_save_obdh_data_to_fram(obdh_telemetry_t tel) | ||
int mem_mng_save_obdh_data_to_fram(obdh_telemetry_t* tel) | ||
{ | ||
int err = -1; | ||
|
||
uint8_t buf[256] = {0}; | ||
uint8_t buf[256]; | ||
|
||
(void)memcpy(buf, tel, sizeof(obdh_telemetry_t)); | ||
|
||
if (memcpy(&buf[0], &tel, sizeof(obdh_telemetry_t)) == &buf[0]) | ||
if (media_write(MEDIA_FRAM, CONFIG_MEM_ADR_SYS_PARAM, buf, 256U) == 0) | ||
{ | ||
if (media_write(MEDIA_FRAM, CONFIG_MEM_ADR_SYS_PARAM, buf, 256U) == 0) | ||
{ | ||
err = 0; | ||
} | ||
err = 0; | ||
} | ||
|
||
return err; | ||
|
@@ -147,14 +149,12 @@ int mem_mng_load_obdh_data_from_fram(obdh_telemetry_t *tel) | |
{ | ||
int err = -1; | ||
|
||
uint8_t sys_par[256] = {0}; | ||
uint8_t sys_par[256]; | ||
|
||
if (media_read(MEDIA_FRAM, CONFIG_MEM_ADR_SYS_PARAM, sys_par, sizeof(obdh_telemetry_t)) == 0) | ||
{ | ||
if (memcpy(&tel, &sys_par[0], sizeof(obdh_telemetry_t)) == &tel) | ||
{ | ||
err = 0; | ||
} | ||
(void)memcpy(tel, sys_par, sizeof(obdh_telemetry_t)); | ||
err = 0; | ||
} | ||
|
||
return err; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.10.9 | ||
* \version 0.10.17 | ||
* | ||
* \date 2024/02/24 | ||
* | ||
|
@@ -41,6 +41,8 @@ | |
|
||
#include <app/structs/satellite.h> | ||
|
||
#define MEM_MNG_NAME "Memory Management" | ||
|
||
/** | ||
* \brief Checks if the FRAM memory is initialized or not. | ||
* | ||
|
@@ -78,7 +80,7 @@ void mem_mng_load_obdh_data_from_default_values(obdh_telemetry_t *tel); | |
* | ||
* \return The status/error code. | ||
*/ | ||
int mem_mng_save_obdh_data_to_fram(obdh_telemetry_t tel); | ||
int mem_mng_save_obdh_data_to_fram(obdh_telemetry_t *tel); | ||
|
||
/** | ||
* \brief Loads the last saved OBDH data from the FRAM memory. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.10.15 | ||
* \version 0.10.17 | ||
* | ||
* \date 2019/10/26 | ||
* | ||
|
@@ -53,6 +53,7 @@ | |
#define CONFIG_TASK_ANTENNA_DEPLOYMENT_ENABLED 0 | ||
#define CONFIG_TASK_POSITION_DETERMINATION_ENABLED 1 | ||
#define CONFIG_TASK_PAYLOAD_X_ENABLED 1 | ||
#define CONFIG_TASK_HOUSEKEEPING_ENABLED 1 | ||
|
||
/* Devices */ | ||
#define CONFIG_DEV_MEDIA_INT_ENABLED 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.6.2 | ||
* \version 0.10.17 | ||
* | ||
* \date 2020/07/11 | ||
* | ||
|
@@ -50,8 +50,8 @@ | |
#define CURRENT_SENSOR_RSENSE_VALUE_MOHM 50 /**< Rsense resistor value in mOhm. */ | ||
|
||
/* Rload value */ | ||
#define CURRENT_SENSOR_RL_VALUE_OHM 1650 /**< RL resistor value in Ohms. */ | ||
#define CURRENT_SENSOR_RL_VALUE_KOHM 1.65 /**< RL resistor value in kOhms. */ | ||
#define CURRENT_SENSOR_RL_VALUE_OHM 12000 /**< RL resistor value in Ohms. */ | ||
#define CURRENT_SENSOR_RL_VALUE_KOHM 12 /**< RL resistor value in kOhms. */ | ||
|
||
/* Gain value */ | ||
#define CURRENT_SENSOR_GAIN_A_V 0.025 /**< Current gain of max9934 in A/V. */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.7.28 | ||
* \version 0.10.17 | ||
* | ||
* \date 2020/03/17 | ||
* | ||
|
@@ -95,9 +95,9 @@ uint16_t temp_sensor_raw_to_k(uint16_t raw) | |
{ | ||
int16_t temp_c = temp_sensor_raw_to_c(raw); | ||
|
||
if (temp_c < 273) | ||
if (temp_c < -273) | ||
{ | ||
temp_c = 273; | ||
temp_c = -273; | ||
} | ||
|
||
uint16_t res = temp_c + 273; | ||
|
Oops, something went wrong.