Added USB switch in config

Develop
Sven Steudte 2017-09-07 21:56:00 +02:00
rodzic 9b11f876a8
commit a162e27d6e
11 zmienionych plików z 43 dodań i 33 usunięć

Wyświetl plik

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

Wyświetl plik

@ -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);

Wyświetl plik

@ -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;

Wyświetl plik

@ -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);

Wyświetl plik

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

Wyświetl plik

@ -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"

Wyświetl plik

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

Wyświetl plik

@ -5,6 +5,7 @@
#include "threads.h"
#include "tracking.h"
#include "watchdog.h"
#include "image.h"
#include "pi2c.h"
#include "pac1720.h"

Wyświetl plik

@ -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);

Wyświetl plik

@ -1,6 +1,7 @@
#include "ch.h"
#include "hal.h"
#include "tracking.h"
#include "debug.h"
#include "ptime.h"
#include "config.h"

Wyświetl plik

@ -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,