How to use GPIO library in VCSharp
this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.
This article aims to help the developer in using Toradex GPIO library in Visual C#. The following steps illustrate how to build a complete project which requires calling Toradex Win32 DLLs in Visual C#.
Steps to follow
1. Follow this tutorial up to step 7 to create a new project in Visual C#.
2. The sequential process for this demo:
- using System.Runtime.InteropServices; is used to provide inter-operability services in Visual C#. This is done to use the Toradex C Win32 DLLs.
- DllImport is used to import the Toradex Win32 DLL for the project. This has to be called for every C function that will be used in the project.
- Every C function to be used in the project has to be declared preceded by public static extern (return type)
- For Toradex new library TdxAllLibraries.cs import all function to be used in Visual c# project.
8. Download and Install .NET Compact Framework directly to the FlashDisk of the device from here.
9. Navigate to Solution Explorer in visual studio > Right Click on Solution > Properties > Devices.
10. Uncheck "Deploy the Latest version of the .NET Compact Framework (including Service Packs)".
11. If using Toradex old library Add GpioLib.dll into project by choosing Add > Existing item.. from solution properties. If using Toradex new library Add TdxAllLibraries.cs and TdxAllLibraries.dll into project by choosing Add > Existing item..**
12. To deploy dll alongwith project executable, right click on dll > Properties and set Copy to Output Directory to Copy always. Alternatively, you can manually copy the dll to the project folder in which .exe will be deployed after step 13.
13. To build and deploy the project, follow steps 12 to 16 from here.
For more information, please refer to the MSDN document on Calling Win32 DLLs in C#
Enter sodimm number to be used as Input or Output.
Gpio demo output configuration
Gpio demo input configuration
|Project||Module compatibility||Language||Library Version|
|GPIO||PXA / Tegra||C#||Toradex CE Library (Old)|
|GPIO||VFxx / iMX6||C#||Toradex CE Library (New)|