Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
high_speed_logger_direct_memory.c File Reference
#include "high_speed_logger_direct_memory.h"
#include <string.h>
#include "modules/imu/imu.h"
#include "mcu_periph/spi.h"
#include "mcu_periph/uart.h"
#include "modules/datalink/downlink.h"
#include "modules/datalink/telemetry.h"
+ Include dependency graph for high_speed_logger_direct_memory.c:

Go to the source code of this file.

Macros

#define READING_BLOCK_SIZE   200
 size of the block that we read in the memory and send over UART. MAX = 250. More...
 
#define ERASE_MEMORY_AT_START   0
 if we completly erase the memory at the start of the log. More...
 
#define SIZE_OF_LOGGED_VALUES   4
 size (in bytes) of the values we log. More...
 
#define SIZE_OF_VALUES_NAMES   10
 size (in characters) of the nameof the logged values. More...
 
#define SKIP_X_CALLS_BETWEEN_VALUES   0
 Skip X values between write. More...
 
#define NBR_VALUES_TO_LOG   9
 nbr of messages you want to log More...
 
#define MEMORY_READ_LATTENCY   5
 nbr of Bytes 0x00 received before the real values when reading the memory More...
 
#define TOTAL_MEMORY_SIZE   32
 nbr of MB in the memory More...
 
#define END_OF_MEMORY_THRESHOLD   10
 the nbr of kilo Bytes left at the end of the memory before stoping the log automaticaly More...
 

Functions

static void memory_transaction_done_cb (struct spi_transaction *trans)
 generic allback function for SPI transactions More...
 
static void memory_read_status_cb (struct spi_transaction *trans)
 Callback function decrypting the status Byte of the memory. More...
 
static void memory_read_values_cb (struct spi_transaction *trans)
 Callback function decrypting the read values from the memory. More...
 
void memory_read_id (void)
 Function sending a request for the ID of the memory chip. More...
 
void memory_send_wren (void)
 Function sending a request to set the writte enable flag in the memory. More...
 
void memory_send_wrdi (void)
 Function sending a request to clear the writte enable flag in the memory. More...
 
void memory_read_status_1 (void)
 Function sending a request to fetch the status Byte of the memory. More...
 
void memory_erase_4k (uint32_t mem_addr)
 Function sending a request to erase 4KB of the memory. More...
 
void memory_completly_erase (void)
 Function sending a request to erase the entire memory. More...
 
void memory_write_values (uint32_t mem_addr, uint8_t *values, uint8_t size)
 Function sending a request to write a buffer of values to the memory. More...
 
void memory_read_values (uint32_t mem_addr, uint8_t size)
 Function sending a request to read some values in memory. More...
 
uint8_t ml_write_values_to_memory (uint32_t mem_addr, uint8_t *values, uint8_t size)
 Function writting a buffer of values to the memory. More...
 
uint8_t ml_erase_4k_on_memory (uint32_t mem_addr)
 Function erasing 4KB of the memory. More...
 
uint8_t ml_erase_completely_memory (void)
 Function erasing the entire memory. More...
 
void ml_read_log_in_memory (void)
 Function continuing the reading of the current log in memory. More...
 
uint8_t append_values_to_memory (uint8_t *values, uint8_t size)
 Function adding a buffer of values to the memory. More...
 
void send_buffer_to_uart (void)
 Function sending the read values from the memory to te UART. More...
 
uint8_t send_buffer_to_memory (uint8_t *buffer, uint8_t *size)
 Function sending a buffer ot the memory. More...
 
void add_byte_to_buffer (uint8_t value)
 Function adding a Byte to the local buffer. More...
 
void add_array_to_buffer (uint8_t *array, uint8_t size)
 Function adding an array to the local buffer. More...
 
uint8_t run_memory_management (void)
 Function sending the buffer to the memory when possible. More...
 
uint8_t are_buffers_empty (void)
 Function returning true if the two local buffers are empty. More...
 
uint8_t start_new_log (void)
 Function starting a new log. More...
 
void add_values_to_buffer (void)
 Function adding the configured messages to the buffers of the values to be written in memory. More...
 
void run_logger (void)
 Funcion called to add the values to log to the buffer with a frequency divider in order to not overflow the buffers. More...
 
uint8_t end_log (void)
 Function ending the current log. More...
 
void high_speed_logger_direct_memory_init (void)
 Function initialisating the module. More...
 
