// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x2c16cf(%rip), %rax    # 0x32101a
cmpb $0x0, (%rax)
jne 0x5fa2d
movl %edi, %ebx
callq 0x55535
leaq 0x297a52(%rip), %r12    # 0x2f73b4
movl (%r12), %eax
cmpl $0x1, %eax
ja 0x5fa26
pushq $0x1c
popq %rsi
movl $0x61d, %edi            # imm = 0x61D
callq 0x57bf3
movl %ebx, %edi
callq 0x525e2
leaq 0x29765e(%rip), %rax    # 0x2f6fe8
movsd (%rax), %xmm0
mulsd 0x936ca(%rip), %xmm0    # 0xf3060
cvttsd2si %xmm0, %edi
callq 0x525e2
leaq 0x29764a(%rip), %rax    # 0x2f6ff0
movsd (%rax), %xmm0
mulsd 0x936ae(%rip), %xmm0    # 0xf3060
cvttsd2si %xmm0, %edi
callq 0x525e2
leaq 0x297636(%rip), %rax    # 0x2f6ff8
movsd 0x93696(%rip), %xmm0    # 0xf3060
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %edi
callq 0x525e2
cmpl $0x1, %ebx
jne 0x5f9f6
movl $0xc350, %edi           # imm = 0xC350
callq 0x525e2
leaq 0x29848b(%rip), %rax    # 0x2f7e78
movl (%rax), %r14d
pushq $-0x1
popq %r15
jmp 0x5fa03
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x525e2
xorl %r15d, %r15d
movl %r14d, %edi
callq 0x525e2
movl %r15d, %edi
callq 0x525e2
callq 0x57cca
movl $0x61d, %edi            # imm = 0x61D
callq 0x59749
movl (%r12), %eax
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
je 0x5fa36
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1c
popq %rsi
movl $0x63d, %edi            # imm = 0x63D
callq 0x57bf3
movl %ebx, %edi
callq 0x525e2
leaq 0x297597(%rip), %rax    # 0x2f6fe8
movsd (%rax), %xmm0
mulsd 0x93603(%rip), %xmm0    # 0xf3060
cvttsd2si %xmm0, %edi
callq 0x525e2
leaq 0x297583(%rip), %rax    # 0x2f6ff0
movsd (%rax), %xmm0
mulsd 0x935e7(%rip), %xmm0    # 0xf3060
cvttsd2si %xmm0, %edi
callq 0x525e2
leaq 0x29756f(%rip), %rax    # 0x2f6ff8
movsd 0x935cf(%rip), %xmm0    # 0xf3060
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %edi
callq 0x525e2
cmpl $0x1, %ebx
jne 0x5fabc
pushq $-0x1
popq %rbx
movl $0xc350, %edi           # imm = 0xC350
callq 0x525e2
leaq 0x2983c1(%rip), %rax    # 0x2f7e78
movl (%rax), %r14d
jmp 0x5fac8
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x525e2
xorl %ebx, %ebx
movl %r14d, %edi
callq 0x525e2
movl %ebx, %edi
callq 0x525e2
callq 0x57cca
movl $0x63d, %edi            # imm = 0x63D
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x59749