// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_ubx_pps()
void parse_ubx_pps()
{
u08 status;
u08 flags;
u08 rsvd;
u32 rate;
u32 width;

   // get timepulse1 info
   log_packet_id("UBX_TP1");
   saw_ubx_tp = 1;

   rate = tsip_dword();  // interval in usec
   if     (rate == 1000000) pps_rate = RATE_1PPS;    // 1pps
   else if(rate == 10000)   pps_rate = RATE_100PPS;  // 100 pps
   else if(rate == 1000)    pps_rate = RATE_1000PPS; // 1000 pps
   else                     pps_rate = RATE_USER;    // user defined rate
   have_pps_rate = 3;
//sprintf(debug_text, "ubxpps: rate:%d", rate);

   width = tsip_dword();  // width in us

   status = tsip_byte();
   if(status == 0) pps_enabled = 0;
   else {
      pps_enabled = 1;
      if(status & 0x80) pps_polarity = 1; // falling
      else              pps_polarity = 0; // rising
      have_pps_polarity = 2;
   }
   have_pps_enable = 2;

   tsip_byte();   // align 0=UTC 1=GPS 2=LOCAL
   flags = tsip_byte();  // 1=always on, 0=when tracking
   rsvd = tsip_byte();   // rsvd

   cable_delay = (double) (s16) tsip_word();
   cable_delay /= 1.0E9;
// if(have_cable_delay == 0) need_redraw = 2020;
   have_cable_delay = 1;

   tsip_word();   // rf group delay
   pps1_delay = (double) (S32) tsip_dword();
   have_pps_delay |= 0x01;

   show_cable_delay();
// sprintf(debug_text2, "UBXPPS: rate:%d  width:%d  ofs:%f  mode:%d flags:%d rcvd:%02X", rate,width, pps1_delay, status,flags,rsvd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x8fc6c(%rip), %rdi     # 0x124795
callq 0x58dc2
leaq 0x2788fb(%rip), %rax    # 0x30d430
movl $0x1, (%rax)
callq 0x58964
cmpl $0x3e8, %eax            # imm = 0x3E8
je 0x94b5d
cmpl $0xf4240, %eax          # imm = 0xF4240
je 0x94b59
cmpl $0x2710, %eax           # imm = 0x2710
jne 0x94b61
movb $-0x7e, %al
jmp 0x94b63
movb $0x2, %al
jmp 0x94b63
movb $-0x7d, %al
jmp 0x94b63
xorl %eax, %eax
leaq 0x2791b9(%rip), %rcx    # 0x30dd23
movb %al, (%rcx)
leaq 0x27875d(%rip), %rax    # 0x30d2d0
movl $0x3, (%rax)
callq 0x58964
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x94b94
leaq 0x1aa3df(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
testb %al, %al
je 0x94bb8
shrl $0x7, %eax
andl $0x1, %eax
leaq 0x279173(%rip), %rcx    # 0x30dd18
movl %eax, (%rcx)
leaq 0x278732(%rip), %rax    # 0x30d2e0
movl $0x2, (%rax)
movb $0x1, %al
jmp 0x94bba
xorl %eax, %eax
leaq 0x27915f(%rip), %rcx    # 0x30dd20
movb %al, (%rcx)
leaq 0x278712(%rip), %rax    # 0x30d2dc
movl $0x2, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x94be6
leaq 0x1aa38d(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x94bfc
leaq 0x1aa377(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x94c12
leaq 0x1aa361(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x588d2
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x74404(%rip), %xmm0    # 0x109028
leaq 0x27919d(%rip), %rax    # 0x30ddc8
movsd %xmm0, (%rax)
leaq 0x27867e(%rip), %rax    # 0x30d2b4
movl $0x1, (%rax)
callq 0x588d2
callq 0x58964
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x279184(%rip), %rax    # 0x30ddd8
movsd %xmm0, (%rax)
leaq 0x278659(%rip), %rax    # 0x30d2b8
orb $0x1, (%rax)
popq %rbp
jmp 0x75326