kopia lustrzana https://github.com/DL7AD/pecanpico9
Increased FIFO buffer in Si4464 to 129bytes
Decreased buffer of USB image capturing Removed defines.h Moved mutex initialization to radio.c and image.cDevelop
rodzic
8ba7249a7e
commit
a4087588fa
|
@ -33,7 +33,7 @@ void debugOnUSB_On(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
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)chp;
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef __DEFINES_H__
|
||||
#define __DEFINES_H__
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#define HIGH true
|
||||
#define LOW false
|
||||
|
||||
#endif
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
#include "ov5640.h"
|
||||
#include "pi2c.h"
|
||||
#include "board.h"
|
||||
#include "defines.h"
|
||||
#include "debug.h"
|
||||
#include "ssdv.h"
|
||||
#include <string.h>
|
||||
|
|
|
@ -287,6 +287,16 @@ void setModem2GFSK(gfsk_conf_t* conf) {
|
|||
uint8_t set_fifo_irq[] = {0x11, 0x12, 0x01, 0x0B, 0x20};
|
||||
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
|
||||
uint8_t disable_preamble[] = {0x11, 0x10, 0x01, 0x00, 0x00};
|
||||
Si4464_write(disable_preamble, 5);
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "defines.h"
|
||||
#include "types.h"
|
||||
|
||||
#define RADIO_WRITE_GPIO(state) palWriteLine(LINE_RADIO_GPIO, state)
|
||||
#define RADIO_READ_GPIO() palReadLine(LINE_RADIO_GPIO)
|
||||
#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_SLEEP 1
|
||||
#define SI4464_STATE_SPI_ACTIVE 2
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "ublox.h"
|
||||
#include "pi2c.h"
|
||||
#include "debug.h"
|
||||
#include "config.h"
|
||||
#include "defines.h"
|
||||
|
||||
// Serial driver configuration for GPS
|
||||
const SerialConfig gps_config =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "padc.h"
|
||||
#include "pac1720.h"
|
||||
|
|
|
@ -28,28 +28,26 @@ int main(void) {
|
|||
chSysInit(); // Startup RTOS
|
||||
|
||||
// Voltage switching (1.8V <=> 3.0V)
|
||||
if(ACTIVATE_USB || ACTIVATE_3V)
|
||||
{
|
||||
boost_voltage(true); // Ramp up voltage to 3V
|
||||
chThdSleepMilliseconds(100);
|
||||
}
|
||||
#if ACTIVATE_USB || ACTIVATE_3V
|
||||
boost_voltage(true); // Ramp up voltage to 3V
|
||||
chThdSleepMilliseconds(100);
|
||||
#endif
|
||||
|
||||
// Init debugging (Serial debug port, LEDs)
|
||||
DEBUG_INIT();
|
||||
TRACE_INFO("MAIN > Startup");
|
||||
|
||||
// Start USB
|
||||
if(ACTIVATE_USB)
|
||||
{
|
||||
sduObjectInit(&SDU1);
|
||||
sduStart(&SDU1, &serusbcfg);
|
||||
#if ACTIVATE_USB
|
||||
sduObjectInit(&SDU1);
|
||||
sduStart(&SDU1, &serusbcfg);
|
||||
|
||||
usbDisconnectBus(serusbcfg.usbp);
|
||||
chThdSleepMilliseconds(100);
|
||||
usbStart(serusbcfg.usbp, &usbcfg);
|
||||
usbConnectBus(serusbcfg.usbp);
|
||||
usb_initialized = true;
|
||||
}
|
||||
usbDisconnectBus(serusbcfg.usbp);
|
||||
chThdSleepMilliseconds(100);
|
||||
usbStart(serusbcfg.usbp, &usbcfg);
|
||||
usbConnectBus(serusbcfg.usbp);
|
||||
usb_initialized = true;
|
||||
#endif
|
||||
|
||||
// Startup threads
|
||||
start_essential_threads(); // Startup required modules (tracking managemer, watchdog)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "tracking.h"
|
||||
#include "debug.h"
|
||||
#include "radio.h"
|
||||
|
@ -18,6 +17,8 @@
|
|||
#define PHASE_DELTA_2200 (((2 * 2200) << 16) / PLAYBACK_RATE) /* Delta-phase per sample for 2200Hz tone */
|
||||
|
||||
mutex_t radio_mtx; // Radio mutex
|
||||
bool radio_mtx_init = false;
|
||||
|
||||
mod_t active_mod = MOD_NOT_SET;
|
||||
static uint32_t phase_delta; // 1200/2200 for standard AX.25
|
||||
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);
|
||||
|
||||
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
|
||||
uint8_t more = Si4464_freeFIFO();
|
||||
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
|
||||
c += more;
|
||||
chThdSleepMilliseconds(5);
|
||||
chThdSleepMilliseconds(15); // That value is ok up to 38k4
|
||||
}
|
||||
|
||||
// Shutdown radio (and wait for Si4464 to finish transmission)
|
||||
|
@ -292,7 +291,7 @@ void shutdownRadio(void)
|
|||
{
|
||||
// Wait for PH to finish transmission for 2GFSK
|
||||
while(active_mod == MOD_2GFSK && Si4464_getState() == SI4464_STATE_TX)
|
||||
chThdSleepMilliseconds(5);
|
||||
chThdSleepMilliseconds(10);
|
||||
|
||||
Si4464_shutdown();
|
||||
active_mod = MOD_NOT_SET;
|
||||
|
@ -435,6 +434,11 @@ uint32_t getFrequency(freq_conf_t *config)
|
|||
|
||||
void lockRadio(void)
|
||||
{
|
||||
// Initialize mutex
|
||||
if(!radio_mtx_init)
|
||||
chMtxObjectInit(&radio_mtx);
|
||||
radio_mtx_init = true;
|
||||
|
||||
chMtxLock(&radio_mtx);
|
||||
|
||||
// Wait for old feeder thread to terminate
|
||||
|
|
|
@ -275,6 +275,7 @@ const uint8_t noCameraFound[4071] = {
|
|||
|
||||
static uint8_t gimage_id; // Global image ID (for all image threads)
|
||||
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)
|
||||
{
|
||||
|
@ -419,6 +420,11 @@ bool takePicture(ssdv_conf_t *conf, bool enableJpegValidation)
|
|||
{
|
||||
bool camera_found = false;
|
||||
|
||||
// Initialize mutex
|
||||
if(!camera_mtx_init)
|
||||
chMtxObjectInit(&camera_mtx);
|
||||
camera_mtx_init = true;
|
||||
|
||||
// Lock camera
|
||||
TRACE_INFO("IMG > Lock camera");
|
||||
chMtxLock(&camera_mtx);
|
||||
|
|
|
@ -16,8 +16,8 @@ void start_essential_threads(void) {
|
|||
init_watchdog();
|
||||
|
||||
// Initialize essential mutex's
|
||||
chMtxObjectInit(&camera_mtx);
|
||||
chMtxObjectInit(&radio_mtx);
|
||||
|
||||
|
||||
|
||||
pi2cInit(); // Initialize I2C
|
||||
pac1720_init(); // Initialize current measurement
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#ifndef __TYPES_H__
|
||||
#define __TYPES_H__
|
||||
|
||||
#define HIGH true
|
||||
#define LOW false
|
||||
|
||||
typedef enum { // Modulation type
|
||||
MOD_NOT_SET,
|
||||
MOD_OOK,
|
||||
|
|
Ładowanie…
Reference in New Issue