Increased FIFO buffer in Si4464 to 129bytes

Decreased buffer of USB image capturing
Removed defines.h
Moved mutex initialization to radio.c and image.c
Develop
Sven Steudte 2017-09-09 00:00:55 +02:00
rodzic 8ba7249a7e
commit a4087588fa
12 zmienionych plików z 46 dodań i 41 usunięć

Wyświetl plik

@ -33,7 +33,7 @@ void debugOnUSB_On(BaseSequentialStream *chp, int argc, char *argv[])
debug_on_usb = true; debug_on_usb = true;
} }
static uint8_t usb_buffer[128*1024] __attribute__((aligned(32))); // USB image buffer static uint8_t usb_buffer[96*1024] __attribute__((aligned(32))); // USB image buffer
void printPicture(BaseSequentialStream *chp, int argc, char *argv[]) void printPicture(BaseSequentialStream *chp, int argc, char *argv[])
{ {
(void)chp; (void)chp;

Wyświetl plik

@ -1,11 +0,0 @@
#ifndef __DEFINES_H__
#define __DEFINES_H__
#include "ch.h"
#include "hal.h"
#define HIGH true
#define LOW false
#endif

Wyświetl plik

@ -8,7 +8,6 @@
#include "ov5640.h" #include "ov5640.h"
#include "pi2c.h" #include "pi2c.h"
#include "board.h" #include "board.h"
#include "defines.h"
#include "debug.h" #include "debug.h"
#include "ssdv.h" #include "ssdv.h"
#include <string.h> #include <string.h>

Wyświetl plik

@ -287,6 +287,16 @@ void setModem2GFSK(gfsk_conf_t* conf) {
uint8_t set_fifo_irq[] = {0x11, 0x12, 0x01, 0x0B, 0x20}; uint8_t set_fifo_irq[] = {0x11, 0x12, 0x01, 0x0B, 0x20};
Si4464_write(set_fifo_irq, 5); Si4464_write(set_fifo_irq, 5);
// Set FIFO to 129 byte
uint8_t set_129byte[] = {0x11, 0x00, 0x01, 0x03, 0x10};
Si4464_write(set_129byte, 5);
// Reset FIFO
uint8_t reset_fifo[] = {0x15, 0x01};
Si4464_write(reset_fifo, 2);
uint8_t unreset_fifo[] = {0x15, 0x00};
Si4464_write(unreset_fifo, 2);
// Disable preamble // Disable preamble
uint8_t disable_preamble[] = {0x11, 0x10, 0x01, 0x00, 0x00}; uint8_t disable_preamble[] = {0x11, 0x10, 0x01, 0x00, 0x00};
Si4464_write(disable_preamble, 5); Si4464_write(disable_preamble, 5);

Wyświetl plik

@ -3,13 +3,15 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "defines.h"
#include "types.h" #include "types.h"
#define RADIO_WRITE_GPIO(state) palWriteLine(LINE_RADIO_GPIO, state) #define RADIO_WRITE_GPIO(state) palWriteLine(LINE_RADIO_GPIO, state)
#define RADIO_READ_GPIO() palReadLine(LINE_RADIO_GPIO) #define RADIO_READ_GPIO() palReadLine(LINE_RADIO_GPIO)
#define inRadioBand(freq) (RADIO_MIN_FREQ <= (freq) && (freq) <= RADIO_MAX_FREQ) #define inRadioBand(freq) (RADIO_MIN_FREQ <= (freq) && (freq) <= RADIO_MAX_FREQ)
#define HIGH true
#define LOW false
#define SI4464_STATE_NOCHANGE 0 #define SI4464_STATE_NOCHANGE 0
#define SI4464_STATE_SLEEP 1 #define SI4464_STATE_SLEEP 1
#define SI4464_STATE_SPI_ACTIVE 2 #define SI4464_STATE_SPI_ACTIVE 2

Wyświetl plik

@ -4,11 +4,11 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "ublox.h" #include "ublox.h"
#include "pi2c.h" #include "pi2c.h"
#include "debug.h" #include "debug.h"
#include "config.h" #include "config.h"
#include "defines.h"
// Serial driver configuration for GPS // Serial driver configuration for GPS
const SerialConfig gps_config = const SerialConfig gps_config =

Wyświetl plik

@ -1,6 +1,6 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "defines.h"
#include "config.h" #include "config.h"
#include "padc.h" #include "padc.h"
#include "pac1720.h" #include "pac1720.h"

Wyświetl plik

@ -28,28 +28,26 @@ int main(void) {
chSysInit(); // Startup RTOS chSysInit(); // Startup RTOS
// Voltage switching (1.8V <=> 3.0V) // Voltage switching (1.8V <=> 3.0V)
if(ACTIVATE_USB || ACTIVATE_3V) #if ACTIVATE_USB || ACTIVATE_3V
{ boost_voltage(true); // Ramp up voltage to 3V
boost_voltage(true); // Ramp up voltage to 3V chThdSleepMilliseconds(100);
chThdSleepMilliseconds(100); #endif
}
// Init debugging (Serial debug port, LEDs) // Init debugging (Serial debug port, LEDs)
DEBUG_INIT(); DEBUG_INIT();
TRACE_INFO("MAIN > Startup"); TRACE_INFO("MAIN > Startup");
// Start USB // Start USB
if(ACTIVATE_USB) #if ACTIVATE_USB
{ sduObjectInit(&SDU1);
sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg);
sduStart(&SDU1, &serusbcfg);
usbDisconnectBus(serusbcfg.usbp); usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(100); chThdSleepMilliseconds(100);
usbStart(serusbcfg.usbp, &usbcfg); usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp); usbConnectBus(serusbcfg.usbp);
usb_initialized = true; usb_initialized = true;
} #endif
// Startup threads // Startup threads
start_essential_threads(); // Startup required modules (tracking managemer, watchdog) start_essential_threads(); // Startup required modules (tracking managemer, watchdog)

Wyświetl plik

@ -1,7 +1,6 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "defines.h"
#include "tracking.h" #include "tracking.h"
#include "debug.h" #include "debug.h"
#include "radio.h" #include "radio.h"
@ -18,6 +17,8 @@
#define PHASE_DELTA_2200 (((2 * 2200) << 16) / PLAYBACK_RATE) /* Delta-phase per sample for 2200Hz tone */ #define PHASE_DELTA_2200 (((2 * 2200) << 16) / PLAYBACK_RATE) /* Delta-phase per sample for 2200Hz tone */
mutex_t radio_mtx; // Radio mutex mutex_t radio_mtx; // Radio mutex
bool radio_mtx_init = false;
mod_t active_mod = MOD_NOT_SET; mod_t active_mod = MOD_NOT_SET;
static uint32_t phase_delta; // 1200/2200 for standard AX.25 static uint32_t phase_delta; // 1200/2200 for standard AX.25
static uint32_t phase; // Fixed point 9.7 (2PI = TABLE_SIZE) static uint32_t phase; // Fixed point 9.7 (2PI = TABLE_SIZE)
@ -105,8 +106,6 @@ THD_FUNCTION(si_fifo_feeder_thd, arg)
radioTune(tim_msg.freq, 0, tim_msg.power, all); radioTune(tim_msg.freq, 0, tim_msg.power, all);
while(c < all) { // Do while bytes not written into FIFO completely while(c < all) { // Do while bytes not written into FIFO completely
//chThdSuspendS(&feeder_ref); // Suspend until interrupt resumes it
// Determine free memory in Si4464-FIFO // Determine free memory in Si4464-FIFO
uint8_t more = Si4464_freeFIFO(); uint8_t more = Si4464_freeFIFO();
if(more > all-c) { if(more > all-c) {
@ -115,7 +114,7 @@ THD_FUNCTION(si_fifo_feeder_thd, arg)
} }
Si4464_writeFIFO(&tim_msg.msg[c], more); // Write into FIFO Si4464_writeFIFO(&tim_msg.msg[c], more); // Write into FIFO
c += more; c += more;
chThdSleepMilliseconds(5); chThdSleepMilliseconds(15); // That value is ok up to 38k4
} }
// Shutdown radio (and wait for Si4464 to finish transmission) // Shutdown radio (and wait for Si4464 to finish transmission)
@ -292,7 +291,7 @@ void shutdownRadio(void)
{ {
// Wait for PH to finish transmission for 2GFSK // Wait for PH to finish transmission for 2GFSK
while(active_mod == MOD_2GFSK && Si4464_getState() == SI4464_STATE_TX) while(active_mod == MOD_2GFSK && Si4464_getState() == SI4464_STATE_TX)
chThdSleepMilliseconds(5); chThdSleepMilliseconds(10);
Si4464_shutdown(); Si4464_shutdown();
active_mod = MOD_NOT_SET; active_mod = MOD_NOT_SET;
@ -435,6 +434,11 @@ uint32_t getFrequency(freq_conf_t *config)
void lockRadio(void) void lockRadio(void)
{ {
// Initialize mutex
if(!radio_mtx_init)
chMtxObjectInit(&radio_mtx);
radio_mtx_init = true;
chMtxLock(&radio_mtx); chMtxLock(&radio_mtx);
// Wait for old feeder thread to terminate // Wait for old feeder thread to terminate

Wyświetl plik

@ -275,6 +275,7 @@ const uint8_t noCameraFound[4071] = {
static uint8_t gimage_id; // Global image ID (for all image threads) static uint8_t gimage_id; // Global image ID (for all image threads)
mutex_t camera_mtx; mutex_t camera_mtx;
bool camera_mtx_init = false;
void encode_ssdv(const uint8_t *image, uint32_t image_len, module_conf_t* conf, uint8_t image_id, bool redudantTx) void encode_ssdv(const uint8_t *image, uint32_t image_len, module_conf_t* conf, uint8_t image_id, bool redudantTx)
{ {
@ -419,6 +420,11 @@ bool takePicture(ssdv_conf_t *conf, bool enableJpegValidation)
{ {
bool camera_found = false; bool camera_found = false;
// Initialize mutex
if(!camera_mtx_init)
chMtxObjectInit(&camera_mtx);
camera_mtx_init = true;
// Lock camera // Lock camera
TRACE_INFO("IMG > Lock camera"); TRACE_INFO("IMG > Lock camera");
chMtxLock(&camera_mtx); chMtxLock(&camera_mtx);

Wyświetl plik

@ -16,8 +16,8 @@ void start_essential_threads(void) {
init_watchdog(); init_watchdog();
// Initialize essential mutex's // Initialize essential mutex's
chMtxObjectInit(&camera_mtx);
chMtxObjectInit(&radio_mtx);
pi2cInit(); // Initialize I2C pi2cInit(); // Initialize I2C
pac1720_init(); // Initialize current measurement pac1720_init(); // Initialize current measurement

Wyświetl plik

@ -1,9 +1,6 @@
#ifndef __TYPES_H__ #ifndef __TYPES_H__
#define __TYPES_H__ #define __TYPES_H__
#define HIGH true
#define LOW false
typedef enum { // Modulation type typedef enum { // Modulation type
MOD_NOT_SET, MOD_NOT_SET,
MOD_OOK, MOD_OOK,