|
@@ -1,11 +1,21 @@
|
|
|
/*
|
|
|
* Project: Arrow
|
|
|
* Author: curiousmuch
|
|
|
+ * Description: This project is an APRS transceiver based on the ESP32 and CC1200.
|
|
|
+ * TODO: Refactor Code to isolate into seperate components
|
|
|
+ * TODO: Isolate BT_SPP.C functionality
|
|
|
+ * TODO: Isolate KISS.C functionality
|
|
|
+ * TODO: Remove any dependancies on Direwolf.
|
|
|
+ * TODO: Transfer DSP functions to APRS folder
|
|
|
+ * TODO: Abstract includes to be nicer (#include aprs.h) for example
|
|
|
+ * TODO: Isolate CC1200 functions from other parts / maybe integrate most of TX scheme into task.
|
|
|
*/
|
|
|
#include <stdio.h>
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
#include "freertos/task.h"
|
|
|
#include "freertos/semphr.h"
|
|
|
+#include "freertos/ringbuf.h"
|
|
|
+
|
|
|
#include "driver/gpio.h"
|
|
|
#include "sdkconfig.h"
|
|
|
#include "esp_task_wdt.h"
|
|
@@ -22,7 +32,7 @@
|
|
|
#include "esp_gap_bt_api.h"
|
|
|
#include "esp_bt_device.h"
|
|
|
#include "esp_spp_api.h"
|
|
|
-#include "bt_spp.c"
|
|
|
+#include "bt_spp.h"
|
|
|
|
|
|
#include "ax25_pad2.h"
|
|
|
#include "ax25_pad.h"
|
|
@@ -39,11 +49,6 @@
|
|
|
|
|
|
//#include "esp_dsp.h"
|
|
|
|
|
|
-uint8_t APRS_TEST_PACKET[] = { 0x82, 0x98, 0x98, 0x40, 0x40, 0x40, 0xe0, 0x96, 0x84, 0x66, 0xaa, 0x96, 0xac, 0xe0, 0xae, 0x92,
|
|
|
- 0x88, 0x8a, 0x62, 0x40, 0x62, 0xae, 0x92, 0x88, 0x8a, 0x64, 0x40, 0x65, 0x03, 0xf0, 0x3a, 0x4b,
|
|
|
- 0x42, 0x33, 0x55, 0x4b, 0x56, 0x2d, 0x32, 0x20, 0x3a, 0x48, 0x69, 0x21, 0x20, 0x54, 0x68, 0x69, 0x73,
|
|
|
- 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x54, 0x65, 0x73, 0x74, 0x7b, 0x31, 0xad, 0xa1 };
|
|
|
-
|
|
|
RingbufHandle_t radio_tx_buf;
|
|
|
RingbufHandle_t radio_rx_buf;
|
|
|
|
|
@@ -113,7 +118,7 @@ void Radio_Task(void *pvParameters)
|
|
|
rx_config.auto_reload = TIMER_AUTORELOAD_EN;
|
|
|
timer_init(TIMER_GROUP_0, TIMER_0, &rx_config);
|
|
|
timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0x00000000ULL);
|
|
|
- timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, 6666);
|
|
|
+ timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, 3030);
|
|
|
timer_isr_register(TIMER_GROUP_0, TIMER_0, rx_timer_isr,
|
|
|
(void *) TIMER_0, ESP_INTR_FLAG_IRAM, NULL);
|
|
|
|
|
@@ -205,26 +210,33 @@ void dsps_biquad_f32_ansi(const float *input, float *output, int len, float *coe
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-float lpf_coef[5];
|
|
|
-float lpf_delay[2];
|
|
|
+float lpf_coef0[5];
|
|
|
+float lpf_coef1[5];
|
|
|
+float lpf_delay0[2];
|
|
|
+float lpf_delay1[2];
|
|
|
|
|
|
void lpf_init(void)
|
|
|
{
|
|
|
// generate filter coef
|
|
|
- dsps_biquad_gen_lpf_f32(lpf_coef, 0.1999, 1);
|
|
|
+ dsps_biquad_gen_lpf_f32(lpf_coef0, 0.10, 0.54119610);
|
|
|
+ dsps_biquad_gen_lpf_f32(lpf_coef1, 0.10, 1.3065630);
|
|
|
+
|
|
|
|
|
|
// setup delay line and lpf_input window
|
|
|
int i;
|
|
|
- for(i=0;i<sizeof(lpf_delay)/sizeof(float);i++)
|
|
|
+ for(i=0;i<2;i++)
|
|
|
{
|
|
|
- lpf_delay[i] = 0;
|
|
|
+ lpf_delay0[i] = 0;
|
|
|
+ lpf_delay1[i] = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
float lpf_baseband(float input)
|
|
|
{
|
|
|
- float output;
|
|
|
- dsps_biquad_f32_ansi(&input, &output, 1, lpf_coef, lpf_delay);
|
|
|
+ float output, temp;
|
|
|
+ dsps_biquad_f32_ansi(&input, &temp, 1, lpf_coef0, lpf_delay0);
|
|
|
+ dsps_biquad_f32_ansi(&temp, &output, 1, lpf_coef1, lpf_delay1);
|
|
|
+
|
|
|
return output;
|
|
|
}
|
|
|
|
|
@@ -233,12 +245,17 @@ void RX_DSP_Task(void *pvParameters)
|
|
|
{
|
|
|
// algorithm variables
|
|
|
volatile float E_s1=0, E_s2=0, lpf_output;
|
|
|
- uint8_t raw_bit=0, previous_raw_bit=0;
|
|
|
+ volatile uint8_t raw_bit=0, previous_raw_bit=1;
|
|
|
volatile int32_t d_pll=0, dpll_error=0, err_div=0, dpll_margin = 1;
|
|
|
uint32_t success = 0;
|
|
|
+ float coeff0, coeff1;
|
|
|
+
|
|
|
+ volatile uint32_t count_start, count_stop; // needed for debuging
|
|
|
+
|
|
|
|
|
|
aprs_decoder_init();
|
|
|
frame_buffer_init(aprs_buf, 256);
|
|
|
+ goertzel_init(1200, 2200, &coeff0, &coeff1);
|
|
|
lpf_init();
|
|
|
|
|
|
// Sampling Semaphore
|
|
@@ -246,6 +263,7 @@ void RX_DSP_Task(void *pvParameters)
|
|
|
|
|
|
while(1)
|
|
|
{
|
|
|
+ count_start = xthal_get_ccount();
|
|
|
if( xSemaphoreTake(xRadioRXISRSemaphore, portMAX_DELAY) == pdTRUE)
|
|
|
{
|
|
|
|
|
@@ -255,6 +273,7 @@ void RX_DSP_Task(void *pvParameters)
|
|
|
//disable_debug_IO(DEBUG_0);
|
|
|
//enable_debug_IO(DEBUG_0);
|
|
|
EXTERNAL_DATA = (int)cc1200_radio_read_CFM();
|
|
|
+ //EXTERNAL_DATA = gpio_get_level(CC1120_GPIO2);
|
|
|
xSemaphoreGive(xRadioMutex);
|
|
|
//disable_debug_IO(DEBUG_0);
|
|
|
}
|
|
@@ -267,8 +286,10 @@ void RX_DSP_Task(void *pvParameters)
|
|
|
|
|
|
window_add(EXTERNAL_DATA);
|
|
|
int8_t *window = window_get();
|
|
|
- E_s1 = goertzelFilter2(window, 1200, WINDOW_SIZE);
|
|
|
- E_s2 = goertzelFilter2(window, 2200, WINDOW_SIZE);
|
|
|
+ E_s1 = goertzel_filter(window, coeff0, WINDOW_SIZE);
|
|
|
+ E_s2 = goertzel_filter(window, coeff1, WINDOW_SIZE);
|
|
|
+ //E_s1 = goertzelFilter(window, 1200, WINDOW_SIZE);
|
|
|
+ //E_s1 = goertzelFilter(window, 2200, WINDOW_SIZE);
|
|
|
lpf_output = lpf_baseband((E_s1 - E_s2));
|
|
|
|
|
|
if (lpf_output > 0)
|
|
@@ -307,7 +328,7 @@ void RX_DSP_Task(void *pvParameters)
|
|
|
if (d_pll >= D_PLL_MAX)
|
|
|
{
|
|
|
// set clock debug I/O high
|
|
|
- enable_debug_IO(DEBUG_0);
|
|
|
+ enable_debug_IO(DEBUG_3);
|
|
|
|
|
|
// feed bit to aprs decoder algorithm
|
|
|
switch(aprs_decoder_feed_bit(raw_bit))
|
|
@@ -333,8 +354,9 @@ void RX_DSP_Task(void *pvParameters)
|
|
|
else
|
|
|
{
|
|
|
// set clock debug I/O low
|
|
|
- disable_debug_IO(DEBUG_0);
|
|
|
+ disable_debug_IO(DEBUG_3);
|
|
|
}
|
|
|
+ count_stop = xthal_get_ccount();
|
|
|
previous_raw_bit = raw_bit;
|
|
|
}
|
|
|
}
|