void high_speed_logger_direct_memory_periodic (void)
 Main function of the module. More...
 
uint8_t is_sequence_in_array (uint8_t *array, uint8_t array_size, uint8_t *sequence, uint8_t sequence_size)
 Function testing if a sequence is in a buffer of values. More...
 
void high_speed_logger_direct_memory_handler (uint8_t val)
 Function managing the interface with the user. More...
 

Variables

uint32_t values_to_log [NBR_VALUES_TO_LOG]
 list of the messages you want to log More...
 
char ** name_of_the_values
 list of the names of the messages you are logging More...
 
uint8_t start_log_sequence [6] = {0xAA, 0x55, 0xFF, 0x00, 0x55, 0xAA}
 Start sequence written at the begining of a log. More...
 
uint8_t start_values_sequence [3] = {0xF0, 0xF0, 0xA5}
 Start sequence written at the begining of the values of a log (after the header) More...
 
uint8_t start_lost_values_sequence [6] = {0x42, 0x0F, 0X42, 0X00, 0XFF, 0xAA}
 Start sequence indicating we have lost some Bytes due to overflows. More...
 
uint8_t stop_lost_values_sequence [6] = {0xAA, 0xFF, 0x00, 0x42, 0x0F, 0x42}
 Stop sequence indicating we have lost some Bytes due to overflows. More...
 
uint8_t stop_log_sequence [6] = {0xFF, 0x00, 0x55, 0xAA, 0x00, 0xFF}
 Stop sequence written at the end of the log. More...
 
uint8_t buff [25]
 Buffer used for general comunication over SPI (in buffer) More...
 
uint8_t uart_read_buff [READING_BLOCK_SIZE+MEMORY_READ_LATTENCY] = {0}
 Buffer used to fetch the values from the memory. More...
 
uint8_t msg [10]
 Buffer used for general comunication over SPI (out buffer) More...
 
uint8_t values_send_buffer [256]
 Buffer used for sending value to the memory. More...
 
uint8_t buffer_values_logged [256]
 First local buffer for the log. More...
 
uint8_t nbr_values_in_buffer = 0
 Number of Bytes in the first buffer (buffer_values_logged) More...
 
uint8_t buffer_values_sending [256]
 Second local buffer for the log. More...
 
uint8_t nbr_values_in_buffer_sending = 0
 Number of Bytes in the second buffer (nbr_values_in_buffer_sending) More...
 
uint8_t buffer_used = 0
 Flag defining wich buffer is used. More...
 
uint8_t wait_answear_from_reading_memory = 0
 Flag defining if we are waiting for an answear from the memory when reading values from it. More...
 
uint8_t memory_status_byte
 Last status Byte read from the memory. More...
 
uint8_t sending_buffer_to_uart = 0
 Flag defining if we are sending values through the UART. More...
 
uint8_t relaunch_reading_memory = 0
 Flag defining if we need to keep reading the memory (if the stop sequence is found we stop) More...
 
uint8_t continue_reading_memory = 0
 Flag defining if we need to keep reading the memory (if the PC asked for new values) More...
 
uint32_t current_writting_addr = 0x00000000
 The address at wich we will write next time. More...
 
uint32_t current_unerased_addr = 0x00000000
 The address of the next block to erase. More...
 
uint32_t current_reading_addr = 0x00000000
 The address at wich we will read next time. More...
 
static volatile bool memory_ready = true
 Flag stating if the memory is being used. More...
 
struct spi_transaction memory_transaction
 Structure used for general comunication with the memory. More...
 
struct spi_transaction memory_send_value_transaction
 Structure used for sending values to the memory. More...
 
uint32_t nbr_lost_values = 0
 Number of Bytes we have lost due to overflows (reseted each time we can write agin in the buffer) More...
 
uint8_t logging_status_gui
 Status of the module. More...
 

Detailed Description

Author
Clement Roblot Module used to connect a memory directly to the SPI port

Definition in file high_speed_logger_direct_memory.c.

Macro Definition Documentation

◆ END_OF_MEMORY_THRESHOLD

#define END_OF_MEMORY_THRESHOLD   10

the nbr of kilo Bytes left at the end of the memory before stoping the log automaticaly

Definition at line 111 of file high_speed_logger_direct_memory.c.

◆ ERASE_MEMORY_AT_START

#define ERASE_MEMORY_AT_START   0

if we completly erase the memory at the start of the log.

Definition at line 48 of file high_speed_logger_direct_memory.c.

