Adjusted clocks for low power operation (camera fix no implemented yet)

Develop
Sven Steudte 2017-08-30 05:29:59 +02:00
rodzic 6851721d03
commit 20b70a5680
7 zmienionych plików z 30 dodań i 16 usunięć

Wyświetl plik

@ -282,7 +282,7 @@ void start_user_modules(void)
chsnprintf(config[5].ssdv_conf.callsign, 7, "DL7AD2"); // SSDV Callsign
config[5].ssdv_conf.ram_buffer = ssdv_buffer; // Camera buffer
config[5].ssdv_conf.ram_size = sizeof(ssdv_buffer); // Buffer size
config[5].ssdv_conf.res = RES_VGA; // Resolution XGA
config[5].ssdv_conf.res = RES_QVGA; // Resolution XGA
//config[5].ssdv_conf.redundantTx = true; // Transmit packets twice
//start_image_thread(&config[5]);

Wyświetl plik

@ -8,15 +8,15 @@
#include "radio.h"
#include "sleep.h"
#define TRACK_CYCLE_TIME 120 /* Tracking cycle (all peripheral data [airpressure, GPS, temperature, ...] is collected each x seconds */
#define TRACK_CYCLE_TIME 60 /* Tracking cycle (all peripheral data [airpressure, GPS, temperature, ...] is collected each x seconds */
#define LOG_CYCLE_TIME 30 /* Log cycle time in seconds */
#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 */
#define GPS_ON_VBAT 3500 /* Battery voltage threshold at which GPS is switched on */
#define GPS_OFF_VBAT 3000 /* Battery voltage threshold at which GPS is switched off */
#define GPS_ON_VBAT 7000 /* Battery voltage threshold at which GPS is switched on */
#define GPS_OFF_VBAT 7000 /* Battery voltage threshold at which GPS is switched off */
#define TRACE_TIME TRUE /* Enables time tracing on debugging port */
#define TRACE_FILE FALSE /* Enables file and line tracing on debugging port */

Wyświetl plik

@ -96,7 +96,7 @@ static const struct regval_list OV5640YUV_Sensor_Dvp_Init[] =
{ 0x3034, 0x1a },
{ 0x3035, 0x11 }, //15fps
{ 0x3036, 0x46 },
{ 0x3037, 0x13 },
{ 0x3037, 0x14 },
{ 0x3038, 0x00 },
{ 0x3039, 0x00 },
@ -755,7 +755,7 @@ static bool analyze_image(uint8_t *image, uint32_t image_len)
uint8_t r = bi < image_len-128 ? 128 : image_len - bi;
bi += r;
if(r <= 0)
break;
return false;
ssdv_enc_feed(&ssdv, b, r);
}
@ -776,12 +776,13 @@ bool OV5640_BufferOverflow(void)
*/
bool OV5640_Snapshot2RAM(void)
{
// Capture image until we get a good image (max 5 tries)
uint8_t cntr = 5;
// Capture image until we get a good image (max 10 tries)
uint8_t cntr = 10;
bool status;
do {
TRACE_INFO("CAM > Capture image");
OV5640_Capture();
status = OV5640_Capture();
TRACE_INFO("CAM > Capture finished");
ov5640_conf->size_sampled = ov5640_conf->ram_size - 1;
@ -790,7 +791,7 @@ bool OV5640_Snapshot2RAM(void)
TRACE_INFO("CAM > Image size: %d bytes", ov5640_conf->size_sampled);
} while(!analyze_image(ov5640_conf->ram_buffer, ov5640_conf->ram_size) && cntr--);
} while((!analyze_image(ov5640_conf->ram_buffer, ov5640_conf->ram_size) || !status) && cntr--);
return true;
}
@ -1373,6 +1374,8 @@ bool OV5640_isAvailable(void)
palSetLine(LINE_CAM_EN); // Switch on camera
palSetLine(LINE_CAM_RESET); // Toggle reset
OV5640_getLightIntensity();
chThdSleepMilliseconds(100);
uint8_t val, val2;
@ -1390,3 +1393,12 @@ bool OV5640_isAvailable(void)
return ret;
}
uint32_t OV5640_getLightIntensity(void)
{
uint8_t val1,val2,val3;
I2C_read8_16bitreg(OV5640_I2C_ADR, 0x3C1B, &val1);
I2C_read8_16bitreg(OV5640_I2C_ADR, 0x3C1C, &val2);
I2C_read8_16bitreg(OV5640_I2C_ADR, 0x3C1D, &val3);
return (val1 << 16) | (val2 << 8) | val3;
}

Wyświetl plik

@ -20,5 +20,6 @@ void OV5640_TransmitConfig(void);
void OV5640_init(ssdv_conf_t *config);
void OV5640_deinit(void);
bool OV5640_isAvailable(void);
uint32_t OV5640_getLightIntensity(void);
#endif

Wyświetl plik

@ -48,8 +48,8 @@
#define STM32_PLLN_VALUE 192
#define STM32_PLLP_VALUE 4
#define STM32_PLLQ_VALUE 4
#define STM32_HPRE STM32_HPRE_DIV2
#define STM32_PPRE1 STM32_PPRE1_DIV2
#define STM32_HPRE STM32_HPRE_DIV8
#define STM32_PPRE1 STM32_PPRE1_DIV1
#define STM32_PPRE2 STM32_PPRE2_DIV4
#define STM32_RTCSEL STM32_RTCSEL_LSI
#define STM32_RTCPRE_VALUE 8
@ -67,7 +67,7 @@
/*
* ADC driver system settings.
*/
#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV2
#define STM32_ADC_USE_ADC1 TRUE
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
#define STM32_ADC_ADC1_DMA_PRIORITY 2

Wyświetl plik

@ -16,7 +16,7 @@
#include "watchdog.h"
#include "flash.h"
static uint8_t gimage_id = 2; // Global image ID (for all image threads)
static uint8_t gimage_id; // Global image ID (for all image threads)
mutex_t camera_mtx;
void encode_ssdv(uint8_t *image, uint32_t image_len, module_conf_t* conf, uint8_t image_id, bool redudantTx)

Wyświetl plik

@ -9,7 +9,7 @@
#include "padc.h"
#include <string.h>
#define PLAYBACK_RATE ((STM32_PCLK1) / 250) /* Samples per second (48Mhz / 250 = 192kHz) */
#define PLAYBACK_RATE ((STM32_PCLK1) / 500) /* Samples per second (48Mhz / 250 = 192kHz) */
#define BAUD_RATE 1200 /* APRS AFSK baudrate */
#define SAMPLES_PER_BAUD (PLAYBACK_RATE / BAUD_RATE) /* Samples per baud (192kHz / 1200baud = 160samp/baud) */
#define PHASE_DELTA_1200 (((2 * 1200) << 16) / PLAYBACK_RATE) /* Delta-phase per sample for 1200Hz tone */
@ -86,7 +86,7 @@ void send2GFSK(radioMSG_t *msg) {
current_byte = 0;
// Initialize variables for timer
uint32_t initial_interval = STM32_PCLK1 / msg->gfsk_conf->speed;
uint32_t initial_interval = STM32_PCLK1 / msg->gfsk_conf->speed / 2;
RCC->APB1ENR |= RCC_APB1ENR_TIM7EN;
nvicEnableVector(TIM7_IRQn, 1);
TIM7->ARR = initial_interval;
@ -136,6 +136,7 @@ CH_FAST_IRQ_HANDLER(STM32_TIM7_HANDLER)
current_sample_in_baud = 0;
packet_pos++;
}
palToggleLine(LINE_IO_LED1);
} else if(tim_msg->mod == MOD_2GFSK) {