0 | module Bindings.RtlSdr.Sampling
2 | import Bindings.RtlSdr.Device
3 | import Bindings.RtlSdr.Error
4 | import Bindings.RtlSdr.Raw.Sampling
17 | setSampleRate : Ptr RtlSdrHandle -> Int -> IO (Either RTLSDR_ERROR ())
18 | setSampleRate h r = do
19 | r <- fromPrim $
set_sample_rate h r
20 | io_pure $
if r == 0 then Right () else Left RtlSdrInvalidRate
26 | getSampleRate : Ptr RtlSdrHandle -> IO Int
27 | getSampleRate h = fromPrim $
get_sample_rate h
34 | setAGCMode : Ptr RtlSdrHandle -> Bool -> IO (Either RTLSDR_ERROR ())
36 | r <- fromPrim $
set_agc_mode h (if t then 1 else 0)
37 | io_pure $
if r == 0 then Right () else Left RtlSdrError
40 | data SamplingType = SAMPLING_DISABLED | SAMPLING_I_ADC_ENABLED | SAMPLING_Q_ADC_ENABLED | SAMPLING_IQ_ADC_ENABLED
43 | Show SamplingType where
44 | show SAMPLING_DISABLED = "Disabled"
45 | show SAMPLING_I_ADC_ENABLED = "I-ADC Input Enabled"
46 | show SAMPLING_Q_ADC_ENABLED = "Q-ADC Input Enabled"
47 | show SAMPLING_IQ_ADC_ENABLED = "IQ-ADC Input Enabled"
49 | toSamplingType : Int -> Maybe SamplingType
50 | toSamplingType 0 = Just SAMPLING_DISABLED
51 | toSamplingType 1 = Just SAMPLING_I_ADC_ENABLED
52 | toSamplingType 2 = Just SAMPLING_Q_ADC_ENABLED
53 | toSamplingType 3 = Just SAMPLING_IQ_ADC_ENABLED
54 | toSamplingType _ = Nothing
56 | fromSamplingType : SamplingType -> Int
57 | fromSamplingType SAMPLING_DISABLED = 0
58 | fromSamplingType SAMPLING_I_ADC_ENABLED = 1
59 | fromSamplingType SAMPLING_Q_ADC_ENABLED = 2
60 | fromSamplingType SAMPLING_IQ_ADC_ENABLED = 3
70 | setDirectSampling : Ptr RtlSdrHandle -> SamplingType -> IO (Either RTLSDR_ERROR ())
71 | setDirectSampling h t = do
72 | r <- fromPrim $
set_direct_sampling h (fromSamplingType t)
73 | io_pure $
if r < 0 then Left RtlSdrError else Right ()
79 | getDirectSampling : Ptr RtlSdrHandle -> IO (Either RTLSDR_ERROR (Maybe SamplingType))
80 | getDirectSampling h = do
81 | r <- fromPrim $
get_direct_sampling h
82 | io_pure $
if r < 0 then Left RtlSdrError else Right (toSamplingType r)