Skip to content
Snippets Groups Projects
Commit 279057d3 authored by Gerrit Maus's avatar Gerrit Maus
Browse files

Initial commit

This is the RSS2I code project that contains the RSS2I firmware sources
as well as the RSS2I command line tool. The development started in 2018
and now results in the release of version 1.0.0.
parents
Branches
Tags v1.0.0
No related merge requests found
Showing
with 1771 additions and 0 deletions
# Ignore common build files
*.o
*.d
*.pico
*.hex
*.elf
generated.*
*.so
# Ignore binaries inside /lookup and /test
/lookup/*
!/lookup/*.c
/lookup/generated.*.c
/test/*
!/lookup/*.c
/test/generated.*.c
# Ignore editor/IDE related files
.vscode
# Ignore pycache
__pycache__
# Changelog
All notable changes to the RSS2I project will be documented in this file.
## [Unreleased](./)
## [1.0.0](tags/v1.0.0) - 2019-07-02
Initial public release.
This diff is collapsed.
Makefile 0 → 100644
#
# This file is part of the RSS2I project licensed under the GNU GPL v3.0+
#
#
# Authors
# =======
#
# Gerrit Maus (funk@maus.xyz) (Bergische Universität Wuppertal, BSMK)
#
# Changelog
# =========
#
# 2019-03-12 Initial release.
# 2019-05-27 Added support for unit tests.
# 2019-06-14 Added cross compilation support.
#
# ------------------------------------------------------------------------------
# Important settings :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
OPENCM3_DIR := ../../nrf5lib
PYTHONPATH := ~/bin/python-packages
INSTALLBIN := ~/bin/rss2i
OOCD_CFG := ./openocd.cfg
HOSTCC := gcc -c
HOSTLD := gcc
XHOSTCC := gcc -c
XHOSTLD := gcc
CC := arm-none-eabi-gcc -c
AS := arm-none-eabi-gcc -c
LD := arm-none-eabi-gcc
OBJCPY := arm-none-eabi-objcopy
OOCD := openocd
RM := rm -rf
MKDIR := mkdir
CP := cp
MV := mv
DIFF := diff
CHMOD := chmod
# ------------------------------------------------------------------------------
# Internal settings ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
DEVICE := NRF52832QFAB
TARGETS := device parameters test memval
OBJS := src/buffer.o
OBJS += src/ble.o
OBJS += src/suart.o
OBJS += src/radio.o
OBJS += src/clock.o
OBJS += src/measure.o
OBJS += src/battery.o
OBJS += src/led.o
OBJS += src/pwm.o
OBJS += src/uarte.o
OBJS += src/usb.o
OBJS += src/debug.o
OBJS += src/timer.o
OBJS += src/spim.o
OBJS += src/memory.o
OBJS += src/print.o
OBJS += src/random.o
OBJS += src/crc.o
OBJS += src/control.o
OBJS += src/power.o
OBJS += src/icache.o
OBJS += src/cmd.o
OBJS += src/watchdog.o
OBJS += src/board.o
OBJS += src/version.o
OBJS += src/ppi.o
OBJS += src/mlc.o
OBJS += lookup/generated.led.o
OBJS += lookup/generated.crc.o
PYLIB_OBJS := src/crc.host.pico
PYLIB_OBJS += lookup/generated.crc.host.pico
PYLIB_TARGETS := crc
PYTHON_MODULE_FILES := __init__.py
LOOKUPS := led
LOOKUPS += crc
TESTS := ble buffer print crc
INCPATHS += ./include
BOARDFILE := include/rss2i/config/generated.board.h
DEBUGFILE := include/rss2i/config/generated.debug.h
LIBS :=
CPPFLAGS := $(foreach INCPATH,$(INCPATHS),-I$(INCPATH))
CPPFLAGS += -MD -MP
CFLAGS := -Wall -Wextra -std=c99 -O3 -fdata-sections -ffunction-sections -flto
HOSTCFLAGS := -fopenmp
LDFLAGS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group -Wl,--gc-sections -flto
LDFLAGS += -nostartfiles
LDLIBS := $(foreach LDLIB,$(LIBS),-l$(LDLIB))
# ------------------------------------------------------------------------------
# Be quiet by default ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
ifneq ($(V),1)
Q := @
NULL := > /dev/null 2>&1
MAKEFLAGS += --no-print-directory
export $(V)
endif
# ------------------------------------------------------------------------------
# Makefile overview ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
.PHONY: help clean lookup all warn-flag warn-board-flag warn-debug-flag install install-module uninstall test runtest
.PRECIOUS: %.c %.o
.PRECIOUS: %.elf
.PRECIOUS: %.host.pico
help:
@printf "\n"
@printf " #############################################################################\n"
@printf " # #\n"
@printf " # Welcome to the RSS2I project #\n"
@printf " # #\n"
@printf " #############################################################################\n"
@printf "\n"
@printf "\n"
@printf " Target overview\n"
@printf " ===============\n"
@printf "\n"
@printf " <firmware> Builds the specified <firmware>.\n"
@printf " flash-<firmware> Uploads <firmware> onto an RSS2I board.\n"
@printf " lookup-<lookup> Generates the lookup table <lookup>.\n"
@printf " lookup Generates all lookup tables.\n"
@printf " test-<test> Compiles (unit) test <test>.\n"
@printf " test Compiles all (unit) tests.\n"
@printf " runtest-<test> Runs the test <test>.\n"
@printf " runtest Runs all tests.\n"
@printf " lib<lib> Compiles the shared library <lib>.\n"
@printf " all Compiles all shared libraries.\n"
@printf " install-<lib> Installs the shared library <lib>.\n"
@printf " install-module Installs the RSS2I python module.\n"
@printf " install Installs the RSS2I python script together with\n"
@printf " all shared libraries and the python module.\n"
@printf " help Prints this information.\n"
@printf " uninstall Reverts installation.\n"
@printf " clean Removes all results of compilation.\n"
@printf "\n"
@printf " Options and Settings\n"
@printf " ====================\n"
@printf "\n"
@printf " V=1 Produces a verbose output during the build process.\n"
@printf " DEBUG=1 Enables the debug output via the serial debug port.\n"
@printf " BOARD_ID=id Forces the RSS2I board ID to be as specified.\n"
@printf " BOARD_REV=rev Forces the RSS2I board revision to be as specified:\n"
@printf " 0 -> Rev. A, 1 -> Rev. B, ...\n"
@printf " BOARD_TYPE=type Forces the RSS2I board type to be as specified:\n"
@printf " 0 -> onboard antenna, 1 -> external antenna, ...\n"
@printf " BOARD_BAT_THRESH=thresh Forces the board-specific ADC battery warning\n"
@printf " threshold to be as specified.\n"
@printf "\n"
@printf " Available substitutes\n"
@printf " =====================\n"
@printf "\n"
@printf " <firmware> files $(TARGETS)\n"
@printf " <lookup> tables $(LOOKUPS)\n"
@printf " shared <lib>raries $(PYLIB_TARGETS)\n"
@printf " (unit) <test>s $(TESTS)\n"
@printf "\n"
@printf " Configuration\n"
@printf " =============\n"
@printf "\n"
@printf " Installed binary $(INSTALLBIN)\n"
@printf " Python module path $(PYTHONPATH)\n"
@printf "\n"
# ------------------------------------------------------------------------------
# Process the given RSS2I board parameters :::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
# If there doesn't exist a board header file, create one.
# Warn the user, if there were board specific parameters specified.
# Update the board header file, if necessary.
warn-board-flag:
@printf " \n"
@printf " WARN You have specified an RSS2I board parameter. Therefore, the resulting\n"
@printf " firmware won't be able to detect that parameter automatically from\n"
@printf " the on-chip UICR (User Information Configuration Register).\n"
@printf " \n"
ifeq ($(wildcard $(BOARDFILE)),)
$(file > $(BOARDFILE),)
endif
ifneq ($(BOARD_ID)$(BOARD_REV)$(BOARD_TYPE)$(BOARD_BAT_THRESH),)
warn-flag: warn-board-flag
endif
$(file > $(BOARDFILE).tmp,/*)
$(file >> $(BOARDFILE).tmp, This file has been generated by the Makefile of the RSS2I project.)
$(file >> $(BOARDFILE).tmp,*/)
$(file >> $(BOARDFILE).tmp,)
ifneq ($(BOARD_ID),)
$(file >> $(BOARDFILE).tmp,#define BOARD_ID $(BOARD_ID))
endif
ifneq ($(BOARD_REV),)
$(file >> $(BOARDFILE).tmp,#define BOARD_REV $(BOARD_REV))
endif
ifneq ($(BOARD_TYPE),)
$(file >> $(BOARDFILE).tmp,#define BOARD_TYPE $(BOARD_TYPE))
endif
ifneq ($(BOARD_BAT_THRESH),)
$(file >> $(BOARDFILE).tmp,#define BOARD_BATTERY_THRESH $(BOARD_BAT_THRESH))
endif
ifneq ($(shell $(DIFF) $(BOARDFILE).tmp $(BOARDFILE)),)
$(shell $(MV) $(BOARDFILE).tmp $(BOARDFILE))
else
$(shell $(RM) $(BOARDFILE).tmp)
endif
# ------------------------------------------------------------------------------
# Process a given debug flag :::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
# If there doesn't exist a debug header file, create one.
# Warn the user, if the debug flag was specified.
# Update the debug header file, if necessary.
warn-debug-flag:
@printf " \n"
@printf " WARN RSS2I debug mode is unadvisable for production use.\n"
@printf " \n"
ifeq ($(wildcard $(DEBUGFILE)),)
$(file > $(DEBUGFILE),)
endif
$(file > $(DEBUGFILE).tmp,/*)
$(file >> $(DEBUGFILE).tmp, This file has been generated by the Makefile of the RSS2I project.)
$(file >> $(DEBUGFILE).tmp,*/)
$(file >> $(DEBUGFILE).tmp,)
ifneq ($(DEBUG),)
warn-flag: warn-debug-flag
$(file >> $(DEBUGFILE).tmp,#define DEBUG_MESSAGES_ENABLED $(DEBUG))
endif
ifneq ($(shell $(DIFF) $(DEBUGFILE).tmp $(DEBUGFILE)),)
$(shell $(MV) $(DEBUGFILE).tmp $(DEBUGFILE))
else
$(shell $(RM) $(DEBUGFILE).tmp)
endif
# ------------------------------------------------------------------------------
# Check for libopencm3 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
PATCHED_OPENCM3_FOUND := $(wildcard $(OPENCM3_DIR)/lib/*nrf5*.a)
ifneq ($(PATCHED_OPENCM3_FOUND),)
# The following will alter some variables
include $(OPENCM3_DIR)/mk/genlink-config.mk
else
$(warning nrf5lib seems to be not built yet. Try 'make' within its directory)
endif
# ------------------------------------------------------------------------------
# Include automatically generated dependencies :::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
-include $(addsuffix .d,$(TARGETS))
-include $(addprefix python/,$(addsuffix .d,$(TARGETS)))
-include $(OBJS:%.o=%.d)
-include $(PYLIB_OBJS:%.pico=%.d)
# ------------------------------------------------------------------------------
# Include libopencm3 linkerscript generator ::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
include $(OPENCM3_DIR)/mk/genlink-rules.mk
# ------------------------------------------------------------------------------
# General receipes :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
%.o: %.c
@printf " CC $@\n"
$(Q)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) $<
%.host.pico: %.c
@printf " XHOSTCC $@\n"
$(Q)$(XHOSTCC) -fpic -o $@ $(CFLAGS) $(CPPFLAGS) $<
%.host.o: %.c
@printf " HOSTCC $@\n"
$(Q)$(HOSTCC) -o $@ $(CFLAGS) $(HOSTCFLAGS) $(CPPFLAGS) $<
%.o: %.S
@printf " AS $@\n"
$(Q)$(AS) -o $@ $(ARCH_FLAGS) $(CPPFLAGS) $<
%.hex: %.elf
@printf " OBJCPY $@\n"
$(Q)$(OBJCPY) -O ihex $< $@
%.elf: %.o $(OBJS) $(LDSCRIPT)
@printf " LD $@\n"
$(Q)$(LD) -o $@ $(LDFLAGS) -T$(LDSCRIPT) $(ARCH_FLAGS) $< $(OBJS) $(LDLIBS)
$(PYTHONPATH)/rss2ipy/%.so: python/%.so
@printf " INSTALL $@\n"
$(Q)$(MKDIR) -p $(dir $@)
$(Q)$(CP) $< $@
python/lib%.so: python/%.host.pico $(PYLIB_OBJS)
@printf " XHOSTLD $@\n"
$(Q)$(XHOSTLD) -shared -o $@ $(CFLAGS) $(CPPFLAGS) $^
# ------------------------------------------------------------------------------
# Install/Uninstall ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
$(PYTHONPATH)/%: python/%
@printf " INSTALL $@\n"
$(Q)$(MKDIR) -p $(dir $@)
$(Q)$(CP) $< $@
$(INSTALLBIN): rss2i.py
@printf " INSTALL $@\n"
$(Q)$(MKDIR) -p $(dir $@)
$(Q)$(CP) $< $@
$(Q)$(CHMOD) a+x $@
install-module: $(addprefix $(PYTHONPATH)/rss2ipy/,$(PYTHON_MODULE_FILES))
install: install-module $(INSTALLBIN)
uninstall:
@printf " UNINST $(INSTALLBIN)\n"
$(Q)$(RM) $(INSTALLBIN)
@printf " UNINST $(PYTHONPATH)/rss2ipy\n"
$(Q)$(RM) $(PYTHONPATH)/rss2ipy
# ------------------------------------------------------------------------------
# Firmware template ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
define BIN_template =
.PHONY: clean-bin-$(1) $(1) flash-$(1)
$(1): warn-flag $(1).hex
flash-$(1): warn-flag $(1).hex
@printf " FLASH $(1) firmware -> $(DEVICE)\n"
$(Q)$(OOCD) -f $(OOCD_CFG) -c "program $(1).hex verify reset exit" $(NULL)
clean-bin-$(1):
@printf " CLEAN $(1).elf\n"
$(Q)$(RM) $(1).elf
@printf " CLEAN $(1).hex\n"
$(Q)$(RM) $(1).hex
@printf " CLEAN $(1).o\n"
$(Q)$(RM) $(1).o
@printf " CLEAN $(1).d\n"
$(Q)$(RM) $(1).d
clean: clean-bin-$(1)
endef
$(foreach TARGET,$(TARGETS),$(eval $(call BIN_template,$(TARGET))))
# ------------------------------------------------------------------------------
# Test template ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
define TEST_template =
.PHONY: clean-test-$(1) test-$(1) runtest-$(1) runtest-call-$(1)
-include test/$(1).host.d
-include src/$(1).host.d
test-$(1): test/$(1)
test/$(1): test/$(1).host.o src/$(1).host.o
@printf " HOSTLD $$@\n"
$(Q)$(HOSTLD) -o $$@ $(CFLAGS) $(HOSTCFLAGS) $(CPPFLAGS) $$^
# Add loookup dependency (if any)
ifneq ($(findstring $(1),$(LOOKUPS)),)
test/$(1): lookup/generated.crc.host.o
endif
runtest-call-$(1): test/$(1)
@printf " RUNTEST $(1)\n\n"
$(Q)./test/$(1)
@printf "\n"
runtest-$(1): runtest-call-$(1)
@printf " INFO Successfully run the test '$(1)'.\n\n"
clean-test-$(1):
@printf " CLEAN test/$(1)\n"
$(Q)$(RM) test/$(1)
@printf " CLEAN test/$(1).host.o\n"
$(Q)$(RM) test/$(1).host.o
@printf " CLEAN test/$(1).host.d\n"
$(Q)$(RM) test/$(1).host.d
@printf " CLEAN src/$(1).host.o\n"
$(Q)$(RM) src/$(1).host.o
@printf " CLEAN src/$(1).host.d\n"
$(Q)$(RM) src/$(1).host.d
ifneq ($(findstring $(1),$(LOOKUPS)),)
@printf " CLEAN lookup/generated.$(1).host.o\n"
$(Q)$(RM) lookup/generated.$(1).host.o
endif
clean: clean-test-$(1)
test: test-$(1)
runtest: runtest-$(1)
endef
$(foreach TEST,$(TESTS),$(eval $(call TEST_template,$(TEST))))
runtest:
@printf " INFO Successfully run all the tests.\n\n"
# ------------------------------------------------------------------------------
# Lookup template ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
define LOOKUP_template =
.PHONY: clean-lookup-$(1) lookup-$(1)
-include lookup/$(1).d
lookup-$(1): lookup/generated.$(1).c
lookup: lookup-$(1)
lookup/$(1): lookup/$(1).c
@printf " HOSTLD $$@\n"
$(Q)$(HOSTLD) -o $$@ $(CFLAGS) $(CPPFLAGS) $$< -lm
lookup/generated.$(1).c: lookup/$(1)
@printf " LOOKUP lookup/generated.$(1).c\n"
$(Q)./lookup/$(1) > lookup/generated.$(1).c
clean-lookup-$(1):
@printf " CLEAN lookup/generated.$(1).c\n"
$(Q)$(RM) lookup/generated.$(1).c
@printf " CLEAN lookup/$(1)\n"
$(Q)$(RM) lookup/$(1)
@printf " CLEAN lookup/$(1).d\n"
$(Q)$(RM) lookup/$(1).d
clean: clean-lookup-$(1)
endef
$(foreach LOOKUP,$(LOOKUPS),$(eval $(call LOOKUP_template,$(LOOKUP))))
# ------------------------------------------------------------------------------
# Shared library template ::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
define PYLIB_template =
.PHONY: clean-lib$(1) lib$(1) install-$(1)
install-$(1): $(PYTHONPATH)/rss2ipy/lib$(1).so
install: install-$(1)
lib$(1): python/lib$(1).so
all: lib$(1)
clean-lib$(1):
@printf " CLEAN python/lib$(1).so\n"
$(Q)$(RM) python/lib$(1).so
@printf " CLEAN python/$(1).host.pico\n"
$(Q)$(RM) python/$(1).host.pico
@printf " CLEAN python/$(1).d\n"
$(Q)$(RM) python/$(1).host.d
clean: clean-lib$(1)
endef
$(foreach PYLIB_TARGET,$(PYLIB_TARGETS),$(eval $(call PYLIB_template,$(PYLIB_TARGET))))
# ------------------------------------------------------------------------------
# Object template ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
define OBJ_template =
.PHONY: clean-$(1)
clean-$(1):
@printf " CLEAN $(1)\n"
$(Q)$(RM) $(1)
@printf " CLEAN $(1:%.o=%.d)\n"
$(Q)$(RM) $(1:%.o=%.d)
clean: clean-$(1)
endef
$(foreach OBJ,$(OBJS),$(eval $(call OBJ_template,$(OBJ))))
# ------------------------------------------------------------------------------
# Python object template :::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
define PYLIB_OBJ_template =
.PHONY: clean-$(1)
clean-$(1):
@printf " CLEAN $(1)\n"
$(Q)$(RM) $(1)
@printf " CLEAN $(1:%.o=%.d)\n"
$(Q)$(RM) $(1:%.pico=%.d)
clean: clean-$(1)
endef
$(foreach PYLIB_OBJ,$(PYLIB_OBJS),$(eval $(call PYLIB_OBJ_template,$(PYLIB_OBJ))))
# ------------------------------------------------------------------------------
# Clean up :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# ------------------------------------------------------------------------------
clean:
@printf " CLEAN $(DEBUGFILE)\n"
$(Q)$(RM) $(DEBUGFILE)
@printf " CLEAN $(BOARDFILE)\n"
$(Q)$(RM) $(BOARDFILE)
@printf " CLEAN $(LDSCRIPT)\n"
$(Q)$(RM) $(LDSCRIPT)
README.md 0 → 100644
# RSS2I Code
The RSS2I project aims to provide Bluetooth Low Energy (BLE) based low-cost
sensor devices that are capable of
field strength measurements inside complex mesh network topologies with high
sampling rates and low measurement uncertainties.
This is the RSS2I code project that holds the firmware sources and the
command line tool. The latter may be used to configure and control an RSS2I
device.
## Getting Started
### Installing the RSS2I command line tool
In order to install and run the RSS2I command line tool, a `python3`
installation and a host toolchain is needed. On
[Debian](https://www.debian.org/) based systems (such as
[Ubuntu](https://ubuntu.com/)) this is as easy as running
```sh
apt-get install gcc libc-dev make python3 python3-serial python3-numpy python3-matplotlib
```
with the appropriate rights.
After that, it is necessary to have a look onto the `Important settings`
section of the project's [Makefile](Makefile), in order to fit the binary names
to that ones of the build system (those ones will be probably fine) and to fit
the installation paths
to the desired ones (that is usually the only thing that needs to be done).
Once ready,
```sh
make all
```
will build the necessary shared library and
```sh
make install
```
will install the python script and the corresponding python package into the
system.
### User Documentation
There is no user documentation for the RSS2I command line tool yet.
Until it is available it may be helpful to run
```sh
rss2i --help
```
and
```sh
rss2i <command> --help
```
in order to get an overview about the tool. Note, that the used terminal
program must be able to interpret ANSI escape
sequences in order to get well formatted output in some cases.
### Firmware Development
In order to build the firmware, an ARM Cortex-M toolchain is needed as well as a
toolchain for the build host (for creating lookup tables, running unit tests,
etc.).
On [Debian](https://www.debian.org/) based systems these may be installed by
running
```sh
apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi gcc libc-dev make
```
with the appropriate rights.
Additionally, a copy of the [nrf5lib](../nrf5lib) is necessary.
In order to flash an RSS2I board, a Serial Wire Debug (SWD) programmer is
needed, e.g.
[Olimex ARM USB JTAG programmer](https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/) +
[Olimex SWD Adapter](https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-SWD/).
OpenOCD is recommended for flashing. On Debian based systems, running
```sh
apt-get install openocd
```
should be sufficient. Other debugging/programming tools
can be used but will need some changes in the project's [Makefile](Makefile).
The [openocd.cfg](openocd.cfg) file is preconfigured to work with the SWD
programmer
mentioned above. It needs to be fitted to the actual debugging hardware.
After that,
it is necessary to have a look onto the `Important settings`
section of the project's Makefile, in order to fit the binary names to that
one of the build system.
Once ready,
```sh
make <firmware>
```
will build the specified firmware and/or
```sh
make flash-<firmware>
```
will flash it onto an RSS2I device. Try
```sh
make help
```
in order to get an overview about the firmware development and the build
system.
### Firmware overview
There are different firmwares available:
* **device**: RSS2I standard firmware. Makes an RSS2I board to be an RSS2I device.
* **test**: Should be used after hardware manufacturing to test the functionality
of the system. The debug UART interface (available via the onboard debug pin header,
activateable via the `DEBUG=1` switch during compilation) provides useful information.
* **parameters**: Programs board-specific parameters (such as the board/device ID)
onto an RSS2I board.
* **memval**: Runs a full memory validation test. The debug UART interface
(mentioned above) provides useful information and progress status.
## Versioning
We use [SemVer](http://semver.org/) for versioning.
For the versions available, see the [tags on this repository](tags/).
## Authors
* **Gerrit Maus** - *Initial firmware development* -
[Communications Engineering](https://www.bsmk.uni-wuppertal.de/) within the
[School of Electrical, Information and Media Engineering](https://fk6.uni-wuppertal.de/) at the
[University of Wuppertal](https://uni-wuppertal.de) ([funk@maus.xyz](mailto:funk@maus.xyz)).
* **Knut Niemann** - *Initial command line tool development* -
[Communications Engineering](https://www.bsmk.uni-wuppertal.de/) within the
[School of Electrical, Information and Media Engineering](https://fk6.uni-wuppertal.de/) at the
[University of Wuppertal](https://uni-wuppertal.de) ([post@knut-niemann.de](mailto:post@knut-niemann.de)).
## License
This project is licensed under the GNU GPL v3.0+. See the [LICENSE.md](LICENSE.md) file for details.
device.c 0 → 100644
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
RSS2I device firmware.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-06-25 Initial public release.
Description
===========
An RSS2I board equipped with this firmware becomes a so called RSS2I device
that can be used for field strength measurements in nearly arbitrary mesh
network configurations.
It is highly configurable via the UART over USB interface. After power-up
the device enters the so called control mode. In this mode all configuration
settings may be modified or may be forwarded to other RSS2I devices.
*/
#include <rss2i/clock.h>
#include <rss2i/measure.h>
#include <rss2i/battery.h>
#include <rss2i/led.h>
#include <rss2i/debug.h>
#include <rss2i/control.h>
#include <rss2i/control.h>
#include <rss2i/icache.h>
#include <rss2i/power.h>
#include <rss2i/watchdog.h>
#include <rss2i/board.h>
#include <rss2i/radio.h>
#include <rss2i/spim.h>
#include <rss2i/mlc.h>
int main(){
led_init(); /* Controls the onboard LEDs. */
debug_init(); /* Debug and reporting system. */
board_init(); /* Holds board-specific parameters. */
power_init(); /* Enables the internal DC/DC regulator. */
clock_init(); /* Configures the High Frequency Clock (HFCLK). */
battery_init(); /* Monitors the battery voltage. */
mlc_init(); /* Monitors the main loop frequency. */
control_init(); /* Handles incoming commands. */
measure_init(); /* Enters control mode. */
watchdog_init(); /* Enables the watchdog. */
while(1){
watchdog_reset();
control_trigger();
measure_trigger();
radio_trigger();
spim_trigger();
debug_trigger();
mlc_trigger();
}
return 0;
}
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Battery monitoring. Further documentation may be found in the corresponding
source file.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-06-24 Initial public release.
*/
#include <stdint.h>
uint8_t battery_get_level(void);
uint16_t battery_get_value(void);
void battery_init(void);
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Holds BLE 5.0 Uncoded PHY compatible Access Addresses. Further documentation
may be found in the corresponding source file.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-05-27 Initial release.
*/
#include <stdint.h>
uint32_t ble_gen_control_access_address(uint8_t devID);
uint32_t ble_gen_measure_access_address(void);
uint32_t ble_gen_disrupt_access_address(void);
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Set and get board-specific parameters to/from the non-volatile User
Information Configuration Registers (UICR). Further documentation may be
found in the corresponding source file.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-04-11 Initial release.
2019-06-03 Added {BOARD_PARAMS_REV} and {BOARD_PARAMS_TYPE}.
2019-06-24 Added {BOARD_BATTERY_THRESH}.
*/
#include <stdint.h>
#include <stdbool.h>
#include <rss2i/config/generated.board.h>
#ifdef BOARD_ID
#if BOARD_ID <= 0 || BOARD_ID >= 252
#error "Invalid RSS2I board ID specified."
#endif
#endif
#ifdef BOARD_TYPE
#if BOARD_TYPE > 1
#error "Invalid RSS2I board type specified."
#endif
#endif
#ifdef BOARD_REV
#if BOARD_REV > 25
#error "Invalid RSS2I board revision specified."
#endif
#endif
#ifdef BOARD_BATTERY_THRESH
#if BOARD_BYTTER_THRESH > 1023
#error "Invalid RSS2I board battery threshold specified."
#endif
#endif
uint8_t board_id(void);
uint8_t board_type(void);
uint8_t board_rev(void);
uint16_t board_battery_threshold(void);
bool board_store_params(uint8_t id,
uint8_t rev,
uint8_t type,
uint16_t batteryThresh);
void board_init(void);
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Thread safe (one producer, one consumer) circular buffers. Further
documentation may be found in the corresponding source file.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2018-07-17 Initial release.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
typedef enum{
BUFFER_ROW,
BUFFER_STRING,
} BufferDataType;
typedef union{
/*
Type for storing an array in memory with different interfaces to the user.
*/
volatile char * c;
volatile uint8_t * u;
} BufferDataPtr;
typedef struct{
/*
Type describing a circular buffer of arrays. The function <buffer_init()>
should be used to initialise it. The other functions <buffer_*()> should be
used to handle it. Its members should never be accessed directly.
*/
volatile size_t length;
volatile size_t width;
volatile BufferDataPtr dataPtr;
volatile size_t * size;
volatile size_t writePointer;
volatile size_t readPointer;
volatile size_t lockPointer;
volatile bool empty;
} Buffer;
void buffer_init_rows(Buffer * buffer, uint8_t * memory, size_t * size, size_t length, size_t width);
void buffer_init_strings(Buffer * buffer, char * memory, size_t * size, size_t length, size_t width);
void buffer_init(Buffer * buffer, BufferDataPtr dataPtr, size_t * size, size_t length, size_t width);
bool buffer_append_row(Buffer * buffer, uint8_t * row, size_t size);
bool buffer_append_string(Buffer * buffer, const char * string);
BufferDataPtr buffer_get(Buffer * buffer, BufferDataType);
uint8_t * buffer_get_row(Buffer * buffer);
char * buffer_get_string(Buffer * buffer);
void buffer_unlock(Buffer * buffer);
size_t buffer_next_size(Buffer * buffer);
void buffer_empty(Buffer * buffer);
size_t buffer_vacant_entries(Buffer * buffer);
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Selects the external crystal oscillator as source for the high frequency
clock (HFCLK). More documentation may be found in the corresponding source
file.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-04-12 Initial release.
*/
void clock_init(void);
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Process incoming commands. Further documentation may be found in the
corresponding source file.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-04-16 Initial public release.
2019-05-29 Added support for iterable commands.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#define CMD_MAX_LENGTH 260
#define CMD_MAX_RESPONSE_LENGTH 300
typedef enum {
/* 0x00 */ CMD_TELL_ME_WHO_YOU_ARE,
/* 0x01 */ CMD_SET_BAUDRATE,
/* 0x02 */ CMD_SET_PREFERENCES,
/* 0x03 */ CMD_RETURN_MEASUREMENT_SESSION_DATA,
/* 0x04 */ CMD_RETURN_CONTENT_OF_SPECIFIED_PAGE,
/* 0x05 */ CMD_RETURN_CONTENT_OF_SPECIFIED_PAGES,
/* 0x06 */ CMD_RETURN_CONTENT_OF_ABSOLUTE_PAGE,
/* 0x07 */ CMD_RETURN_CONTENT_OF_ABSOLUTE_PAGES,
/* 0x08 */ CMD_SET_LIVE_LOG_CONFIGURATION,
/* 0x09 */ CMD_START_LIVE_LOG,
/* 0x0a */ CMD_STOP_LIVE_LOG,
/* 0x0b */ CMD_ENTER_CONTROL_MODE,
/* 0x0c */ CMD_FORCE_CONTROL_MODE,
/* 0x0d */ CMD_JUMP_ON_MEASUREMENT,
/* 0x0e */ CMD_START_UP_MEASUREMENT,
/* 0x0f */ CMD_RESERVED_0x0f,
/* 0x10 */ CMD_SET_MEASUREMENT_CONFIGURATION,
/* 0x11 */ CMD_SET_SYNCHRONIZATION_MAP,
/* 0x12 */ CMD_SET_POOR_SYNC_THRESHOLDS,
/* 0x13 */ CMD_SET_OUT_OF_SYNC_THRESHOLDS,
/* 0x14 */ CMD_SET_REMOTE_RSS_INPUT_MAP,
/* 0x15 */ CMD_SET_REMOTE_RSS_OUTPUT_MAP,
CMD_ALWAYS_LAST_ITEM,
} CMDNames;
typedef struct{
size_t length; /* Command's length. */
size_t responseLength; /* Response's length. */
bool targetFieldPresent; /* Whether a target field is present or not. */
bool responseExpected; /* Whether a response is expected or not. */
bool isIterable; /* Whether this command is iterable or not. */
size_t timeoutLength; /* Number of bytes specified below. The missing */
/* bytes of the response may have arbitrary */
/* values. */
uint8_t * timeoutData; /* First few bytes of the response in the case */
/* of a RADIO timeout. */
size_t busyLength; /* Number of bytes specified below. The missing */
/* bytes of the response may have arbitrary */
/* values. */
uint8_t * busyData; /* First few bytes of the response in the case */
/* that a command should be forwarded over-the- */
/* air but the forwarding device is not in */
/* control mode yet. */
} CMD;
uint8_t cmd_is_iterable(uint8_t * cmd);
void cmd_iterate(uint8_t * cmd);
bool cmd_handle(uint8_t * cmd);
void cmd_timeout_response(uint8_t cmd, uint8_t * response);
void cmd_busy_response(uint8_t cmd, uint8_t * response);
void cmd_init(void);
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Some settings regarding the battery monitoring.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-07-02 Initial public release.
*/
/* Frequency of battery measurement in 1/10 Hz. */
#define BATTERY_FREQUENCY 10
/* Number of measurements that have to be below the board-specific battery */
/* threshold (see board.c), before a battery warning is reported. */
#define BATTERY_ITERATIONS 10
/* Reset the low thresh counter (see above), if the battery measurement is */
/* {BATTERY_THRESHOLD_DIFF} higher than the board-specific battery threshold. */
#define BATTERY_THRESHOLD_DIFF 10
/* Auto calibration period in multiples of battery measurements. */
#define BATTERY_CALIBRATION_PERIOD 100
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Some settings regarding the command handling.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-07-02 Initial public release.
*/
/*
Some settings that affect the Over-The-Air (OTA) command forwarding.
*/
/* USB receive/reset timeout in ms. */
#define CONTROL_USB_RECV_TIMEOUT 200
/* Maximum number of tries for an over-the-air request (default value). */
#define CONTROL_OTA_TRIES 10
/* Over-the-air timeout in ms. A value of {5} may be fine. */
/* A value of {10} should be safe. */
#define CONTROL_OTA_TIMEOUT 10
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Some settings regarding the CRC generation.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-07-02 Initial public release.
*/
/*
32bit CRC polynomial used for memory verification and USB communication.
Changes should be adopted into the USB documentation.
*/
/*
This polynomial is represented in 'explicit +1' noation ('implicit 32bit'
notation) and equals the polynomial {0x992c1a4c} in 'implicit +1' notation.
Credits go to Philip Koopman, Carnegie Mellon University, who published this
polynomial on his website (http://users.ece.cmu.edu/~koopman/crc/) licensed
under a Creative Commons Attribution 4.0 International License
(http://creativecommons.org/licenses/by/4.0/).
*/
#define CRC_POLYNOMIAL 0x32583499
#define CRC_START_VALUE 0xffffffff
#define CRC_FINAL_XOR 0xffffffff
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Some settings regarding the dubug module.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-07-02 Initial public release.
*/
/*
Some settings that affect the serial debug output.
*/
/* Pause between repeated error/warning messages in multiples of ~4 µs. */
#define DEBUG_REPETITION_DELAY 400000
/* Buffer dimensions */
#define DEBUG_BUFFER_LENGTH 64
#define DEBUG_BUFFER_WIDTH 110
/* Debug baudrate. This shouldn't be too high since this is a software UART. */
#define DEBUG_BAUDRATE 9600
/*
Switch for debugging measurement frames.
{0}: Disabled.
{1}: {DEBUG_MEASUREMENT_FRAME_GPIO} pin gets toggled at the beginning of
every frame. This is useful in order to measure the exact frame length
with a scope, e.g. when trying to fit {MEASURE_NEGATIVE_TX_DELAY}.
{2}: {DEBUG_MEASUREMENT_FRAME_GPIO} pin gets toggled multiple times during
a frame. This allows precise debugging of the internal schedule
management and the RADIO timings.
GPIO behaviour when sending a measurement packet:
Transmission successfull. --.
|
.-- Frame's beginning. |
| |
| .-- Prepare transmission. |
| | |
| | .-- Start transmission. |
| | | |
_ _ ___________________ _ _
| | | | | | | | | |
| | | | | | | | | |
_| |_| |____| |_| |_____________________| |________
GPIO behaviour when receiving/trying to receive a measurement packet:
Optional: Successfully received. --.
The receiver now synchronizes |
himself to this event. |
|
|
.-- Frame's beginning. |
| |
| .-- Prepare reception. |
| | |
| | .-- Ready to receive. |
| | | |
_ _ ________ _
| | | | | | | |
| | | | | | | |
_| |_| |____| |____________________________________| |________
*/
#define DEBUG_MEASUREMENT_FRAME 0
#define DEBUG_MEASUREMENT_FRAME_GPIO GPIO6
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Some settings regarding the behaviour of the onboard LEDs.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-07-02 Initial public release.
*/
/* PWM counter top values, i.e. the maximal brightness, for each LED. */
#define PWM_TOP_RED 1500
#define PWM_TOP_YELLOW 2800
#define PWM_TOP_GREEN 4095
/* Duration of the time slot for a single LED in ms */
#define LED_SLOT_DURATION 800
/* Time in ms between two neighboring (and (maybe) overlapping) slots. */
#define LED_SLOT_OFFSET 150
/* Pause in ms after the three LED slots got triggered. */
#define LED_SLOT_PAUSE 1200
/* Number of values within the rising part of one PWM sequence. */
/* Correlates with the dimming resolution. */
#define PWM_CYCLES 30
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Some settings regarding the RSS measurements.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-07-02 Initial public release.
Measurement frame timing and its nomenclature
=============================================
.-- Frame's begin: Disable the RADIO.
|
| .-- Prepare the RADIO for the upcoming task.
| |
| | .-- Trigger the transmission of a
| | | measurement packet. Due to processing
| | | time, this happens slightly before the
| | | actual transmission's start.
| | |
_________ _______________ __________ __________________________ __________
| | | | | |
| Disable | Ramp up | Guard | Measurement | Guard |
| RADIO | RADIO | Interval | packet | Interval |
|_________|_______________|__________|__________________________|__________|
|---| |
| |
Negative TX dealy. --' |
|
This is the synchronization's fixed point. --'
*/
/*
Frame timings.
*/
#define MEASURE_FRAME_LENGTH 200 /* µs */
#define MEASURE_RADIO_RAMP_UP_TIME 40 /* µs */
#define MEASURE_RADIO_DISABLE_TIME 10 /* µs */
#define MEASURE_PACKET_LENGTH 100 /* µs */
#define MEASURE_GUARD_INTERVAL_LENGTH 25 /* µs */
#define MEASURE_TX_NEGATIVE_DELAY 122 /* 1/16 µs */
/*
Buffer dimensions for caching measurement results.
*/
#define MEASURE_BUFFER_LENGTH 32
#define MEASURE_BUFFER_WIDTH 17
/* Default frequency for resynchonization. Used when this device */
/* has no passive part within a measurement condiguration. */
#define MEASURE_DEFAULT_FREQUENCY 17 /* + 2400 MHz */
/*
Maximal number of frames within a measurement cycle. This value must not
exceed {250} and should be at least {5}. Changing this value affects the valid
ranges described in the user documentation but may save some RAM space.
*/
#define MEASURE_MAX_FRAME_COUNT 250
/*
Approximate minimal number of disruptive frames that get sent when trying
to force other divices into control mode. This is useful in order to avoid
quitting the disrupting process to early e.g. when a remote device still
sends measurement packets who wasn't received correctly due to temporary
noise or other pertubations.
Note, that changing this value affects the timings of the force-control-mode
command.
*/
#define MEASURE_MIN_DISRUPT_FRAMES 10000
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Some settings regarding the Main Loop Counter (MLC).
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-07-02 Initial public release.
*/
/* Monitoring period in ms. */
#define MLC_PERIOD 1000
/*
This file is part of the RSS2I project licensed under the GNU GPL v3.0+
*/
/*
Some settings regarding the RADIO module.
Authors
=======
Copyright (C) 2018-2019 Gerrit Maus (funk@maus.xyz)
License
=======
This firmware 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 3 of the License, or (at your option)
any later version.
This firmware 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
this firmware. If not, see <https://www.gnu.org/licenses/>.
Changelog
=========
2019-07-02 Initial public release.
*/
/*
Some settings that affect the RSS measurements.
*/
/* Default RADIO TX power. */
#define RADIO_TX_POWER 3 /* 3 -> 0 dBm */
/* Something like the RSS sampling period. The lower this value the */
/* more RSSI samples are taken within one measurment packet. An extremly low */
/* value may lead to a system freeze. A value of {8} is recommended. */
#define RADIO_RSSI_SAMPLE_PERIOD 8
/* Length of a measurement packet's payload in bytes. */
/* This should be compatible with the measurement frame timings. */
#define RADIO_MEASURE_PAYLOAD_LENGTH 14
/*
Some settings that affect the OTA transmission/reception.
*/
/* Maximal OTA message size (PAYLOAD + S0) receivable by the RADIO */
/* peripheral. Extra size for USB-CRC bytes that may be added later on. */
#define RADIO_OTA_RECV_BUFFER_WIDTH (256 + 4)
/* Maximal OTA message size (PAYLOAD + S0) the RADIO peripheral may send. */
/* Extra size for storing the targeted device inside the output buffer. */
/* Extra size for the length field inside the RADIO packet. */
#define RADIO_OTA_SEND_BUFFER_WIDTH (256 + 1 + 1)
/* Buffer dimensions. */
#define RADIO_OTA_RECV_BUFFER_LENGTH 8
#define RADIO_OTA_SEND_BUFFER_LENGTH 4
/* Affects the LED behaviour: The lower this value the */
/* faster the LED gets disabled after an OTA event. */
#define RADIO_LED_TIMEOUT 60000
/* Default OTA frequency. */
#define RADIO_CONTROL_FREQUENCY 9 /* + 2400 [MHz] */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment