mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-02 21:37:24 +08:00
[modules] new high_speed_logger_direct_memory using SPI
Added a tool to log messages by connecting a simple flash chip directly to the SPI of the autopilot closes #815
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
<!DOCTYPE module SYSTEM "module.dtd">
|
||||||
|
|
||||||
|
<module name="loggers">
|
||||||
|
<doc>
|
||||||
|
<description>
|
||||||
|
SPI logger
|
||||||
|
A logger that connects and manage a memory directly connected to th SPI.
|
||||||
|
|
||||||
|
This module includes some configurations :
|
||||||
|
- @b ERASE_MEMORY_AT_START : if set to 1 the memory will be erased completly when starting a new log. This will take a little bit less than a minute, but afterwards you will be able to log values at a higher rate than if you didn't do it. If you let it to 0, the module is going to erase the memory block by block of 4K when needed.
|
||||||
|
- @b SIZE_OF_LOGGED_VALUES : the number of Bytes that each value logged must be (in memory). You can write a 4 Bytes values in a 2 Bytes slots, you just need to be certain that you don't have any overflows.
|
||||||
|
- @b NBR_VALUES_TO_LOG : the number of messages you want to log. This value is equivalent to the size of the values_to_log array.
|
||||||
|
- @b SKIP_X_CALLS_BETWEEN_VALUES : you might want to slow down the logger instead of losing values (because of buffer overflows). if that value is set to 0, a new value of every logged messages will be added to the buffer. If set to 2, we will wait two calls to the module, then during the third one we will writte the values to the buffer. By default this modules is called at 512Hz.
|
||||||
|
|
||||||
|
Then you have two arrays :
|
||||||
|
|
||||||
|
- @b values_to_log : containing the pointer to the values to log.
|
||||||
|
- @b name_of_the_values : the name of the messages logged. This is simply an aesthetic configuration, for you to know which message were logged.
|
||||||
|
|
||||||
|
The applicaton to read the memory back is available here : http://karlito139.github.io/lisa_s_logger_reader/
|
||||||
|
|
||||||
|
For more informations on how to use this module you can refer to the wiki : http://wiki.paparazziuav.org/wiki/Micro_logger
|
||||||
|
</description>
|
||||||
|
<configure name="HS_LOG_UART" value="UART1|UART2|UART3|UART4|UART5|UART6" description="Port to read back the memory"/>
|
||||||
|
<configure name="HS_LOG_SPI" value="SPI1|SPI2|SPI3|SPI4|SPI5|SPI6" description="Port to read back the memory"/>
|
||||||
|
<configure name="HS_LOG_SPI_SLAVE" value="SPI_SLAVE1|SPI_SLAVE2|SPI_SLAVE3|SPI_SLAVE4|SPI_SLAVE5|SPI_SLAVE6" description="Port to read back the memory"/>
|
||||||
|
</doc>
|
||||||
|
<header>
|
||||||
|
<file name="high_speed_logger_direct_memory.h"/>
|
||||||
|
</header>
|
||||||
|
<init fun="high_speed_logger_direct_memory_init()"/>
|
||||||
|
<periodic fun="high_speed_logger_direct_memory_periodic()" autorun="TRUE"/>
|
||||||
|
<makefile>
|
||||||
|
|
||||||
|
<raw>
|
||||||
|
HS_LOG_UART ?= uart3
|
||||||
|
HS_LOG_UART_LOWER=$(shell echo $(HS_LOG_UART) | tr A-Z a-z)
|
||||||
|
HS_LOG_UART_UPPER=$(shell echo $(HS_LOG_UART) | tr a-z A-Z)
|
||||||
|
|
||||||
|
HS_LOG_SPI ?= spi1
|
||||||
|
HS_LOG_SPI_LOWER=$(shell echo $(HS_LOG_SPI) | tr A-Z a-z)
|
||||||
|
HS_LOG_SPI_UPPER=$(shell echo $(HS_LOG_SPI) | tr a-z A-Z)
|
||||||
|
|
||||||
|
HS_LOG_SPI_SLAVE ?= spi_slave1
|
||||||
|
HS_LOG_SPI_SLAVE_LOWER=$(shell echo $(HS_LOG_SPI_SLAVE) | tr A-Z a-z)
|
||||||
|
HS_LOG_SPI_SLAVE_UPPER=$(shell echo $(HS_LOG_SPI_SLAVE) | tr a-z A-Z)
|
||||||
|
</raw>
|
||||||
|
|
||||||
|
<define name="SPI_MASTER" value="1" />
|
||||||
|
<define name="USE_$(HS_LOG_SPI_UPPER)" value="1" />
|
||||||
|
<define name="USE_$(HS_LOG_SPI_SLAVE_UPPER)" value="1" />
|
||||||
|
<define name="HIGH_SPEED_LOGGER_DIRECT_MEMORY_DEVICE" value="$(HS_LOG_SPI_LOWER)" />
|
||||||
|
<define name="HIGH_SPEED_LOGGER_DIRECT_MEMORY_SLAVE_NUMBER" value="$(HS_LOG_SPI_SLAVE_UPPER)" />
|
||||||
|
|
||||||
|
<define name="HS_LOG_UART" value="$(HS_LOG_UART_LOWER)"/>
|
||||||
|
<define name="USE_$(HS_LOG_UART_UPPER)"/>
|
||||||
|
<define name="$(HS_LOG_UART_UPPER)_BAUD" value="B115200"/>
|
||||||
|
|
||||||
|
<file name="high_speed_logger_direct_memory.c"/>
|
||||||
|
</makefile>
|
||||||
|
</module>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE settings SYSTEM "../settings.dtd">
|
||||||
|
|
||||||
|
<settings>
|
||||||
|
<dl_settings>
|
||||||
|
|
||||||
|
<dl_settings NAME="logger">
|
||||||
|
<dl_setting shortname="Status" var="logging_status_gui" min="0" max="3" module="loggers/high_speed_logger_direct_memory" values="idle|Initialise|start log|stop log" handler="handler"/>
|
||||||
|
</dl_settings>
|
||||||
|
|
||||||
|
</dl_settings>
|
||||||
|
</settings>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Clement Roblot
|
||||||
|
*
|
||||||
|
* This file is part of paparazzi.
|
||||||
|
*
|
||||||
|
* paparazzi is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* paparazzi is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with paparazzi; see the file COPYING. If not, see
|
||||||
|
* <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file high_speed_logger_direct_memory.h
|
||||||
|
* @author Clement Roblot
|
||||||
|
* Module used to connect a memory directly to the SPI port
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HIGH_SPEED_LOGGER_DIRECT_MEMORY_H_
|
||||||
|
#define HIGH_SPEED_LOGGER_DIRECT_MEMORY_H_
|
||||||
|
|
||||||
|
#include "std.h"
|
||||||
|
|
||||||
|
|
||||||
|
//Low level functions, directly acting with the SPI
|
||||||
|
extern void memory_read_id(void);
|
||||||
|
extern void memory_send_wren(void);
|
||||||
|
extern void memory_send_wrdi(void);
|
||||||
|
extern void memory_read_status_1(void);
|
||||||
|
extern void memory_read_values(uint32_t mem_addr, uint8_t size);
|
||||||
|
extern void memory_write_values(uint32_t mem_addr, uint8_t *values, uint8_t size);
|
||||||
|
extern void memory_completly_erase(void);
|
||||||
|
extern void memory_erase_4k(uint32_t mem_addr);
|
||||||
|
|
||||||
|
//Mid low level functions, abstracting the low SPI layer
|
||||||
|
extern uint8_t ml_write_values_to_memory(uint32_t mem_addr, uint8_t *values, uint8_t size);
|
||||||
|
extern uint8_t ml_erase_4k_on_memory(uint32_t mem_addr);
|
||||||
|
extern uint8_t ml_erase_completely_memory(void);
|
||||||
|
extern void ml_read_log_in_memory(void);
|
||||||
|
|
||||||
|
//Mid high level function : memory management
|
||||||
|
extern uint8_t append_values_to_memory(uint8_t *values, uint8_t size);
|
||||||
|
extern uint8_t send_buffer_to_memory(uint8_t *buffer, uint8_t *size);
|
||||||
|
extern void send_buffer_to_uart(void);
|
||||||
|
|
||||||
|
//High level function : local buffer management
|
||||||
|
extern void add_byte_to_buffer(uint8_t value);
|
||||||
|
extern void add_array_to_buffer(uint8_t *array, uint8_t size);
|
||||||
|
extern uint8_t run_memory_management(void);
|
||||||
|
extern uint8_t are_buffers_empty(void);
|
||||||
|
|
||||||
|
//High level function : log commands
|
||||||
|
extern uint8_t start_new_log(void);
|
||||||
|
extern void add_values_to_buffer(void);
|
||||||
|
extern void run_logger(void);
|
||||||
|
extern uint8_t end_log(void);
|
||||||
|
|
||||||
|
//Module function
|
||||||
|
extern void high_speed_logger_direct_memory_init(void);
|
||||||
|
extern void high_speed_logger_direct_memory_periodic(void);
|
||||||
|
|
||||||
|
//Other functions
|
||||||
|
extern uint8_t is_sequence_in_array(uint8_t *array, uint8_t array_size, uint8_t *sequence, uint8_t sequence_size);
|
||||||
|
|
||||||
|
extern void high_speed_logger_direct_memory_handler(uint8_t val);
|
||||||
|
|
||||||
|
extern uint8_t logging_status_gui;
|
||||||
|
|
||||||
|
#endif /* HIGH_SPEED_LOGGER_DIRECT_MEMORY_H_ */
|
||||||
Reference in New Issue
Block a user