// File: /workspace/github_c_makefile_star2_O0/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetModulationParams
void SX126xSetModulationParams( ModulationParams_t *modulationParams )
{
    uint8_t n;
    uint32_t tempVal = 0;
    uint8_t buf[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

    // Check if required configuration corresponds to the stored packet type
    // If not, silently update radio packet type
    if( PacketType != modulationParams->PacketType )
    {
        SX126xSetPacketType( modulationParams->PacketType );
    }

    switch( modulationParams->PacketType )
    {
    case PACKET_TYPE_GFSK:
        n = 8;
        tempVal = ( uint32_t )( 32 * SX126X_XTAL_FREQ / modulationParams->Params.Gfsk.BitRate );
        buf[0] = ( tempVal >> 16 ) & 0xFF;
        buf[1] = ( tempVal >> 8 ) & 0xFF;
        buf[2] = tempVal & 0xFF;
        buf[3] = modulationParams->Params.Gfsk.ModulationShaping;
        buf[4] = modulationParams->Params.Gfsk.Bandwidth;
        tempVal = SX126xConvertFreqInHzToPllStep( modulationParams->Params.Gfsk.Fdev );
        buf[5] = ( tempVal >> 16 ) & 0xFF;
        buf[6] = ( tempVal >> 8 ) & 0xFF;
        buf[7] = ( tempVal& 0xFF );
        SX126xWriteCommand( RADIO_SET_MODULATIONPARAMS, buf, n );
        break;
    case PACKET_TYPE_LORA:
        n = 4;
        buf[0] = modulationParams->Params.LoRa.SpreadingFactor;
        buf[1] = modulationParams->Params.LoRa.Bandwidth;
        buf[2] = modulationParams->Params.LoRa.CodingRate;
        buf[3] = modulationParams->Params.LoRa.LowDatarateOptimize;

        SX126xWriteCommand( RADIO_SET_MODULATIONPARAMS, buf, n );

        break;
    default:
    case PACKET_TYPE_NONE:
        return;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x10(%rbp)
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x2100
movl 0x82b3(%rip), %eax      # 0xe4cc
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
je 0x622c
movq -0x8(%rbp), %rax
movl (%rax), %edi
callq 0x60a0
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
testl %eax, %eax
je 0x625a
jmp 0x623b
movl -0x1c(%rbp), %eax
subl $0x1, %eax
je 0x62fc
jmp 0x6249
movl -0x1c(%rbp), %eax
subl $0xf, %eax
je 0x6341
jmp 0x633f
movb $0x8, -0x9(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %ecx
movl $0x3d090000, %eax       # imm = 0x3D090000
xorl %edx, %edx
divq %rcx
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, -0x18(%rbp)
movl -0x10(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, -0x17(%rbp)
movl -0x10(%rbp), %eax
andl $0xff, %eax
movb %al, -0x16(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movb %al, -0x15(%rbp)
movq -0x8(%rbp), %rax
movb 0x10(%rax), %al
movb %al, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x6040
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, -0x13(%rbp)
movl -0x10(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, -0x12(%rbp)
movl -0x10(%rbp), %eax
andl $0xff, %eax
movb %al, -0x11(%rbp)
leaq -0x18(%rbp), %rsi
movzbl -0x9(%rbp), %eax
movl $0x8b, %edi
movzwl %ax, %edx
callq 0x6d60
jmp 0x6343
movb $0x4, -0x9(%rbp)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movb %al, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movb %al, -0x17(%rbp)
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
movb %al, -0x16(%rbp)
movq -0x8(%rbp), %rax
movb 0x20(%rax), %al
movb %al, -0x15(%rbp)
leaq -0x18(%rbp), %rsi
movzbl -0x9(%rbp), %eax
movl $0x8b, %edi
movzwl %ax, %edx
callq 0x6d60
jmp 0x6343
jmp 0x6341
jmp 0x6343
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)