Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
high_speed_logger_direct_memory.h File Reference
#include "std.h"
+ Include dependency graph for high_speed_logger_direct_memory.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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_read_values (uint32_t mem_addr, uint8_t size)
 Function sending a request to read some values in 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_completly_erase (void)
 Function sending a request to erase the entire memory. More...
 
void memory_erase_4k (uint32_t mem_addr)
 Function sending a request to erase 4KB of the 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...
 
uint8_t send_buffer_to_memory (uint8_t *buffer, uint8_t *size)
 Function sending a buffer ot the memory. More...
 
void send_buffer_to_uart (void)
 Function sending the read values from the memory to te UART. 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

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.h.

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_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_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_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

◆ logging_status_gui

uint8_t logging_status_gui
extern