◆ MEMORY_READ_LATTENCY

#define MEMORY_READ_LATTENCY   5

nbr of Bytes 0x00 received before the real values when reading the memory

Definition at line 107 of file high_speed_logger_direct_memory.c.

◆ NBR_VALUES_TO_LOG

#define NBR_VALUES_TO_LOG   9

nbr of messages you want to log

Definition at line 61 of file high_speed_logger_direct_memory.c.

◆ READING_BLOCK_SIZE

#define READING_BLOCK_SIZE   200

size of the block that we read in the memory and send over UART. MAX = 250.

Definition at line 46 of file high_speed_logger_direct_memory.c.

◆ SIZE_OF_LOGGED_VALUES

#define SIZE_OF_LOGGED_VALUES   4

size (in bytes) of the values we log.

Definition at line 50 of file high_speed_logger_direct_memory.c.

◆ SIZE_OF_VALUES_NAMES

#define SIZE_OF_VALUES_NAMES   10

size (in characters) of the nameof the logged values.

Definition at line 52 of file high_speed_logger_direct_memory.c.

◆ SKIP_X_CALLS_BETWEEN_VALUES

#define SKIP_X_CALLS_BETWEEN_VALUES   0

Skip X values between write.

if = 2 we writte a values, then the next two calls to the modules will not add any values to the memory, then the third will add a new values.

Definition at line 58 of file high_speed_logger_direct_memory.c.

◆ TOTAL_MEMORY_SIZE

#define TOTAL_MEMORY_SIZE   32

nbr of MB in the memory

Definition at line 109 of file high_speed_logger_direct_memory.c.

Function Documentation

◆ add_array_to_buffer()

void add_array_to_buffer ( uint8_t array,
uint8_t  size 
)

Function adding an array to the local buffer.

This function will just add the values sended to the local buffer. The buffer will then be automaticaly written to the memory when possible.

Parameters
arraythe array to add to the buffer
sizethe size of the array to add to the buffer

Definition at line 854 of file high_speed_logger_direct_memory.c.

References add_byte_to_buffer(), and array.

Referenced by end_log(), run_memory_management(), and start_new_log().

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

◆ add_byte_to_buffer()

void add_byte_to_buffer ( uint8_t  value)

Function adding a Byte to the local buffer.

This function will just add the value sended to the local buffer. The buffer will then be automaticaly written to the memory when possible.

Parameters
valuethe value to add to the buffer
Todo:
Add a protection against overflows

Definition at line 822 of file high_speed_logger_direct_memory.c.

References buffer_used, buffer_values_logged, buffer_values_sending, nbr_lost_values, nbr_values_in_buffer, and nbr_values_in_buffer_sending.

Referenced by add_array_to_buffer(), add_values_to_buffer(), run_memory_management(), and start_new_log().

+ Here is the caller graph for this function:

◆ add_values_to_buffer()

void add_values_to_buffer ( void  )

Function adding the configured messages to the buffers of the values to be written in memory.

This function will fetch the values of the variables setted in the array values_to_log, and send them to the local buffer to be written in memory

Definition at line 1026 of file high_speed_logger_direct_memory.c.

References add_byte_to_buffer(), NBR_VALUES_TO_LOG, SIZE_OF_LOGGED_VALUES, and values_to_log.

Referenced by run_logger().

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

◆ append_values_to_memory()

uint8_t append_values_to_memory ( uint8_t values,
uint8_t  size 
)

Function adding a buffer of values to the memory.

This function is going to take care of writting a buffer of values into the memory. It starts at the address 0x00000000 and will writte after that. It keeps the last written address in memory and will erase the blocks if needed and configured (ERASE_MEMORY_AT_START) before programming the values into the blocks. This function is non blocking, it must be called multiple times to complet it's work.

Parameters
valuesthe buffer of values to writte to the memory
sizethe size of the buffer of values to writte
Returns
0 when done, else return 1

Definition at line 643 of file high_speed_logger_direct_memory.c.

References current_unerased_addr, current_writting_addr, END_OF_MEMORY_THRESHOLD, ERASE_MEMORY_AT_START, logging_status_gui, ml_erase_4k_on_memory(), ml_write_values_to_memory(), and TOTAL_MEMORY_SIZE.

Referenced by send_buffer_to_memory().

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

◆ are_buffers_empty()

uint8_t are_buffers_empty ( void  )

Function returning true if the two local buffers are empty.

Definition at line 928 of file high_speed_logger_direct_memory.c.

References nbr_values_in_buffer, and nbr_values_in_buffer_sending.

Referenced by end_log().

+ Here is the caller graph for this function:

◆ end_log()

uint8_t end_log ( void  )

Function ending the current log.

This function will simply write the ending tag of the log.

This function is none blocking and need to be called multiple times to complete it's work. It will return 0 when the work is completed.

Returns
0 when done, 1 in other cases.

Definition at line 1070 of file high_speed_logger_direct_memory.c.

References add_array_to_buffer(), are_buffers_empty(), and stop_log_sequence.

Referenced by high_speed_logger_direct_memory_periodic().

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

◆ high_speed_logger_direct_memory_handler()

void high_speed_logger_direct_memory_handler ( uint8_t  val)

Function managing the interface with the user.

Definition at line 1242 of file high_speed_logger_direct_memory.c.

References logging_status_gui, and val.

◆ high_speed_logger_direct_memory_init()

◆ high_speed_logger_direct_memory_periodic()

void high_speed_logger_direct_memory_periodic ( void  )

Main function of the module.

Will manage the log.

Definition at line 1141 of file high_speed_logger_direct_memory.c.

References continue_reading_memory, end_log(), logging_status_gui, memory_ready, ml_read_log_in_memory(), run_logger(), run_memory_management(), send_buffer_to_uart(), start_new_log(), uart_char_available(), and uart_getch().

+ Here is the call graph for this function:

◆ is_sequence_in_array()

uint8_t is_sequence_in_array ( uint8_t array,
uint8_t  array_size,
uint8_t sequence,
uint8_t  sequence_size 
)

Function testing if a sequence is in a buffer of values.

This function is usefull to detect the tag indicating the end of the log in order to stop reading. This function will remember the previus values and as such can detect tags even when cutted. We can detect the first half of the tag at the end of one buffer and detect the other half at the begining of the folowing buffer.

Parameters
arraythe buffer in wich we are searching for the sequence
array_sizethe size of the buffer in wich we are searching
sequencethe tag we are searching for
sequence_sizethe size of the tag we are searching for

Definition at line 1217 of file high_speed_logger_direct_memory.c.

References array, and MEMORY_READ_LATTENCY.

Referenced by memory_read_values_cb().

+ Here is the caller graph for this function:

◆ memory_completly_erase()

void memory_completly_erase ( void  )

Function sending a request to erase the entire memory.

Definition at line 319 of file high_speed_logger_direct_memory.c.

References spi_transaction::after_cb, spi_transaction::input_buf, spi_transaction::input_length, memory_ready, memory_transaction, memory_transaction_done_cb(), msg, spi_transaction::output_buf, spi_transaction::output_length, and spi_submit().

Referenced by ml_erase_completely_memory().

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

◆ memory_erase_4k()

void memory_erase_4k ( uint32_t  mem_addr)

Function sending a request to erase 4KB of the memory.

Parameters
mem_addrthe address of the block of 4K that you want to erase

Definition at line 293 of file high_speed_logger_direct_memory.c.

References spi_transaction::after_cb, spi_transaction::input_buf, spi_transaction::input_length, memory_ready, memory_transaction, memory_transaction_done_cb(), msg, spi_transaction::output_buf, spi_transaction::output_length, and spi_submit().

Referenced by ml_erase_4k_on_memory().

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

◆ memory_read_id()

void memory_read_id ( void  )

Function sending a request for the ID of the memory chip.

Todo:
change the cb function to actualy read the value returned

Definition at line 200 of file high_speed_logger_direct_memory.c.

References spi_transaction::after_cb, buff, spi_transaction::input_buf, spi_transaction::input_length, memory_ready, memory_transaction, memory_transaction_done_cb(), msg, spi_transaction::output_buf, spi_transaction::output_length, and spi_submit().

+ Here is the call graph for this function:

◆ memory_read_status_1()

void memory_read_status_1 ( void  )

Function sending a request to fetch the status Byte of the memory.

Definition at line 258 of file high_speed_logger_direct_memory.c.

References spi_transaction::after_cb, buff, spi_transaction::input_buf, spi_transaction::input_length, memory_read_status_cb(), memory_ready, memory_transaction, msg, spi_transaction::output_buf, spi_transaction::output_length, and spi_submit().

