What Is This?
-------------

This is a simple example for using the NI FPGA Interface C API
17.0 with the Host Memory Buffer (HMB) extension.

Manifest
--------

for_bitfile_compilation.lvproj
	LabVIEW project, which contains a single RT target with a HMB called HMB1.
	The project is used for compiling the bitfile and then generating capi
	for said bitfile.
HMBFPGA.vi
	Example FPGA VI that uses a HMB. It has controls and indicators that can be
	used to tell the FPGA to write and read from the HMB
test_example.c
	Simple c program, which uses the NI FPGA Interface C API to open a FPGA
	Session and use the HMB extension to open a HMB and read and write from it.
FPGA Bitfiles/
	The folder where the LabVIEW project places compiled bitfiles during
	normal bifile compilation. Unused by this example, but present for
	illustration.
capi/
	This folder originaly contains just the files representing the HMB extension to FPGA Interface C API 17.0
	    * NiFpga_HMB.h
	    * NiFpga_HMB.c
	Code generation will add
	    * NiFpga_HMBFPGA.lvbitx (A copy of the bifile, but with a prettier name)
	    * NiFpga_HMBFPGA.h (The capi for the bitfile)
	    * NiFpga.h/c (The standard NI FPGA Interface C API 17.0 files)

How to run this example
-----------------------------

1. Change the provided LavVIEW project to work with your target.
	The project is currently setup for a cRIO-9068.
	For information on moving this example to another FPGA target, refer to
	ni.com/info and enter info code fpgaex.
2. Compile HMBFPGA.vi
3. Generate the capi for HMBFPGA.vi
	See the C API WP: ni.com/info and enter info code fpgacapitutorial.
	The example c program assumes the generated capi will be placed in capi/
4. Compile the c program
	Example compile command
	    gcc test_example.c capi/NiFpga.c capi/NiFpga_HMB.c -ldl -o test
	The code needs to be compiled for the same architecture as the target device.
	This can be achieved by compiling on the target device.
5. Copy the example directory to the target device
	Example scp command
	    scp -r ./hmbcapi admin@TARGET_DEVICE:~/hmbcapi
	The location of the bitfile is hardcoded to an absolute path in test_example.c
	    /home/admin/hmbcapi/capi/NiFpga_HMBFPGA.lvbitx
	Ensure all the contents of the example are place in /home/admin/hmbcapi
	on the target device, or change the code.
6. Exectue the program on the target device
	On the target device run
		./test
	The following output should appear on the console.
		Value read by FPGA is 1001
		Value read by Host 1002





