Merge remote-tracking branch 'origin/master' into Development

Conflicts:
	tracker/software/make/pp10b.make
	tracker/software/source/config/config.c
webcam_dev
bob 2018-08-16 10:02:00 +10:00
commit 5f0e5a4833
21 zmienionych plików z 775 dodań i 514 usunięć

Wyświetl plik

@ -294,7 +294,18 @@ function time_format(time) {
}
function get_alt(p) {
return '---'; // TODO: Implement pressure to altitude calculation
var p_height;
p = p / 100; // convert pascal to millibar
if (p >= 226.32) {
p_height = 44330.8 * (1.0 - Math.exp(Math.log(p / 1013.25) * 0.190263));
}
if (p < 226.32 && p > 54.749) {
p_height = 11000 - 6341.624 * Math.log(p / 226.3202);
}
if (p <= 54.749) {
p_height = 20000 + 216650 * (Math.exp(Math.log(p / 54.749) * -0.0292173) -1.0);
}
return p_height;
}
function updateData() {

Wyświetl plik

@ -16,7 +16,7 @@ int main(void) {
pktConfigureCoreIO();
/* Setup the mutex for trace output. */
//DEBUG_INIT();
debug_init();
#if ACTIVATE_CONSOLE
/* Start console. */
@ -33,7 +33,7 @@ int main(void) {
chDbgAssert(pkt == true, "failed to init packet system");
/* Start serial debug channel(s) if selected. */
pktSerialStart();
//pktSerialStart();
/*
* Create a packet radio service.

Wyświetl plik

@ -1,243 +1,243 @@
##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
USE_COPT = -std=c11
endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -fno-rtti
endif
# Enable this if you want the linker to remove unused code and data
ifeq ($(USE_LINK_GC),)
USE_LINK_GC = yes
endif
# Linker extra moptions here.
ifeq ($(USE_LDOPT),)
USE_LDOPT =
endif
# Enable this if you want link time optimizations (LTO)
ifeq ($(USE_LTO),)
USE_LTO = yes
endif
# If enabled, this option allows to compile the application in THUMB mode.
ifeq ($(USE_THUMB),)
USE_THUMB = yes
endif
# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
USE_VERBOSE_COMPILE = no
endif
# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
USE_SMART_BUILD = yes
endif
#
# Build global options
##############################################################################
##############################################################################
# Architecture or project specific options
#
# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
USE_PROCESS_STACKSIZE = 0x1000
endif
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
USE_EXCEPTIONS_STACKSIZE = 0x5000
endif
# Enables the use of FPU (no, softfp, hard).
ifeq ($(USE_FPU),)
USE_FPU = hard
USE_FPU_OPT = -mfloat-abi=$(USE_FPU) \
-mfpu=fpv4-sp-d16 -fsingle-precision-constant
endif
#
# Architecture or project specific options
##############################################################################
##############################################################################
# Project, sources and paths
#
# Define project name here
PROJECT = pp10a
# Imported source files and paths
CHIBIOS = ChibiOS
CONFDIR := ${CURDIR}/cfg/$(PROJECT)
BUILDDIR := ${CURDIR}/build/$(PROJECT)
DEPDIR := ${CURDIR}/.dep/$(PROJECT)
CMSISINC = ${CURDIR}/CMSIS/include
CMSISLIB = ${CURDIR}/CMSIS/Lib/GCC
# ChibiOS versions of system calls
ALLCSRC := $(CHIBIOS)/os/various/syscalls.c
# Licensing files.
include $(CHIBIOS)/os/license/license.mk
# Startup files.
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
# BOARD files.
include $(CONFDIR)/board/board.mk
# PORTAB files.
include $(CONFDIR)/portab.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Auto-build files in AUTOBUILD_ROOT recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional).
include $(CHIBIOS)/test/lib/test.mk
include $(CHIBIOS)/test/rt/rt_test.mk
include $(CHIBIOS)/test/oslib/oslib_test.mk
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
include $(CHIBIOS)/os/various/shell/shell.mk
include $(CHIBIOS)/os/various/fatfs_bindings/fatfs.mk
# Define linker script file here
LDSCRIPT= $(CONFDIR)/STM32F413xH.ld
#$(info $$ALLCSRC is [${ALLCSRC}])
#$(info $$CONFDIR is [${CONFDIR}])
#$(info $$ALLINC is [${ALLINC}])
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(ALLCSRC) \
$(TESTSRC) \
main.c \
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(ALLCPPSRC)
# C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
ACSRC =
# C++ sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
ACPPSRC =
# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
TCSRC =
# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
TCPPSRC =
# List ASM source files here
ASMSRC = $(ALLASMSRC)
ASMXSRC = $(ALLXASMSRC)
INCDIR = $(ALLINC) $(TESTINC)
#$(info $$INCDIR is [${INCDIR}])
#
# Project, sources and paths
##############################################################################
##############################################################################
# Compiler settings
#
MCU = cortex-m4
#TRGT = arm-elf-
TRGT = arm-none-eabi-
CC = $(TRGT)gcc
CPPC = $(TRGT)g++
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
# runtime support makes code size explode.
LD = $(TRGT)gcc
#LD = $(TRGT)g++
CP = $(TRGT)objcopy
AS = $(TRGT)gcc -x assembler-with-cpp
AR = $(TRGT)ar
OD = $(TRGT)objdump
SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# ARM-specific options here
AOPT =
# THUMB-specific options here
TOPT = -mthumb -DTHUMB
# Define C warning options here
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
# Define C++ warning options here
CPPWARN = -Wall -Wextra -Wundef
#
# Compiler settings
##############################################################################
##############################################################################
# Start of user section
#
# List all user C define here, like -D_DEBUG=1
UDEFS = -D_GNU_SOURCE -DARM_MATH_CM4 -DSHELL_CMD_TEST_ENABLED=0 \
-DSHELL_CMD_EXIT_ENABLED=1 -DUSB_TRACE_LEVEL=5 \
-DSHELL_CMD_MEM_ENABLED=0
# -DDISABLE_HW_WATCHDOG=1
# Define ASM defines here
UADEFS =
# List all user directories here
UINCDIR = $(CMSISINC)
# List the user directory to look for the libraries here
ULIBDIR = $(CMSISLIB)
# List all user libraries here
ULIBS = -lm $(CMSISLIB)/libarm_cortexM4l_math.a
#
# End of user defines
##############################################################################
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
include $(RULESPATH)/rules.mk
burn-$(PROJECT):
st-flash write build/$(PROJECT)/$(PROJECT).bin 0x08000000
##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
USE_COPT = -std=c11
endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -fno-rtti
endif
# Enable this if you want the linker to remove unused code and data
ifeq ($(USE_LINK_GC),)
USE_LINK_GC = yes
endif
# Linker extra moptions here.
ifeq ($(USE_LDOPT),)
USE_LDOPT =
endif
# Enable this if you want link time optimizations (LTO)
ifeq ($(USE_LTO),)
USE_LTO = yes
endif
# If enabled, this option allows to compile the application in THUMB mode.
ifeq ($(USE_THUMB),)
USE_THUMB = yes
endif
# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
USE_VERBOSE_COMPILE = no
endif
# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
USE_SMART_BUILD = yes
endif
#
# Build global options
##############################################################################
##############################################################################
# Architecture or project specific options
#
# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
USE_PROCESS_STACKSIZE = 0x1000
endif
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
USE_EXCEPTIONS_STACKSIZE = 0x5000
endif
# Enables the use of FPU (no, softfp, hard).
ifeq ($(USE_FPU),)
USE_FPU = hard
USE_FPU_OPT = -mfloat-abi=$(USE_FPU) \
-mfpu=fpv4-sp-d16 -fsingle-precision-constant
endif
#
# Architecture or project specific options
##############################################################################
##############################################################################
# Project, sources and paths
#
# Define project name here
PROJECT = pp10a
# Imported source files and paths
CHIBIOS = ChibiOS
CONFDIR := ${CURDIR}/cfg/$(PROJECT)
BUILDDIR := ${CURDIR}/build/$(PROJECT)
DEPDIR := ${CURDIR}/.dep/$(PROJECT)
CMSISINC = ${CURDIR}/CMSIS/include
CMSISLIB = ${CURDIR}/CMSIS/Lib/GCC
# ChibiOS versions of system calls
ALLCSRC := $(CHIBIOS)/os/various/syscalls.c
# Licensing files.
include $(CHIBIOS)/os/license/license.mk
# Startup files.
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
# BOARD files.
include $(CONFDIR)/board/board.mk
# PORTAB files.
include $(CONFDIR)/portab.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Auto-build files in AUTOBUILD_ROOT recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional).
include $(CHIBIOS)/test/lib/test.mk
include $(CHIBIOS)/test/rt/rt_test.mk
include $(CHIBIOS)/test/oslib/oslib_test.mk
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
include $(CHIBIOS)/os/various/shell/shell.mk
include $(CHIBIOS)/os/various/fatfs_bindings/fatfs.mk
# Define linker script file here
LDSCRIPT= $(CONFDIR)/STM32F413xH.ld
#$(info $$ALLCSRC is [${ALLCSRC}])
#$(info $$CONFDIR is [${CONFDIR}])
#$(info $$ALLINC is [${ALLINC}])
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(ALLCSRC) \
$(TESTSRC) \
main.c \
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(ALLCPPSRC)
# C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
ACSRC =
# C++ sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
ACPPSRC =
# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
TCSRC =
# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
TCPPSRC =
# List ASM source files here
ASMSRC = $(ALLASMSRC)
ASMXSRC = $(ALLXASMSRC)
INCDIR = $(ALLINC) $(TESTINC)
#$(info $$INCDIR is [${INCDIR}])
#
# Project, sources and paths
##############################################################################
##############################################################################
# Compiler settings
#
MCU = cortex-m4
#TRGT = arm-elf-
TRGT = arm-none-eabi-
CC = $(TRGT)gcc
CPPC = $(TRGT)g++
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
# runtime support makes code size explode.
LD = $(TRGT)gcc
#LD = $(TRGT)g++
CP = $(TRGT)objcopy
AS = $(TRGT)gcc -x assembler-with-cpp
AR = $(TRGT)ar
OD = $(TRGT)objdump
SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# ARM-specific options here
AOPT =
# THUMB-specific options here
TOPT = -mthumb -DTHUMB
# Define C warning options here
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
# Define C++ warning options here
CPPWARN = -Wall -Wextra -Wundef
#
# Compiler settings
##############################################################################
##############################################################################
# Start of user section
#
# List all user C define here, like -D_DEBUG=1
UDEFS = -D_GNU_SOURCE -DARM_MATH_CM4 -DSHELL_CMD_TEST_ENABLED=0 \
-DSHELL_CMD_EXIT_ENABLED=1 -DUSB_TRACE_LEVEL=5 \
-DSHELL_CMD_MEM_ENABLED=0
# -DDISABLE_HW_WATCHDOG=1
# Define ASM defines here
UADEFS =
# List all user directories here
UINCDIR = $(CMSISINC)
# List the user directory to look for the libraries here
ULIBDIR = $(CMSISLIB)
# List all user libraries here
ULIBS = -lm $(CMSISLIB)/libarm_cortexM4l_math.a
#
# End of user defines
##############################################################################
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
include $(RULESPATH)/rules.mk
burn-$(PROJECT):
st-flash write build/$(PROJECT)/$(PROJECT).bin 0x08000000

Wyświetl plik

@ -239,4 +239,4 @@ include $(RULESPATH)/rules.mk
burn-$(PROJECT):
st-flash write build/$(PROJECT)/$(PROJECT).bin 0x08000000

Wyświetl plik

@ -0,0 +1,197 @@
/**
* Put your configuration settings here. See description of all fields in types.h
*/
#include "config.h"
#include "aprs.h"
#include "geofence.h"
conf_t conf_sram;
const conf_t conf_flash_default = {
// Primary position app
.pos_pri = {
.beacon = {
.active = false,
.cycle = TIME_S2I(60 * 5),
.init_delay = TIME_S2I(60),
.fixed = false // Add lat, lon, alt fields when enabling fixed
},
.radio_conf = {
.pwr = 0x1F,
.freq = 144860000,
.mod = MOD_2FSK,
.cca = 0x4F,
},
// App identity
.call = "DL0CPS-11",
.path = "WIDE1-1",
.symbol = SYM_BALLOON,
.aprs_msg = true, // Enable APRS message reception on this app
},
// Secondary position app
.pos_sec = {
.beacon = {
.active = false,
.cycle = TIME_S2I(60 * 30), // Beacon interval
.init_delay = TIME_S2I(60),
.fixed = true, // Add lat, lon alt fields when enabling fixed
.lat = -337331175, // Degrees (expressed in 1e-7 form)
.lon = 1511143478, // Degrees (expressed in 1e-7 form)
.alt = 144 // Altitude in metres
},
.radio_conf = {
.pwr = 0x7F,
.freq = FREQ_APRS_RECEIVE,
.mod = MOD_AFSK,
.cca = 0x4F
},
// App identity
.call = "DL0CPS-5",
.path = "WIDE2-1",
.symbol = SYM_DIGIPEATER,
.aprs_msg = false, // Enable APRS message reception on this app
},
// Primary image app
.img_pri = {
.svc_conf = {
.active = false,
.cycle = TIME_S2I(60 * 5),
.init_delay = TIME_S2I(60 * 1),
.send_spacing = TIME_S2I(5)
},
.radio_conf = {
.pwr = 0x7F,
.freq = 144860000,
.mod = MOD_2FSK,
.cca = 0x4F
},
// App identity
.call = "DL0CPS-15",
.path = "",
// Image settings
.res = RES_VGA,
.quality = 4,
.buf_size = 40 * 1024,
.redundantTx = false
},
// Secondary image app
.img_sec = {
.svc_conf = {
.active = false,
.cycle = TIME_S2I(60 * 15),
.init_delay = TIME_S2I(15 * 1),
.send_spacing = TIME_S2I(2)
},
.radio_conf = {
.pwr = 0x1F,
.freq = 144860000,
.mod = MOD_2FSK,
.cca = 0x4F
},
// App identity
.call = "DL0CPS-12",
.path = "",
// Image settings
.res = RES_QVGA,
.quality = 4,
.buf_size = 15 * 1024,
.redundantTx = false
},
// Log app
.log = {
.svc_conf = {
.active = false,
.cycle = TIME_S2I(10),
.init_delay = TIME_S2I(5)
},
.radio_conf = {
.pwr = 0x7F,
.freq = 144860000,
.mod = MOD_2FSK,
.cca = 0x4F
},
// Node identity
.call = "DL0CPS-11",
.path = "WIDE1-1",
.density = 10
},
// APRS app
.aprs = {
// The receive identity for APRS
.rx = {
.svc_conf = {
// The packet receive service is enabled if true
// Receive is paused and resumed by transmission
.active = true,
.init_delay = TIME_S2I(20)
},
// Receive radio configuration
.radio_conf = {
.freq = 144840000,
.mod = MOD_AFSK,
.rssi = 0x3F
},
// APRS identity used in message responses if digipeat is not enabled
.call = "DL0CPS-4",
.symbol = SYM_ANTENNA
},
.aprs_msg = false, // Set true to enable messages to be accepted on RX call sign
.digi = true,
.tx = {
// Transmit radio configuration
.radio_conf = {
.freq = FREQ_APRS_RECEIVE,
.pwr = 0x7F,
.mod = MOD_AFSK,
.cca = 0x4F
},
// Digipeat transmission identity
.call = "VK2GJ-5",
.path = "WIDE2-1",
.symbol = SYM_DIGIPEATER,
// A digipeater beacon can be added using one of the POS apps
// Set the POS identity the same as the dipipeater TX identity
// Alternatively the digipeater can have its own .beacon entry here
},
},
// Global controls
// Power control
.keep_cam_switched_on = false,
.gps_on_vbat = 3600, // mV
.gps_off_vbat = 3400, // mV
.gps_onper_vbat = 4000, // mV
// GPS altitude model control (air pressure controlled using on-board BME280)
.gps_pressure = 90000, // Air pressure (Pa) threshold for alt model switch
.gps_low_alt = GPS_STATIONARY,
.gps_high_alt = GPS_AIRBORNE_1G,
// APRS
// How often to send telemetry config (global for beacons)
.tel_enc_cycle = TIME_S2I(60 * 60 * 2),
// The default APRS frequency when geofence is not resolved
.freq = 144860000,
// The base station identity.
.base = {
// If enabled tracker initiated APRS messages are addressed to this call sign
.enabled = true,
.call = "DL0CPS-7",
.path = "WIDE2-1",
},
.magic = CONFIG_MAGIC_DEFAULT // Do not remove. This is the activation bit.
};

Wyświetl plik

@ -48,7 +48,7 @@ const conf_t conf_flash_default = {
.mod = MOD_AFSK,
.cca = 0x4F
},
// App identity
// App identity
.call = "VK2GJ-5",
.path = "WIDE2-1",
.symbol = SYM_DIGIPEATER,
@ -65,8 +65,8 @@ const conf_t conf_flash_default = {
},
.radio_conf = {
.pwr = 0x7F,
.freq = FREQ_GEOFENCE,
.mod = MOD_AFSK,
.freq = 144860000,
.mod = MOD_2FSK,
.cca = 0x5F
},
@ -75,7 +75,7 @@ const conf_t conf_flash_default = {
.path = "",
// Image settings
.res = RES_QVGA,
.res = RES_VGA,
.quality = 4,
.buf_size = 50 * 1024,
.redundantTx = false
@ -85,15 +85,15 @@ const conf_t conf_flash_default = {
.img_sec = {
.svc_conf = {
.active = false,
.cycle = TIME_S2I(60 * 5),
.init_delay = TIME_S2I(15 * 1),
.send_spacing = TIME_S2I(2)
.cycle = CYCLE_CONTINUOUSLY,
.init_delay = TIME_S2I(60),
.send_spacing = TIME_S2I(10)
},
.radio_conf = {
.pwr = 0x1F,
.freq = FREQ_APRS_AUSTRALIA,
.mod = MOD_AFSK,
.cca = 0x4F
.pwr = 0x7F,
.freq = 144860000,
.mod = MOD_2FSK,
.cca = 0x5F
},
// App identity
.call = "VK2GJ-12",
@ -139,9 +139,9 @@ const conf_t conf_flash_default = {
.radio_conf = {
.freq = FREQ_APRS_AUSTRALIA,
.mod = MOD_AFSK,
.rssi = 0x3F
.rssi = 0x5F
},
// APRS identity used in message responses if digipeat is not enabled
// APRS identity used in message responses if digipeat is not enabled
.call = "VK2GJ-4",
.symbol = SYM_ANTENNA
},
@ -153,7 +153,7 @@ const conf_t conf_flash_default = {
.freq = FREQ_RX_APRS,
.pwr = 0x7F,
.mod = MOD_AFSK,
.cca = 0x4F
.cca = 0x5F
},
// Digipeat transmission identity
.call = "VK2GJ-5",
@ -169,9 +169,9 @@ const conf_t conf_flash_default = {
// Power control
.keep_cam_switched_on = false,
.gps_on_vbat = 3600, // mV
.gps_off_vbat = 3400, // mV
.gps_onper_vbat = 4000, // mV
.gps_on_vbat = 3300, // mV
.gps_off_vbat = 3000, // mV
.gps_onper_vbat = 3500, // mV
// GPS altitude model control (air pressure controlled using on-board BME280)
.gps_pressure = 90000, // Air pressure (Pa) threshold for alt model switch
@ -180,7 +180,7 @@ const conf_t conf_flash_default = {
// APRS
// How often to send telemetry config (global for beacons)
.tel_enc_cycle = TIME_S2I(60 * 60 * 2),
.tel_enc_cycle = TIME_S2I(3600),
// The default APRS frequency when geofence is not resolved
.freq = FREQ_APRS_EUROPE,

Wyświetl plik

@ -1,15 +1,15 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#define TRACE_TIME TRUE /* Enables time tracing on debugging port */
#define TRACE_FILE TRUE /* Enables file and line tracing on debugging port */
#include "types.h"
#define CONFIG_MAGIC_DEFAULT 0x41583235
#define CONFIG_MAGIC_UPDATED 0x46583235
extern conf_t conf_sram;
extern const conf_t conf_flash_default;
#endif /* __CONFIG_H__ */
#ifndef __CONFIG_H__
#define __CONFIG_H__
#define TRACE_TIME TRUE /* Enables time tracing on debugging port */
#define TRACE_FILE TRUE /* Enables file and line tracing on debugging port */
#include "types.h"
#define CONFIG_MAGIC_DEFAULT 0x41583235
#define CONFIG_MAGIC_UPDATED 0x46583235
extern conf_t conf_sram;
extern const conf_t conf_flash_default;
#endif /* __CONFIG_H__ */

Wyświetl plik

@ -1,72 +1,72 @@
#include "ch.h"
#include "hal.h"
#include "sleep.h"
#include "padc.h"
#include "collector.h"
#include "debug.h"
#include "padc.h"
#include "pac1720.h"
/**
* Sleeping method. Returns true if sleeping condition are given.
*/
bool p_sleep(const sleep_conf_t *config)
{
switch(config->type)
{
case SLEEP_WHEN_VBAT_BELOW_THRES:
return stm32_get_vbat() < config->vbat_thres;
case SLEEP_WHEN_VSOL_BELOW_THRES:
return stm32_get_vsol() < config->vsol_thres;
case SLEEP_WHEN_VBAT_ABOVE_THRES:
return stm32_get_vbat() > config->vbat_thres;
case SLEEP_WHEN_VSOL_ABOVE_THRES:
return stm32_get_vsol() > config->vsol_thres;
case SLEEP_WHEN_DISCHARGING:
case SLEEP_WHEN_CHARGING:
TRACE_WARN("Sleeping method not implemented");
return false;
case SLEEP_DISABLED:
return false;
}
return false;
}
sysinterval_t waitForTrigger(sysinterval_t prev, sysinterval_t timeout)
{
/*switch(config->type)
{
case TRIG_NEW_POINT: // Wait for new data point
waitForNewDataPoint();
return chVTGetSystemTimeX();
case TRIG_TIMEOUT: // Wait for specified timeout
return chThdSleepUntilWindowed(prev, prev + TIME_S2I(config->timeout));
case TRIG_CONTINUOUSLY: // Immediate trigger
return chVTGetSystemTimeX();
case TRIG_ONCE: // No trigger defined
chThdSleep(TIME_S2I(10));
}
return chVTGetSystemTimeX();*/
return chThdSleepUntilWindowed(prev, prev + timeout);
}
void trigger_new_data_point(void)
{
uint32_t oldID = getLastDataPoint()->id;
dataPoint_t *newtp;
do { // Wait for new serial ID to be deployed
chThdSleep(TIME_MS2I(100));
newtp = getLastDataPoint();
} while(newtp->id == oldID);
}
#include "ch.h"
#include "hal.h"
#include "sleep.h"
#include "padc.h"
#include "collector.h"
#include "debug.h"
#include "padc.h"
#include "pac1720.h"
/**
* Sleeping method. Returns true if sleeping condition are given.
*/
bool p_sleep(const sleep_conf_t *config)
{
switch(config->type)
{
case SLEEP_WHEN_VBAT_BELOW_THRES:
return stm32_get_vbat() < config->vbat_thres;
case SLEEP_WHEN_VSOL_BELOW_THRES:
return stm32_get_vsol() < config->vsol_thres;
case SLEEP_WHEN_VBAT_ABOVE_THRES:
return stm32_get_vbat() > config->vbat_thres;
case SLEEP_WHEN_VSOL_ABOVE_THRES:
return stm32_get_vsol() > config->vsol_thres;
case SLEEP_WHEN_DISCHARGING:
case SLEEP_WHEN_CHARGING:
TRACE_WARN("Sleeping method not implemented");
return false;
case SLEEP_DISABLED:
return false;
}
return false;
}
sysinterval_t waitForTrigger(sysinterval_t prev, sysinterval_t timeout)
{
/*switch(config->type)
{
case TRIG_NEW_POINT: // Wait for new data point
waitForNewDataPoint();
return chVTGetSystemTimeX();
case TRIG_TIMEOUT: // Wait for specified timeout
return chThdSleepUntilWindowed(prev, prev + TIME_S2I(config->timeout));
case TRIG_CONTINUOUSLY: // Immediate trigger
return chVTGetSystemTimeX();
case TRIG_ONCE: // No trigger defined
chThdSleep(TIME_S2I(10));
}
return chVTGetSystemTimeX();*/
return chThdSleepUntilWindowed(prev, prev + timeout);
}
void trigger_new_data_point(void)
{
uint32_t oldID = getLastDataPoint()->id;
dataPoint_t *newtp;
do { // Wait for new serial ID to be deployed
chThdSleep(TIME_MS2I(100));
newtp = getLastDataPoint();
} while(newtp->id == oldID);
}

Wyświetl plik

@ -1,17 +1,17 @@
#ifndef __SLEEP_H__
#define __SLEEP_H__
#include "ch.h"
#include "hal.h"
#include "types.h"
#define WAIT_FOR_DATA_POINT trigger_new_data_point
#define TX_CONTINUOSLY trigger_immediately
bool p_sleep(const sleep_conf_t *config);
sysinterval_t waitForTrigger(sysinterval_t prev, sysinterval_t timeout);
void trigger_new_data_point(void);
void trigger_immediately(void);
#endif /* __SLEEP_H__ */
#ifndef __SLEEP_H__
#define __SLEEP_H__
#include "ch.h"
#include "hal.h"
#include "types.h"
#define WAIT_FOR_DATA_POINT trigger_new_data_point
#define TX_CONTINUOSLY trigger_immediately
bool p_sleep(const sleep_conf_t *config);
sysinterval_t waitForTrigger(sysinterval_t prev, sysinterval_t timeout);
void trigger_new_data_point(void);
void trigger_immediately(void);
#endif /* __SLEEP_H__ */

Wyświetl plik

@ -50,7 +50,7 @@ typedef enum { // Modulation type
MOD_NONE,
MOD_AFSK,
MOD_2FSK
} mod_t;
} radio_mod_t;
typedef enum {
RES_NONE = 0,
@ -66,7 +66,7 @@ typedef enum {
typedef struct {
radio_pwr_t pwr;
radio_freq_t freq;
mod_t mod;
radio_mod_t mod;
link_speed_t speed;
union {
radio_squelch_t cca;
@ -77,14 +77,14 @@ typedef struct {
typedef struct {
radio_pwr_t pwr;
radio_freq_t freq;
mod_t mod;
radio_mod_t mod;
link_speed_t speed;
radio_squelch_t cca;
} radio_tx_conf_t; // Radio / Modulation
typedef struct {
radio_freq_t freq;
mod_t mod;
radio_mod_t mod;
link_speed_t speed;
radio_squelch_t rssi;
} radio_rx_conf_t; // Radio / Modulation

Wyświetl plik

@ -1063,7 +1063,7 @@ bool Si446x_receiveNoLock(const radio_unit_t radio,
channel_hz_t step,
radio_ch_t channel,
radio_squelch_t rssi,
mod_t mod) {
radio_mod_t mod) {
radio_freq_t op_freq = pktComputeOperatingFrequency(radio, freq,
step, channel,
@ -1123,7 +1123,7 @@ bool Si4464_enableReceive(const radio_unit_t radio,
const channel_hz_t rx_step,
const radio_ch_t rx_chan,
const radio_squelch_t rx_rssi,
const mod_t rx_mod) {
const radio_mod_t rx_mod) {
/* Get an absolute operating frequency in Hz. */
radio_freq_t op_freq = pktComputeOperatingFrequency(radio,

Wyświetl plik

@ -316,13 +316,13 @@ extern "C" {
channel_hz_t rx_step,
radio_ch_t rx_chan,
radio_squelch_t rx_rssi,
mod_t rx_mod);
radio_mod_t rx_mod);
bool Si446x_receiveNoLock(const radio_unit_t radio,
radio_freq_t rx_frequency,
channel_hz_t rx_step,
radio_ch_t chan,
radio_squelch_t rssi,
mod_t mod);
radio_mod_t mod);
void Si446x_lockRadio(const radio_mode_t mode);
void Si446x_unlockRadio(const radio_mode_t mode);
void Si446x_lockRadioByCamera(void);

Wyświetl plik

@ -1,15 +1,67 @@
#include "ch.h"
#include "hal.h"
#include "debug.h"
#include "portab.h"
//mutex_t trace_mtx; // Used internal to synchronize multiple chprintf in debug.h
mutex_t mtx; // Used internal to synchronize multiple chprintf in debug.h
char error_list[ERROR_LIST_SIZE][ERROR_LIST_LENGTH];
uint8_t error_counter;
static const SerialConfig debug_config = {
115200,
0,
0,
0
};
#ifdef USB_TRACE_LEVEL
uint8_t usb_trace_level = USB_TRACE_LEVEL; // Set in makefile UDEFS
#else
uint8_t usb_trace_level = 2; // Level: Errors + Warnings
#endif
void debug_init(void) {
chMtxObjectInit(&mtx);
sdStart(&SD3, &debug_config);
palSetLineMode(LINE_IO_TXD, PAL_MODE_ALTERNATE(7));
palSetLineMode(LINE_IO_RXD, PAL_MODE_ALTERNATE(7));
}
void debug_print(char *type, char* filename, uint32_t line, char* format, ...)
{
chMtxLock(&mtx);
uint8_t str[256];
va_list args;
va_start(args, format);
chsnprintf((char*)str, sizeof(str), format, args);
va_end(args);
if(isConsoleOutputAvailable()) {
if(TRACE_TIME) {
chprintf((BaseSequentialStream*)&SDU1, "[%8d.%03d]", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000);
}
chprintf((BaseSequentialStream*)&SDU1, "[%s]", type);
if(TRACE_FILE) {
chprintf((BaseSequentialStream*)&SDU1, "[%12s %04d]", filename, line);
}
chprintf((BaseSequentialStream*)&SDU1, " %s\r\n", str);
}
if(TRACE_TIME) {
chprintf((BaseSequentialStream*)&SD3, "[%8d.%03d]", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000);
}
chprintf((BaseSequentialStream*)&SD3, "[%s]", type);
if(TRACE_FILE) {
chprintf((BaseSequentialStream*)&SD3, "[%12s %04d]", filename, line);
}
chprintf((BaseSequentialStream*)&SD3, " %s\r\n", str);
chMtxUnlock(&mtx);
}

Wyświetl plik

@ -17,40 +17,15 @@
extern char error_list[ERROR_LIST_SIZE][ERROR_LIST_LENGTH];
extern uint8_t error_counter;
extern mutex_t trace_mtx;
extern const SerialConfig uart_config;
extern uint8_t usb_trace_level;
// Initializer for serial debug and LEDs
/*
#define DEBUG_INIT() { \
chMtxObjectInit(&trace_mtx); \
}
*/
#define TRACE_BASE(format, type, args...) { \
if(isConsoleOutputAvailable()) { \
if(TRACE_TIME) { \
chprintf((BaseSequentialStream*)&SDU1, "[%8d.%03d]", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); \
} \
chprintf((BaseSequentialStream*)&SDU1, "[%s]", type); \
if(TRACE_FILE) { \
chprintf((BaseSequentialStream*)&SDU1, "[%12s %04d]", __FILENAME__, __LINE__); \
} \
chprintf((BaseSequentialStream*)&SDU1, " "); \
chprintf((BaseSequentialStream*)&SDU1, (format), ##args); \
chprintf((BaseSequentialStream*)&SDU1, "\r\n"); \
chThdSleep(TIME_MS2I(10)); \
} \
}
#define TRACE_DEBUG(format, args...) if(usb_trace_level > 4) { TRACE_BASE(format, "DEBUG", ##args) }
#define TRACE_INFO(format, args...) if(usb_trace_level > 3) { TRACE_BASE(format, " ", ##args) }
#define TRACE_MON(format, args...) if(usb_trace_level > 2) { TRACE_BASE(format, " ", ##args) }
#define TRACE_WARN(format, args...) if(usb_trace_level > 1) { TRACE_BASE(format, "WARN ", ##args) }
#define TRACE_DEBUG(format, args...) if(usb_trace_level > 4) { debug_print("DEBUG", __FILENAME__, __LINE__, format, ##args); }
#define TRACE_INFO(format, args...) if(usb_trace_level > 3) { debug_print(" ", __FILENAME__, __LINE__, format, ##args); }
#define TRACE_MON(format, args...) if(usb_trace_level > 2) { debug_print(" ", __FILENAME__, __LINE__, format, ##args); }
#define TRACE_WARN(format, args...) if(usb_trace_level > 1) { debug_print("WARN ", __FILENAME__, __LINE__, format, ##args); }
#define TRACE_ERROR(format, args...) { \
if(usb_trace_level > 0) { \
TRACE_BASE(format, "ERROR", ##args); \
debug_print("ERROR", __FILENAME__, __LINE__, format, ##args); \
} \
\
uint8_t strcnt = chsnprintf(error_list[error_counter], ERROR_LIST_LENGTH, "[%8d.%03d] ", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); \
@ -68,28 +43,6 @@ extern uint8_t usb_trace_level;
#define TRACE_TAB " "
#endif
/*
#define TRACE_BIN(data, len) { \
chMtxLock(&trace_mtx); \
chprintf((BaseSequentialStream*)&SD3, "[%8d.%03d][DEBUG] ", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); \
chprintf((BaseSequentialStream*)&SD3, " > Binary data (%d bits)\r\n", (len)); \
for(uint32_t i=0; i<((len)+7)/8; i+=8) \
chprintf((BaseSequentialStream*)&SD3, "%s 0x%03x ... 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n", \
TRACE_TAB, i, (data)[i], (data)[i+1], (data)[i+2], (data)[i+3], (data)[i+4], (data)[i+5], (data)[i+6], (data)[i+7]); \
chMtxUnlock(&trace_mtx); \
}
#define TRACE_BIN_CHAR(data, len) { \
chMtxLock(&trace_mtx); \
chprintf((BaseSequentialStream*)&SD3, "[%8d.%03d][DEBUG] ", chVTGetSystemTime()/CH_CFG_ST_FREQUENCY, (chVTGetSystemTime()*1000/CH_CFG_ST_FREQUENCY)%1000); \
chprintf((BaseSequentialStream*)&SD3, " > Binary data (%d bits)\r\n", (len)); \
for(uint32_t i=0; i<((len)+7)/8; i+=8) \
chprintf((BaseSequentialStream*)&SD3, "%s %c%c%c%c%c%c%c%c\r\n", \
TRACE_TAB, i, (data)[i], (data)[i+1], (data)[i+2], (data)[i+3], (data)[i+4], (data)[i+5], (data)[i+6], (data)[i+7]); \
chMtxUnlock(&trace_mtx); \
}
*/
/*
#if USE_CCM_FOR_PKT_POOL == TRUE
@ -110,5 +63,8 @@ static inline heap_header_t *pktSystemCheck(void) {
}
#endif
void debug_init(void);
void debug_print(char *type, char* filename, uint32_t line, char* format, ...);
#endif /* __TRACE_H__ */

Wyświetl plik

@ -1053,7 +1053,7 @@ bool pktLLDradioResumeReceive(const radio_unit_t radio) {
channel_hz_t step = handler->radio_rx_config.step_hz;
radio_ch_t chan = handler->radio_rx_config.channel;
radio_squelch_t rssi = handler->radio_rx_config.squelch;
mod_t mod = handler->radio_rx_config.type;
radio_mod_t mod = handler->radio_rx_config.type;
bool result = Si4464_enableReceive(radio, freq, step, chan, rssi, mod);
return result;
}
@ -1185,4 +1185,45 @@ uint8_t pktLLDradioReadCCA(const radio_unit_t radio) {
return Si446x_readCCA(radio);
}
/**
*
*/
void pktLLDradioConfigIndicators(const radio_unit_t radio) {
(void)radio;
}
/**
*
*/
void pktLLDradioDeconfigIndicators(const radio_unit_t radio) {
(void)radio;
}
/**
*
*/
void pktLLDradioSetIndicator(const radio_unit_t radio,
radio_indicator_t ind) {
(void)radio;
(void)ind;
}
/**
*
*/
void pktLLDradioClearIndicator(const radio_unit_t radio,
radio_indicator_t ind) {
(void)radio;
(void)ind;
}
/**
*
*/
void pktLLDradioToggleIndicator(const radio_unit_t radio,
radio_indicator_t ind) {
(void)radio;
(void)ind;
}
/** @} */

Wyświetl plik

@ -38,6 +38,13 @@
/* Module data structures and types. */
/*===========================================================================*/
typedef enum radioIndicators {
PKT_INDICATOR_DECODE,
PKT_INDICATOR_SQUELCH,
PKT_INDICATOR_FIFO,
PKT_INDICATOR_OVERFLOW
} radio_indicator_t;
#include "pkttypes.h"
/**
@ -61,27 +68,27 @@ typedef enum radioCommand {
typedef struct radioTask radio_task_object_t;
typedef struct packetHandlerData packet_svc_t;
typedef struct radioConfig radio_config_t;
typedef struct radioSettings radio_settings_t;
typedef struct radioAction radio_action_t;
//typedef struct radioSettings radio_settings_t;
//typedef struct radioAction radio_action_t;
/**
* @brief Radio task notification callback type.
* @brief Radio task notification callback type.
*
* @param[in] rcob pointer to a @p radio task object
* @param[in] task_object pointer to a @p radio task object
*/
typedef void (*radio_task_cb_t)(radio_task_object_t *task_object);
#include "ax25_pad.h"
struct radioSettings {
mod_t type;
typedef struct radioSettings {
radio_mod_t type;
radio_freq_t base_frequency;
channel_hz_t step_hz;
radio_ch_t channel;
radio_squelch_t squelch;
};
} radio_settings_t;
struct radioAction {
typedef struct radioAction {
radio_command_t command;
radio_task_cb_t callback;
msg_t result;
@ -89,12 +96,12 @@ struct radioAction {
char tx_thd_name[16];
packet_svc_t *handler;
packet_t packet_out;
};
} radio_action_t;
struct radioTaskx {
/*struct radioTaskx {
radio_settings_t settings;
radio_action_t action;
};
};*/
/**
* @brief Radio task object.
@ -104,7 +111,7 @@ struct radioTask {
/* For safety keep clear - where pool stores its free link. */
struct pool_header link;
radio_command_t command;
mod_t type;
radio_mod_t type;
radio_freq_t base_frequency;
channel_hz_t step_hz;
radio_ch_t channel;
@ -120,10 +127,30 @@ struct radioTask {
};
/*===========================================================================*/
/* External declarations. */
/* Module macros. */
/*===========================================================================*/
//extern const ICUConfig pwm_icucfg;
/**
* @brief Alias of pktStopDecoder for convenience.
*
* @param[in] radio radio unit ID
*
* @api
*/
#define pktPauseDecoding(radio) pktStopDecoder(radio)
/**
* @brief Alias for convenience of pktStartDecoder.
*
* @param[in] radio radio unit ID
*
* @api
*/
#define pktResumeDecoding(radio) pktStartDecoder(radio)
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
@ -181,6 +208,14 @@ extern "C" {
size_t size);
const radio_config_t *pktGetRadioData(radio_unit_t radio);
uint8_t pktLLDradioReadCCA(const radio_unit_t radio);
void pktLLDradioConfigIndicators(const radio_unit_t radio);
void pktLLDradioDeconfigIndicators(const radio_unit_t radio);
void pktLLDradioSetIndicator(const radio_unit_t radio,
radio_indicator_t ind);
void pktLLDradioClearIndicator(const radio_unit_t radio,
radio_indicator_t ind);
void pktLLDradioToggleIndicator(const radio_unit_t radio,
radio_indicator_t ind);
#ifdef __cplusplus
}
#endif
@ -189,24 +224,6 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
/**
* @brief Alias of pktStopDecoder for convenience.
*
* @param[in] radio radio unit ID
*
* @api
*/
#define pktPauseDecoding(radio) pktStopDecoder(radio)
/**
* @brief Alias for convenience of pktStartDecoder.
*
* @param[in] radio radio unit ID
*
* @api
*/
#define pktResumeDecoding(radio) pktStartDecoder(radio)
#endif /* PKT_MANAGERS_PKTRADIO_H_ */
/** @} */

Wyświetl plik

@ -53,7 +53,7 @@ typedef enum HDLCFrameStates {
#include "types.h"
/* Link level encoding type. */
typedef mod_t encoding_type_t;
typedef radio_mod_t encoding_type_t;
#include "pktradio.h"

Wyświetl plik

@ -69,7 +69,7 @@ typedef struct APRSIdentity {
/* Radio parameters. */
radio_freq_t freq;
radio_pwr_t pwr;
mod_t mod;
radio_mod_t mod;
radio_squelch_t cca;
} aprs_identity_t;

Wyświetl plik

@ -104,7 +104,7 @@ void start_aprs_threads(radio_unit_t radio, radio_freq_t base_freq,
*/
bool transmitOnRadio(packet_t pp, const radio_freq_t base_freq,
const channel_hz_t step, radio_ch_t chan,
const radio_pwr_t pwr, const mod_t mod,
const radio_pwr_t pwr, const radio_mod_t mod,
const radio_squelch_t cca) {
/* Select a radio by frequency. */
radio_unit_t radio = pktSelectRadioForFrequency(base_freq,

Wyświetl plik

@ -1,34 +1,34 @@
#ifndef __RADIO_H__
#define __RADIO_H__
#include "ch.h"
#include "hal.h"
#include "config.h"
#include "ax25_pad.h"
#include "pktconf.h"
// APRS region frequencies
#define APRS_FREQ_OTHER 144800000
#define APRS_FREQ_AMERICA 144390000
#define APRS_FREQ_CHINA 144640000
#define APRS_FREQ_JAPAN 144660000
#define APRS_FREQ_SOUTHKOREA 144620000
#define APRS_FREQ_SOUTHEASTASIA 144390000
#define APRS_FREQ_AUSTRALIA 145175000
#define APRS_FREQ_NEWZEALAND 144575000
#define APRS_FREQ_ARGENTINA 144930000
#define APRS_FREQ_BRAZIL 145575000
void start_aprs_threads(radio_unit_t radio, radio_freq_t freq, channel_hz_t step,
radio_ch_t chan, radio_squelch_t rssi);
bool transmitOnRadio(packet_t pp, radio_freq_t freq, channel_hz_t step,
radio_ch_t chan, radio_pwr_t pwr, mod_t mod,
radio_squelch_t rssi);
inline const char *getModulation(uint8_t key) {
const char *val[] = {"NONE", "AFSK", "2FSK"};
return val[key];
};
#endif /* __RADIO_H__ */
#ifndef __RADIO_H__
#define __RADIO_H__
#include "ch.h"
#include "hal.h"
#include "config.h"
#include "ax25_pad.h"
#include "pktconf.h"
// APRS region frequencies
#define APRS_FREQ_OTHER 144800000
#define APRS_FREQ_AMERICA 144390000
#define APRS_FREQ_CHINA 144640000
#define APRS_FREQ_JAPAN 144660000
#define APRS_FREQ_SOUTHKOREA 144620000
#define APRS_FREQ_SOUTHEASTASIA 144390000
#define APRS_FREQ_AUSTRALIA 145175000
#define APRS_FREQ_NEWZEALAND 144575000
#define APRS_FREQ_ARGENTINA 144930000
#define APRS_FREQ_BRAZIL 145575000
void start_aprs_threads(radio_unit_t radio, radio_freq_t freq, channel_hz_t step,
radio_ch_t chan, radio_squelch_t rssi);
bool transmitOnRadio(packet_t pp, radio_freq_t freq, channel_hz_t step,
radio_ch_t chan, radio_pwr_t pwr, radio_mod_t mod,
radio_squelch_t rssi);
inline const char *getModulation(uint8_t key) {
const char *val[] = {"NONE", "AFSK", "2FSK"};
return val[key];
};
#endif /* __RADIO_H__ */

Wyświetl plik

@ -24,21 +24,8 @@ void start_essential_threads(void)
}
void start_user_threads(void) {
conf_t *conf_flash = (conf_t*)0x08060000;
/* Check if a user update has been made to configuration in flash. */
if(conf_flash->magic != CONFIG_MAGIC_UPDATED) {
if(conf_flash->magic != CONFIG_MAGIC_DEFAULT
|| memcmp(&conf_flash, &conf_flash_default, sizeof(conf_t)) != 0) {
/* No configuration found in flash memory or default config has changed. */
flashSectorBegin(flashSectorAt((uint32_t)conf_flash));
flashErase((uint32_t)conf_flash, 0x20000);
flashWrite((uint32_t)conf_flash, (char*)&conf_flash_default, sizeof(conf_t));
flashSectorEnd(flashSectorAt((uint32_t)conf_flash));
}
}
// Copy
memcpy(&conf_sram, conf_flash, sizeof(conf_t));
memcpy(&conf_sram, &conf_flash_default, sizeof(conf_t));
/* TODO: Implement scheduler that will run threads based on schedule. */
if(conf_sram.pos_pri.beacon.active)