Referenced by ml_erase_4k_on_memory(), ml_erase_completely_memory(), and ml_write_values_to_memory().

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

◆ memory_read_status_cb()

static void memory_read_status_cb ( struct spi_transaction trans)
static

Callback function decrypting the status Byte of the memory.

The resulting value will be setted in the global variable "memory_status_byte".

Definition at line 279 of file high_speed_logger_direct_memory.c.

References buff, memory_ready, memory_status_byte, and wait_answear_from_reading_memory.

Referenced by memory_read_status_1().

+ Here is the caller graph for this function:

◆ memory_read_values()

void memory_read_values ( uint32_t  mem_addr,
uint8_t  size 
)

Function sending a request to read some values in memory.

Parameters
mem_addrthe address at wich we want to read
sizethe number of Bytes to be read

Definition at line 377 of file high_speed_logger_direct_memory.c.

References spi_transaction::after_cb, spi_transaction::input_buf, spi_transaction::input_length, MEMORY_READ_LATTENCY, memory_read_values_cb(), memory_ready, memory_transaction, msg, spi_transaction::output_buf, spi_transaction::output_length, spi_submit(), and uart_read_buff.

Referenced by ml_read_log_in_memory().

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

◆ memory_read_values_cb()

static void memory_read_values_cb ( struct spi_transaction trans)
static

Callback function decrypting the read values from the memory.

The resulting values will be sended to the UART by calling the send_buffer_to_uart function

Definition at line 406 of file high_speed_logger_direct_memory.c.

References current_reading_addr, spi_transaction::input_length, is_sequence_in_array(), memory_ready, memory_transaction, relaunch_reading_memory, send_buffer_to_uart(), sending_buffer_to_uart, stop_log_sequence, and uart_read_buff.

Referenced by memory_read_values().

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

◆ memory_send_wrdi()

void memory_send_wrdi ( void  )

Function sending a request to clear the writte enable flag in the memory.

Definition at line 239 of file high_speed_logger_direct_memory.c.

References spi_transaction::after_cb, spi_transaction::input_buf, spi_transaction::input_length, memory_ready, memory_transaction, memory_transaction_done_cb(), msg, spi_transaction::output_buf, spi_transaction::output_length, and spi_submit().

+ Here is the call graph for this function:

◆ memory_send_wren()

void memory_send_wren ( void  )

Function sending a request to set the writte enable flag in the memory.

Definition at line 220 of file high_speed_logger_direct_memory.c.

References spi_transaction::after_cb, spi_transaction::input_buf, spi_transaction::input_length, memory_ready, memory_transaction, memory_transaction_done_cb(), msg, spi_transaction::output_buf, spi_transaction::output_length, and spi_submit().

Referenced by ml_erase_4k_on_memory(), ml_erase_completely_memory(), and ml_write_values_to_memory().

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

◆ memory_transaction_done_cb()

static void memory_transaction_done_cb ( struct spi_transaction trans)
static

generic allback function for SPI transactions

This function will just set a flag telling that the SPI bus can be use now.

Definition at line 435 of file high_speed_logger_direct_memory.c.

References memory_ready.

Referenced by high_speed_logger_direct_memory_init(), memory_completly_erase(), memory_erase_4k(), memory_read_id(), memory_send_wrdi(), memory_send_wren(), and memory_write_values().

+ Here is the caller graph for this function:

◆ memory_write_values()

void memory_write_values ( uint32_t  mem_addr,
uint8_t values,
uint8_t  size 
)

Function sending a request to write a buffer of values to the memory.

Parameters
mem_addrthe address at wich the block must beggin to be written
valuespointer to the buffer of value to be written to the memory. This buffer will be copied during this function. It can be reused right after having called this function.
sizethe size of the buffer of values

Definition at line 343 of file high_speed_logger_direct_memory.c.

References spi_transaction::after_cb, spi_transaction::input_buf, spi_transaction::input_length, memory_ready, memory_send_value_transaction, memory_transaction_done_cb(), spi_transaction::output_buf, spi_transaction::output_length, spi_submit(), and values_send_buffer.

Referenced by ml_write_values_to_memory().

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

◆ ml_erase_4k_on_memory()

uint8_t ml_erase_4k_on_memory ( uint32_t  mem_addr)

Function erasing 4KB of the memory.

This function is going to take care of setting the writte enable flag, then will erase the block, then will check the status of the erase process. Once the erasing is done it will return 0. This function must be called multiple times to complet it's work, it is a none blocking function

