CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
mpi_command_handling.h File Reference
#include <stdint.h>
#include <stddef.h>
#include "mpi/mpi_types.h"
#include "littlefs/lfs.h"
Include dependency graph for mpi_command_handling.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint8_t MPI_send_command_get_response (const uint8_t *bytes_to_send, const size_t bytes_to_send_len, uint8_t *rx_buffer, const size_t rx_buffer_max_size, uint16_t *rx_buffer_len)
 Sends commandcode+params to the MPI as bytes.
 
uint8_t MPI_enable_active_mode (const char output_file_path[])
 Turns on MPI science mode and Enables DMA interrupt for MPI channel.
 
uint8_t MPI_disable_active_mode ()
 
uint8_t MPI_validate_command_response (const uint8_t command_code, uint8_t *rx_buffer, const uint16_t rx_buffer_len)
 The MPI responds to each telecommand with a response code consisting of an echo of the telecommand code byte and a status byte (either 254 or OxFE) for success or error code otherwise.
 

Variables

static const uint8_t MPI_COMMAND_SUCCESS_RESPONSE_VALUE = 0xFE
 
volatile MPI_rx_mode_t MPI_current_uart_rx_mode
 Current mode under which the MPI is being operated.
 
uint8_t MPI_science_data_file_is_open
 
uint32_t MPI_science_data_bytes_lost
 
lfs_file_t MPI_science_data_file_pointer
 
uint32_t MPI_recording_start_uptime_ms
 

Function Documentation

◆ MPI_disable_active_mode()

uint8_t MPI_disable_active_mode ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MPI_enable_active_mode()

uint8_t MPI_enable_active_mode ( const char output_file_path[])

Turns on MPI science mode and Enables DMA interrupt for MPI channel.

Returns
0: MPI and DMA successfully enabled, < 0: Error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MPI_send_command_get_response()

uint8_t MPI_send_command_get_response ( const uint8_t * bytes_to_send,
const size_t bytes_to_send_len,
uint8_t * rx_buffer,
const size_t rx_buffer_max_size,
uint16_t * rx_buffer_len )

Sends commandcode+params to the MPI as bytes.

Parameters
bytes_to_sendBuffer containing the telecommand + params (IF ANY) as hex bytes
bytes_to_send_lenSize of telecommand buffer
rx_bufferBuffer to store incoming response from the MPI
rx_buffer_max_sizeThe maximum size of the MPI response buffer
rx_buffer_lenPointer to variable that will contain the length of the populated MPI response buffer
Returns
0: Success, 2: Failed UART transmission, 3: Failed UART reception, 4: Timeout waiting for 1st byte from MPI, 8: Not enough space in the MPI response buffer
Note
If the MPI is in "science data" mode, it will be disabled after the command is executed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MPI_validate_command_response()

uint8_t MPI_validate_command_response ( const uint8_t command_code,
uint8_t * rx_buffer,
const uint16_t rx_buffer_len )

The MPI responds to each telecommand with a response code consisting of an echo of the telecommand code byte and a status byte (either 254 or OxFE) for success or error code otherwise.

Parameters
tx_bufferMPI telecommand buffer containing bytes sent
rx_bufferMPI response buffer containing bytes received
tx_buffer_sizeSize of the MPI response buffer
Returns
0: MPI successfully executed telecommand, 5: MPI failed to execute telecommand, 6: Invalid response from the MPI
Here is the caller graph for this function:

Variable Documentation

◆ MPI_COMMAND_SUCCESS_RESPONSE_VALUE

const uint8_t MPI_COMMAND_SUCCESS_RESPONSE_VALUE = 0xFE
static

◆ MPI_current_uart_rx_mode

volatile MPI_rx_mode_t MPI_current_uart_rx_mode
extern

Current mode under which the MPI is being operated.

◆ MPI_recording_start_uptime_ms

uint32_t MPI_recording_start_uptime_ms
extern

◆ MPI_science_data_bytes_lost

uint32_t MPI_science_data_bytes_lost
extern

◆ MPI_science_data_file_is_open

uint8_t MPI_science_data_file_is_open
extern

◆ MPI_science_data_file_pointer

lfs_file_t MPI_science_data_file_pointer
extern