diff --git a/tracker/software/config.c b/tracker/software/config.c index 3cb5c13..97687d8 100644 --- a/tracker/software/config.c +++ b/tracker/software/config.c @@ -355,7 +355,10 @@ // Global variables #include "config.h" #include "aprs.h" -#include "debug.h" +#include "image.h" +#include "position.h" +#include "log.h" +#include "chprintf.h" module_conf_t config[7]; @@ -363,7 +366,7 @@ uint8_t ssdv_buffer[128*1024] __attribute__((aligned(32))); // Image buffer systime_t track_cycle_time = S2ST(60); // Tracking cycle (all peripheral data [airpressure, GPS, temperature, ...] is collected each 60 seconds systime_t log_cycle_time = S2ST(600); // Log cycle time in seconds (600 seconds) -bool keep_cam_switched_on = false; // Keep camera switched on and initialized after it has been switched on once, no configuration change is possible +bool keep_cam_switched_on = true; // Keep camera switched on and initialized after it has been switched on once, no configuration change is possible uint16_t gps_on_vbat = 3000; // Battery voltage threshold at which GPS is switched on uint16_t gps_off_vbat = 2500; // Battery voltage threshold at which GPS is switched off @@ -448,7 +451,7 @@ void start_user_modules(void) // Module IMAGE, APRS 2m 2GFSK config[4].power = 127; // Transmission Power config[4].protocol = PROT_APRS_2GFSK; // Protocol APRS/SSDV (2GFSK) - config[4].gfsk_conf.speed = 9600; // 2GFSK Speed + config[4].gfsk_conf.speed = 19200; // 2GFSK Speed config[4].frequency.type = FREQ_STATIC; // Static frequency allocation config[4].frequency.hz = 144860000; // Transmission frequency 144.860 MHz config[4].trigger.type = TRIG_CONTINUOUSLY; // Transmit continuously diff --git a/tracker/software/config.h b/tracker/software/config.h index a11012b..50a35ee 100644 --- a/tracker/software/config.h +++ b/tracker/software/config.h @@ -1,13 +1,6 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ -#include "ch.h" -#include "hal.h" -#include "chprintf.h" -#include "types.h" -#include "radio.h" -#include "sleep.h" - #define LOG_FLASH_ADDR1 0x080C0000 /* Log flash memory address 1 */ #define LOG_FLASH_ADDR2 0x080E0000 /* Log flash memory address 2 */ #define LOG_SECTOR_SIZE 0x20000 /* Log flash memory size */ @@ -15,9 +8,21 @@ #define TRACE_TIME TRUE /* Enables time tracing on debugging port */ #define TRACE_FILE FALSE /* Enables file and line tracing on debugging port */ -#define RUN_3V TRUE /* Lets the tracker run a 3V otherwise 1.8V. 3V is needed to do 20dBm radio output power. - * With 1.8V only 15dBm can be done. Some serial-USB adapters also need a 3V IO level in - * order to work. However 3V takes a lot of power in idle. You can save energy using 1.8V. */ +#define ACTIVATE_3V TRUE /* Lets the tracker run a 3V otherwise 1.8V. 3V is needed to do 20dBm radio output power + * and to run USB. With 1.8V only 15dBm can be done only. Some serial-USB adapters also + * need a 3V IO level in order to work. However 3V takes a lot of power in idle. You can + * save energy using 1.8V. This option is activated automatically if ACTIVATE_USB is set + * true. */ + +#define ACTIVATE_USB TRUE /* If set to true, the USB interface will be switched on. The tracker is also switched to + * 3V, because USB would not work at 1.8V. Note that the transmission power is increased + * too when operating at 3V. This option will also run the STM32 at 48MHz (AHB) permanently + * because USB needs that speed, otherwise it is running at 6MHz which saves a lot of power. */ + + +#include "ch.h" +#include "types.h" +#include "radio.h" void start_user_modules(void); diff --git a/tracker/software/drivers/wrapper/ptime.h b/tracker/software/drivers/wrapper/ptime.h index b8e684a..290005b 100644 --- a/tracker/software/drivers/wrapper/ptime.h +++ b/tracker/software/drivers/wrapper/ptime.h @@ -1,8 +1,7 @@ -#ifndef __TIME_H__ -#define __TIME_H__ +#ifndef __PTIME_H__ +#define __PTIME_H__ #include "ch.h" -#include "hal.h" typedef struct { uint16_t year; diff --git a/tracker/software/main.c b/tracker/software/main.c index 0f12775..a592c59 100644 --- a/tracker/software/main.c +++ b/tracker/software/main.c @@ -27,8 +27,7 @@ int main(void) { chSysInit(); // Startup RTOS // Voltage switching (1.8V <=> 3.0V) - bool usbConnected = isUsbConnected(); - if(usbConnected || RUN_3V) + if(ACTIVATE_USB || ACTIVATE_3V) { boost_voltage(true); // Ramp up voltage to 3V chThdSleepMilliseconds(100); @@ -38,11 +37,9 @@ int main(void) { DEBUG_INIT(); TRACE_INFO("MAIN > Startup"); - // Start USB (if connected) - if(usbConnected) + // Start USB + if(ACTIVATE_USB) { - TRACE_INFO("MAIN > USB detected"); - sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); @@ -51,8 +48,6 @@ int main(void) { usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); usb_initialized = true; - } else { - TRACE_INFO("MAIN > USB not detected"); } // Startup threads @@ -62,7 +57,7 @@ int main(void) { // Print time every 10 sec while(true) { if (SDU1.config->usbp->state == USB_ACTIVE) { - thread_t *shelltp = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(2048), "shell", NORMALPRIO+1, shellThread, (void*)&shell_cfg); + thread_t *shelltp = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(512), "shell", NORMALPRIO+1, shellThread, (void*)&shell_cfg); chThdWait(shelltp); } chThdSleepMilliseconds(1000); diff --git a/tracker/software/mcuconf.h b/tracker/software/mcuconf.h index 9e47470..de95b66 100644 --- a/tracker/software/mcuconf.h +++ b/tracker/software/mcuconf.h @@ -17,6 +17,8 @@ #ifndef MCUCONF_H #define MCUCONF_H +#include "config.h" + /* * STM32F4xx drivers configuration. * The following settings override the default settings present in @@ -48,7 +50,11 @@ #define STM32_PLLN_VALUE 192 #define STM32_PLLP_VALUE 4 #define STM32_PLLQ_VALUE 4 -#define STM32_HPRE STM32_HPRE_DIV2 +#if ACTIVATE_USB /* Activate 48MHz when USB is activated, otherwise 6MHz */ +#define STM32_HPRE STM32_HPRE_DIV1 +#else +#define STM32_HPRE STM32_HPRE_DIV8 +#endif #define STM32_PPRE1 STM32_PPRE1_DIV1 #define STM32_PPRE2 STM32_PPRE2_DIV1 #define STM32_RTCSEL STM32_RTCSEL_LSI diff --git a/tracker/software/radio.c b/tracker/software/radio.c index 5c633a1..03e2ea8 100644 --- a/tracker/software/radio.c +++ b/tracker/software/radio.c @@ -1,6 +1,8 @@ #include "ch.h" #include "hal.h" + #include "defines.h" +#include "tracking.h" #include "debug.h" #include "radio.h" #include "si4464.h" diff --git a/tracker/software/threads/log.c b/tracker/software/threads/log.c index 7d06e55..1a38723 100644 --- a/tracker/software/threads/log.c +++ b/tracker/software/threads/log.c @@ -12,6 +12,7 @@ #include "aprs.h" #include "flash.h" #include "watchdog.h" +#include "sleep.h" /* * Sequence determines in which order log packets are sent out diff --git a/tracker/software/threads/threads.c b/tracker/software/threads/threads.c index 9428044..8cc1db4 100644 --- a/tracker/software/threads/threads.c +++ b/tracker/software/threads/threads.c @@ -5,6 +5,7 @@ #include "threads.h" #include "tracking.h" #include "watchdog.h" +#include "image.h" #include "pi2c.h" #include "pac1720.h" diff --git a/tracker/software/threads/threads.h b/tracker/software/threads/threads.h index 75977b7..99d7663 100644 --- a/tracker/software/threads/threads.h +++ b/tracker/software/threads/threads.h @@ -1,13 +1,7 @@ #ifndef __MODULES_H__ #define __MODULES_H__ -#include "position.h" -#include "image.h" -#include "tracking.h" -#include "log.h" -#include "sgp4.h" -#include "config.h" -#include "types.h" +#include "ch.h" void start_essential_threads(void); diff --git a/tracker/software/threads/tracking.c b/tracker/software/threads/tracking.c index f17c70f..766fb9f 100644 --- a/tracker/software/threads/tracking.c +++ b/tracker/software/threads/tracking.c @@ -1,6 +1,7 @@ #include "ch.h" #include "hal.h" +#include "tracking.h" #include "debug.h" #include "ptime.h" #include "config.h" diff --git a/tracker/software/types.h b/tracker/software/types.h index b47a551..8ad0109 100644 --- a/tracker/software/types.h +++ b/tracker/software/types.h @@ -1,6 +1,9 @@ #ifndef __TYPES_H__ #define __TYPES_H__ +//#define HIGH true +//#define LOW false + typedef enum { // Modulation type MOD_NOT_SET, MOD_OOK,