Parameters
mem_addrThe address of the 4KB block we want to erase
Returns
0 when done, else the status of the state machine (between 1 and 2)

Definition at line 528 of file high_speed_logger_direct_memory.c.

References memory_erase_4k(), memory_read_status_1(), memory_send_wren(), memory_status_byte, and wait_answear_from_reading_memory.

Referenced by append_values_to_memory().

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

◆ ml_erase_completely_memory()

uint8_t ml_erase_completely_memory ( void  )

Function erasing the entire memory.

This function is going to take care of setting the writte enable flag, then will erase the memory, then will check the status of the erase process. Once the erasing is done it will return 0. This function must be called multiple times to complet it's work, it is a none blocking function

Returns
0 when done, else the status of the state machine (between 1 and 2)

Definition at line 573 of file high_speed_logger_direct_memory.c.

References memory_completly_erase(), memory_read_status_1(), memory_send_wren(), memory_status_byte, and wait_answear_from_reading_memory.

Referenced by start_new_log().

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

◆ ml_read_log_in_memory()

void ml_read_log_in_memory ( void  )

Function continuing the reading of the current log in memory.

This function will start the reading of a new block of the memory, the size of this block is defined by READING_BLOCK_SIZE.

Definition at line 613 of file high_speed_logger_direct_memory.c.

References current_reading_addr, memory_read_values(), and READING_BLOCK_SIZE.

Referenced by high_speed_logger_direct_memory_periodic(), and send_buffer_to_uart().

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

◆ ml_write_values_to_memory()

uint8_t ml_write_values_to_memory ( uint32_t  mem_addr,
uint8_t values,
uint8_t  size 
)

Function writting a buffer of values to the memory.

This function is going to take care of setting the writte enable flag, then will write the values, then will check the status of the write process. Once the writting is done it will return 0. This function must be called multiple times to complet it's work, it is a none blocking function

Parameters
mem_addrThe address at which we want to write the buffer of values
valuesA pointer to the buffer of values we want to write
sizeThe size of the buffer
Returns
0 when done, else the status of the state machine (between 1 and 3)

Definition at line 462 of file high_speed_logger_direct_memory.c.

References memory_read_status_1(), memory_send_wren(), memory_status_byte, memory_write_values(), and wait_answear_from_reading_memory.

Referenced by append_values_to_memory().

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

◆ run_logger()

void run_logger ( void  )

Funcion called to add the values to log to the buffer with a frequency divider in order to not overflow the buffers.

Definition at line 1046 of file high_speed_logger_direct_memory.c.

References add_values_to_buffer(), and SKIP_X_CALLS_BETWEEN_VALUES.

Referenced by high_speed_logger_direct_memory_periodic().

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

◆ run_memory_management()

uint8_t run_memory_management ( void  )

Function sending the buffer to the memory when possible.

This function will send a local buffer to the memory when possible.

Todo:
We don't need two buffers as far as they are imadiatly copied when sended to the memory

Definition at line 869 of file high_speed_logger_direct_memory.c.

References add_array_to_buffer(), add_byte_to_buffer(), buffer_used, buffer_values_logged, buffer_values_sending, nbr_lost_values, nbr_values_in_buffer, nbr_values_in_buffer_sending, send_buffer_to_memory(), start_lost_values_sequence, and stop_lost_values_sequence.

Referenced by high_speed_logger_direct_memory_periodic().

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

◆ send_buffer_to_memory()

uint8_t send_buffer_to_memory ( uint8_t buffer,
uint8_t size 
)

Function sending a buffer ot the memory.

This function is just a verification that the buffer is not empty and that we are not asking for writting an empty buffer. It is simply an abstraction of the append_values_to_memory function.

Parameters
bufferthe buffer of values to writte to the memory
sizethe size of the buffer of values to writte
Returns
0 when done, else return 1

Definition at line 786 of file high_speed_logger_direct_memory.c.

References append_values_to_memory().

Referenced by run_memory_management().

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

◆ send_buffer_to_uart()

void send_buffer_to_uart ( void  )

Function sending the read values from the memory to te UART.

This function will send the buffer of values read back to the UART and will launch an other blokc to be read if needed.

Definition at line 738 of file high_speed_logger_direct_memory.c.

References continue_reading_memory, fd, spi_transaction::input_length, MEMORY_READ_LATTENCY, memory_transaction, ml_read_log_in_memory(), relaunch_reading_memory, sending_buffer_to_uart, uart_check_free_space(), uart_put_byte(), and uart_read_buff.

