@@ -48,6 +48,95 @@ def _return_ctype(self):
4848 return _datatype_ctype [self ]
4949
5050
51+ class FifoPropertyType (Enum ):
52+ """ Types of FIFO Properties, intended to abstract away the C Type. """
53+ I32 = 1
54+ U32 = 2
55+ I64 = 3
56+ U64 = 4
57+ Ptr = 5
58+
59+ def __str__ (self ):
60+ return self .name
61+
62+ def _return_ctype (self ):
63+ """ Returns the associated ctype of a given property type. """
64+ _propertyType_ctype = {
65+ FifoPropertyType .I32 : ctypes .c_int32 ,
66+ FifoPropertyType .U32 : ctypes .c_uint32 ,
67+ FifoPropertyType .I64 : ctypes .c_int64 ,
68+ FifoPropertyType .U64 : ctypes .c_uint64 ,
69+ FifoPropertyType .Ptr : ctypes .c_void_p
70+ }
71+ return _propertyType_ctype [self ]
72+
73+
74+ class FifoProperty (Enum ):
75+ BytesPerElement = 1 # U32
76+ BufferAllocationGranularityElements = 2 # U32
77+ BufferSizeElements = 3 # U64
78+ MirroredElements = 4 # U64
79+ DmaBufferType = 5 # I32
80+ DmaBuffer = 6 # Ptr
81+ FlowControl = 7 # I32
82+
83+ def __str__ (self ):
84+ return self .name
85+
86+
87+ class FlowControl (Enum ):
88+ """ When flow control is disabled, the FIFO no longer acts like a FIFO.
89+ The FIFO will overwrite data in this mode. The FPGA fully controls when
90+ data transfers. This can be useful when regenerating a waveform or when
91+ you only care about the most recent data.
92+ For Host to Target FIFOs, this only disables flow control when the entire FIFO
93+ has been written once.
94+ For Target to Host FIFOs, flow control is disabled on start and the FPGA can
95+ begin writing then.
96+ """
97+ DisableFlowControl = 1
98+ """ Default FIFO behavior. No data is lost, data only moves when there is
99+ room for it.
100+ """
101+ EnableFlowControl = 2
102+
103+
104+ class DmaBufferType (Enum ):
105+ """ Allocated by RIO means the driver take the other properties and create
106+ a buffer that meets their requirements.
107+ """
108+ AllocatedByRIO = 1
109+ """ Allocated by User means you will allocate a buffer and set the DMA Buffer
110+ property with your buffer. The driver will then use this buffer as the
111+ underlying host memory in the FIFO.
112+ """
113+ AllocatedByUser = 2
114+
115+
116+ _fifo_properties_to_types = {
117+ FifoProperty .BytesPerElement : FifoPropertyType .U32 ,
118+ FifoProperty .BufferAllocationGranularityElements : FifoPropertyType .U32 ,
119+ FifoProperty .BufferSizeElements : FifoPropertyType .U64 ,
120+ FifoProperty .MirroredElements : FifoPropertyType .U64 ,
121+ FifoProperty .DmaBufferType : FifoPropertyType .I32 ,
122+ FifoProperty .DmaBuffer : FifoPropertyType .Ptr ,
123+ FifoProperty .FlowControl : FifoPropertyType .I32 ,
124+ }
125+
126+
127+ class FpgaViState (Enum ):
128+ """ The FPGA VI has either been downloaded and not run, or the VI was aborted
129+ or reset. """
130+ NotRunning = 0
131+ """ An error has occurred. """
132+ Invalid = 1
133+ """ The FPGA VI is currently executing. """
134+ Running = 2
135+ """ The FPGA VI stopped normally. This indicates it was not aborted or reset,
136+ but instead reached the end of any loops it was executing and ended. """
137+ NaturallyStopped = 3
138+
139+
51140_SessionType = ctypes .c_uint32
52141_IrqContextType = ctypes .c_void_p
53142
@@ -244,6 +333,38 @@ def __init__(self):
244333 NamedArgtype ("inBufferSize" , ctypes .c_size_t ),
245334 NamedArgtype ("outBuffer" , ctypes .c_void_p ),
246335 NamedArgtype ("outBufferSize" , ctypes .c_size_t ),
336+ ]),
337+ LibraryFunctionInfo (
338+ pretty_name = "FindRegisterPrivate" ,
339+ name_in_library = "NiFpgaDll_FindRegisterPrivate" ,
340+ named_argtypes = [
341+ NamedArgtype ("session" , _SessionType ),
342+ NamedArgtype ("name" , ctypes .c_char_p ),
343+ NamedArgtype ("expectedType" , ctypes .c_uint32 ),
344+ NamedArgtype ("offset" , ctypes .POINTER (ctypes .c_uint32 )),
345+ ]),
346+ LibraryFunctionInfo (
347+ pretty_name = "FindFifoPrivate" ,
348+ name_in_library = "NiFpgaDll_FindFifoPrivate" ,
349+ named_argtypes = [
350+ NamedArgtype ("session" , _SessionType ),
351+ NamedArgtype ("name" , ctypes .c_char_p ),
352+ NamedArgtype ("expectedType" , ctypes .c_uint32 ),
353+ NamedArgtype ("fifoNumber" , ctypes .POINTER (ctypes .c_uint32 )),
354+ ]),
355+ LibraryFunctionInfo (
356+ pretty_name = "GetFpgaViState" ,
357+ name_in_library = "NiFpgaDll_GetFpgaViState" ,
358+ named_argtypes = [
359+ NamedArgtype ("session" , _SessionType ),
360+ NamedArgtype ("state" , ctypes .POINTER (ctypes .c_uint32 )),
361+ ]),
362+ LibraryFunctionInfo (
363+ pretty_name = "CommitFifoConfiguration" ,
364+ name_in_library = "NiFpgaDll_CommitFifoConfiguration" ,
365+ named_argtypes = [
366+ NamedArgtype ("session" , _SessionType ),
367+ NamedArgtype ("fifo" , ctypes .c_uint32 ),
247368 ])
248369 ] # list of function_infos
249370
@@ -331,6 +452,29 @@ def __init__(self):
331452 NamedArgtype ("elements remaining" , ctypes .POINTER (ctypes .c_size_t )),
332453 ]),
333454 ]) # end of library_function_infos.extend() call
455+
456+ for fifoPropertyType in FifoPropertyType :
457+ type_ctype = fifoPropertyType ._return_ctype ()
458+ library_function_infos .extend ([
459+ LibraryFunctionInfo (
460+ pretty_name = "GetFifoProperty%s" % fifoPropertyType ,
461+ name_in_library = "NiFpgaDll_GetFifoProperty%s" % fifoPropertyType ,
462+ named_argtypes = [
463+ NamedArgtype ("session" , _SessionType ),
464+ NamedArgtype ("fifo" , ctypes .c_uint32 ),
465+ NamedArgtype ("property" , ctypes .c_uint32 ),
466+ NamedArgtype ("value" , ctypes .POINTER (type_ctype )),
467+ ]),
468+ LibraryFunctionInfo (
469+ pretty_name = "SetFifoProperty%s" % fifoPropertyType ,
470+ name_in_library = "NiFpgaDll_SetFifoProperty%s" % fifoPropertyType ,
471+ named_argtypes = [
472+ NamedArgtype ("session" , _SessionType ),
473+ NamedArgtype ("fifo" , ctypes .c_uint32 ),
474+ NamedArgtype ("property" , ctypes .c_uint32 ),
475+ NamedArgtype ("value" , type_ctype ),
476+ ]),
477+ ])
334478 try :
335479 super (_NiFpga , self ).__init__ (library_name = "NiFpga" ,
336480 library_function_infos = library_function_infos )
0 commit comments