Nadawanie RTTY i APRS

aprs_test
Łukasz Nidecki 2017-01-22 00:39:32 +01:00
rodzic 29b80363d4
commit 5ec1244516
7 zmienionych plików z 102 dodań i 55 usunięć

Wyświetl plik

@ -236,6 +236,7 @@ void QAPRSBase::disableTranssmision() {
this->enabled = 0;
radio_set_tx_frequency(RTTY_FREQUENCY);
radio_rw_register(0x71, 0x00, 1);
init_timer(RTTY_SPEED);
}
/**

Wyświetl plik

@ -5,12 +5,14 @@
#include "aprs.h"
#include "QAPRSBase.h"
#include "stdio.h"
#include "ublox.h"
#include "config.h"
QAPRSBase qaprs;
void aprs_init(){
qaprs.init(0, 0, (char *) "SQ5RWU", '7', (char *) "URQU70", '0', (char *) "WIDE1-1,WIDE2-1");
qaprs.init(0, 0, (const char *) APRS_CALLSIGN, (const uint8_t) APRS_SSID, (char *) "APZQAP", '0', (char *) "WIDE1-1,WIDE2-1");
}
@ -21,9 +23,42 @@ void aprs_timer_handler() {
uint8_t aprs_is_active() {
return qaprs.enabled;
}
void aprs_test(uint16_t x) {
void calcDMH(long x, int8_t* degrees, uint8_t* minutes, uint8_t* h_minutes) {
uint8_t sign = (uint8_t) (x > 0 ? 1 : 0);
if (!sign) {
x = -(x);
}
*degrees = (int8_t) (x / 1000000);
x = x - (*degrees * 1000000);
x = (x) * 60 / 10000;
*minutes = (uint8_t) (x / 100);
*h_minutes = (uint8_t) (x - (*minutes * 100));
if (!sign) {
*degrees = -*degrees;
}
}
void aprs_send_position(GPSEntry gpsData) {
char packet_buffer[128];
sprintf(packet_buffer, ":T %d", x);
int8_t la_degrees, lo_degrees;
uint8_t la_minutes, la_h_minutes, lo_minutes, lo_h_minutes;
calcDMH(gpsData.lat_raw, &la_degrees, &la_minutes, &la_h_minutes);
calcDMH(gpsData.lon_raw, &lo_degrees, &lo_minutes, &lo_h_minutes);
static uint16_t aprs_packet_counter = 0;
aprs_packet_counter ++;
sprintf(packet_buffer,
("!%02d%02d.%02u%c/%03d%02u.%02u%cO/A=%06ld/%d,%d"),
abs(la_degrees), la_minutes, la_h_minutes,
la_degrees > 0 ? 'N' : 'S',
abs(lo_degrees), lo_minutes, lo_h_minutes,
lo_degrees > 0 ? 'E' : 'W',
(gpsData.alt_raw/1000) * 3280 / 1000,
aprs_packet_counter,
gpsData.sats_raw);
qaprs.sendData(packet_buffer);
}
@ -49,4 +84,4 @@ void t(){
// QAPRS.setRelays("WIDE1-1");
// QAPRS.sendData(packet_buffer);
// delay(5000);
}
}

5
aprs.h
Wyświetl plik

@ -7,12 +7,15 @@
#ifdef __cplusplus
#include <stdint.h>
#include <stdlib.h>
#include "ublox.h"
extern "C" {
#endif
void aprs_init();
void aprs_timer_handler();
uint8_t aprs_is_active();
void aprs_test(uint16_t x);
void aprs_send_position(GPSEntry gpsData);
void aprs_change_tone_time(uint16_t x);
#ifdef __cplusplus
};

Wyświetl plik

@ -6,8 +6,12 @@
#define STM32_RTTY_CONFIG_H
//**************config**************
#define CALLSIGN "NO1LIC-1" // put your callsign here
#define APRS_CALLSIGN "NO1LIC"
#define APRS_SSID 'B'
#define RTTY_TO_APRS_RATIO 5
//*************frequency********************
#define RTTY_FREQUENCY 434.150f //Mhz middle frequency
#define RTTY_FREQUENCY 434.500f //Mhz middle frequency
#define APRS_FREQUENCY 432.500f //Mhz middle frequency
//************rtty speed****************** si4032
#define RTTY_SPEED 300
@ -16,7 +20,8 @@
//************rtty stop bits****************** si4032
#define RTTY_USE_2_STOP_BITS 0
//********* power definition**************************
#define Smoc 1 // PWR 0...7 0- MIN ... 7 - MAX
#define Smoc 7 // PWR 0...7 0- MIN ... 7 - MAX
// 7 -> 42.95 mW@434.150 MHz na E4406A
//***************************************************
//********** frame delay in msec**********

4
init.c
Wyświetl plik

@ -81,8 +81,8 @@ void RCC_Conf()
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
FLASH_SetLatency(FLASH_Latency_2);
RCC_HCLKConfig(RCC_SYSCLK_Div4); // 24 / 4 -> 6
RCC_PCLK2Config(RCC_HCLK_Div4); // 6 / 4 = 1,5 -> APB2
RCC_PCLK1Config(RCC_HCLK_Div2); // 6 / 2 = 3 -> APB1
RCC_PCLK2Config(RCC_HCLK_Div4); // 6 / 4 = 1,5 -> APB2 -> TIMERS x 2
RCC_PCLK1Config(RCC_HCLK_Div2); // 6 / 2 = 3 -> APB1 -> TIMERS x 2
RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE); // 24
while(RCC_GetSYSCLKSource() != 0x04);
}

87
main.c
Wyświetl plik

@ -48,6 +48,7 @@ rttyStates send_rtty_status = rttyZero;
volatile char *rtty_buf;
unsigned char cun_off = 0;
void send_rtty_packet();
/**
* GPS data processing
@ -121,7 +122,6 @@ int main(void) {
delay_init();
ublox_init();
int8_t temperatura;
GPIO_SetBits(GPIOB, RED);
USART_SendData(USART3, 0xc);
@ -154,54 +154,23 @@ int main(void) {
aprs_init();
radio_enable_tx();
uint16_t x = 710;
while (1){
radio_enable_tx();
USART_Cmd(USART1, DISABLE);
x+=1;
//aprs_change_tone_time(x);
aprs_test(x);
USART_Cmd(USART1, ENABLE);
radio_disable_tx();
_delay_ms(1000);
}
uint8_t rtty_before_aprs_left = RTTY_TO_APRS_RATIO;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
while (1) {
if (tx_on == 0 && tx_enable) {
start_bits = RTTY_PRE_START_BITS;
temperatura = radio_read_temperature();
napiecie = srednia(ADCVal[0] * 600 / 4096);
GPSEntry gpsData;
ublox_get_last_data(&gpsData);
if (gpsData.fix >= 3) {
flaga |= 0x80;
if (rtty_before_aprs_left){
send_rtty_packet();
rtty_before_aprs_left --;
} else {
flaga &= ~0x80;
rtty_before_aprs_left = RTTY_TO_APRS_RATIO;
radio_enable_tx();
GPSEntry gpsData;
ublox_get_last_data(&gpsData);
aprs_send_position(gpsData);
radio_disable_tx();
}
uint8_t lat_d = (uint8_t) abs(gpsData.lat_raw / 10000000);
uint32_t lat_fl = (uint32_t) abs(abs(gpsData.lat_raw) - lat_d * 10000000) / 100;
uint8_t lon_d = (uint8_t) abs(gpsData.lon_raw / 10000000);
uint32_t lon_fl = (uint32_t) abs(abs(gpsData.lon_raw) - lon_d * 10000000) / 100;
sprintf(buf_rtty, "$$$$%s,%d,%02u%02u%02u,%s%d.%05ld,%s%d.%05ld,%ld,%d,%d,%d,%d,%d,%02x", callsign, send_cun,
gpsData.hours, gpsData.minutes, gpsData.seconds,
gpsData.lat_raw < 0 ? "-" : "", lat_d, lat_fl,
gpsData.lon_raw < 0 ? "-" : "", lon_d, lon_fl,
(gpsData.alt_raw / 1000), temperatura, napiecie, gpsData.sats_raw,
gpsData.ok_packets, gpsData.bad_packets,
flaga);
CRC_rtty = 0xffff; //napiecie flaga
CRC_rtty = gps_CRC16_checksum(buf_rtty + 4);
sprintf(buf_rtty, "%s*%04X\n", buf_rtty, CRC_rtty & 0xffff);
rtty_buf = buf_rtty;
radio_enable_tx();
tx_on = 1;
send_cun++;
} else {
NVIC_SystemLPConfig(NVIC_LP_SEVONPEND, DISABLE);
__WFI();
@ -210,6 +179,40 @@ int main(void) {
#pragma clang diagnostic pop
}
void send_rtty_packet() {
start_bits = RTTY_PRE_START_BITS;
int8_t temperatura = radio_read_temperature();
napiecie = srednia(ADCVal[0] * 600 / 4096);
GPSEntry gpsData;
ublox_get_last_data(&gpsData);
if (gpsData.fix >= 3) {
flaga |= 0x80;
} else {
flaga &= ~0x80;
}
uint8_t lat_d = (uint8_t) abs(gpsData.lat_raw / 10000000);
uint32_t lat_fl = (uint32_t) abs(abs(gpsData.lat_raw) - lat_d * 10000000) / 100;
uint8_t lon_d = (uint8_t) abs(gpsData.lon_raw / 10000000);
uint32_t lon_fl = (uint32_t) abs(abs(gpsData.lon_raw) - lon_d * 10000000) / 100;
sprintf(buf_rtty, "$$$$%s,%d,%02u%02u%02u,%s%d.%05ld,%s%d.%05ld,%ld,%d,%d,%d,%d,%d,%02x", callsign, send_cun,
gpsData.hours, gpsData.minutes, gpsData.seconds,
gpsData.lat_raw < 0 ? "-" : "", lat_d, lat_fl,
gpsData.lon_raw < 0 ? "-" : "", lon_d, lon_fl,
(gpsData.alt_raw / 1000), temperatura, napiecie, gpsData.sats_raw,
gpsData.ok_packets, gpsData.bad_packets,
flaga);
CRC_rtty = 0xffff; //napiecie flaga
CRC_rtty = gps_CRC16_checksum(buf_rtty + 4);
sprintf(buf_rtty, "%s*%04X\n", buf_rtty, CRC_rtty & 0xffff);
rtty_buf = buf_rtty;
radio_enable_tx();
tx_on = 1;
send_cun++;
}
#ifdef DEBUG
void assert_failed(uint8_t* file, uint32_t line)
{

Wyświetl plik

@ -86,8 +86,8 @@
<File name="cmsis_boot" path="" type="2"/>
<File name="delay.h" path="delay.h" type="1"/>
<File name="init.h" path="init.h" type="1"/>
<File name="stm_lib/src/stm32f10x_tim.c" path="stm_lib/src/stm32f10x_tim.c" type="1"/>
<File name="stm_lib/inc/stm32f10x_pwr.h" path="stm_lib/inc/stm32f10x_pwr.h" type="1"/>
<File name="stm_lib/src/stm32f10x_tim.c" path="stm_lib/src/stm32f10x_tim.c" type="1"/>
<File name="cmsis_boot/startup" path="" type="2"/>
<File name="cmsis/core_cmFunc.h" path="cmsis/core_cmFunc.h" type="1"/>
<File name="stm_lib/src/misc.c" path="stm_lib/src/misc.c" type="1"/>
@ -100,8 +100,8 @@
<File name="syscalls/syscalls.c" path="syscalls/syscalls.c" type="1"/>
<File name="stm_lib/inc/stm32f10x_spi.h" path="stm_lib/inc/stm32f10x_spi.h" type="1"/>
<File name="init.c" path="init.c" type="1"/>
<File name="stm_lib/inc/stm32f10x_dma.h" path="stm_lib/inc/stm32f10x_dma.h" type="1"/>
<File name="stm_lib/src/stm32f10x_adc.c" path="stm_lib/src/stm32f10x_adc.c" type="1"/>
<File name="stm_lib/inc/stm32f10x_dma.h" path="stm_lib/inc/stm32f10x_dma.h" type="1"/>
<File name="radio.c" path="radio.c" type="1"/>
<File name="ublox.h" path="ublox.h" type="1"/>
<File name="stm_lib/src/stm32f10x_usart.c" path="stm_lib/src/stm32f10x_usart.c" type="1"/>
@ -113,14 +113,14 @@
<File name="cmsis_boot/system_stm32f10x.c" path="cmsis_boot/system_stm32f10x.c" type="1"/>
<File name="stm_lib/inc/misc.h" path="stm_lib/inc/misc.h" type="1"/>
<File name="cmsis/core_cmInstr.h" path="cmsis/core_cmInstr.h" type="1"/>
<File name="QAPRSCommon.h" path="QAPRSCommon.h" type="1"/>
<File name="cmsis/core_cm3.h" path="cmsis/core_cm3.h" type="1"/>
<File name="QAPRSCommon.h" path="QAPRSCommon.h" type="1"/>
<File name="stm_lib/src/stm32f10x_rcc.c" path="stm_lib/src/stm32f10x_rcc.c" type="1"/>
<File name="fun.c" path="fun.c" type="1"/>
<File name="aprs.cpp" path="aprs.cpp" type="1"/>
<File name="radio.h" path="radio.h" type="1"/>
<File name="f_rtty.h" path="f_rtty.h" type="1"/>
<File name="stm_lib/src/stm32f10x_dma.c" path="stm_lib/src/stm32f10x_dma.c" type="1"/>
<File name="f_rtty.h" path="f_rtty.h" type="1"/>
<File name="stm_lib/src" path="" type="2"/>
<File name="cmsis" path="" type="2"/>
<File name="stm_lib" path="" type="2"/>