Referenced by high_speed_logger_direct_memory_periodic(), and memory_read_values_cb().

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

◆ start_new_log()

uint8_t start_new_log ( void  )

Function starting a new log.

This function will start a new log by erasing he memory if configured (ERASE_MEMORY_AT_START) and then will send the starting tags and the name of the messages.

This function is none blokcing, it need to be called multiples times to complete it's work. It will return 0 when the work have been done.

Returns
0 when done, 1 in other case.
Todo:

Add the size of the values sended (in Bytes : SIZE_OF_LOGGED_VALUES).

Add a space to writte the total size of that log (for the progress bar in the downloading application)

Definition at line 961 of file high_speed_logger_direct_memory.c.

References add_array_to_buffer(), add_byte_to_buffer(), current_unerased_addr, current_writting_addr, ERASE_MEMORY_AT_START, ml_erase_completely_memory(), name_of_the_values, NBR_VALUES_TO_LOG, SIZE_OF_LOGGED_VALUES, SIZE_OF_VALUES_NAMES, start_log_sequence, and start_values_sequence.

Referenced by high_speed_logger_direct_memory_periodic().

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

Variable Documentation

◆ buff

◆ buffer_used

uint8_t buffer_used = 0

Flag defining wich buffer is used.

Definition at line 148 of file high_speed_logger_direct_memory.c.

Referenced by add_byte_to_buffer(), and run_memory_management().

◆ buffer_values_logged

uint8_t buffer_values_logged[256]

First local buffer for the log.

Definition at line 140 of file high_speed_logger_direct_memory.c.

Referenced by add_byte_to_buffer(), and run_memory_management().

◆ buffer_values_sending

uint8_t buffer_values_sending[256]

Second local buffer for the log.

Definition at line 144 of file high_speed_logger_direct_memory.c.

Referenced by add_byte_to_buffer(), and run_memory_management().

◆ continue_reading_memory

uint8_t continue_reading_memory = 0

Flag defining if we need to keep reading the memory (if the PC asked for new values)

Definition at line 160 of file high_speed_logger_direct_memory.c.

Referenced by high_speed_logger_direct_memory_periodic(), and send_buffer_to_uart().

◆ current_reading_addr

uint32_t current_reading_addr = 0x00000000

The address at wich we will read next time.

Definition at line 169 of file high_speed_logger_direct_memory.c.

Referenced by memory_read_values_cb(), and ml_read_log_in_memory().

◆ current_unerased_addr

uint32_t current_unerased_addr = 0x00000000

The address of the next block to erase.

Definition at line 167 of file high_speed_logger_direct_memory.c.

Referenced by append_values_to_memory(), and start_new_log().

◆ current_writting_addr

uint32_t current_writting_addr = 0x00000000

The address at wich we will write next time.

Definition at line 165 of file high_speed_logger_direct_memory.c.

Referenced by append_values_to_memory(), and start_new_log().

◆ logging_status_gui

◆ memory_ready

◆ memory_send_value_transaction

struct spi_transaction memory_send_value_transaction

Structure used for sending values to the memory.

Definition at line 171 of file high_speed_logger_direct_memory.c.

Referenced by high_speed_logger_direct_memory_init(), and memory_write_values().

◆ memory_status_byte

uint8_t memory_status_byte

Last status Byte read from the memory.

Definition at line 154 of file high_speed_logger_direct_memory.c.

Referenced by memory_read_status_cb(), ml_erase_4k_on_memory(), ml_erase_completely_memory(), and ml_write_values_to_memory().

◆ memory_transaction

◆ msg

◆ name_of_the_values

char** name_of_the_values
Initial value:
{
"acc x",
"acc y",
"acc z",
"gyro p",
"gyro q",
"gyro r",
"mag x",
"mag y",
"mag z"
}
#define SIZE_OF_VALUES_NAMES
size (in characters) of the nameof the logged values.

list of the names of the messages you are logging

Definition at line 86 of file high_speed_logger_direct_memory.c.

Referenced by start_new_log().

◆ nbr_lost_values

uint32_t nbr_lost_values = 0

Number of Bytes we have lost due to overflows (reseted each time we can write agin in the buffer)

Definition at line 177 of file high_speed_logger_direct_memory.c.

Referenced by add_byte_to_buffer(), and run_memory_management().

