Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerfox committed Feb 10, 2018
2 parents 8239efe + d076fc1 commit b5ceed2
Show file tree
Hide file tree
Showing 276 changed files with 75,342 additions and 11,264 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ Temporary Items
*.eep

EQUiSatOS/.vs/EQUiSatOS/v14/.atsuo

# CLion
.idea
CMakeLists.txt
cmake-build-debug
Expand Down
9 changes: 9 additions & 0 deletions EQUiSatOS/EQUiSatOS/EQUiSatOs.cproj
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,9 @@
<Compile Include="src\rtos_tasks\transmit_task.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\rtos_tasks\transmit_task.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\rtos_tasks\watchdog_task.c">
<SubType>compile</SubType>
</Compile>
Expand Down Expand Up @@ -1186,6 +1189,12 @@
<Compile Include="src\telemetry\rscode-1.3\rs.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\testing_functions\battery_charging_simulated_data.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\testing_functions\battery_charging_simulated_data.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\testing_functions\sat_data_tests.c">
<SubType>compile</SubType>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
*
* Only applicable if TRC_CFG_USE_SEPARATE_USER_EVENT_BUFFER is 1.
******************************************************************************/
#define TRC_CFG_UB_CHANNELS 32
#define TRC_CFG_UB_CHANNELS 2

/*******************************************************************************
* TRC_CFG_ISR_TAILCHAINING_THRESHOLD
Expand Down
28 changes: 20 additions & 8 deletions EQUiSatOS/EQUiSatOS/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,41 @@

/**
* flags to control dangerous / inconvenient functions of the satellite
* MAKE SURE to RE-build solution to be double-sure they were disabled
* MAKE SURE to RE-BUILD solution to be double-sure they were disabled
*/
//#define FLASH_ACTIVE // enable flashing
//#define ANTENNA_DEPLOY_ACTIVE // enable antenna deployment
//#define RADIO_ACTIVE // enable radio transmission (note PRINT_DEBUG must be 0)
//#define BAT_CHARGING_ACTIVE // enable battery charging logic
#define BAT_CHARGING_ACTIVE // enable battery charging logic
//#define WATCHDOG_RESET_ACTIVE // enable watchdog actually rebooting satellite

/*** TESTING / DEBUG ***/
// define this flag to disable normal frequencies and read data faster
// (ex: don't read data distributed around an orbit)
// define this flag to disable normal frequencies and read data faster,
// ***AT THE EXPENSE OF COMPLETELY NORMAL FUNCTIONALITY***
// ENUMERATION of changes when ON:
// - don't read data distributed around an orbit
// - don't populate ECC tables on boot (Reed-Solomon will be wrong)
#define TESTING_SPEEDUP

// use this flag to disable reed-solomon tables (frees up memory)
//#define USE_REED_SOLOMON

// if defined, explicitly sets the initial SAT state (must set both)
#define OVERRIDE_INIT_SAT_STATE IDLE_FLASH
#define OVERRIDE_INIT_TASK_STATES IDLE_FLASH_TASK_STATES
// WATCHDOG, STATE, ANTENNA, BAT, TRANS, FLASH, IDLE, LOWP, ATTI, PERSIST
//#define OVERRIDE_INIT_TASK_STATES ((task_states){T_STATE_SUSPENDED, T_STATE_SUSPENDED, T_STATE_SUSPENDED, T_STATE_SUSPENDED, T_STATE_SUSPENDED, T_STATE_SUSPENDED, T_STATE_SUSPENDED, T_STATE_SUSPENDED, T_STATE_SUSPENDED, T_STATE_SUSPENDED})
#define OVERRIDE_STATE_HOLD_INIT 1 // whether to hold initial state (stop auto state changes)

// whether to start up testing tasks
//#define RUN_TESTING_TASKS

// 0 to suppress prints and send data to RADIO, 1 to print over USART
#define PRINT_DEBUG 0
#define RUN_TESTING_TASKS

// debug print control; set to:
// 0 to suppress prints and allow radio transmission
// 1 to print over USART
// 2 to print over Tracelyzer trace_print
// 3 to print over both
#define PRINT_DEBUG 1

/****************************************************************************************/
/* DO NOT EDIT BELOW THIS LINE UNLESS YOU ARE INTENTIONALLY MODIFYING CONFIGURATION */
Expand Down
2 changes: 1 addition & 1 deletion EQUiSatOS/EQUiSatOS/src/config/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void assert_triggered( const char * file, uint32_t line );
#define configPRIO_BITS 2
#define configCPU_CLOCK_HZ ( 8000000 ) // (system_gclk_gen_get_hz(GCLK_GENERATOR_0))
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) // so portTICK_PERIOD_MS = 1
#define configMAX_PRIORITIES ( ( uint32_t ) 5 )
#define configMAX_PRIORITIES ( ( uint32_t ) 6 )
#define configMINIMAL_STACK_SIZE ( ( uint16_t ) 100 )
/* configTOTAL_HEAP_SIZE is not used when heap_3.c is used. */
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0 ) )
Expand Down
1 change: 0 additions & 1 deletion EQUiSatOS/EQUiSatOS/src/data_handling/Sensor_Structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ typedef uint8_t led_current_batch [4];
typedef uint8_t lifepo_bank_temps_batch [2];
typedef uint8_t ir_ambient_temps_batch [6];
typedef uint8_t radio_temp_batch; // single value
typedef uint8_t radio_volts_batch; // single value
typedef uint8_t proc_temp_batch; // single value
typedef uint16_t ad7991_ctrlbrd_batch [4];
typedef uint16_t bat_charge_dig_sigs_batch; // single value
Expand Down
56 changes: 35 additions & 21 deletions EQUiSatOS/EQUiSatOS/src/data_handling/equistack.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
//////////////////////////////////////////////////////////////////////////

