CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
adcs_internal_drivers.h File Reference
#include "adcs_drivers/adcs_types.h"
#include "main.h"
#include <time.h>
Include dependency graph for adcs_internal_drivers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ADCS_i2c_HANDLE   &hi2c1
 

Functions

uint8_t ADCS_convert_uint16_to_reversed_uint8_array_members (uint8_t *array, uint16_t value, uint16_t index)
 Swap low and high bytes of a uint16 to turn into uint8 and put into specified index of an array.
 
uint8_t ADCS_convert_uint32_to_reversed_uint8_array_members (uint8_t *array, uint32_t value, uint16_t index)
 Reverse the order of the four bytes of a uint32 to turn into uint8 and put into specified index of an array.
 
uint8_t ADCS_convert_double_to_string (double input, uint8_t precision, char *output_string, uint16_t str_len)
 Convert a double into a string with a given decimal precision.
 
uint8_t ADCS_combine_sd_log_bitmasks (const uint8_t **array_in, const uint8_t array_in_len, uint8_t *array_out)
 Take an arbitrary number (up to 63) of 10-byte uint8 arrays and return a single array which is the bitwise OR of all of them.
 
uint8_t ADCS_i2c_send_command_and_check (uint8_t id, uint8_t *data, uint32_t data_length, uint8_t include_checksum)
 Sends a telecommand over I2C to the ADCS, checks that it's been acknowledged, and returns the ACK error flag.
 
uint8_t ADCS_i2c_request_telemetry_and_check (uint8_t id, uint8_t *data, uint32_t data_length, uint8_t include_checksum)
 Sends a telemetry request over I2C to the ADCS, and resends repeatedly if the checksums don't match.
 
uint8_t ADCS_send_i2c_telecommand (uint8_t id, uint8_t *data, uint32_t data_length, uint8_t include_checksum)
 Sends a telecommand over I2C to the ADCS.
 
uint8_t ADCS_send_i2c_telemetry_request (uint8_t id, uint8_t *data, uint32_t data_length, uint8_t include_checksum)
 Sends a telemetry request over I2C to the ADCS.
 
uint8_t ADCS_initialize_crc8_checksum ()
 Initialize the lookup table for 8-bit CRC calculation. Code provided by ADCS Firmware Reference Manual (p.18-19).
 
uint8_t ADCS_calculate_crc8_checksum (uint8_t *buffer, uint16_t len)
 Calculates an 8-bit CRC value. Code provided by ADCS Firmware Reference Manual (p.19).
 

Variables

static const uint8_t ADCS_INCLUDE_CHECKSUM = 1
 
static const uint8_t ADCS_NO_CHECKSUM = 0
 
static const uint8_t ADCS_CHECKSUM_TIMEOUT_TRIES = 100
 
static const uint16_t ADCS_PROCESSED_TIMEOUT_TRIES = 1000
 
static const uint16_t ADCS_FILE_POINTER_TIMEOUT_MS = 60000
 
static const uint32_t ADCS_FILE_DOWNLOAD_TIMEOUT_MS = 290000
 

Macro Definition Documentation

◆ ADCS_i2c_HANDLE

#define ADCS_i2c_HANDLE   &hi2c1

Function Documentation

◆ ADCS_calculate_crc8_checksum()

uint8_t ADCS_calculate_crc8_checksum ( uint8_t * buffer,
uint16_t len )

Calculates an 8-bit CRC value. Code provided by ADCS Firmware Reference Manual (p.19).

Parameters
[in]bufferthe buffer containing data for which to calculate the crc value
[in]lenthe number of bytes of valid data in the buffer
Returns
the CRC value calculated (which is 0xFF for an empty buffer)
Here is the caller graph for this function:

◆ ADCS_combine_sd_log_bitmasks()

uint8_t ADCS_combine_sd_log_bitmasks ( const uint8_t ** array_in,
const uint8_t array_in_len,
uint8_t * array_out )

Take an arbitrary number (up to 63) of 10-byte uint8 arrays and return a single array which is the bitwise OR of all of them.

Parameters
[in]array_inArray of pointers to 10-byte uint8 data arrays
[in]array_in_lenSize of the array_in array
[out]array_out10-byte uint8 data array to send the result to
Returns
0 once complete.
Here is the caller graph for this function:

◆ ADCS_convert_double_to_string()

uint8_t ADCS_convert_double_to_string ( double input,
uint8_t precision,
char * output_string,
uint16_t str_len )

Convert a double into a string with a given decimal precision.

Note
This is used because snprintf doesn't support printing doubles.
Parameters
[in]inputValue to convert.
[in]precisionNumber of decimal places to use.
[out]output_stringCharacter array to write the string number to.
[in]str_lenLength of the output string.
Returns
0 once complete, 1 if the string is too short, 2 if there was an error printing to the string.
Here is the caller graph for this function:

◆ ADCS_convert_uint16_to_reversed_uint8_array_members()

uint8_t ADCS_convert_uint16_to_reversed_uint8_array_members ( uint8_t * array,
uint16_t value,
uint16_t index )

Swap low and high bytes of a uint16 to turn into uint8 and put into specified index of an array.

