Nuand / bladeRF

bladeRF USB 3.0 Superspeed Software Defined Radio Source Code
http://nuand.com
Other
1.13k stars 455 forks source link

libbladeRF: Add API call for switching betweein internal/external setting #65

Closed jynik closed 11 years ago

jynik commented 11 years ago

This code from the CLI should be integrated into an API call, and the CLI adjusted to use this:

int set_sampling(struct cli_state *state, int argc, char **argv)
{
    /* Usage: set sampling [internal|external] */
    int rv = CMD_RET_OK;
    uint8_t val = 0;
    if( argc != 3 ) {
        rv = CMD_RET_NARGS ;
    } else {
        if( strcasecmp( "internal", argv[2] ) == 0 ) {
            /* Disconnect the ADC input from the outside world */
            bladerf_lms_read( state->dev, 0x09, &val );
            val &= ~(1<<7) ;
            bladerf_lms_write( state->dev, 0x09, val );

            /* Turn on RXVGA2 */
            bladerf_lms_read( state->dev, 0x64, &val );
            val |= (1<<1) ;
            bladerf_lms_write( state->dev, 0x64, val );

        } else if( strcasecmp( "external", argv[2] ) == 0 ) {
            /* Turn off RXVGA2 */
            bladerf_lms_read( state->dev, 0x64, &val );
            val &= ~(1<<1) ;
            bladerf_lms_write( state->dev, 0x64, val );

            /* Connect the external ADC pins to the internal ADC input */
            bladerf_lms_read( state->dev, 0x09, &val );
            val |= (1<<7) ;
            bladerf_lms_write( state->dev, 0x09, val );
        } else {
            cli_err(state, argv[0], "Invalid sampling mode (%s)", argv[2] );
        }
    }
    return rv;
}
jynik commented 11 years ago

Addressed in 4d8312b59bf0b3327c74d0ea9615c8c05ed84c7d