#include "equistack.h"
#include "errors.h"

/**
* Takes in a pointer to an equistack to construct and a pointer to a data array to use, the size
Expand All @@ -47,7 +48,10 @@ equistack* equistack_Init(equistack* S, void* data, size_t data_size, uint16_t m
// Returns a pointer to the nth most recent element
void* equistack_Get(equistack* S, int16_t n)
{
xSemaphoreTake(S->mutex, (TickType_t) EQUISTACK_MUTEX_WAIT_TIME_TICKS);
if (!xSemaphoreTake(S->mutex, (TickType_t) EQUISTACK_MUTEX_WAIT_TIME_TICKS)) {
// log error, but continue on because we're just reading
log_error(ELOC_EQUISTACK_GET, ECODE_EQUISTACK_MUTEX_TIMEOUT, true);
}

// We want to ignore the bottom index which is currently staged and maybe
// being overwritten
Expand Down Expand Up @@ -79,34 +83,44 @@ void* equistack_Initial_Stage(equistack* S)

// Returns the next pointer and "finalizes" the previous one (staging)
// Overwrites the bottom value if need be
// NOTE: if fails to obtain mutex (timeout), returns previous pointer
// (does not add onto stack)
void* equistack_Stage(equistack* S)
{
xSemaphoreTake(S->mutex, (TickType_t) EQUISTACK_MUTEX_WAIT_TIME_TICKS);

S->top_index = (S->top_index + 1) % S->max_size;

if (S->bottom_index == (S->top_index + 1) % S->max_size)
{
S->bottom_index = (S->bottom_index + 1) % S->max_size;
}
else
void *staged_pointer = NULL;
if (xSemaphoreTake(S->mutex, (TickType_t) EQUISTACK_MUTEX_WAIT_TIME_TICKS))
{
// It doesn't make sense for the current size to be the max size because
// at least one value is always being rewritten
if (S->cur_size < S->max_size - 1)
S->top_index = (S->top_index + 1) % S->max_size;

if (S->bottom_index == (S->top_index + 1) % S->max_size)
{
S->cur_size++;
S->bottom_index = (S->bottom_index + 1) % S->max_size;
}

if (S->bottom_index == -1)
else
{
S->bottom_index = 0;
// It doesn't make sense for the current size to be the max size because
// at least one value is always being rewritten
if (S->cur_size < S->max_size - 1)
{
S->cur_size++;
}

if (S->bottom_index == -1)
{
S->bottom_index = 0;
}
}
}

void* staged_pointer = S->data + S->data_size*((S->top_index + 1) % S->max_size);
clear_existing_data(staged_pointer, S->data_size);

staged_pointer = S->data + S->data_size*((S->top_index + 1) % S->max_size);
clear_existing_data(staged_pointer, S->data_size);
} else {
// log error if mutex can't be obtained, and give pointer to previously staged
// struct (the one currently at the top index;
// note that the above staged_pointer is using an incremented top_index)
// TODO: check
log_error(ELOC_EQUISTACK_PUT, ECODE_EQUISTACK_MUTEX_TIMEOUT, true);
staged_pointer = S->data + (S->data_size)*((S->top_index + 1) % S->max_size);
}
xSemaphoreGive(S->mutex);
return staged_pointer; // return pointer to staged data
}
Expand Down
4 changes: 3 additions & 1 deletion EQUiSatOS/EQUiSatOS/src/data_handling/package_transmission.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,9 @@ void write_low_power_data_packet(uint8_t* buffer, uint8_t* buf_index, low_power_
void write_parity(uint8_t* buffer, uint8_t* buf_index) {
// encode using Reed-Solomon (START_PARITY is the number of bytes in buffer before parity section)
// NOTE we don't encode the callsign
encode_data(buffer + CALLSIGN_SIZE, START_PARITY - CALLSIGN_SIZE, buffer + CALLSIGN_SIZE);
#ifdef USE_REED_SOLOMON
encode_data(buffer + CALLSIGN_SIZE, START_PARITY - CALLSIGN_SIZE, buffer + CALLSIGN_SIZE);
#endif
*buf_index = *buf_index + MSG_PARITY_LENGTH;
}

Expand Down
6 changes: 4 additions & 2 deletions EQUiSatOS/EQUiSatOS/src/data_handling/package_transmission.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

#include <global.h>
#include "rtos_tasks/rtos_tasks.h"
#include "../telemetry/rscode-1.3/ecc.h"
#ifdef USE_REED_SOLOMON
#include "../telemetry/rscode-1.3/ecc.h"
#endif
#include "../data_handling/persistent_storage.h"

/************************************************************************/
Expand All @@ -21,7 +23,7 @@
// various section sizes in bytes
#define MSG_PREAMBLE_LENGTH 13
#define MSG_CUR_DATA_LEN 16
#define MSG_DATA_AND_ERRORS_LEN 196 // sum of possible data, error, and padding sections
#define MSG_DATA_AND_ERRORS_LEN 194 // sum of possible data, error, and padding sections (make sure up to date)
#define MSG_PARITY_LENGTH 32
#define MSG_SIZE 255
#define MSG_BUFFER_SIZE (MSG_SIZE + 1) // = sum of all sections (largest) + 1 for null terminator
Expand Down

0 comments on commit b5ceed2

Please sign in to comment.