◆ nbr_values_in_buffer

uint8_t nbr_values_in_buffer = 0

Number of Bytes in the first buffer (buffer_values_logged)

Definition at line 142 of file high_speed_logger_direct_memory.c.

Referenced by add_byte_to_buffer(), are_buffers_empty(), and run_memory_management().

◆ nbr_values_in_buffer_sending

uint8_t nbr_values_in_buffer_sending = 0

Number of Bytes in the second buffer (nbr_values_in_buffer_sending)

Definition at line 146 of file high_speed_logger_direct_memory.c.

Referenced by add_byte_to_buffer(), are_buffers_empty(), and run_memory_management().

◆ relaunch_reading_memory

uint8_t relaunch_reading_memory = 0

Flag defining if we need to keep reading the memory (if the stop sequence is found we stop)

Definition at line 158 of file high_speed_logger_direct_memory.c.

Referenced by memory_read_values_cb(), and send_buffer_to_uart().

◆ sending_buffer_to_uart

uint8_t sending_buffer_to_uart = 0

Flag defining if we are sending values through the UART.

Definition at line 156 of file high_speed_logger_direct_memory.c.

Referenced by memory_read_values_cb(), and send_buffer_to_uart().

◆ start_log_sequence

uint8_t start_log_sequence[6] = {0xAA, 0x55, 0xFF, 0x00, 0x55, 0xAA}

Start sequence written at the begining of a log.

Definition at line 116 of file high_speed_logger_direct_memory.c.

Referenced by start_new_log().

◆ start_lost_values_sequence

uint8_t start_lost_values_sequence[6] = {0x42, 0x0F, 0X42, 0X00, 0XFF, 0xAA}

Start sequence indicating we have lost some Bytes due to overflows.

Definition at line 120 of file high_speed_logger_direct_memory.c.

Referenced by run_memory_management().

◆ start_values_sequence

uint8_t start_values_sequence[3] = {0xF0, 0xF0, 0xA5}

Start sequence written at the begining of the values of a log (after the header)

Definition at line 118 of file high_speed_logger_direct_memory.c.

Referenced by start_new_log().

◆ stop_log_sequence

uint8_t stop_log_sequence[6] = {0xFF, 0x00, 0x55, 0xAA, 0x00, 0xFF}

Stop sequence written at the end of the log.

Definition at line 126 of file high_speed_logger_direct_memory.c.

Referenced by end_log(), and memory_read_values_cb().

◆ stop_lost_values_sequence

uint8_t stop_lost_values_sequence[6] = {0xAA, 0xFF, 0x00, 0x42, 0x0F, 0x42}

Stop sequence indicating we have lost some Bytes due to overflows.

Definition at line 122 of file high_speed_logger_direct_memory.c.

Referenced by run_memory_management().

◆ uart_read_buff

Buffer used to fetch the values from the memory.

Definition at line 132 of file high_speed_logger_direct_memory.c.

Referenced by memory_read_values(), memory_read_values_cb(), and send_buffer_to_uart().

◆ values_send_buffer

uint8_t values_send_buffer[256]

Buffer used for sending value to the memory.

Definition at line 136 of file high_speed_logger_direct_memory.c.

Referenced by memory_write_values().

◆ values_to_log

uint32_t values_to_log[NBR_VALUES_TO_LOG]
Initial value:
= {
(uint32_t) &imu.accel_unscaled.x,
(uint32_t) &imu.accel_unscaled.y,
(uint32_t) &imu.accel_unscaled.z,
(uint32_t) &imu.gyro_unscaled.p,
(uint32_t) &imu.gyro_unscaled.q,
(uint32_t) &imu.gyro_unscaled.r,
(uint32_t) &imu.mag_unscaled.x,
(uint32_t) &imu.mag_unscaled.y,
(uint32_t) &imu.mag_unscaled.z
}
struct Imu imu
global IMU state
Definition: imu.c:337
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78

list of the messages you want to log

Definition at line 64 of file high_speed_logger_direct_memory.c.

Referenced by add_values_to_buffer().

◆ wait_answear_from_reading_memory

uint8_t wait_answear_from_reading_memory = 0

Flag defining if we are waiting for an answear from the memory when reading values from it.

Definition at line 152 of file high_speed_logger_direct_memory.c.

Referenced by memory_read_status_cb(), ml_erase_4k_on_memory(), ml_erase_completely_memory(), and ml_write_values_to_memory().