LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioAddRegisterToRetentionList
void RadioAddRegisterToRetentionList( uint16_t registerAddress )
{
    uint8_t buffer[9];

    // Read the address and registers already added to the list
    SX126xReadRegisters( REG_RETENTION_LIST_BASE_ADDRESS, buffer, 9 );

    const uint8_t nbOfRegisters = buffer[0];
    uint8_t* registerList   = &buffer[1];

    // Check if the register given as parameter is already added to the list
    for( uint8_t i = 0; i < nbOfRegisters; i++ )
    {
        if( registerAddress == ( ( uint16_t ) registerList[2 * i] << 8 ) + registerList[2 * i + 1] )
        {
            return;
        }
    }

    if( nbOfRegisters < MAX_NB_REG_IN_RETENTION )
    {
        buffer[0] += 1;
        registerList[2 * nbOfRegisters]     = ( uint8_t )( registerAddress >> 8 );
        registerList[2 * nbOfRegisters + 1] = ( uint8_t )( registerAddress >> 0 );

        // Update radio with modified list
        SX126xWriteRegisters( REG_RETENTION_LIST_BASE_ADDRESS, buffer, 9 );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %r14d
leaq -0x19(%rbp), %rbx
movl $0x29f, %edi            # imm = 0x29F
movq %rbx, %rsi
movl $0x9, %edx
callq 0x4d9a
movzbl (%rbx), %eax
testq %rax, %rax
je 0x3a3e
movl %r14d, %ecx
movzwl %cx, %ecx
xorl %edx, %edx
movzwl -0x18(%rbp,%rdx,2), %esi
rolw $0x8, %si
movzwl %si, %esi
cmpl %ecx, %esi
je 0x3a6a
incq %rdx
cmpb %dl, %al
jne 0x3a27
cmpb $0x3, %al
ja 0x3a6a
leal 0x1(%rax), %ecx
leaq -0x19(%rbp), %rsi
movb %cl, (%rsi)
addl %eax, %eax
movl %r14d, %ecx
movb %ch, -0x18(%rbp,%rax)
movzbl %al, %eax
movb %cl, -0x17(%rbp,%rax)
movl $0x29f, %edi            # imm = 0x29F
movl $0x9, %edx
callq 0x4d1e
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioGetFskBandwidthRegValue
static uint8_t RadioGetFskBandwidthRegValue( uint32_t bandwidth )
{
    uint8_t i;

    if( bandwidth == 0 )
    {
        return( 0x1F );
    }

    for( i = 0; i < ( sizeof( FskBandwidths ) / sizeof( FskBandwidth_t ) ) - 1; i++ )
    {
        if( ( bandwidth >= FskBandwidths[i].bandwidth ) && ( bandwidth < FskBandwidths[i + 1].bandwidth ) )
        {
            return FskBandwidths[i+1].RegValue;
        }
    }
    // ERROR: Value not found
    printf("RadioGetFskBandwidthRegValue: not found, bandwidth=%d\r\n", (int) bandwidth);
    assert(false);
    while( 1 );
}

// Assembly:
testl %edi, %edi
je 0x3b0e
movl %edi, %esi
xorl %eax, %eax
leaq 0x266c(%rip), %rcx      # 0x6130
cmpl %esi, (%rcx,%rax,8)
ja 0x3acf
cmpl %esi, 0x8(%rcx,%rax,8)
ja 0x3b09
incq %rax
cmpq $0x15, %rax
jne 0x3ac4
pushq %rbp
movq %rsp, %rbp
leaq 0x29ff(%rip), %rdi      # 0x64e2
xorl %eax, %eax
callq 0x2050
leaq 0x2a29(%rip), %rdi      # 0x651a
leaq 0x2703(%rip), %rsi      # 0x61fb
leaq 0x2a21(%rip), %rcx      # 0x6520
movl $0x207, %edx            # imm = 0x207
callq 0x20f0
movb 0xc(%rcx,%rax,8), %al
retq
movb $0x1f, %al
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xInit
void SX126xInit( DioIrqHandler dioIrq )
{
    SX126xReset( );

    SX126xIoIrqInit( dioIrq );

    SX126xWakeup( );
    SX126xSetStandby( STDBY_RC );

    // Initialize TCXO control
    SX126xIoTcxoInit( );

    // Initialize RF switch control
    SX126xIoRfSwitchInit( );

    // Force image calibration
    ImageCalibrated = false;

    SX126xSetOperatingMode( MODE_STDBY_RC );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x498b
movq %rbx, %rdi
callq 0x4926
callq 0x49b7
xorl %edi, %edi
callq 0x3b57
callq 0x4953
callq 0x4964
movb $0x0, 0x6951(%rip)      # 0xa498
movl $0x1, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x497f
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xCheckDeviceReady
void SX126xCheckDeviceReady( void )
{
    if( ( SX126xGetOperatingMode( ) == MODE_SLEEP ) || ( SX126xGetOperatingMode( ) == MODE_RX_DC ) )
    {
        SX126xWakeup( );
        // Switch is turned off when device is in sleep mode and turned on is all other modes
        SX126xAntSwOn( );
    }
    SX126xWaitOnBusy( );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
callq 0x4973
testl %eax, %eax
je 0x3ba3
callq 0x4973
cmpl $0x6, %eax
jne 0x3bad
callq 0x49b7
callq 0x4f09
popq %rbp
jmp 0x499c
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetPayload
uint8_t SX126xGetPayload( uint8_t *buffer, uint8_t *size,  uint8_t maxSize )
{
    uint8_t offset = 0;

    SX126xGetRxBufferStatus( size, &offset );
    if( *size > maxSize )
    {
        return 1;
    }
    SX126xReadBuffer( offset, buffer, *size );
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x19(%rbp), %rsi
movb $0x0, (%rsi)
movq %r15, %rdi
callq 0x3c0c
movb (%r15), %cl
movb $0x1, %al
cmpb %r14b, %cl
ja 0x3c01
movzbl -0x19(%rbp), %edi
movzbl %cl, %edx
movq %rbx, %rsi
callq 0x4e72
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetRxBufferStatus
void SX126xGetRxBufferStatus( uint8_t *payloadLength, uint8_t *rxStartBufferPointer )
{
    uint8_t status[2];

    SX126xReadCommand( RADIO_GET_RXBUFFERSTATUS, status, 2 );

    // In case of LORA fixed header, the payloadLength is obtained by reading
    // the register REG_LR_PAYLOADLENGTH
    if( ( SX126xGetPacketType( ) == PACKET_TYPE_LORA ) && ( LoRaHeaderType == LORA_PACKET_FIXED_LENGTH ) )
    {
        *payloadLength = SX126xReadRegister( REG_LR_PAYLOADLENGTH );
    }
    else
    {
        *payloadLength = status[0];
    }
    *rxStartBufferPointer = status[1];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x12(%rbp), %rsi
movl $0x13, %edi
movl $0x2, %edx
callq 0x4b60
cmpl $0x1, 0x6865(%rip)      # 0xa49c
jne 0x3c50
movl 0x6861(%rip), %eax      # 0xa4a0
cmpl $0x1, %eax
jne 0x3c50
movl $0x702, %edi            # imm = 0x702
callq 0x4dfc
jmp 0x3c53
movb -0x12(%rbp), %al
movb %al, (%r14)
movb -0x11(%rbp), %al
movb %al, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetTx
void SX126xSetTx( uint32_t timeout )
{
    uint8_t buf[3];

    SX126xSetOperatingMode( MODE_TX );

    buf[0] = ( uint8_t )( ( timeout >> 16 ) & 0xFF );
    buf[1] = ( uint8_t )( ( timeout >> 8 ) & 0xFF );
    buf[2] = ( uint8_t )( timeout & 0xFF );
    SX126xWriteCommand( RADIO_SET_TX, buf, 3 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x4, %edi
callq 0x497f
movl %ebx, %eax
shrl $0x10, %eax
leaq -0xb(%rbp), %rsi
movb %al, (%rsi)
movb %bh, -0xa(%rbp)
movb %bl, 0x2(%rsi)
movl $0x83, %edi
movl $0x3, %edx
callq 0x4aff
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetWhiteningSeed
void SX126xSetWhiteningSeed( uint16_t seed )
{
    uint8_t regValue = 0;
    
    switch( SX126xGetPacketType( ) )
    {
        case PACKET_TYPE_GFSK:
            regValue = SX126xReadRegister( REG_LR_WHITSEEDBASEADDR_MSB ) & 0xFE;
            regValue = ( ( seed >> 8 ) & 0x01 ) | regValue;
            SX126xWriteRegister( REG_LR_WHITSEEDBASEADDR_MSB, regValue ); // only 1 bit.
            SX126xWriteRegister( REG_LR_WHITSEEDBASEADDR_LSB, ( uint8_t )seed );
            break;

        default:
            break;
    }
}

// Assembly:
cmpl $0x0, 0x674d(%rip)      # 0xa49c
je 0x3d52
retq
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x6b8, %edi            # imm = 0x6B8
callq 0x4dfc
andb $-0x2, %al
movl %ebx, %ecx
shrl $0x8, %ecx
andb $0x1, %cl
orb %al, %cl
movzbl %cl, %esi
movl $0x6b8, %edi            # imm = 0x6B8
callq 0x4d78
movzbl %bl, %esi
movl $0x6b9, %edi            # imm = 0x6B9
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4d78
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetRandom
uint32_t SX126xGetRandom( void )
{
    uint32_t number = 0;
    uint8_t regAnaLna = 0;
    uint8_t regAnaMixer = 0;

    regAnaLna = SX126xReadRegister( REG_ANA_LNA );
    SX126xWriteRegister( REG_ANA_LNA, regAnaLna & ~( 1 << 0 ) );

    regAnaMixer = SX126xReadRegister( REG_ANA_MIXER );
    SX126xWriteRegister( REG_ANA_MIXER, regAnaMixer & ~( 1 << 7 ) );

    // Set radio in continuous reception
    SX126xSetRx( 0xFFFFFF ); // Rx Continuous

    SX126xReadRegisters( RANDOM_NUMBER_GENERATORBASEADDR, ( uint8_t* )&number, 4 );

    SX126xSetStandby( STDBY_RC );

    SX126xWriteRegister( REG_ANA_LNA, regAnaLna );
    SX126xWriteRegister( REG_ANA_MIXER, regAnaMixer );

    return number;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq -0x1c(%rbp), %rbx
movl $0x0, (%rbx)
movl $0x8e2, %edi            # imm = 0x8E2
callq 0x4dfc
movl %eax, %r14d
andb $-0x2, %al
movzbl %al, %esi
movl $0x8e2, %edi            # imm = 0x8E2
callq 0x4d78
movl $0x8e5, %edi            # imm = 0x8E5
callq 0x4dfc
movl %eax, %r15d
andb $0x7f, %al
movzbl %al, %esi
movl $0x8e5, %edi            # imm = 0x8E5
callq 0x4d78
movl $0xffffff, %edi         # imm = 0xFFFFFF
callq 0x3e28
movl $0x819, %edi            # imm = 0x819
movq %rbx, %rsi
movl $0x4, %edx
callq 0x4d9a
xorl %edi, %edi
callq 0x3b57
movzbl %r14b, %esi
movl $0x8e2, %edi            # imm = 0x8E2
callq 0x4d78
movzbl %r15b, %esi
movl $0x8e5, %edi            # imm = 0x8E5
callq 0x4d78
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetRx
void SX126xSetRx( uint32_t timeout )
{
    uint8_t buf[3];

    SX126xSetOperatingMode( MODE_RX );

    SX126xWriteRegister( REG_RX_GAIN, 0x94 ); // default gain

    buf[0] = ( uint8_t )( ( timeout >> 16 ) & 0xFF );
    buf[1] = ( uint8_t )( ( timeout >> 8 ) & 0xFF );
    buf[2] = ( uint8_t )( timeout & 0xFF );
    SX126xWriteCommand( RADIO_SET_RX, buf, 3 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x5, %edi
callq 0x497f
movl $0x8ac, %edi            # imm = 0x8AC
movl $0x94, %esi
callq 0x4d78
movl %ebx, %eax
shrl $0x10, %eax
leaq -0xb(%rbp), %rsi
movb %al, (%rsi)
movb %bh, -0xa(%rbp)
movb %bl, 0x2(%rsi)
movl $0x82, %edi
movl $0x3, %edx
callq 0x4aff
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetSleep
void SX126xSetSleep( SleepParams_t sleepConfig )
{
    SX126xAntSwOff( );

    uint8_t value = ( ( ( uint8_t )sleepConfig.Fields.WarmStart << 2 ) |
                      ( ( uint8_t )sleepConfig.Fields.Reset << 1 ) |
                      ( ( uint8_t )sleepConfig.Fields.WakeUpRTC ) );

    if( sleepConfig.Fields.WarmStart == 0 )
    {
        // Force image calibration
        ImageCalibrated = false;
    }
    SX126xWriteCommand( RADIO_SET_SLEEP, &value, 1 );
    SX126xSetOperatingMode( MODE_SLEEP );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
callq 0x4f0f
movl %ebx, %eax
andb $0x7, %al
movb %al, -0x9(%rbp)
testb $0x4, %bl
jne 0x3e90
movb $0x0, 0x6608(%rip)      # 0xa498
leaq -0x9(%rbp), %rsi
movl $0x84, %edi
movl $0x1, %edx
callq 0x4aff
xorl %edi, %edi
callq 0x497f
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetRxDutyCycle
void SX126xSetRxDutyCycle( uint32_t rxTime, uint32_t sleepTime )
{
    uint8_t buf[6];

    buf[0] = ( uint8_t )( ( rxTime >> 16 ) & 0xFF );
    buf[1] = ( uint8_t )( ( rxTime >> 8 ) & 0xFF );
    buf[2] = ( uint8_t )( rxTime & 0xFF );
    buf[3] = ( uint8_t )( ( sleepTime >> 16 ) & 0xFF );
    buf[4] = ( uint8_t )( ( sleepTime >> 8 ) & 0xFF );
    buf[5] = ( uint8_t )( sleepTime & 0xFF );
    SX126xWriteCommand( RADIO_SET_RXDUTYCYCLE, buf, 6 );
    SX126xSetOperatingMode( MODE_RX_DC );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %esi, %eax
movl %edi, %ecx
movl %edi, %edx
shrl $0x10, %edx
leaq -0x6(%rbp), %rsi
movb %dl, (%rsi)
movb %ch, -0x5(%rbp)
movb %cl, 0x2(%rsi)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x3(%rsi)
movb %ah, -0x2(%rbp)
movb %al, 0x5(%rsi)
movl $0x94, %edi
movl $0x6, %edx
callq 0x4aff
movl $0x6, %edi
callq 0x497f
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetLoRaSymbNumTimeout
void SX126xSetLoRaSymbNumTimeout( uint8_t symbNum )
{
    uint8_t mant = ( ( ( symbNum > SX126X_MAX_LORA_SYMB_NUM_TIMEOUT ) ?
                       SX126X_MAX_LORA_SYMB_NUM_TIMEOUT : 
                       symbNum ) + 1 ) >> 1;
    uint8_t exp  = 0;
    uint8_t reg  = 0;

    while( mant > 31 )
    {
        mant = ( mant + 3 ) >> 2;
        exp++;
    }

    reg = mant << ( 2 * exp + 1 );
    SX126xWriteCommand( RADIO_SET_LORASYMBTIMEOUT, &reg, 1 );

    if( symbNum != 0 )
    {
        reg = exp + ( mant << 3 );
        SX126xWriteRegister( REG_LR_SYNCH_TIMEOUT, reg );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
cmpb $-0x8, %bl
movl $0xf8, %eax
cmovbl %edi, %eax
incb %al
shrb %al
movzbl %al, %eax
leal 0x3(%rax), %r14d
shrl $0x2, %r14d
cmpb $0x3f, %bl
cmovbl %eax, %r14d
setae %cl
addb %cl, %cl
incb %cl
movl %r14d, %eax
shll %cl, %eax
leaq -0x11(%rbp), %rsi
movb %al, (%rsi)
movl $0xa0, %edi
movl $0x1, %edx
callq 0x4aff
testl %ebx, %ebx
je 0x404d
cmpb $0x3f, %bl
setae %al
shlb $0x3, %r14b
orb %al, %r14b
movb %r14b, -0x11(%rbp)
movzbl %r14b, %esi
movl $0x706, %edi            # imm = 0x706
callq 0x4d78
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xCalibrateImage
void SX126xCalibrateImage( uint32_t freq )
{
    uint8_t calFreq[2];

    if( freq > 900000000 )
    {
        calFreq[0] = 0xE1;
        calFreq[1] = 0xE9;
    }
    else if( freq > 850000000 )
    {
        calFreq[0] = 0xD7;
        calFreq[1] = 0xDB;
    }
    else if( freq > 770000000 )
    {
        calFreq[0] = 0xC1;
        calFreq[1] = 0xC5;
    }
    else if( freq > 460000000 )
    {
        calFreq[0] = 0x75;
        calFreq[1] = 0x81;
    }
    else if( freq > 425000000 )
    {
        calFreq[0] = 0x6B;
        calFreq[1] = 0x6F;
    }
    SX126xWriteCommand( RADIO_CALIBRATEIMAGE, calFreq, 2 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
cmpl $0x35a4e901, %edi       # imm = 0x35A4E901
jb 0x40b9
movb $-0x1f, -0x2(%rbp)
movb $-0x17, %al
jmp 0x40f7
cmpl $0x32a9f881, %edi       # imm = 0x32A9F881
jb 0x40c9
movb $-0x29, -0x2(%rbp)
movb $-0x25, %al
jmp 0x40f7
cmpl $0x2de54481, %edi       # imm = 0x2DE54481
jb 0x40d9
movb $-0x3f, -0x2(%rbp)
movb $-0x3b, %al
jmp 0x40f7
cmpl $0x1b6b0b01, %edi       # imm = 0x1B6B0B01
jb 0x40e9
movb $0x75, -0x2(%rbp)
movb $-0x7f, %al
jmp 0x40f7
cmpl $0x1954fc41, %edi       # imm = 0x1954FC41
jb 0x40fa
movb $0x6b, -0x2(%rbp)
movb $0x6f, %al
movb %al, -0x1(%rbp)
leaq -0x2(%rbp), %rsi
movl $0x98, %edi
movl $0x2, %edx
callq 0x4aff
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetPaConfig
void SX126xSetPaConfig( uint8_t paDutyCycle, uint8_t hpMax, uint8_t deviceSel, uint8_t paLut )
{
	printf("SX126xSetPaConfig: paDutyCycle=%d, hpMax=%d, deviceSel=%d, paLut=%d \r\n", (int) paDutyCycle, (int) hpMax, (int) deviceSel, (int) paLut);
    uint8_t buf[4];

    buf[0] = paDutyCycle;
    buf[1] = hpMax;
    buf[2] = deviceSel;
    buf[3] = paLut;
    SX126xWriteCommand( RADIO_SET_PACONFIG, buf, 4 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %ecx, %ebx
movl %edx, %r14d
movl %esi, %r15d
movl %edi, %r12d
leaq 0x2574(%rip), %rdi      # 0x66a8
movl %r12d, %esi
movl %r15d, %edx
movl %r14d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x2050
leaq -0x24(%rbp), %rsi
movb %r12b, (%rsi)
movb %r15b, 0x1(%rsi)
movb %r14b, 0x2(%rsi)
movb %bl, 0x3(%rsi)
movl $0x95, %edi
movl $0x4, %edx
callq 0x4aff
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetDioIrqParams
void SX126xSetDioIrqParams( uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask, uint16_t dio3Mask )
{
    uint8_t buf[8];

    buf[0] = ( uint8_t )( ( irqMask >> 8 ) & 0x00FF );
    buf[1] = ( uint8_t )( irqMask & 0x00FF );
    buf[2] = ( uint8_t )( ( dio1Mask >> 8 ) & 0x00FF );
    buf[3] = ( uint8_t )( dio1Mask & 0x00FF );
    buf[4] = ( uint8_t )( ( dio2Mask >> 8 ) & 0x00FF );
    buf[5] = ( uint8_t )( dio2Mask & 0x00FF );
    buf[6] = ( uint8_t )( ( dio3Mask >> 8 ) & 0x00FF );
    buf[7] = ( uint8_t )( dio3Mask & 0x00FF );
    SX126xWriteCommand( RADIO_CFG_DIOIRQ, buf, 8 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %esi, %eax
movl %edi, %ebx
movb %bh, -0x10(%rbp)
leaq -0x10(%rbp), %rsi
movb %bl, 0x1(%rsi)
movb %ah, -0xe(%rbp)
movb %al, 0x3(%rsi)
movb %dh, -0xc(%rbp)
movb %dl, 0x5(%rsi)
movb %ch, -0xa(%rbp)
movb %cl, 0x7(%rsi)
movl $0x8, %edi
movl $0x8, %edx
callq 0x4aff
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetDio3AsTcxoCtrl
void SX126xSetDio3AsTcxoCtrl( RadioTcxoCtrlVoltage_t tcxoVoltage, uint32_t timeout )
{
    uint8_t buf[4];

    buf[0] = tcxoVoltage & 0x07;
    buf[1] = ( uint8_t )( ( timeout >> 16 ) & 0xFF );
    buf[2] = ( uint8_t )( ( timeout >> 8 ) & 0xFF );
    buf[3] = ( uint8_t )( timeout & 0xFF );

    SX126xWriteCommand( RADIO_SET_TCXOMODE, buf, 4 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %esi, %eax
andb $0x7, %dil
leaq -0x4(%rbp), %rsi
movb %dil, (%rsi)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rsi)
movb %ah, -0x2(%rbp)
movb %al, 0x3(%rsi)
movl $0x97, %edi
movl $0x4, %edx
callq 0x4aff
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetRfFrequency
void SX126xSetRfFrequency( uint32_t frequency )
{
    uint8_t buf[4];

    if( ImageCalibrated == false )
    {
        SX126xCalibrateImage( frequency );
        ImageCalibrated = true;
    }

    uint32_t freqInPllSteps = SX126xConvertFreqInHzToPllStep( frequency );

    buf[0] = ( uint8_t )( ( freqInPllSteps >> 24 ) & 0xFF );
    buf[1] = ( uint8_t )( ( freqInPllSteps >> 16 ) & 0xFF );
    buf[2] = ( uint8_t )( ( freqInPllSteps >> 8 ) & 0xFF );
    buf[3] = ( uint8_t )( freqInPllSteps & 0xFF );
    SX126xWriteCommand( RADIO_SET_RFFREQUENCY, buf, 4 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
cmpb $0x0, 0x622e(%rip)      # 0xa498
jne 0x427a
movl %ebx, %edi
callq 0x40a1
movb $0x1, 0x621e(%rip)      # 0xa498
movl %ebx, %eax
imulq $0x431bde83, %rax, %rax # imm = 0x431BDE83
shrq $0x2c, %rax
imull $0x3c2f7, %eax, %ecx    # imm = 0x3C2F7
addl %ebx, %ecx
shll $0xe, %eax
shll $0xe, %ecx
orl $0x1e84, %ecx           # imm = 0x1E84
imulq $0x431bde83, %rcx, %rcx # imm = 0x431BDE83
shrq $0x2c, %rcx
addl %ecx, %eax
movl %eax, %edx
shrl $0x18, %edx
leaq -0xc(%rbp), %rsi
movb %dl, (%rsi)
movl %eax, %edx
shrl $0x10, %edx
movb %dl, 0x1(%rsi)
movb %ah, -0xa(%rbp)
movb %cl, 0x3(%rsi)
movl $0x86, %edi
movl $0x4, %edx
callq 0x4aff
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetTxParams
void SX126xSetTxParams( int8_t power, RadioRampTimes_t rampTime )
{
    printf("SX126xSetTxParams: power=%d, rampTime=%d\r\n", (int) power, (int) rampTime);
    uint8_t buf[2];

    if( SX126xGetDeviceId( ) == SX1261 )
    {
        if( power == 15 )
        {
            SX126xSetPaConfig( 0x06, 0x00, 0x01, 0x01 );
        }
        else
        {
            SX126xSetPaConfig( 0x04, 0x00, 0x01, 0x01 );
        }
        if( power >= 14 )
        {
            power = 14;
        }
        else if( power < -17 )
        {
            power = -17;
        }
        ////  TODO: Set the current max value in the over current protection. From SX126x-Arduino/src/radio/sx126x/sx126x.cpp
		SX126xWriteRegister(REG_OCP, 0x18); // current max is 80 mA for the whole device
    }
    else // sx1262
    {
        // WORKAROUND - Better Resistance of the SX1262 Tx to Antenna Mismatch, see DS_SX1261-2_V1.2 datasheet chapter 15.2
        SX126xWriteRegister( REG_TX_CLAMP_CFG, SX126xReadRegister( REG_TX_CLAMP_CFG ) | ( 0x0F << 1 ) );
        // WORKAROUND END

        SX126xSetPaConfig( 0x04, 0x07, 0x00, 0x01 );
        if( power > 22 )
        {
            power = 22;
        }
        else if( power < -9 )
        {
            power = -9;
        }

        ////  TODO: Set the current max value in the over current protection. From SX126x-Arduino/src/radio/sx126x/sx126x.cpp
        SX126xWriteRegister(REG_OCP, 0x38); // current max 160mA for the whole device
    }
    buf[0] = power;
    buf[1] = ( uint8_t )rampTime;
    SX126xWriteCommand( RADIO_SET_TXPARAMS, buf, 2 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movl %edi, %r14d
leaq 0x23d8(%rip), %rdi      # 0x66ef
movl %r14d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2050
callq 0x4ef5
cmpb $0x1, %al
jne 0x436e
xorl %eax, %eax
cmpb $0xf, %r14b
sete %al
leal 0x4(,%rax,2), %edi
xorl %esi, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x4113
movzbl %r14b, %eax
cmpb $-0x10, %r14b
movl $0xef, %ecx
cmovgel %eax, %ecx
cmpb $0xe, %cl
movl $0xe, %r14d
cmovll %ecx, %r14d
movb $0x18, %al
jmp 0x43ba
movl $0x8d8, %edi            # imm = 0x8D8
callq 0x4dfc
orb $0x1e, %al
movzbl %al, %esi
movl $0x8d8, %edi            # imm = 0x8D8
callq 0x4d78
movl $0x4, %edi
movl $0x7, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x4113
movzbl %r14b, %eax
cmpb $-0x8, %al
movl $0xf7, %ecx
cmovgel %eax, %ecx
cmpb $0x16, %cl
movl $0x16, %r14d
cmovll %ecx, %r14d
movb $0x38, %al
movzbl %al, %esi
movl $0x8e7, %edi            # imm = 0x8E7
callq 0x4d78
leaq -0x12(%rbp), %rsi
movb %r14b, (%rsi)
movb %bl, 0x1(%rsi)
movl $0x8e, %edi
movl $0x2, %edx
callq 0x4aff
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq $0x0, -0x10(%rbp)
movl (%rdi), %eax
cmpl %eax, 0x6097(%rip)      # 0xa49c
je 0x4422
leaq -0x14(%rbp), %rsi
movl %eax, (%rsi)
movl %eax, 0x6089(%rip)      # 0xa49c
movl $0x8a, %edi
movl $0x1, %edx
callq 0x4aff
movl (%rbx), %eax
cmpl $0x1, %eax
je 0x449a
testl %eax, %eax
jne 0x44ca
leaq -0x9(%rbp), %rcx
movl $0x3d090000, %eax       # imm = 0x3D090000
xorl %edx, %edx
divl 0x4(%rbx)
movl %eax, %edx
shrl $0x10, %edx
movb %dl, -0x7(%rcx)
movb %ah, -0xf(%rbp)
movb %al, -0x5(%rcx)
movb 0xc(%rbx), %al
movb %al, -0x4(%rcx)
movb 0x10(%rbx), %al
movb %al, -0x3(%rcx)
movl 0x8(%rbx), %eax
imulq $0x431bde83, %rax, %rdx # imm = 0x431BDE83
shrq $0x2c, %rdx
imull $0x3c2f7, %edx, %esi    # imm = 0x3C2F7
addl %eax, %esi
shll $0xe, %edx
shll $0xe, %esi
orl $0x1e84, %esi           # imm = 0x1E84
imulq $0x431bde83, %rsi, %rax # imm = 0x431BDE83
shrq $0x2c, %rax
addl %eax, %edx
movl %edx, %esi
shrl $0x10, %esi
movb %sil, -0x2(%rcx)
movb %dh, -0xa(%rbp)
movw $0x8, %dx
jmp 0x44b7
leaq -0xd(%rbp), %rcx
movb 0x14(%rbx), %al
movb %al, -0x3(%rcx)
movb 0x18(%rbx), %al
movb %al, -0x2(%rcx)
movb 0x1c(%rbx), %al
movb %al, -0x1(%rcx)
movb 0x20(%rbx), %al
movw $0x4, %dx
movb %al, (%rcx)
movzwl %dx, %edx
leaq -0x10(%rbp), %rsi
movl $0x8b, %edi
callq 0x4aff
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetCadParams
void SX126xSetCadParams( RadioLoRaCadSymbols_t cadSymbolNum, uint8_t cadDetPeak, uint8_t cadDetMin, RadioCadExitModes_t cadExitMode, uint32_t cadTimeout )
{
    uint8_t buf[7];

    buf[0] = ( uint8_t )cadSymbolNum;
    buf[1] = cadDetPeak;
    buf[2] = cadDetMin;
    buf[3] = ( uint8_t )cadExitMode;
    buf[4] = ( uint8_t )( ( cadTimeout >> 16 ) & 0xFF );
    buf[5] = ( uint8_t )( ( cadTimeout >> 8 ) & 0xFF );
    buf[6] = ( uint8_t )( cadTimeout & 0xFF );
    SX126xWriteCommand( RADIO_SET_CADPARAMS, buf, 7 );
    SX126xSetOperatingMode( MODE_CAD );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %r8d, %ebx
leaq -0xf(%rbp), %rax
movb %dil, (%rax)
movb %sil, 0x1(%rax)
movb %dl, 0x2(%rax)
movb %cl, 0x3(%rax)
movl %r8d, %ecx
shrl $0x10, %ecx
movb %cl, 0x4(%rax)
movb %bh, -0xa(%rbp)
movb %bl, 0x6(%rax)
movl $0x88, %edi
movq %rax, %rsi
movl $0x7, %edx
callq 0x4aff
movl $0x7, %edi
callq 0x497f
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetPacketStatus
void SX126xGetPacketStatus( PacketStatus_t *pktStatus )
{
    uint8_t status[3];

    SX126xReadCommand( RADIO_GET_PACKETSTATUS, status, 3 );

    pktStatus->packetType = SX126xGetPacketType( );
    switch( pktStatus->packetType )
    {
        case PACKET_TYPE_GFSK:
            pktStatus->Params.Gfsk.RxStatus = status[0];
            pktStatus->Params.Gfsk.RssiSync = -status[1] >> 1;
            pktStatus->Params.Gfsk.RssiAvg = -status[2] >> 1;
            pktStatus->Params.Gfsk.FreqError = 0;
            break;

        case PACKET_TYPE_LORA:
            pktStatus->Params.LoRa.RssiPkt = -status[0] >> 1;
            // Returns SNR value [dB] rounded to the nearest integer value
            pktStatus->Params.LoRa.SnrPkt = ( ( ( int8_t )status[1] ) + 2 ) >> 2;
            pktStatus->Params.LoRa.SignalRssiPkt = -status[2] >> 1;
            pktStatus->Params.LoRa.FreqError = FrequencyError;
            break;

        default:
        case PACKET_TYPE_NONE:
            // In that specific case, we set everything in the pktStatus to zeros
            // and reset the packet type accordingly
            memset( pktStatus, 0, sizeof( PacketStatus_t ) );
            pktStatus->packetType = PACKET_TYPE_NONE;
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq -0xb(%rbp), %rsi
movl $0x14, %edi
movl $0x3, %edx
callq 0x4b60
movl 0x5d64(%rip), %eax      # 0xa49c
movl %eax, (%rbx)
cmpl $0x1, %eax
je 0x4768
testl %eax, %eax
jne 0x4796
movb -0xb(%rbp), %al
movb %al, 0x4(%rbx)
movzbl -0xa(%rbp), %eax
negl %eax
shrl %eax
movb %al, 0x6(%rbx)
movzbl -0x9(%rbp), %eax
negl %eax
shrl %eax
movb %al, 0x5(%rbx)
movl $0x0, 0x8(%rbx)
jmp 0x47a9
movzbl -0xb(%rbp), %eax
negl %eax
shrl %eax
movb %al, 0xc(%rbx)
movsbl -0xa(%rbp), %eax
addl $0x2, %eax
shrl $0x2, %eax
movb %al, 0xd(%rbx)
movzbl -0x9(%rbp), %eax
negl %eax
shrl %eax
movb %al, 0xe(%rbx)
movl 0x5d03(%rip), %eax      # 0xa494
movl %eax, 0x10(%rbx)
jmp 0x47a9
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movl $0x0, 0x10(%rbx)
movl $0xf, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetDeviceErrors
RadioError_t SX126xGetDeviceErrors( void )
{
    uint8_t err[] = { 0, 0 };
    RadioError_t error = { .Value = 0 };

    SX126xReadCommand( RADIO_GET_ERROR, ( uint8_t* )err, 2 );
    error.Fields.PaRamp     = ( err[0] & ( 1 << 0 ) ) >> 0;
    error.Fields.PllLock    = ( err[1] & ( 1 << 6 ) ) >> 6;
    error.Fields.XoscStart  = ( err[1] & ( 1 << 5 ) ) >> 5;
    error.Fields.ImgCalib   = ( err[1] & ( 1 << 4 ) ) >> 4;
    error.Fields.AdcCalib   = ( err[1] & ( 1 << 3 ) ) >> 3;
    error.Fields.PllCalib   = ( err[1] & ( 1 << 2 ) ) >> 2;
    error.Fields.Rc13mCalib = ( err[1] & ( 1 << 1 ) ) >> 1;
    error.Fields.Rc64kCalib = ( err[1] & ( 1 << 0 ) ) >> 0;
    return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq -0xa(%rbp), %rbx
movw $0x0, (%rbx)
movl $0x17, %edi
movq %rbx, %rsi
movl $0x2, %edx
callq 0x4b60
movzbl (%rbx), %ecx
andl $0x1, %ecx
shll $0x8, %ecx
movzbl 0x1(%rbx), %eax
movl %eax, %edx
andl $0x40, %edx
orl %ecx, %edx
movl %eax, %ecx
andl $0x20, %ecx
orl %edx, %ecx
movl %eax, %edx
andl $0x10, %edx
orl %ecx, %edx
movl %eax, %ecx
andl $0x8, %ecx
orl %edx, %ecx
movl %eax, %edx
andl $0x4, %edx
orl %ecx, %edx
andl $0x3, %eax
orl %edx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xIoInit
void SX126xIoInit( void )
{
    printf("SX126xIoInit\r\n");

    //  Init SPI Bus
    int rc = init_spi();
    assert(rc == 0);

    //  TODO: Init GPIO Pins
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x222b(%rip), %rdi      # 0x6a96
callq 0x2260
leaq 0x21fd(%rip), %rdi      # 0x6a74
movl $0x2, %esi
xorl %eax, %eax
callq 0x2100
movl %eax, 0x6437(%rip)      # 0xacc0
testl %eax, %eax
jle 0x48c9
leaq -0x2(%rbp), %rdx
movb $0x0, (%rdx)
movl $0x40016b01, %esi       # imm = 0x40016B01
movl %eax, %edi
xorl %eax, %eax
callq 0x21e0
testl %eax, %eax
jne 0x48e8
leaq -0x1(%rbp), %rdx
movb $0x0, (%rdx)
movl 0x640d(%rip), %edi      # 0xacc0
movl $0x40016b02, %esi       # imm = 0x40016B02
xorl %eax, %eax
callq 0x21e0
testl %eax, %eax
jne 0x4907
addq $0x10, %rsp
popq %rbp
retq
leaq 0x2091(%rip), %rdi      # 0x6961
leaq 0x1e4b(%rip), %rsi      # 0x6722
leaq 0x21a5(%rip), %rcx      # 0x6a83
movl $0x28f, %edx            # imm = 0x28F
callq 0x20f0
leaq 0x1e2b(%rip), %rdi      # 0x671a
leaq 0x1e2c(%rip), %rsi      # 0x6722
leaq 0x2186(%rip), %rcx      # 0x6a83
movl $0x294, %edx            # imm = 0x294
callq 0x20f0
leaq 0x1e0c(%rip), %rdi      # 0x671a
leaq 0x1e0d(%rip), %rsi      # 0x6722
leaq 0x2167(%rip), %rcx      # 0x6a83
movl $0x299, %edx            # imm = 0x299
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xWakeup
void SX126xWakeup( void )
{
    printf("SX126xWakeup\r\n");
    CRITICAL_SECTION_BEGIN( );

    // Write RADIO_GET_STATUS command followed by 0
    uint8_t commands[1] = { RADIO_GET_STATUS };
    uint8_t buffer[1]   = { 0 };
    int rc = sx126x_hal_write(NULL, commands, sizeof(commands), buffer, sizeof(buffer));
    assert(rc == 0);

    // Wait for chip to be ready.
    SX126xWaitOnBusy( );

    // Update operating mode context variable
    SX126xSetOperatingMode( MODE_STDBY_RC );

    CRITICAL_SECTION_END( );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x213a(%rip), %rdi      # 0x6afc
callq 0x2260
leaq 0x1eda(%rip), %rdi      # 0x68a8
movl $0x1, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x2050
movw $0x0, 0x5ed8(%rip)      # 0xa8c0
movw $0xc0, 0x5acf(%rip)     # 0xa4c0
movl $0x2, %edi
callq 0x50e6
leaq 0x20e2(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
callq 0x21f0
movl $0x1, 0x5a95(%rip)      # 0xa4b0
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: sx126x_hal_write
static int sx126x_hal_write( 
    const void* context, const uint8_t* command, const uint16_t command_length,
    const uint8_t* data, const uint16_t data_length ) {
    printf("sx126x_hal_write: command_length=%d, data_length=%d\n", command_length, data_length);

    //  Total length is command + data length
    uint16_t len = command_length + data_length;
    assert(len > 0);
    assert(len <= SPI_BUFFER_SIZE);

    //  Clear the SPI Transmit and Receive buffers
    memset(&spi_tx_buf, 0, len);
    memset(&spi_rx_buf, 0, len);

    //  Copy command bytes to SPI Transmit Buffer
    memcpy(&spi_tx_buf, command, command_length);

    //  Copy data bytes to SPI Transmit Buffer
    memcpy(&spi_tx_buf[command_length], data, data_length);

    //  Transmit and receive the SPI buffers
    int rc = transfer_spi(spi_tx_buf, spi_rx_buf, len);
    assert(rc == 0);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r14d
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x1e6a(%rip), %rdi      # 0x68a8
movl %ecx, %edx
xorl %eax, %eax
callq 0x2050
movl %r14d, %eax
addw %r12w, %ax
je 0x4ac1
movq %rbx, -0x30(%rbp)
movzwl %ax, %r13d
cmpl $0x401, %r13d           # imm = 0x401
jae 0x4ae0
leaq 0x5a58(%rip), %rbx      # 0xa4c0
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x20d0
leaq 0x5e44(%rip), %rdi      # 0xa8c0
xorl %esi, %esi
movq %r13, %rdx
callq 0x20d0
movzwl %r12w, %r12d
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
movq %r12, %rdx
callq 0x2130
addq %r12, %rbx
movzwl %r14w, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2130
movl %r13d, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x50e6
leaq 0x1e15(%rip), %rdi      # 0x68dd
leaq 0x1c53(%rip), %rsi      # 0x6722
leaq 0x1e0f(%rip), %rcx      # 0x68e5
movl $0x228, %edx            # imm = 0x228
callq 0x20f0
leaq 0x1e63(%rip), %rdi      # 0x694a
leaq 0x1c34(%rip), %rsi      # 0x6722
leaq 0x1df0(%rip), %rcx      # 0x68e5
movl $0x229, %edx            # imm = 0x229
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xWriteCommand
void SX126xWriteCommand( RadioCommands_t command, uint8_t *buffer, uint16_t size )
{
    SX126xCheckDeviceReady( );

    //  Write the command followed by buffer
    uint8_t commands[1] = { (uint8_t) command };
    int rc = sx126x_hal_write(NULL, commands, sizeof(commands), buffer, size);
    assert(rc == 0);

    if( command != RADIO_SET_SLEEP )
    {
        SX126xWaitOnBusy( );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movl %edi, %r15d
callq 0x3b8c
leaq -0x19(%rbp), %rdi
movb %r15b, (%rdi)
movl $0x1, %esi
movq %r14, %rdx
movl %ebx, %ecx
callq 0x4a1d
cmpl $0x84, %r15d
jne 0x4b40
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f9d(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x21f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xReadCommand
uint8_t SX126xReadCommand( RadioCommands_t command, uint8_t *buffer, uint16_t size )
{
    printf("SX126xReadCommand: command=0x%02x, size=%d\r\n", command, size);
    uint8_t status = 0;

    SX126xCheckDeviceReady( );

    //  Write the command, read the status and read the buffer
    uint8_t commandStatus[2] = { 
        (uint8_t) command,  //  Command
        0                   //  Status
    };
    int rc = sx126x_hal_read(NULL, commandStatus, sizeof(commandStatus), buffer, size, &status);
    assert(rc == 0);
    printf("status=0x%02x\n", status);

#ifdef NOTUSED  //  Previously...
    bl_gpio_output_set( SX126X_SPI_CS_PIN, 0 );
    if (SX126X_DEBUG_CS_PIN >= 0) { bl_gpio_output_set( SX126X_DEBUG_CS_PIN, 0 ); }

    SpiInOut( SX126X_SPI_IDX, ( uint8_t )command );
    status = SpiInOut( SX126X_SPI_IDX, 0x00 );
    for( uint16_t i = 0; i < size; i++ )
    {
        buffer[i] = SpiInOut( SX126X_SPI_IDX, 0 );
    }

    bl_gpio_output_set( SX126X_SPI_CS_PIN, 1 );
    if (SX126X_DEBUG_CS_PIN >= 0) { bl_gpio_output_set( SX126X_DEBUG_CS_PIN, 1 ); }
#endif  //  NOTUSED

    SX126xWaitOnBusy( );

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movl %edi, %r12d
leaq 0x1bb7(%rip), %rdi      # 0x6735
xorl %r13d, %r13d
movl %r12d, %esi
xorl %eax, %eax
callq 0x2050
leaq -0x29(%rbp), %rbx
movb %r13b, (%rbx)
callq 0x3b8c
leaq -0x2b(%rbp), %rdi
movb %r12b, (%rdi)
movb %r13b, 0x1(%rdi)
movl $0x2, %esi
movq %r15, %rdx
movl %r14d, %ecx
movq %rbx, %r8
callq 0x4bed
movzbl (%rbx), %esi
leaq 0x1ba3(%rip), %rdi      # 0x6762
xorl %eax, %eax
callq 0x2050
leaq 0x1f17(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
callq 0x21f0
movb (%rbx), %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: sx126x_hal_read
static int sx126x_hal_read( 
    const void* context, const uint8_t* command, const uint16_t command_length,
    uint8_t* data, const uint16_t data_length, uint8_t *status ) {
    printf("sx126x_hal_read: command_length=%d, data_length=%d\n", command_length, data_length);

    //  Total length is command + data length
    uint16_t len = command_length + data_length;
    assert(len > 0);
    assert(len <= SPI_BUFFER_SIZE);

    //  Clear the SPI Transmit and Receive buffers
    memset(&spi_tx_buf, 0, len);
    memset(&spi_rx_buf, 0, len);

    //  Copy command bytes to SPI Transmit Buffer
    memcpy(&spi_tx_buf, command, command_length);

    //  Transmit and receive the SPI buffers
    int rc = transfer_spi(spi_tx_buf, spi_rx_buf, len);
    assert(rc == 0);

    //  Copy SPI Receive buffer to data buffer
    memcpy(data, &spi_rx_buf[command_length], data_length);

    //  Return the second SPI byte received as status
    if (status != NULL) {
        assert(len >= 2);
        *status = spi_rx_buf[1];
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r14
movl %ecx, %r15d
movq %rdx, %r12
movl %esi, %r13d
movq %rdi, -0x40(%rbp)
leaq 0x1db9(%rip), %rdi      # 0x69ce
movl %ecx, %edx
xorl %eax, %eax
callq 0x2050
movl %r15d, %ebx
addw %r13w, %bx
je 0x4cc1
movq %r12, -0x30(%rbp)
movq %r14, -0x38(%rbp)
movzwl %bx, %r14d
cmpl $0x401, %r14d           # imm = 0x401
jae 0x4ce0
leaq 0x5875(%rip), %rdi      # 0xa4c0
xorl %esi, %esi
movq %r14, %rdx
callq 0x20d0
leaq 0x5c64(%rip), %r12      # 0xa8c0
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20d0
movzwl %r13w, %r13d
leaq 0x584c(%rip), %rdi      # 0xa4c0
movq -0x40(%rbp), %rsi
movq %r13, %rdx
callq 0x2130
movl %r14d, %edi
callq 0x50e6
addq %r13, %r12
movzwl %r15w, %edx
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x2130
movq -0x38(%rbp), %rcx
testq %rcx, %rcx
je 0x4cb2
cmpw $0x1, %bx
je 0x4cff
movb 0x5c11(%rip), %al       # 0xa8c1
movb %al, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c15(%rip), %rdi      # 0x68dd
leaq 0x1a53(%rip), %rsi      # 0x6722
leaq 0x1d2c(%rip), %rcx      # 0x6a02
movl $0x250, %edx            # imm = 0x250
callq 0x20f0
leaq 0x1c63(%rip), %rdi      # 0x694a
leaq 0x1a34(%rip), %rsi      # 0x6722
leaq 0x1d0d(%rip), %rcx      # 0x6a02
movl $0x251, %edx            # imm = 0x251
callq 0x20f0
leaq 0x1d65(%rip), %rdi      # 0x6a6b
leaq 0x1a15(%rip), %rsi      # 0x6722
leaq 0x1cee(%rip), %rcx      # 0x6a02
movl $0x263, %edx            # imm = 0x263
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xWriteRegisters
void SX126xWriteRegisters( uint16_t address, uint8_t *buffer, uint16_t size )
{
    SX126xCheckDeviceReady( );
    int rc = sx126x_write_register(NULL, address, buffer, size);
    assert(rc == 0);
    SX126xWaitOnBusy( );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movq %rsi, %r14
movl %edi, %ebx
callq 0x3b8c
leaq -0x1c(%rbp), %rdi
movw $0x0, (%rdi)
movb $0xd, (%rdi)
movb %bh, -0x1b(%rbp)
movb %bl, 0x2(%rdi)
movzbl %r15b, %ecx
movl $0x3, %esi
movq %r14, %rdx
callq 0x4a1d
leaq 0x1d85(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x21f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xReadRegisters
void SX126xReadRegisters( uint16_t address, uint8_t *buffer, uint16_t size )
{
    SX126xCheckDeviceReady( );
    int rc = sx126x_read_register(NULL, address, buffer, size);
    assert(rc == 0);
    SX126xWaitOnBusy( );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movq %rsi, %r14
movl %edi, %ebx
callq 0x3b8c
leaq -0x1c(%rbp), %rdi
movl $0x0, (%rdi)
movb $0x1d, (%rdi)
movb %bh, -0x1b(%rbp)
movb %bl, 0x2(%rdi)
movb $0x0, 0x3(%rdi)
movzbl %r15b, %ecx
movl $0x4, %esi
movq %r14, %rdx
xorl %r8d, %r8d
callq 0x4bed
leaq 0x1d01(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x21f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xWriteBuffer
void SX126xWriteBuffer( uint8_t offset, uint8_t *buffer, uint8_t size )
{
    SX126xCheckDeviceReady( );
    int rc = sx126x_write_buffer(NULL, offset, buffer, size);
    assert(rc == 0);
    SX126xWaitOnBusy( );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movl %edi, %r15d
callq 0x3b8c
leaq -0x1a(%rbp), %rdi
movw $0x0, (%rdi)
movb $0xe, (%rdi)
movb %r15b, 0x1(%rdi)
movl $0x2, %esi
movq %r14, %rdx
movl %ebx, %ecx
callq 0x4a1d
leaq 0x1c8b(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x21f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xReadBuffer
void SX126xReadBuffer( uint8_t offset, uint8_t *buffer, uint8_t size )
{
    SX126xCheckDeviceReady( );
    int rc = sx126x_read_buffer(NULL, offset, buffer, size);
    assert(rc == 0);
    SX126xWaitOnBusy( );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movl %edi, %r15d
callq 0x3b8c
leaq -0x1c(%rbp), %rdi
movw $0x0, (%rdi)
movb $0x0, 0x2(%rdi)
movb $0x1e, (%rdi)
movb %r15b, 0x1(%rdi)
movl $0x3, %esi
movq %r14, %rdx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x4bed
leaq 0x1c2e(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x21f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: TimerInit
void TimerInit(
    struct ble_npl_callout *timer,  //  The timer to initialize. Cannot be NULL.
    ble_npl_event_fn *f)            //  The timer callback function. Cannot be NULL.
{
    puts("TimerInit");
    assert(timer != NULL);
    assert(f != NULL);

    //  Event Queue containing Events to be processed, defined in demo.c.  TODO: Move to header file.
    extern struct ble_npl_eventq event_queue;

    //  Init the Callout Timer with the Callback Function
    ble_npl_callout_init(
        timer,         //  Callout Timer
        &event_queue,  //  Event Queue that will handle the Callout upon timeout
        f,             //  Callback Function
        NULL           //  Argument to be passed to Callback Function
    );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1848(%rip), %rdi      # 0x678d
callq 0x2260
testq %r14, %r14
je 0x4f6c
testq %rbx, %rbx
je 0x4f8b
leaq 0x5265(%rip), %rsi      # 0xa1c0
movq %r14, %rdi
movq %rbx, %rdx
xorl %ecx, %ecx
popq %rbx
popq %r14
popq %rbp
jmp 0x5288
leaq 0x1824(%rip), %rdi      # 0x6797
leaq 0x17a8(%rip), %rsi      # 0x6722
leaq 0x1824(%rip), %rcx      # 0x67a5
movl $0x16f, %edx            # imm = 0x16F
callq 0x20f0
leaq 0x1850(%rip), %rdi      # 0x67e2
leaq 0x1789(%rip), %rsi      # 0x6722
leaq 0x1805(%rip), %rcx      # 0x67a5
movl $0x170, %edx            # imm = 0x170
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: TimerStop
void TimerStop(
    struct ble_npl_callout *timer)  //  Pointer to timer to stop. Cannot be NULL.
{
    puts("TimerStop");
    assert(timer != NULL);

    //  If Callout Timer is still running...
    if (ble_npl_callout_is_active(timer)) {
        //  Stop the Callout Timer
        ble_npl_callout_stop(timer);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1832(%rip), %rdi      # 0x67ec
callq 0x2260
testq %rbx, %rbx
je 0x4fe5
movq %rbx, %rdi
callq 0x5320
testb %al, %al
je 0x4fde
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x53ed
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x17ab(%rip), %rdi      # 0x6797
leaq 0x172f(%rip), %rsi      # 0x6722
leaq 0x17fc(%rip), %rcx      # 0x67f6
movl $0x183, %edx            # imm = 0x183
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O1/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: TimerStart
void TimerStart(
    struct ble_npl_callout *timer,  //  Pointer to timer. Cannot be NULL.
    uint32_t millisecs)             //  The number of milliseconds from now at which the timer will expire.
{
    puts("TimerStart");
    assert(timer != NULL);

    //  Stop the timer if running
    TimerStop(timer);

    //  Convert milliseconds to ticks
    ble_npl_time_t ticks = ble_npl_time_ms_to_ticks32(
        millisecs  //  Duration in milliseconds
    );

    //  Wait at least 1 tick
    if (ticks == 0) { ticks = 1; }

    //  Trigger the Callout Timer after the elapsed ticks
    ble_npl_error_t rc = ble_npl_callout_reset(
        timer,  //  Callout Timer
        ticks   //  Number of ticks
    );
    assert(rc == 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x1807(%rip), %rdi      # 0x681f
callq 0x2260
testq %rbx, %rbx
je 0x504b
movq %rbx, %rdi
callq 0x4faa
movl %r14d, %edi
callq 0x5709
cmpl $0x1, %eax
adcl $0x0, %eax
movq %rbx, %rdi
movl %eax, %esi
callq 0x5339
testl %eax, %eax
jne 0x506a
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1745(%rip), %rdi      # 0x6797
leaq 0x16c9(%rip), %rsi      # 0x6722
leaq 0x17ca(%rip), %rcx      # 0x682a
movl $0x192, %edx            # imm = 0x192
callq 0x20f0
leaq 0x16a9(%rip), %rdi      # 0x671a
leaq 0x16aa(%rip), %rsi      # 0x6722
leaq 0x17ab(%rip), %rcx      # 0x682a
movl $0x1a4, %edx            # imm = 0x1A4
callq 0x20f0