CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
adcs_internal_drivers.h
Go to the documentation of this file.
1#ifndef INC_ADCS_INTERNAL_DRIVERS_H_
2#define INC_ADCS_INTERNAL_DRIVERS_H_
3
5#include "main.h" // this is necessary because &hi2c1 is defined in that file
6
7#include <time.h>
8
9#define ADCS_i2c_HANDLE &hi2c1
10
11static const uint8_t ADCS_INCLUDE_CHECKSUM = 1;
12static const uint8_t ADCS_NO_CHECKSUM = 0;
13static const uint8_t ADCS_CHECKSUM_TIMEOUT_TRIES = 100;
14static const uint16_t ADCS_PROCESSED_TIMEOUT_TRIES = 1000;
15static const uint16_t ADCS_FILE_POINTER_TIMEOUT_MS = 60000; // worst-case navigation time for the file pointer is 51 seconds (255 files)
16static const uint32_t ADCS_FILE_DOWNLOAD_TIMEOUT_MS = 290000; // we expect about 4.675 minutes to download 1024x1024px files, which are the largest.
17
18/* Function Definitions */
19
20// byte transforms
21uint8_t ADCS_convert_uint16_to_reversed_uint8_array_members(uint8_t *array, uint16_t value, uint16_t index);
22uint8_t ADCS_convert_uint32_to_reversed_uint8_array_members(uint8_t *array, uint32_t value, uint16_t index);
23uint8_t ADCS_convert_double_to_string(double input, uint8_t precision, char* output_string, uint16_t str_len);
24uint8_t ADCS_combine_sd_log_bitmasks(const uint8_t **array_in, const uint8_t array_in_len, uint8_t *array_out);
25
26// TC/TLM functions (basic communication)
27uint8_t ADCS_i2c_send_command_and_check(uint8_t id, uint8_t* data, uint32_t data_length, uint8_t include_checksum);
28uint8_t ADCS_i2c_request_telemetry_and_check(uint8_t id, uint8_t* data, uint32_t data_length, uint8_t include_checksum);
29uint8_t ADCS_send_i2c_telecommand(uint8_t id, uint8_t* data, uint32_t data_length, uint8_t include_checksum);
30uint8_t ADCS_send_i2c_telemetry_request(uint8_t id, uint8_t* data, uint32_t data_length, uint8_t include_checksum);
31
32// CRC functions
34uint8_t ADCS_calculate_crc8_checksum(uint8_t* buffer, uint16_t len);
35
36#endif /* INC_ADCS_INTERNAL_DRIVERS_H_ */
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 bi...
Definition adcs_internal_drivers.c:210
static const uint32_t ADCS_FILE_DOWNLOAD_TIMEOUT_MS
Definition adcs_internal_drivers.h:16
static const uint16_t ADCS_FILE_POINTER_TIMEOUT_MS
Definition adcs_internal_drivers.h:15
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.
Definition adcs_internal_drivers.c:183
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.
Definition adcs_internal_drivers.c:68
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...
Definition adcs_internal_drivers.c:168
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.
Definition adcs_internal_drivers.c:86
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....
Definition adcs_internal_drivers.c:246
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.
Definition adcs_internal_drivers.c:157
uint8_t ADCS_initialize_crc8_checksum()
Initialize the lookup table for 8-bit CRC calculation. Code provided by ADCS Firmware Reference Manua...
Definition adcs_internal_drivers.c:226
static const uint8_t ADCS_NO_CHECKSUM
Definition adcs_internal_drivers.h:12
static const uint8_t ADCS_CHECKSUM_TIMEOUT_TRIES
Definition adcs_internal_drivers.h:13
static const uint8_t ADCS_INCLUDE_CHECKSUM
Definition adcs_internal_drivers.h:11
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.
Definition adcs_internal_drivers.c:118
static const uint16_t ADCS_PROCESSED_TIMEOUT_TRIES
Definition adcs_internal_drivers.h:14
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 err...
Definition adcs_internal_drivers.c:22
: Header for main.c file. This file contains the common defines of the application.