Drobne zmiany gps i kosmetyka rtty

aprs_test
Łukasz Nidecki 2016-12-28 17:12:39 +01:00
rodzic 28133d4cd0
commit 90478f5650
4 zmienionych plików z 33 dodań i 43 usunięć

13
main.c
Wyświetl plik

@ -71,7 +71,7 @@ void TIM2_IRQHandler(void) {
if (tx_on /*&& ++cun_rtty == 17*/) {
send_rtty_status = send_rtty((char *) rtty_buf);
if (send_rtty_status == rttyEnd) {
GPIO_ResetBits(GPIOB, RED);
GPIO_SetBits(GPIOB, RED);
if (*(++rtty_buf) == 0) {
tx_on = 0;
tx_on_delay = tx_delay / (1000/RTTY_SPEED);//2500;
@ -104,8 +104,6 @@ void TIM2_IRQHandler(void) {
}
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
int main(void) {
#ifdef DEBUG
debug();
@ -151,6 +149,8 @@ int main(void) {
//Button = ADCVal[1];
radio_enable_tx();
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
while (1) {
if (tx_on == 0 && tx_enable) {
start_bits = RTTY_PRE_START_BITS;
@ -169,7 +169,7 @@ int main(void) {
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,
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,
@ -177,7 +177,7 @@ int main(void) {
gpsData.ok_packets, gpsData.bad_packets,
flaga);
CRC_rtty = 0xffff; //napiecie flaga
CRC_rtty = gps_CRC16_checksum(buf_rtty + 7);
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();
@ -189,9 +189,8 @@ int main(void) {
__WFI();
}
}
}
#pragma clang diagnostic pop
}
#ifdef DEBUG
void assert_failed(uint8_t* file, uint32_t line)

Wyświetl plik

@ -16,7 +16,7 @@ uint8_t _spi_sendrecv(const uint16_t data_word) {
return (uint8_t) SPI_I2S_ReceiveData(SPI2);
}
uint8_t radio_rw_register(const uint8_t register_addr, uint8_t value, uint8_t write){
inline uint8_t radio_rw_register(const uint8_t register_addr, uint8_t value, uint8_t write){
return _spi_sendrecv(((write ? register_addr | WR : register_addr) << 8) | value);
}

36
ublox.c
Wyświetl plik

@ -69,15 +69,15 @@ 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}
.data.cfgrst = { .navBbrMask=0xffff, .resetMode=1, .reserved1 = 0}
};
send_ublox_packet(&msgcfgrst);
_delay_ms(800);
uBloxPacket msfcgprt = {.header = {0xb5, 0x62, .messageClass=0x06, .messageId=0x00, .payloadSize=sizeof(uBloxCFGPRTPayload)},
uBloxPacket msgcgprt = {.header = {0xb5, 0x62, .messageClass=0x06, .messageId=0x00, .payloadSize=sizeof(uBloxCFGPRTPayload)},
.data.cfgprt = {.portID=1, .reserved1=0, .txReady=0, .mode=0b00100011000000, .baudRate=38400,
.inProtoMask=1, .outProtoMask=1, .flags=0, .reserved2={0,0}}};
send_ublox_packet(&msfcgprt);
send_ublox_packet(&msgcgprt);
init_usart_gps(38400, 1);
_delay_ms(10);
@ -86,6 +86,10 @@ void ublox_init(){
.data.cfgmsg = {.msgClass=0x01, .msgID=0x02, .rate=1}};
send_ublox_packet(&msgcfgmsg);
_delay_ms(10);
uBloxPacket msgcfgrxm = {.header = {0xb5, 0x62, .messageClass=0x06, .messageId=0x11, .payloadSize=sizeof(uBloxCFGRXMPayload)},
.data.cfgrxm = {.reserved1=8, .lpMode=4}};
send_ublox_packet(&msgcfgrxm);
_delay_ms(10);
msgcfgmsg.data.cfgmsg.msgID = 0x6;
send_ublox_packet(&msgcfgmsg);
@ -96,9 +100,8 @@ void ublox_init(){
_delay_ms(10);
uBloxPacket msgcfgnav5 = {.header = {0xb5, 0x62, .messageClass=0x06, .messageId=0x24, .payloadSize=sizeof(uBloxCFGNAV5Payload)},
.data.cfgnav5={.mask=0b00000001111111111, .dynModel=8, .fixMode=3, .fixedAlt=0, .fixedAltVar=10000, .minElev=2, .drLimit=0, .pDop=0xfa, .tDop=0xfa,
.pAcc=100, .tAcc=300, .staticHoldThresh=0, .dgnssTimeout=0, .cnoThreshNumSVs=0, .cnoThresh=0, .reserved1={0,0}, .staticHoldMaxDist=0,
.utcStandard=0, .reserved2={0,0,0,0,0}}};
.data.cfgnav5={.mask=0b00000001111111111, .dynModel=8, .fixMode=3, .fixedAlt=0, .fixedAltVar=10000, .minElev=15, .drLimit=0, .pDop=60, .tDop=60,
.pAcc=100, .tAcc=300, .staticHoldThresh=0, .dgpsTimeOut=2, .reserved2=0, .reserved3=0, .reserved4=0}};
send_ublox_packet(&msgcfgnav5);
_delay_ms(10);
}
@ -161,24 +164,9 @@ 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){
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;
}
}
}
}
currentGPSData.hours = pkt->data.navtimeutc.hour;
currentGPSData.minutes = pkt->data.navtimeutc.min;
currentGPSData.seconds = pkt->data.navtimeutc.sec;
} else if (pkt->header.messageClass == 0x05 && pkt->header.messageId == 0x01){
currentGPSData.fix += 1;
} else if (pkt->header.messageClass == 0x05 && pkt->header.messageId == 0x00){

25
ublox.h
Wyświetl plik

@ -157,27 +157,29 @@ typedef struct {
} 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) [- -]
uint8_t fixMode; //Position Fixing Mode: 1: 2D only 2: 3D only 3: auto 2D/3D [- -]
uint16_t mask; //Parameters Bitmask. Only the masked parameters will be applied. (see graphic below) [- -]
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 [- -]
uint8_t fixMode; //Position Fixing Mode. - 1: 2D only - 2: 3D only - 3: Auto 2D/3D [- -]
int32_t fixedAlt; //Fixed altitude (mean sea level) for 2D fix mode. [0.01 m]
uint32_t fixedAltVar; //Fixed altitude variance for 2D mode. [0.0001 m^2]
int8_t minElev; //Minimum Elevation for a GNSS satellite to be used in NAV [- deg]
uint8_t drLimit; //Reserved [- s]
uint8_t drLimit; //Maximum time to perform dead reckoning (linear extrapolation) in case of GPS signal loss [- s]
uint16_t pDop; //Position DOP Mask to use [0.1 -]
uint16_t tDop; //Time DOP Mask to use [0.1 -]
uint16_t pAcc; //Position Accuracy Mask [- m]
uint16_t tAcc; //Time Accuracy Mask [- m]
uint8_t staticHoldThresh; //Static hold threshold [- cm/s]
uint8_t dgnssTimeout; //DGNSS timeout [- s]
uint8_t cnoThreshNumSVs; //Number of satellites required to have C/N0 above cnoThresh for a fix to be attempted [- -]
uint8_t cnoThresh; //C/N0 threshold for deciding whether to attempt a fix [- dBHz]
uint8_t reserved1[2]; //Reserved [- -]
uint16_t staticHoldMaxDist; //Static hold distance threshold (before quitting static hold) [- m]
uint8_t utcStandard; //UTC standard to be used: 0: Automatic; receiver selects based on GNSS configuration (see GNSS time bases). 3: UTC as operated by the U.S. Naval Observatory (USNO); derived from GPS time 6: UTC as operated by the former Soviet Union; derived from GLONASS time 7: UTC as operated by the National Time Service Center, China; derived from BeiDou time (not supported in protocol versions less than 16). [- -]
uint8_t reserved2[5]; //Reserved [- -]
uint8_t dgpsTimeOut; //DGPS timeout, firmware 7 and newer only [- s]
uint32_t reserved2; //Always set to zero [- -]
uint32_t reserved3; //Always set to zero [- -]
uint32_t reserved4; //Always set to zero [- -]
} uBloxCFGNAV5Payload;
typedef struct {
uint8_t reserved1; //Always set to 8 [- -]
uint8_t lpMode; //Low Power Mode 0: Max. performance mode 1: Power Save Mode (>= FW 6.00 only) 2-3: reserved 4: Eco mode 5-255: reserved [- -]
} uBloxCFGRXMPayload;
typedef union {
uBloxNAVPVTPayload navpvt;
uBloxCFGPRTPayload cfgprt;
@ -188,6 +190,7 @@ typedef union {
uBloxNAVTIMEUTCPayload navtimeutc;
uBloxACKACKayload ackack;
uBloxCFGRSTPayload cfgrst;
uBloxCFGRXMPayload cfgrxm;
} ubloxPacketData;
typedef struct __attribute__((packed)){