// File: jkingan[P]ladyheather/heathgps.cpp
// Function: set_ubx_config(int, double, double, double)
void set_ubx_config(int mode, double slat,double slon,double salt)
{
   if(read_only) return;

   lla_to_ecef(slat, slon, salt);

   if((have_ubx_tmode == 0) || (have_ubx_tmode == 1)) {
      send_ubx_start(UBX_CFG_TMODE, 28);
      send_dword((u32) mode);
      send_dword((S32) (ecef_x*100.0));
      send_dword((S32) (ecef_y*100.0));
      send_dword((S32) (ecef_z*100.0));
      if(mode == 1) {
         send_dword(50000);       // fixed posn variance
         send_dword(do_survey);   // min survey time
         send_dword(0xFFFFFFFF);  // survey stop required variance (mm^2)
      }                           // ... we set to max value so survey is based only on time
      else {
         send_dword(0);   // fixed posn variance
         send_dword(0);   // min survey time
         send_dword(0);   // survey stop required variance (mm^2)
      }
      send_ubx_end();

      request_ubx_msg(UBX_CFG_TMODE);
   }


   // M8T survey / timing mode
   if((have_ubx_tmode == 0) || (have_ubx_tmode == 2)) {
      send_ubx_start(UBX_CFG_TMODE2, 28);
      send_dword((u32) mode);
      send_dword((S32) (ecef_x*100.0));
      send_dword((S32) (ecef_y*100.0));
      send_dword((S32) (ecef_z*100.0));
      if(mode == 1) {
         send_dword(50000);       // fixed posn variance
         send_dword(do_survey);   // min survey time
         send_dword(0xFFFFFFFF);  // survey stop required variance (mm^2)
      }                           // ... we set to max value so survey is based only on time
      else {
         send_dword(0);   // fixed posn variance
         send_dword(0);   // min survey time
         send_dword(0);   // survey stop required variance (mm^2)
      }
      send_ubx_end();

      request_ubx_msg(UBX_CFG_TMODE2);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
leaq 0x307ee9(%rip), %rax    # 0x3961fa
cmpb $0x0, (%rax)
je 0x8e31b
jmp 0x8e4df
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x20(%rbp), %xmm2
callq 0x7fcf0
leaq 0x2de25e(%rip), %rax    # 0x36c594
cmpl $0x0, (%rax)
je 0x8e34b
leaq 0x2de252(%rip), %rax    # 0x36c594
cmpl $0x1, (%rax)
jne 0x8e407
movl $0x61d, %edi            # imm = 0x61D
movl $0x1c, %esi
callq 0x83710
movl -0x4(%rbp), %edi
callq 0x7b520
movsd 0xe0ce6(%rip), %xmm0    # 0x16f050
leaq 0x2dde57(%rip), %rax    # 0x36c1c8
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %edi
callq 0x7b520
movsd 0xe0cca(%rip), %xmm0    # 0x16f050
leaq 0x2dde43(%rip), %rax    # 0x36c1d0
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %edi
callq 0x7b520
movsd 0xe0cae(%rip), %xmm0    # 0x16f050
leaq 0x2dde2f(%rip), %rax    # 0x36c1d8
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %edi
callq 0x7b520
cmpl $0x1, -0x4(%rbp)
jne 0x8e3e3
movl $0xc350, %edi           # imm = 0xC350
callq 0x7b520
leaq 0x2dec8b(%rip), %rax    # 0x36d058
movq (%rax), %rax
movl %eax, %edi
callq 0x7b520
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x7b520
jmp 0x8e3f8
xorl %edi, %edi
callq 0x7b520
xorl %edi, %edi
callq 0x7b520
xorl %edi, %edi
callq 0x7b520
callq 0x83820
movl $0x61d, %edi            # imm = 0x61D
callq 0x85d00
leaq 0x2de186(%rip), %rax    # 0x36c594
cmpl $0x0, (%rax)
je 0x8e423
leaq 0x2de17a(%rip), %rax    # 0x36c594
cmpl $0x2, (%rax)
jne 0x8e4df
movl $0x63d, %edi            # imm = 0x63D
movl $0x1c, %esi
callq 0x83710
movl -0x4(%rbp), %edi
callq 0x7b520
movsd 0xe0c0e(%rip), %xmm0    # 0x16f050
leaq 0x2ddd7f(%rip), %rax    # 0x36c1c8
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %edi
callq 0x7b520
movsd 0xe0bf2(%rip), %xmm0    # 0x16f050
leaq 0x2ddd6b(%rip), %rax    # 0x36c1d0
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %edi
callq 0x7b520
movsd 0xe0bd6(%rip), %xmm0    # 0x16f050
leaq 0x2ddd57(%rip), %rax    # 0x36c1d8
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %edi
callq 0x7b520
cmpl $0x1, -0x4(%rbp)
jne 0x8e4bb
movl $0xc350, %edi           # imm = 0xC350
callq 0x7b520
leaq 0x2debb3(%rip), %rax    # 0x36d058
movq (%rax), %rax
movl %eax, %edi
callq 0x7b520
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x7b520
jmp 0x8e4d0
xorl %edi, %edi
callq 0x7b520
xorl %edi, %edi
callq 0x7b520
xorl %edi, %edi
callq 0x7b520
callq 0x83820
movl $0x63d, %edi            # imm = 0x63D
callq 0x85d00
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)