kopia lustrzana https://github.com/Qyon/STM32_RTTY
Uprzatnięcie kodu GPS, usunięcie prędkości i kierunku z danych rtty
rodzic
a9544b7348
commit
ef6a8c3806
2
config.h
2
config.h
|
@ -26,7 +26,7 @@
|
|||
//***************************************************
|
||||
|
||||
//********** frame delay in msec**********
|
||||
#define tx_delay 100 // 2500 ~2,5 w polu flaga wpisywany jest tx_delay/1000 modulo 16 czyl;i dla 16000 bedzie 0 póki co.
|
||||
#define tx_delay 1000
|
||||
|
||||
|
||||
#endif //STM32_RTTY_CONFIG_H
|
||||
|
|
179
main.c
179
main.c
|
@ -24,91 +24,31 @@
|
|||
const unsigned char test = 0; // 0 - normal, 1 - short frame only cunter, height, flag
|
||||
char callsign[15] = {CALLSIGN};
|
||||
|
||||
#define gps_RMC_dlugosc 5
|
||||
#define gps_RMC_dlugosc_len 10
|
||||
#define gps_RMC_dlugosc_kier 6
|
||||
#define gps_RMC_dlugosc_kier_len 1
|
||||
#define gps_RMC_szerokosc 3
|
||||
#define gps_RMC_szerokosc_len 9
|
||||
#define gps_RMC_szerokosc_kier 4
|
||||
#define gps_RMC_szerokosc_kier_len 1
|
||||
#define gps_RMC_status 2
|
||||
#define gps_RMC_status_len 1
|
||||
#define gps_RMC_data 9
|
||||
#define gps_RMC_data_len 6
|
||||
#define gps_RMC_czas 1
|
||||
#define gps_RMC_czas_len 6
|
||||
#define gps_RMC_predkosc 7
|
||||
#define gps_RMC_predkosc_len 5
|
||||
#define gps_RMC_kierunek 8
|
||||
#define gps_RMC_kierunek_len 5
|
||||
#define gps_GGA_wysokosc 9
|
||||
#define gps_GGA_wysokosc_len 5 //*
|
||||
#define gps_GGA_use_sat 7
|
||||
#define gps_GGA_use_sat_len 2 //*
|
||||
#define gps_VTG_predkosc 7
|
||||
#define gps_VTG_predkosc_len 5
|
||||
|
||||
#define GREEN GPIO_Pin_7
|
||||
#define RED GPIO_Pin_8
|
||||
#define GPS_START '$'
|
||||
#define GPS_STOP 0x0a // LF
|
||||
#define OFF GPIO_Pin_12
|
||||
unsigned int send_cun; //frame counter
|
||||
char czas[7] = {"000000"};
|
||||
char status[2] = {'N'};
|
||||
char dlugosc[14] = {"0.00000"};
|
||||
char dlugosc_kier = 0;//'W';
|
||||
char szerokosc[13] = {"0.00000"};
|
||||
char szerokosc_kier = 0;// 'S';s
|
||||
char wysokosc[6] = {"0"};
|
||||
char predkosc[6] = {"0"};
|
||||
char kierunek[6] = {"0"};
|
||||
char FixOk = 0;
|
||||
int napiecie;
|
||||
unsigned int czest;
|
||||
|
||||
float deg = 0;
|
||||
float fbuf = 0;
|
||||
char use_sat[3] = {'0'};
|
||||
unsigned int send_cun; //frame counter
|
||||
char status[2] = {'N'};
|
||||
int napiecie;
|
||||
|
||||
char flaga = ((((tx_delay / 1000) & 0x0f) << 3) | Smoc);
|
||||
uint16_t CRC_rtty = 0x12ab; //checksum
|
||||
char buf[512];
|
||||
char buf_rtty[200];
|
||||
char menu[] = "$$$$$$STM32 RTTY tracker by Blasiu, enjoy and see you on the HUB... \n\r";
|
||||
char init_trx[] = "\n\rPowering up TX\n\r";
|
||||
char powitanie[] = "greetings from earth";
|
||||
unsigned char pun = 0;
|
||||
unsigned int cun = 10;
|
||||
unsigned char dev = 0;
|
||||
unsigned char tx_on = 0;
|
||||
volatile unsigned char tx_on = 0;
|
||||
unsigned int tx_on_delay;
|
||||
unsigned char tx_enable = 0;
|
||||
volatile unsigned char tx_enable = 0;
|
||||
rttyStates send_rtty_status = rttyZero;
|
||||
unsigned char cun_rtty = 0;
|
||||
char *rtty_buf;
|
||||
unsigned char GPS_temp;
|
||||
char GPS_buf[200];
|
||||
char *wsk_GPS_buf;
|
||||
char GPS_rec = 0;
|
||||
char new_GPS_msg = 0;
|
||||
unsigned char crc_GPS = 0;
|
||||
char crc_GPS_start = 0;
|
||||
char crc_GPS_rec = 0;
|
||||
char crc_GPS_cun = 0;
|
||||
uint8_t confGPSNAV[] = {0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27,
|
||||
0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t GPSon[] = {0xB5, 0x62, 0x02, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x4C, 0x37};
|
||||
uint8_t GPSoff[] = {0xB5, 0x62, 0x02, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00};//, 0x4D, 0x3B};
|
||||
uint8_t GPS_ZDA_OFF[] = {0xb5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xf0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t GPS_GLL_OFF[] = {0xb5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t GPS_GSA_OFF[] = {0xb5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t GPS_GSV_OFF[] = {0xb5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
int Button = 0;
|
||||
unsigned char cun_off = 0;
|
||||
unsigned char bOFF = 0;
|
||||
unsigned char bCheckKay = 0;
|
||||
unsigned char GPSConf = 0;
|
||||
|
||||
|
||||
void processGPS();
|
||||
|
@ -133,7 +73,7 @@ void TIM2_IRQHandler(void) {
|
|||
GPIO_SetBits(GPIOB, RED);
|
||||
if (*(++rtty_buf) == 0) {
|
||||
tx_on = 0;
|
||||
tx_on_delay = 1;//tx_delay;//2500;
|
||||
tx_on_delay = tx_delay / (1000/RTTY_SPEED);//2500;
|
||||
tx_enable = 0;
|
||||
radio_disable_tx();
|
||||
}
|
||||
|
@ -162,7 +102,6 @@ void TIM2_IRQHandler(void) {
|
|||
}
|
||||
cun = 200;
|
||||
}
|
||||
bCheckKay = 1;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
|
@ -180,8 +119,6 @@ int main(void) {
|
|||
|
||||
ublox_init();
|
||||
|
||||
wsk_GPS_buf = GPS_buf;
|
||||
|
||||
int8_t temperatura;
|
||||
|
||||
GPIO_SetBits(GPIOB, RED);
|
||||
|
@ -214,7 +151,7 @@ int main(void) {
|
|||
tx_on = 0;
|
||||
tx_enable = 1;
|
||||
//tx_enable =0;
|
||||
Button = ADCVal[1];
|
||||
//Button = ADCVal[1];
|
||||
|
||||
|
||||
while (1) {
|
||||
|
@ -230,19 +167,15 @@ int main(void) {
|
|||
} else {
|
||||
flaga &= ~0x80;
|
||||
}
|
||||
if (test) {
|
||||
sprintf(buf_rtty, "$$$$$$$%d,%d,%02x", send_cun, atoi(wysokosc), flaga);
|
||||
} else {
|
||||
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,%s,%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), atoi(predkosc), kierunek, temperatura, napiecie, gpsData.fix, gpsData.sats_raw, flaga);
|
||||
}
|
||||
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,%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, flaga);
|
||||
CRC_rtty = 0xffff; //napiecie flaga
|
||||
CRC_rtty = gps_CRC16_checksum(buf_rtty + 7);
|
||||
sprintf(buf_rtty, "%s*%04X\n", buf_rtty, CRC_rtty & 0xffff);
|
||||
|
@ -252,85 +185,9 @@ int main(void) {
|
|||
|
||||
send_cun++;
|
||||
}
|
||||
|
||||
//processGPS();
|
||||
}
|
||||
}
|
||||
|
||||
void processGPS() {
|
||||
if (new_GPS_msg) {
|
||||
//print(GPS_buf);
|
||||
new_GPS_msg = 0;
|
||||
if (strncmp(GPS_buf, "$GPRMC", 6) == 0) {
|
||||
// if (czytaj_GPS(gps_RMC_czas, gps_RMC_czas_len, GPS_buf, czas) == 0) {
|
||||
// strcpy(czas, "000000");
|
||||
// }
|
||||
|
||||
if (czytaj_GPS(gps_RMC_kierunek, gps_RMC_kierunek_len, GPS_buf, kierunek) == 0) {
|
||||
strcpy(kierunek, "0");
|
||||
}
|
||||
if (czytaj_GPS(gps_RMC_szerokosc, gps_RMC_szerokosc_len, GPS_buf, szerokosc) == 0) {
|
||||
strcpy(szerokosc, "0.00000");
|
||||
}
|
||||
|
||||
if (czytaj_GPS(gps_RMC_szerokosc_kier, gps_RMC_szerokosc_kier_len, GPS_buf, &szerokosc_kier) == 0) {
|
||||
szerokosc_kier = 0;
|
||||
}
|
||||
|
||||
if (czytaj_GPS(gps_RMC_dlugosc, gps_RMC_dlugosc_len, GPS_buf, dlugosc) == 0) {
|
||||
strcpy(dlugosc, "0.00000");
|
||||
}
|
||||
|
||||
if (czytaj_GPS(gps_RMC_dlugosc_kier, gps_RMC_dlugosc_kier_len, GPS_buf, &dlugosc_kier) == 0) {
|
||||
dlugosc_kier = 0;
|
||||
}
|
||||
|
||||
|
||||
if (czytaj_GPS(gps_RMC_status, gps_RMC_status_len, GPS_buf, status) == 0) {
|
||||
strcpy(status, "-");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (strncmp(GPS_buf, "$GPGGA", 6) == 0) {
|
||||
if (czytaj_GPS(gps_GGA_wysokosc, gps_GGA_wysokosc_len, GPS_buf, wysokosc) == 0) {
|
||||
strcpy(wysokosc, "0");
|
||||
}
|
||||
if (czytaj_GPS(gps_GGA_use_sat, gps_GGA_use_sat_len, GPS_buf, use_sat) == 0) {
|
||||
strcpy(use_sat, "0");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (strncmp(GPS_buf, "$GPVTG", 6) == 0) {
|
||||
if (czytaj_GPS(gps_VTG_predkosc, gps_VTG_predkosc_len, GPS_buf, predkosc) == 0) {
|
||||
strcpy(predkosc, "0");
|
||||
}
|
||||
}
|
||||
if (strncmp(GPS_buf, "$GPZDA", 6) == 0) {
|
||||
switch (GPSConf) {
|
||||
case 0:
|
||||
send_ublox_packet((uBloxPacket *) confGPSNAV);
|
||||
break;
|
||||
case 1:
|
||||
send_ublox_packet((uBloxPacket *) GPS_GSV_OFF);
|
||||
break;
|
||||
case 2:
|
||||
send_ublox_packet((uBloxPacket *) GPS_GSA_OFF);
|
||||
break;
|
||||
case 3:
|
||||
send_ublox_packet((uBloxPacket *) GPS_GLL_OFF);
|
||||
break;
|
||||
case 4:
|
||||
send_ublox_packet((uBloxPacket *) GPS_ZDA_OFF);
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
GPSConf++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
49
ublox.c
49
ublox.c
|
@ -66,13 +66,19 @@ void ublox_get_last_data(GPSEntry * gpsEntry){
|
|||
}
|
||||
|
||||
void ublox_init(){
|
||||
uBloxPacket msgcfgrst = {.header = {0xb5, 0x62, .messageClass=0x06, .messageId=0x04, .payloadSize=sizeof(uBloxCFGRSTPayload)},
|
||||
.data.cfgrst = { .navBbrMask=0xffff, .resetMode=0, .reserved1 = 0}
|
||||
};
|
||||
send_ublox_packet(&msgcfgrst);
|
||||
_delay_ms(800);
|
||||
|
||||
uBloxPacket msfcgprt = {.header = {0xb5, 0x62, .messageClass=0x06, .messageId=0x00, .payloadSize=sizeof(uBloxCFGPRTPayload)},
|
||||
.data.cfgprt = {.portID=1, .reserved1=0, .txReady=0, .mode=0b00100011000000, .baudRate=9600,
|
||||
.data.cfgprt = {.portID=1, .reserved1=0, .txReady=0, .mode=0b00100011000000, .baudRate=57600,
|
||||
.inProtoMask=1, .outProtoMask=1, .flags=0, .reserved2={0,0}}};
|
||||
send_ublox_packet(&msfcgprt);
|
||||
_delay_ms(10);
|
||||
// init_usart_gps(57600);
|
||||
// _delay_ms(10);
|
||||
init_usart_gps(57600);
|
||||
_delay_ms(10);
|
||||
|
||||
uBloxPacket msgcfgmsg = {.header = {0xb5, 0x62, .messageClass=0x06, .messageId=0x01, .payloadSize=sizeof(uBloxCFGMSGPayload)},
|
||||
.data.cfgmsg = {.msgClass=0x01, .msgID=0x02, .rate=1}};
|
||||
|
@ -98,28 +104,28 @@ void ublox_init(){
|
|||
void ublox_handle_incoming_byte(uint8_t data){
|
||||
static uint8_t sync = 0;
|
||||
static uint8_t buffer_pos = 0;
|
||||
volatile static uBloxPacket incoming_packet;
|
||||
|
||||
volatile static uint8_t incoming_packet_buffer[sizeof(uBloxPacket) + sizeof(uBloxChecksum)];
|
||||
static uBloxPacket * incoming_packet = (uBloxPacket *) incoming_packet_buffer;
|
||||
if (!sync){
|
||||
if (!buffer_pos && data == 0xB5){
|
||||
buffer_pos = 1;
|
||||
incoming_packet.header.sc1 = data;
|
||||
incoming_packet->header.sc1 = data;
|
||||
} else if (buffer_pos == 1 && data == 0x62){
|
||||
sync = 1;
|
||||
buffer_pos = 2;
|
||||
incoming_packet.header.sc2 = data;
|
||||
incoming_packet->header.sc2 = data;
|
||||
} else {
|
||||
buffer_pos = 0;
|
||||
}
|
||||
} else {
|
||||
((uint8_t *)&incoming_packet)[buffer_pos] = data;
|
||||
if ((buffer_pos >= sizeof(uBloxHeader)-1) && (buffer_pos-1 == (incoming_packet.header.payloadSize + sizeof(uBloxHeader) + sizeof(uBloxChecksum)))){
|
||||
ublox_handle_packet((uBloxPacket *) &incoming_packet);
|
||||
((uint8_t *)incoming_packet)[buffer_pos] = data;
|
||||
if ((buffer_pos >= sizeof(uBloxHeader)-1) && (buffer_pos-1 == (incoming_packet->header.payloadSize + sizeof(uBloxHeader) + sizeof(uBloxChecksum)))){
|
||||
ublox_handle_packet((uBloxPacket *) incoming_packet);
|
||||
buffer_pos = 0;
|
||||
sync = 0;
|
||||
} else {
|
||||
buffer_pos++;
|
||||
if (buffer_pos == 255) {
|
||||
if (buffer_pos >= sizeof(uBloxPacket) + sizeof(uBloxChecksum)) {
|
||||
buffer_pos = 0;
|
||||
sync = 0;
|
||||
}
|
||||
|
@ -152,9 +158,24 @@ void ublox_handle_packet(uBloxPacket *pkt) {
|
|||
currentGPSData.fix = pkt->data.navsol.gpsFix;
|
||||
currentGPSData.sats_raw = pkt->data.navsol.numSV;
|
||||
} else if (pkt->header.messageClass == 0x01 && pkt->header.messageId == 0x21){
|
||||
currentGPSData.hours = pkt->data.navtimeutc.hour;
|
||||
currentGPSData.minutes = pkt->data.navtimeutc.min;
|
||||
currentGPSData.seconds = pkt->data.navtimeutc.sec;
|
||||
if (pkt->data.navtimeutc.valid & 1){
|
||||
currentGPSData.hours = pkt->data.navtimeutc.hour;
|
||||
currentGPSData.minutes = pkt->data.navtimeutc.min;
|
||||
currentGPSData.seconds = pkt->data.navtimeutc.sec;
|
||||
} else {
|
||||
currentGPSData.seconds += 1;
|
||||
if (currentGPSData.seconds > 60){
|
||||
currentGPSData.seconds = 0;
|
||||
currentGPSData.minutes += 1;
|
||||
if (currentGPSData.minutes > 60){
|
||||
currentGPSData.minutes = 0;
|
||||
currentGPSData.hours += 1;
|
||||
if (currentGPSData.hours > 23){
|
||||
currentGPSData.hours = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pkt->header.messageClass == 0x05 && pkt->header.messageId == 0x01){
|
||||
currentGPSData.fix += 1;
|
||||
} else if (pkt->header.messageClass == 0x05 && pkt->header.messageId == 0x00){
|
||||
|
|
18
ublox.h
18
ublox.h
|
@ -136,6 +136,23 @@ typedef struct {
|
|||
uint8_t rate; //Send rate on current Port [- -]
|
||||
} uBloxCFGMSGPayload;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t navBbrMask; //BBR Sections to clear. The following Special Sets apply:
|
||||
// 0x0000 Hotstart
|
||||
// 0x0001 Warmstart
|
||||
// 0xFFFF Coldstart [- -]
|
||||
uint8_t resetMode; //Reset Type
|
||||
// - 0x00 - Hardware reset (Watchdog) immediately
|
||||
// - 0x01 - Controlled Software reset
|
||||
// - 0x02 - Controlled Software reset (GPS only)
|
||||
// - 0x04 - Hardware reset (Watchdog) after shutdown (>=FW6.0)
|
||||
// - 0x08 - Controlled GPS stop
|
||||
// - 0x09 - Controlled GPS start [- -]
|
||||
// - 0x09 - Controlled GPS start [- -]
|
||||
uint8_t reserved1; //Reserved [- -]
|
||||
} uBloxCFGRSTPayload;
|
||||
|
||||
typedef struct {
|
||||
uint16_t mask; //Parameters Bitmask. Only the masked parameters will be applied. [- -]
|
||||
uint8_t dynModel; //Dynamic platform model: 0: portable 2: stationary 3: pedestrian 4: automotive 5: sea 6: airborne with <1g acceleration 7: airborne with <2g acceleration 8: airborne with <4g acceleration 9: wrist worn watch (not supported in protocol versions less than 18) [- -]
|
||||
|
@ -167,6 +184,7 @@ typedef union {
|
|||
uBloxNAVSOLPayload navsol;
|
||||
uBloxNAVTIMEUTCPayload navtimeutc;
|
||||
uBloxACKACKayload ackack;
|
||||
uBloxCFGRSTPayload cfgrst;
|
||||
} ubloxPacketData;
|
||||
|
||||
typedef struct __attribute__((packed)){
|
||||
|
|
Ładowanie…
Reference in New Issue