channel controls done

This commit is contained in:
Eray Arslan 2021-05-20 22:53:40 +03:00
parent d9b9c7520a
commit de423438e0
7 changed files with 78 additions and 0 deletions

View File

@ -66,6 +66,22 @@ func GetFpgaSize(bladeRF BladeRF) (FpgaSize, error) {
return FpgaSize(size), nil
}
func GetQuickTune(bladeRF BladeRF, channel Channel) (QuickTune, error) {
var quickTune C.struct_bladerf_quick_tune
err := GetError(C.bladerf_get_quick_tune(bladeRF.ref, C.bladerf_channel(channel), &quickTune))
if err != nil {
return QuickTune{}, err
}
return QuickTune{ref: &quickTune}, nil
}
func CancelScheduledReTunes(bladeRF BladeRF, channel Channel) error {
return GetError(C.bladerf_cancel_scheduled_retunes(bladeRF.ref, C.bladerf_channel(channel)))
}
func GetFpgaSource(bladeRF BladeRF) (FpgaSource, error) {
var source C.bladerf_fpga_source
err := GetError(C.bladerf_get_fpga_source(bladeRF.ref, &source))
@ -300,6 +316,10 @@ func GetLoopback(bladeRF BladeRF) (Loopback, error) {
return Loopback(loopback), nil
}
func ScheduleReTune(bladeRF BladeRF, channel Channel, timestamp Timestamp, frequency uint64, quickTune QuickTune) error {
return GetError(C.bladerf_schedule_retune(bladeRF.ref, C.bladerf_channel(channel), C.bladerf_timestamp(timestamp), C.bladerf_frequency(frequency), quickTune.ref))
}
func SelectBand(bladeRF BladeRF, channel Channel, frequency uint64) error {
return GetError(C.bladerf_select_band(bladeRF.ref, C.bladerf_channel(channel), C.bladerf_frequency(frequency)))
}
@ -521,6 +541,21 @@ func GetNumberOfGainStages(bladeRF BladeRF, channel Channel) (int, error) {
return int(countOrCode), nil
}
func SetCorrection(bladeRF BladeRF, channel Channel, correction Correction, correctionValue int16) error {
return GetError(C.bladerf_set_correction(bladeRF.ref, C.bladerf_channel(channel), C.bladerf_correction(correction), C.bladerf_correction_value(correctionValue)))
}
func GetCorrection(bladeRF BladeRF, channel Channel, correction Correction) (uint16, error) {
var correctionValue C.int16_t
err := GetError(C.bladerf_get_correction(bladeRF.ref, C.bladerf_channel(channel), C.bladerf_correction(correction), &correctionValue))
if err != nil {
return 0, err
}
return uint16(correctionValue), nil
}
func BackendString(backend Backend) string {
return C.GoString(C.bladerf_backend_str(C.bladerf_backend(backend)))
}

View File

@ -286,6 +286,38 @@ func TestGetLoopbackModes(t *testing.T) {
}
}
func TestGetQuickTune(t *testing.T) {
log.SetVerbosity(log.Debug)
devices, _ := GetDeviceList()
if len(devices) == 0 {
fmt.Println("NO DEVICE")
return
}
rf, _ := OpenWithDeviceInfo(devices[0])
defer Close(rf)
channel := ChannelRx(1)
quickTune, err := GetQuickTune(rf, channel)
if err != nil {
panic(err)
}
err = ScheduleReTune(rf, channel, ReTuneNow, 96600000, quickTune)
if err != nil {
panic(err)
}
}
func TestReTuneNow(t *testing.T) {
fmt.Println(ReTuneNow)
}
func TestTrigger(t *testing.T) {
log.SetVerbosity(log.Debug)

View File

@ -21,6 +21,7 @@ type PowerSource int
type RxMux int
type TriggerRole int
type TriggerSignal int
type Timestamp uint64
const (
BackendAny Backend = C.BLADERF_BACKEND_ANY

View File

@ -1,5 +1,7 @@
#include "macro_wrapper.h"
uint64_t ReTuneNow = BLADERF_RETUNE_NOW;
int ChannelRx(const int ch) {
return BLADERF_CHANNEL_RX(ch);
}

View File

@ -1,5 +1,7 @@
#include <libbladeRF.h>
extern uint64_t ReTuneNow;
int ChannelRx(const int ch);
int ChannelTx(const int ch);
int ChannelIsTx(const int ch);

View File

@ -3,6 +3,8 @@ package bladerf
// #include "macro_wrapper.h"
import "C"
var ReTuneNow = Timestamp(C.ReTuneNow)
func ChannelRx(ch int) Channel {
return Channel(C.ChannelRx(C.int(ch)))
}

View File

@ -96,6 +96,10 @@ type BladeRF struct {
ref *C.struct_bladerf
}
type QuickTune struct {
ref *C.struct_bladerf_quick_tune
}
type Serial struct {
ref *C.struct_bladerf_serial
serial string