|
@@ -50,7 +50,7 @@ SemaphoreHandle_t xRadioTXSemaphore;
|
|
|
|
|
|
extern int8_t EXTERNAL_DATA;
|
|
|
|
|
|
-#define WINDOW_SIZE 6
|
|
|
+#define WINDOW_SIZE 7
|
|
|
#define SAMPLEFREQUENCY 6000
|
|
|
|
|
|
int window[WINDOW_SIZE];
|
|
@@ -115,7 +115,7 @@ int window_get_size(void)
|
|
|
void IRAM_ATTR rx_timer_isr(void *para)
|
|
|
{
|
|
|
|
|
|
- GPIO.out_w1ts = (1 << DEBUG_0);
|
|
|
+ //GPIO.out_w1ts = (1 << DEBUG_0);
|
|
|
|
|
|
int timer_idx = (int) para;
|
|
|
|
|
@@ -135,7 +135,7 @@ void IRAM_ATTR rx_timer_isr(void *para)
|
|
|
portYIELD_FROM_ISR( );
|
|
|
}
|
|
|
|
|
|
- GPIO.out_w1tc = (1 << DEBUG_0);
|
|
|
+ //GPIO.out_w1tc = (1 << DEBUG_0);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -144,8 +144,49 @@ void TX_Task(void *pvParameters)
|
|
|
{
|
|
|
size_t p_size;
|
|
|
|
|
|
+ // Setup Timer for TX Task
|
|
|
+ timer_config_t config;
|
|
|
+ config.divider = 2;
|
|
|
+ config.counter_dir = TIMER_COUNT_UP;
|
|
|
+ config.counter_en = TIMER_PAUSE;
|
|
|
+ config.alarm_en = TIMER_ALARM_EN;
|
|
|
+ config.intr_type = TIMER_INTR_LEVEL;
|
|
|
+ config.auto_reload = TIMER_AUTORELOAD_EN;
|
|
|
+ timer_init(TIMER_GROUP_0, TIMER_1, &config);
|
|
|
+ timer_set_counter_value(TIMER_GROUP_0, TIMER_1, 0x00000000ULL);
|
|
|
+ timer_set_alarm_value(TIMER_GROUP_0, TIMER_1, 3030);
|
|
|
+ timer_isr_register(TIMER_GROUP_0, TIMER_1, cc1200_aprs_tx_isr,
|
|
|
+ (void *) TIMER_1, ESP_INTR_FLAG_IRAM, NULL);
|
|
|
+
|
|
|
+ // Setup Sampling Timer for RX Task
|
|
|
+ timer_config_t rx_config;
|
|
|
+ rx_config.divider = 2;
|
|
|
+ rx_config.counter_dir = TIMER_COUNT_UP;
|
|
|
+ rx_config.counter_en = TIMER_PAUSE;
|
|
|
+ rx_config.alarm_en = TIMER_ALARM_EN;
|
|
|
+ rx_config.intr_type = TIMER_INTR_LEVEL;
|
|
|
+ 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_isr_register(TIMER_GROUP_0, TIMER_0, rx_timer_isr,
|
|
|
+ (void *) TIMER_0, ESP_INTR_FLAG_IRAM, NULL);
|
|
|
+
|
|
|
+ // Initialize Radio
|
|
|
+ cc1200_radio_init(APRS_RX2_SETTINGS, sizeof(APRS_RX2_SETTINGS)/sizeof(cc1200_reg_settings_t));
|
|
|
+ cc1200_radio_frequency(144390000);
|
|
|
+
|
|
|
+
|
|
|
while(1)
|
|
|
{
|
|
|
+ // setup LEDs for RX mode
|
|
|
+ disable_red_led();
|
|
|
+ enable_green_led();
|
|
|
+ cc1200_radio_start_APRSRX();
|
|
|
+ timer_enable_intr(TIMER_GROUP_0, TIMER_0);
|
|
|
+ timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0x00000000ULL);
|
|
|
+ timer_start(TIMER_GROUP_0, TIMER_0);
|
|
|
+
|
|
|
|
|
|
// block until packet is in queue
|
|
|
uint8_t *p = (uint8_t *)xRingbufferReceive(radio_tx_buf, &p_size, portMAX_DELAY);
|
|
@@ -155,26 +196,18 @@ void TX_Task(void *pvParameters)
|
|
|
{
|
|
|
|
|
|
// disable RX mode
|
|
|
- timer_pause(TIMER_GROUP_0, TIMER_0);
|
|
|
timer_disable_intr(TIMER_GROUP_0, TIMER_0);
|
|
|
+ timer_pause(TIMER_GROUP_0, TIMER_0);
|
|
|
cc1200_radio_stop_APRSRX();
|
|
|
|
|
|
// setup LEDs for TX mode
|
|
|
enable_red_led();
|
|
|
disable_green_led();
|
|
|
|
|
|
- cc1200_radio_APRSTXPacket(p, p_size, 2, 0);
|
|
|
+ cc1200_radio_APRSTXPacket(p, p_size, 4, 1);
|
|
|
|
|
|
vRingbufferReturnItem(radio_tx_buf, (void *)p);
|
|
|
|
|
|
- // setup LEDs for RX mode
|
|
|
- disable_red_led();
|
|
|
- enable_green_led();
|
|
|
-
|
|
|
- cc1200_radio_start_APRSRX();
|
|
|
- timer_enable_intr(TIMER_GROUP_0, TIMER_0);
|
|
|
- timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0x00000000ULL);
|
|
|
- timer_start(TIMER_GROUP_0, TIMER_0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -198,6 +231,7 @@ void RX_Task(void *pvParameters)
|
|
|
double E_s1=0, E_s2=0;
|
|
|
uint8_t raw_bit=0, previous_raw_bit=0;
|
|
|
int32_t d_pll=0, dpll_error=0, err_div=2;
|
|
|
+ int lpf_input = 0;
|
|
|
int lpf_output = 0;
|
|
|
|
|
|
aprs_decoder_init();
|
|
@@ -206,40 +240,36 @@ void RX_Task(void *pvParameters)
|
|
|
// Sampling Semaphore
|
|
|
xRadioRXISRSemaphore = xSemaphoreCreateBinary();
|
|
|
|
|
|
- // setup LEDs for RX mode
|
|
|
- enable_green_led();
|
|
|
- disable_red_led();
|
|
|
-
|
|
|
- cc1200_radio_start_APRSRX();
|
|
|
- timer_enable_intr(TIMER_GROUP_0, TIMER_0);
|
|
|
- timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0x00000000ULL);
|
|
|
- timer_start(TIMER_GROUP_0, TIMER_0);
|
|
|
-
|
|
|
-
|
|
|
while(1)
|
|
|
{
|
|
|
if( xSemaphoreTake(xRadioRXISRSemaphore, portMAX_DELAY) == pdTRUE)
|
|
|
{
|
|
|
|
|
|
- enable_debug_IO(DEBUG_0);
|
|
|
+ //enable_debug_IO(DEBUG_0);
|
|
|
EXTERNAL_DATA = (int)cc1200_radio_read_CFM();
|
|
|
- disable_debug_IO(DEBUG_0);
|
|
|
- enable_debug_IO(DEBUG_0);
|
|
|
- lpf_output += (50000 * (((int)EXTERNAL_DATA) - lpf_output)) / 100000;
|
|
|
+ //disable_debug_IO(DEBUG_0);
|
|
|
+ //enable_debug_IO(DEBUG_0);
|
|
|
+ //lpf_output += (50000 * (((int)EXTERNAL_DATA) - lpf_output)) / 100000;
|
|
|
window_add((int) EXTERNAL_DATA);
|
|
|
E_s1 = goertzelFilter(window, 1200, WINDOW_SIZE);
|
|
|
E_s2 = goertzelFilter(window, 2200, WINDOW_SIZE);
|
|
|
+
|
|
|
if (E_s1 > E_s2)
|
|
|
{
|
|
|
raw_bit = 1;
|
|
|
+ enable_debug_IO(DEBUG_2);
|
|
|
+ enable_debug_IO(DEBUG_0);
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
raw_bit = 0;
|
|
|
+ disable_debug_IO(DEBUG_2);
|
|
|
+ disable_debug_IO(DEBUG_0);
|
|
|
}
|
|
|
|
|
|
- disable_debug_IO(DEBUG_0);
|
|
|
- enable_debug_IO(DEBUG_0);
|
|
|
+ //disable_debug_IO(DEBUG_0);
|
|
|
+ //enable_debug_IO(DEBUG_0);
|
|
|
// DPLL for sampling
|
|
|
if (raw_bit != previous_raw_bit)
|
|
|
{
|
|
@@ -258,11 +288,11 @@ void RX_Task(void *pvParameters)
|
|
|
|
|
|
d_pll += D_PLL_INC;
|
|
|
|
|
|
- disable_debug_IO(DEBUG_0);
|
|
|
- enable_debug_IO(DEBUG_0);
|
|
|
+ disable_debug_IO(DEBUG_3);
|
|
|
if (d_pll >= D_PLL_MAX)
|
|
|
{
|
|
|
// set clock debug I/O high
|
|
|
+ enable_debug_IO(DEBUG_3);
|
|
|
|
|
|
// feed bit to aprs decoder algorithm
|
|
|
switch(aprs_decoder_feed_bit(raw_bit))
|
|
@@ -271,7 +301,8 @@ void RX_Task(void *pvParameters)
|
|
|
break;
|
|
|
case FRAME_DECODED:
|
|
|
ESP_LOGI("APRS RX", "AX.25 Frame Received");
|
|
|
- ESP_LOG_BUFFER_HEXDUMP("APRS RX", aprs_buf, 100, ESP_LOG_INFO);
|
|
|
+ // send via KISS TNC to over BLE SPP
|
|
|
+ //ESP_LOG_BUFFER_HEXDUMP("APRS RX", aprs_buf, 100, ESP_LOG_INFO);
|
|
|
break;
|
|
|
case ERROR_FCS_MISMATCH:
|
|
|
ESP_LOGV("APRS RX", "AX.25 FCS Error\n");
|
|
@@ -288,7 +319,7 @@ void RX_Task(void *pvParameters)
|
|
|
// set clock debug I/O low
|
|
|
}
|
|
|
previous_raw_bit = raw_bit;
|
|
|
- disable_debug_IO(DEBUG_0);
|
|
|
+ //disable_debug_IO(DEBUG_0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -300,24 +331,6 @@ void radio_init()
|
|
|
xRadioRXSemaphore = xSemaphoreCreateBinary();
|
|
|
xRadioTXSemaphore = xSemaphoreCreateBinary();
|
|
|
|
|
|
- // Initialize Radio
|
|
|
- cc1200_radio_init(APRS_RX2_SETTINGS, sizeof(APRS_RX2_SETTINGS)/sizeof(cc1200_reg_settings_t));
|
|
|
- cc1200_radio_frequency(144390000-6000);
|
|
|
-
|
|
|
- // Setup Sampling Timer
|
|
|
- timer_config_t config;
|
|
|
- config.divider = 2;
|
|
|
- config.counter_dir = TIMER_COUNT_UP;
|
|
|
- config.counter_en = TIMER_PAUSE;
|
|
|
- config.alarm_en = TIMER_ALARM_EN;
|
|
|
- config.intr_type = TIMER_INTR_LEVEL;
|
|
|
- config.auto_reload = TIMER_AUTORELOAD_EN;
|
|
|
- timer_init(TIMER_GROUP_0, TIMER_0, &config);
|
|
|
- timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0x00000000ULL);
|
|
|
- timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, 6666);
|
|
|
- timer_isr_register(TIMER_GROUP_0, TIMER_0, rx_timer_isr,
|
|
|
- (void *) TIMER_0, ESP_INTR_FLAG_IRAM, NULL);
|
|
|
-
|
|
|
xTaskCreatePinnedToCore(TX_Task, "TX Task", 1024*4, 0, 2, NULL, 1);
|
|
|
xTaskCreatePinnedToCore(RX_Task, "RX Task", 1024*4, 0, 1, NULL, 1);
|
|
|
|