Parameters
[in]valueValue to split and swap the order of.
[in]indexIndex in array to write the result. (Array must contain at least two bytes, with index pointing to the first)
[out]arrayData array to write the two bytes to at the specified index and index + 1.
Returns
0 once complete.
Here is the caller graph for this function:

◆ ADCS_convert_uint32_to_reversed_uint8_array_members()

uint8_t ADCS_convert_uint32_to_reversed_uint8_array_members ( uint8_t * array,
uint32_t value,
uint16_t index )

Reverse the order of the four bytes of a uint32 to turn into uint8 and put into specified index of an array.

Parameters
[in]valueValue to split and swap the order of.
[in]indexIndex in array to write the result. (Array must contain at least four bytes, with index pointing to the first)
[out]arrayData array to write the four bytes to at the specified index and the three subsequent indices.
Returns
0 once complete.
Here is the caller graph for this function:

◆ ADCS_i2c_request_telemetry_and_check()

uint8_t ADCS_i2c_request_telemetry_and_check ( uint8_t id,
uint8_t * data,
uint32_t data_length,
uint8_t include_checksum )

Sends a telemetry request over I2C to the ADCS, and resends repeatedly if the checksums don't match.

Parameters
[in]idValid ADCS telemetry request ID (see Firmware Reference Manual)
[in]include_checksumTells the ADCS whether to use a CRC8 checksum; should be either ADCS_INCLUDE_CHECKSUM or ADCS_NO_CHECKSUM
[in]data_lengthLength of the data array.
[out]dataData array to write the raw telemetry bytes to; length must be at least data_length (should contain the correct number of bytes for the given telemetry request ID)
Returns
0 if successful, other numbers if the HAL failed to transmit or receive data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ADCS_i2c_send_command_and_check()

uint8_t ADCS_i2c_send_command_and_check ( uint8_t id,
uint8_t * data,
uint32_t data_length,
uint8_t include_checksum )

Sends a telecommand over I2C to the ADCS, checks that it's been acknowledged, and returns the ACK error flag.

Parameters
[in]idValid ADCS telecommand ID (see Firmware Reference Manual)
[in]dataData array to send the raw data bytes; length must be at least data_length (should contain the correct number of bytes for the given telecommand ID)
[in]data_lengthLength of the data array.
[in]include_checksumTells the ADCS whether to use a CRC8 checksum; should be either ADCS_INCLUDE_CHECKSUM or ADCS_NO_CHECKSUM
Returns
0 if successful, 1 if invalid ID, 2 if incorrect parameter length, 3 if incorrect parameter value, and 4 if failed CRC
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ADCS_initialize_crc8_checksum()

uint8_t ADCS_initialize_crc8_checksum ( )

Initialize the lookup table for 8-bit CRC calculation. Code provided by ADCS Firmware Reference Manual (p.18-19).

Returns
0 once successful.
Here is the caller graph for this function:

◆ ADCS_send_i2c_telecommand()

uint8_t ADCS_send_i2c_telecommand ( uint8_t id,
uint8_t * data,
uint32_t data_length,
uint8_t include_checksum )

Sends a telecommand over I2C to the ADCS.

Parameters
[in]idValid ADCS telecommand ID (see Firmware Reference Manual)
[in]dataData array to send the raw data bytes; length must be at least data_length (should contain the correct number of bytes for the given telecommand ID)
[in]data_lengthLength of the data array.
[in]include_checksumTells the ADCS whether to use a CRC8 checksum; should be either ADCS_INCLUDE_CHECKSUM or ADCS_NO_CHECKSUM
Returns
0 if successful, 4 if the checksums don't match, other numbers if the HAL failed to transmit or receive data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ADCS_send_i2c_telemetry_request()

uint8_t ADCS_send_i2c_telemetry_request ( uint8_t id,
uint8_t * data,
uint32_t data_length,
uint8_t include_checksum )

Sends a telemetry request over I2C to the ADCS.

Parameters
[in]idValid ADCS telemetry request ID (see Firmware Reference Manual)
[in]include_checksumTells the ADCS whether to use a CRC8 checksum; should be either ADCS_INCLUDE_CHECKSUM or ADCS_NO_CHECKSUM
[in]data_lengthLength of the data array.
[out]dataData array to write the raw telemetry bytes to; length must be at least data_length (should contain the correct number of bytes for the given telemetry request ID)
Returns
0 if successful, 4 if the checksums don't match, other numbers if the HAL failed to transmit or receive data.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ADCS_CHECKSUM_TIMEOUT_TRIES

const uint8_t ADCS_CHECKSUM_TIMEOUT_TRIES = 100
static

◆ ADCS_FILE_DOWNLOAD_TIMEOUT_MS

const uint32_t ADCS_FILE_DOWNLOAD_TIMEOUT_MS = 290000
static

◆ ADCS_FILE_POINTER_TIMEOUT_MS

const uint16_t ADCS_FILE_POINTER_TIMEOUT_MS = 60000
static

◆ ADCS_INCLUDE_CHECKSUM

const uint8_t ADCS_INCLUDE_CHECKSUM = 1
static

◆ ADCS_NO_CHECKSUM

const uint8_t ADCS_NO_CHECKSUM = 0
static

◆ ADCS_PROCESSED_TIMEOUT_TRIES

const uint16_t ADCS_PROCESSED_TIMEOUT_TRIES = 1000
static