CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
obc_systems_telecommand_defs.c File Reference
#include "telecommands/obc_systems_telecommand_defs.h"
#include "obc_systems/obc_temperature_sensor.h"
#include "obc_systems/adc_vbat_monitor.h"
#include "debug_tools/debug_uart.h"
#include "stm32l4xx_hal_rcc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
Include dependency graph for obc_systems_telecommand_defs.c:

Functions

uint8_t TCMDEXEC_obc_read_temperature_complex (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Reads the temperature from the STDS75DS2F and stores it in the provided variable temperature. Temperature range is -55 to 125 degrees celsius with +/- 3 degrees celsius accuracy over the whole range.
uint8_t TCMDEXEC_obc_read_temperature (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Reads the temperature from the STDS75DS2F in centi-Celsius.
uint8_t TCMDEXEC_obc_adc_read_vbat_voltage (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Read the battery voltage using the ADC. Returns the result in mV. Voltage divider ratio is already applied.
static uint8_t SystemClock_Config_with_hse (void)
 This is a version of the SystemClock_Config function in main.c, generated with the HSE SYSCLK config.
static HAL_StatusTypeDef MX_TIM6_Init_with_new_25MHz_speed (void)
 TIM6 Initialization Function.
uint8_t TCMDEXEC_obc_set_stm32_sysclk_to_hse (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Change the STM32 SYSCLK clock from the HSI to the HSE.

Variables

TIM_HandleTypeDef htim6

Function Documentation

◆ MX_TIM6_Init_with_new_25MHz_speed()

HAL_StatusTypeDef MX_TIM6_Init_with_new_25MHz_speed ( void )
static

TIM6 Initialization Function.

Re-init the TIM6 timer with a period of 1ms, with the new 25MHz clock.

This is a version of the MX_TIM6_Init function in main.c, with the Prescaler line changed.

Here is the caller graph for this function:

◆ SystemClock_Config_with_hse()

uint8_t SystemClock_Config_with_hse ( void )
static

This is a version of the SystemClock_Config function in main.c, generated with the HSE SYSCLK config.

Configure the main internal regulator output voltage

Initializes the RCC Oscillators according to the specified parameters in the RCC_OscInitTypeDef structure.

Initializes the CPU, AHB and APB buses clocks

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TCMDEXEC_obc_adc_read_vbat_voltage()

uint8_t TCMDEXEC_obc_adc_read_vbat_voltage ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Read the battery voltage using the ADC. Returns the result in mV. Voltage divider ratio is already applied.

Parameters
args_strNo arguments.
Returns
Here is the call graph for this function:

◆ TCMDEXEC_obc_read_temperature()

uint8_t TCMDEXEC_obc_read_temperature ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Reads the temperature from the STDS75DS2F in centi-Celsius.

Returns
0 if successful, >0 if error.
Note
Temperature range is -55 to 125 degrees celsius with +/- 3 degrees celsius accuracy over the whole range.
Here is the call graph for this function:

◆ TCMDEXEC_obc_read_temperature_complex()

uint8_t TCMDEXEC_obc_read_temperature_complex ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Reads the temperature from the STDS75DS2F and stores it in the provided variable temperature. Temperature range is -55 to 125 degrees celsius with +/- 3 degrees celsius accuracy over the whole range.

Parameters
args_str
  • Arg 0: Precision we want the temperature to be (9-12 bits).
Returns
0 if successful, 1 if error.
Note
There are better ways to get the temperature.
Here is the call graph for this function:

◆ TCMDEXEC_obc_set_stm32_sysclk_to_hse()

uint8_t TCMDEXEC_obc_set_stm32_sysclk_to_hse ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Change the STM32 SYSCLK clock from the HSI to the HSE.

Parameters
args_strNo arguments.
Returns
0 on success.

On bootup, the OBC will use the HSI as its clock, as the HSE may have a PCB design defect, where the output capacitance of the HSE clock is too high. Running this command will switch the SYSCLK from the High-Speed Internal (HSI) at 16 MHz to the probably-fine-but-maybe-questionable High-Speed External (HSE) clock at 25 MHz. The main benefit is that the HSE clock is a Temperature-Compensated Crystal Oscillator (TXCO), and thus maintains the system clock much more reliably.

Note
To switch back to the HSI, simply reboot.
If the HSE fails, the Independent Watchdog will reset. Thus, this reconfiguration is low-risk.
Here is the call graph for this function:

Variable Documentation

◆ htim6

TIM_HandleTypeDef htim6
extern