// File: /workspace/github_cpp_makefile_star2_O1/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 0x8fc17(%rip), %rdi     # 0x1246b5
callq 0x58e77
leaq 0x278986(%rip), %rax    # 0x30d430
movl $0x1, (%rax)
callq 0x589b0
cmpl $0x3e8, %eax            # imm = 0x3E8
je 0x94ad2
cmpl $0xf4240, %eax          # imm = 0xF4240
je 0x94ace
cmpl $0x2710, %eax           # imm = 0x2710
jne 0x94ad6
movb $-0x7e, %al
jmp 0x94ad8
movb $0x2, %al
jmp 0x94ad8
movb $-0x7d, %al
jmp 0x94ad8
xorl %eax, %eax
leaq 0x279244(%rip), %rcx    # 0x30dd23
movb %al, (%rcx)
leaq 0x2787e8(%rip), %rax    # 0x30d2d0
movl $0x3, (%rax)
callq 0x589b0
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x94b09
leaq 0x1aa46a(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
testb %al, %al
je 0x94b35
leaq 0x27920c(%rip), %rcx    # 0x30dd20
movb $0x1, (%rcx)
shrl $0x7, %eax
andl $0x1, %eax
leaq 0x2791f4(%rip), %rcx    # 0x30dd18
movl %eax, (%rcx)
leaq 0x2787b3(%rip), %rax    # 0x30d2e0
movl $0x2, (%rax)
jmp 0x94b3f
leaq 0x2791e4(%rip), %rax    # 0x30dd20
movb $0x0, (%rax)
leaq 0x278796(%rip), %rax    # 0x30d2dc
movl $0x2, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x94b62
leaq 0x1aa411(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x94b78
leaq 0x1aa3fb(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x94b8e
leaq 0x1aa3e5(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x588f0
cwtl
cvtsi2sd %eax, %xmm0
divsd 0x74488(%rip), %xmm0    # 0x109028
leaq 0x279221(%rip), %rax    # 0x30ddc8
movsd %xmm0, (%rax)
leaq 0x278702(%rip), %rax    # 0x30d2b4
movl $0x1, (%rax)
callq 0x588f0
callq 0x589b0
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x279208(%rip), %rax    # 0x30ddd8
movsd %xmm0, (%rax)
leaq 0x2786dd(%rip), %rax    # 0x30d2b8
orb $0x1, (%rax)
popq %rbp
jmp 0x754c4