0 | module Bindings.RtlSdr.Raw.Support
 1 |
 2 | import System.FFI
 3 |
 4 | %default total
 5 |
 6 | -- wrapper C func helper.
 7 | idris_rtlsdr : String -> String
 8 | idris_rtlsdr fn = "C:" ++ "idris_rtlsdr_" ++ fn ++ ",rtlsdr-idris"
 9 |
10 | -- XXX support/ runtime wraps
11 | export
12 | %foreign (idris_rtlsdr "open")
13 | idris_rtlsdr_open : Int -> Ptr Int -> PrimIO AnyPtr
14 |
15 | -- XXX support/.. int read_ptr_ref(int *p, int off);
16 | %foreign (idris_rtlsdr "read_ptr_ref")
17 | idris_rtlsdr_read_ptr_ref : Ptr Int -> Int -> Int
18 |
19 | export
20 | readBufPtr : Ptr Int -> Int -> IO (List Int)
21 | readBufPtr p n = for [0..n-1] $ \i => io_pure $ idris_rtlsdr_read_ptr_ref p i
22 |
23 | %foreign (idris_rtlsdr "read_ptr_ref_")
24 | idris_rtlsdr_read_ptr_ref' : Ptr Bits8 -> Int -> Bits8
25 |
26 | export
27 | readBufPtr' : Ptr Bits8 -> Int -> IO (List Bits8)
28 | readBufPtr' p n = for [0..n-1] $ \i => io_pure $ idris_rtlsdr_read_ptr_ref' p i
29 |
30 | export
31 | peekInt : Ptr Int -> Int
32 | peekInt p = idris_rtlsdr_read_ptr_ref p 0
33 |
34 | export
35 | %foreign (idris_rtlsdr "getstring")
36 | idris_rtlsdr_getstring : Ptr String -> String
37 |