PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Help in accessing GPIOs in an i.MX21 (ADS21 board)
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Help in accessing GPIOs in an i.MX21 (ADS21 board)
![]() |
Help in accessing GPIOs in an i.MX21 (ADS21 board) |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
Has anyone had any success in accessing (reading and writing) the GPIOs in a Freescale i.MX21 (ADS21 board) from a managed code application? The problem that I have is that regardless of which port parameter I pass in the GPIO method calls, the GPIO driver always take Port_A as default. The rest of the parameters are passed correctly. Any inputs or suggestions on how to fix this is appreciated. Thanks. I am not sure if this is the correct forum, but I did not get any response after posting the same question in the freescale site for almost two weeks. -- mario |
|
|
|
#2 |
|
Guest
Posts: n/a
|
What GPIO method calls?
Paul T. "Mario" <alphatommy@hotmail.com> wrote in message news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... > Hi, > > Has anyone had any success in accessing (reading and writing) the GPIOs > in a Freescale i.MX21 (ADS21 board) from a managed code application? > The problem that I have is that regardless of which port parameter I > pass in the GPIO method calls, the GPIO driver always take Port_A as > default. The rest of the parameters are passed correctly. Any inputs > or suggestions on how to fix this is appreciated. Thanks. > > I am not sure if this is the correct forum, but I did not get any > response after posting the same question in the freescale site for > almost two weeks. > > > -- mario > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Hi Paul,
I have tried the following methods (their signatures are as follow): 1. INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, UINT32 signal) 2. void DDKSetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, UINT32 signal, UINT8 state, BOOL bInPowerMode) 3. UINT32 DDKGetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, UINT32 signalMask) 4. void DDKSetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, UINT32 signalMask, UINT32 stateMask) GPIO_PORT is defined in the driver header as: typedef enum { GPIO_PORT_A, GPIO_PORT_B, GPIO_PORT_C, GPIO_PORT_D, GPIO_PORT_E, GPIO_PORT_F, GPIO_PORT_MAX, } GPIO_PORT; Thanks in advance for any input. -- mario Paul G. Tobey [eMVP] wrote: > What GPIO method calls? > > Paul T. > > "Mario" <alphatommy@hotmail.com> wrote in message > news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... > > Hi, > > > > Has anyone had any success in accessing (reading and writing) the GPIOs > > in a Freescale i.MX21 (ADS21 board) from a managed code application? > > The problem that I have is that regardless of which port parameter I > > pass in the GPIO method calls, the GPIO driver always take Port_A as > > default. The rest of the parameters are passed correctly. Any inputs > > or suggestions on how to fix this is appreciated. Thanks. > > > > I am not sure if this is the correct forum, but I did not get any > > response after posting the same question in the freescale site for > > almost two weeks. > > > > > > -- mario > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Those don't appear to be standard DDK calls to me, but I'm no expert on any
i.MX21 BSPs. How have you P/Invoked them? GPIOHANDLE is probably an IntPtr, GPIO_PORT you can probably create an enum for that corresponds directly to what the C/C++ code uses, UINT32 is pretty obvious, 'uint', etc. What value, integer value, are you passing in the GPIO_PORT parameters? Paul T. "Mario" <alphatommy@hotmail.com> wrote in message news:1158785258.148715.111740@i42g2000cwa.googlegroups.com... > Hi Paul, > > I have tried the following methods (their signatures are as follow): > > 1. INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, > UINT32 signal) > 2. void DDKSetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, > UINT32 signal, UINT8 state, BOOL bInPowerMode) > > 3. UINT32 DDKGetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, > UINT32 signalMask) > > 4. void DDKSetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, > UINT32 signalMask, UINT32 stateMask) > > GPIO_PORT is defined in the driver header as: > > typedef enum { > GPIO_PORT_A, > GPIO_PORT_B, > GPIO_PORT_C, > GPIO_PORT_D, > GPIO_PORT_E, > GPIO_PORT_F, > GPIO_PORT_MAX, > } GPIO_PORT; > > Thanks in advance for any input. > > -- mario > > > Paul G. Tobey [eMVP] wrote: >> What GPIO method calls? >> >> Paul T. >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... >> > Hi, >> > >> > Has anyone had any success in accessing (reading and writing) the GPIOs >> > in a Freescale i.MX21 (ADS21 board) from a managed code application? >> > The problem that I have is that regardless of which port parameter I >> > pass in the GPIO method calls, the GPIO driver always take Port_A as >> > default. The rest of the parameters are passed correctly. Any inputs >> > or suggestions on how to fix this is appreciated. Thanks. >> > >> > I am not sure if this is the correct forum, but I did not get any >> > response after posting the same question in the freescale site for >> > almost two weeks. >> > >> > >> > -- mario >> > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Hi Paul,
For the method INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, UINT32 signal) I did the following: [DllImport ("mx21ddk.dll")] //mx21ddk.dll contains the methods that I am calling public static extern Int16 DDKGetGpioSignalState(IntPtr gpiohandle, GPIO_PORT port, UInt32 signal); The reason why I used Int16 is because there is no Int16 in C#. //GPIO in C# public enum { GPIO_PORT_A, GPIO_PORT_B, GPIO_PORT_C, GPIO_PORT_D, GPIO_PORT_E, GPIO_PORT_F, GPIOPORTMAX } Please let me know if you see any errors. Thanks. mario Paul G. Tobey [eMVP] wrote: > Those don't appear to be standard DDK calls to me, but I'm no expert on any > i.MX21 BSPs. How have you P/Invoked them? GPIOHANDLE is probably an > IntPtr, GPIO_PORT you can probably create an enum for that corresponds > directly to what the C/C++ code uses, UINT32 is pretty obvious, 'uint', etc. > What value, integer value, are you passing in the GPIO_PORT parameters? > > Paul T. > > "Mario" <alphatommy@hotmail.com> wrote in message > news:1158785258.148715.111740@i42g2000cwa.googlegroups.com... > > Hi Paul, > > > > I have tried the following methods (their signatures are as follow): > > > > 1. INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, > > UINT32 signal) > > 2. void DDKSetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, > > UINT32 signal, UINT8 state, BOOL bInPowerMode) > > > > 3. UINT32 DDKGetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, > > UINT32 signalMask) > > > > 4. void DDKSetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, > > UINT32 signalMask, UINT32 stateMask) > > > > GPIO_PORT is defined in the driver header as: > > > > typedef enum { > > GPIO_PORT_A, > > GPIO_PORT_B, > > GPIO_PORT_C, > > GPIO_PORT_D, > > GPIO_PORT_E, > > GPIO_PORT_F, > > GPIO_PORT_MAX, > > } GPIO_PORT; > > > > Thanks in advance for any input. > > > > -- mario > > > > > > Paul G. Tobey [eMVP] wrote: > >> What GPIO method calls? > >> > >> Paul T. > >> > >> "Mario" <alphatommy@hotmail.com> wrote in message > >> news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... > >> > Hi, > >> > > >> > Has anyone had any success in accessing (reading and writing) the GPIOs > >> > in a Freescale i.MX21 (ADS21 board) from a managed code application? > >> > The problem that I have is that regardless of which port parameter I > >> > pass in the GPIO method calls, the GPIO driver always take Port_A as > >> > default. The rest of the parameters are passed correctly. Any inputs > >> > or suggestions on how to fix this is appreciated. Thanks. > >> > > >> > I am not sure if this is the correct forum, but I did not get any > >> > response after posting the same question in the freescale site for > >> > almost two weeks. > >> > > >> > > >> > -- mario > >> > > > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Well, that return type is wrong. Clearly you should be returning some 8-bit
value, which you aren't. Try 'byte'; it's a good choice. Try also, for now, just making the GPIO_PORT parameter an Int32 and passing the right value as an integer to it. Does that work? Paul T. "Mario" <alphatommy@hotmail.com> wrote in message news:1158791251.466377.92460@m7g2000cwm.googlegroups.com... > Hi Paul, > > For the method INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, > GPIO_PORT port, UINT32 signal) > > I did the following: > > [DllImport ("mx21ddk.dll")] //mx21ddk.dll contains the methods that > I am calling > public static extern Int16 DDKGetGpioSignalState(IntPtr gpiohandle, > GPIO_PORT port, UInt32 signal); > > The reason why I used Int16 is because there is no Int16 in C#. > > //GPIO in C# > public enum > { > GPIO_PORT_A, > GPIO_PORT_B, > GPIO_PORT_C, > GPIO_PORT_D, > GPIO_PORT_E, > GPIO_PORT_F, > GPIOPORTMAX > } > > Please let me know if you see any errors. Thanks. > > mario > > > Paul G. Tobey [eMVP] wrote: >> Those don't appear to be standard DDK calls to me, but I'm no expert on >> any >> i.MX21 BSPs. How have you P/Invoked them? GPIOHANDLE is probably an >> IntPtr, GPIO_PORT you can probably create an enum for that corresponds >> directly to what the C/C++ code uses, UINT32 is pretty obvious, 'uint', >> etc. >> What value, integer value, are you passing in the GPIO_PORT parameters? >> >> Paul T. >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> news:1158785258.148715.111740@i42g2000cwa.googlegroups.com... >> > Hi Paul, >> > >> > I have tried the following methods (their signatures are as follow): >> > >> > 1. INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, >> > UINT32 signal) >> > 2. void DDKSetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, >> > UINT32 signal, UINT8 state, BOOL bInPowerMode) >> > >> > 3. UINT32 DDKGetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, >> > UINT32 signalMask) >> > >> > 4. void DDKSetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, >> > UINT32 signalMask, UINT32 stateMask) >> > >> > GPIO_PORT is defined in the driver header as: >> > >> > typedef enum { >> > GPIO_PORT_A, >> > GPIO_PORT_B, >> > GPIO_PORT_C, >> > GPIO_PORT_D, >> > GPIO_PORT_E, >> > GPIO_PORT_F, >> > GPIO_PORT_MAX, >> > } GPIO_PORT; >> > >> > Thanks in advance for any input. >> > >> > -- mario >> > >> > >> > Paul G. Tobey [eMVP] wrote: >> >> What GPIO method calls? >> >> >> >> Paul T. >> >> >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> >> news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... >> >> > Hi, >> >> > >> >> > Has anyone had any success in accessing (reading and writing) the >> >> > GPIOs >> >> > in a Freescale i.MX21 (ADS21 board) from a managed code application? >> >> > The problem that I have is that regardless of which port parameter I >> >> > pass in the GPIO method calls, the GPIO driver always take Port_A as >> >> > default. The rest of the parameters are passed correctly. Any >> >> > inputs >> >> > or suggestions on how to fix this is appreciated. Thanks. >> >> > >> >> > I am not sure if this is the correct forum, but I did not get any >> >> > response after posting the same question in the freescale site for >> >> > almost two weeks. >> >> > >> >> > >> >> > -- mario >> >> > >> > > |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Hi Paul,
I could try using byte for return value. On the GPIO_PORT, I have tried Int32 before, but it did not work. Thanks. -- mario Paul G. Tobey [eMVP] wrote: > Well, that return type is wrong. Clearly you should be returning some 8-bit > value, which you aren't. Try 'byte'; it's a good choice. > > Try also, for now, just making the GPIO_PORT parameter an Int32 and passing > the right value as an integer to it. Does that work? > > Paul T. > > > "Mario" <alphatommy@hotmail.com> wrote in message > news:1158791251.466377.92460@m7g2000cwm.googlegroups.com... > > Hi Paul, > > > > For the method INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, > > GPIO_PORT port, UINT32 signal) > > > > I did the following: > > > > [DllImport ("mx21ddk.dll")] //mx21ddk.dll contains the methods that > > I am calling > > public static extern Int16 DDKGetGpioSignalState(IntPtr gpiohandle, > > GPIO_PORT port, UInt32 signal); > > > > The reason why I used Int16 is because there is no Int16 in C#. > > > > //GPIO in C# > > public enum > > { > > GPIO_PORT_A, > > GPIO_PORT_B, > > GPIO_PORT_C, > > GPIO_PORT_D, > > GPIO_PORT_E, > > GPIO_PORT_F, > > GPIOPORTMAX > > } > > > > Please let me know if you see any errors. Thanks. > > > > mario > > > > > > Paul G. Tobey [eMVP] wrote: > >> Those don't appear to be standard DDK calls to me, but I'm no expert on > >> any > >> i.MX21 BSPs. How have you P/Invoked them? GPIOHANDLE is probably an > >> IntPtr, GPIO_PORT you can probably create an enum for that corresponds > >> directly to what the C/C++ code uses, UINT32 is pretty obvious, 'uint', > >> etc. > >> What value, integer value, are you passing in the GPIO_PORT parameters? > >> > >> Paul T. > >> > >> "Mario" <alphatommy@hotmail.com> wrote in message > >> news:1158785258.148715.111740@i42g2000cwa.googlegroups.com... > >> > Hi Paul, > >> > > >> > I have tried the following methods (their signatures are as follow): > >> > > >> > 1. INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, > >> > UINT32 signal) > >> > 2. void DDKSetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT port, > >> > UINT32 signal, UINT8 state, BOOL bInPowerMode) > >> > > >> > 3. UINT32 DDKGetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, > >> > UINT32 signalMask) > >> > > >> > 4. void DDKSetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, > >> > UINT32 signalMask, UINT32 stateMask) > >> > > >> > GPIO_PORT is defined in the driver header as: > >> > > >> > typedef enum { > >> > GPIO_PORT_A, > >> > GPIO_PORT_B, > >> > GPIO_PORT_C, > >> > GPIO_PORT_D, > >> > GPIO_PORT_E, > >> > GPIO_PORT_F, > >> > GPIO_PORT_MAX, > >> > } GPIO_PORT; > >> > > >> > Thanks in advance for any input. > >> > > >> > -- mario > >> > > >> > > >> > Paul G. Tobey [eMVP] wrote: > >> >> What GPIO method calls? > >> >> > >> >> Paul T. > >> >> > >> >> "Mario" <alphatommy@hotmail.com> wrote in message > >> >> news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... > >> >> > Hi, > >> >> > > >> >> > Has anyone had any success in accessing (reading and writing) the > >> >> > GPIOs > >> >> > in a Freescale i.MX21 (ADS21 board) from a managed code application? > >> >> > The problem that I have is that regardless of which port parameter I > >> >> > pass in the GPIO method calls, the GPIO driver always take Port_A as > >> >> > default. The rest of the parameters are passed correctly. Any > >> >> > inputs > >> >> > or suggestions on how to fix this is appreciated. Thanks. > >> >> > > >> >> > I am not sure if this is the correct forum, but I did not get any > >> >> > response after posting the same question in the freescale site for > >> >> > almost two weeks. > >> >> > > >> >> > > >> >> > -- mario > >> >> > > >> > > > |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Sorry, "did not work" is useless information. What value did you pass?
What was returned in the byte? What do you get when you pass the same values from unmanaged code? Paul T. "Mario" <alphatommy@hotmail.com> wrote in message news:1158794169.432339.250470@i42g2000cwa.googlegroups.com... > Hi Paul, > > I could try using byte for return value. On the GPIO_PORT, I have > tried Int32 before, but it did not work. Thanks. > > -- mario > > > Paul G. Tobey [eMVP] wrote: >> Well, that return type is wrong. Clearly you should be returning some >> 8-bit >> value, which you aren't. Try 'byte'; it's a good choice. >> >> Try also, for now, just making the GPIO_PORT parameter an Int32 and >> passing >> the right value as an integer to it. Does that work? >> >> Paul T. >> >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> news:1158791251.466377.92460@m7g2000cwm.googlegroups.com... >> > Hi Paul, >> > >> > For the method INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, >> > GPIO_PORT port, UINT32 signal) >> > >> > I did the following: >> > >> > [DllImport ("mx21ddk.dll")] //mx21ddk.dll contains the methods that >> > I am calling >> > public static extern Int16 DDKGetGpioSignalState(IntPtr gpiohandle, >> > GPIO_PORT port, UInt32 signal); >> > >> > The reason why I used Int16 is because there is no Int16 in C#. >> > >> > //GPIO in C# >> > public enum >> > { >> > GPIO_PORT_A, >> > GPIO_PORT_B, >> > GPIO_PORT_C, >> > GPIO_PORT_D, >> > GPIO_PORT_E, >> > GPIO_PORT_F, >> > GPIOPORTMAX >> > } >> > >> > Please let me know if you see any errors. Thanks. >> > >> > mario >> > >> > >> > Paul G. Tobey [eMVP] wrote: >> >> Those don't appear to be standard DDK calls to me, but I'm no expert >> >> on >> >> any >> >> i.MX21 BSPs. How have you P/Invoked them? GPIOHANDLE is probably an >> >> IntPtr, GPIO_PORT you can probably create an enum for that corresponds >> >> directly to what the C/C++ code uses, UINT32 is pretty obvious, >> >> 'uint', >> >> etc. >> >> What value, integer value, are you passing in the GPIO_PORT >> >> parameters? >> >> >> >> Paul T. >> >> >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> >> news:1158785258.148715.111740@i42g2000cwa.googlegroups.com... >> >> > Hi Paul, >> >> > >> >> > I have tried the following methods (their signatures are as follow): >> >> > >> >> > 1. INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT >> >> > port, >> >> > UINT32 signal) >> >> > 2. void DDKSetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT >> >> > port, >> >> > UINT32 signal, UINT8 state, BOOL bInPowerMode) >> >> > >> >> > 3. UINT32 DDKGetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, >> >> > UINT32 signalMask) >> >> > >> >> > 4. void DDKSetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, >> >> > UINT32 signalMask, UINT32 stateMask) >> >> > >> >> > GPIO_PORT is defined in the driver header as: >> >> > >> >> > typedef enum { >> >> > GPIO_PORT_A, >> >> > GPIO_PORT_B, >> >> > GPIO_PORT_C, >> >> > GPIO_PORT_D, >> >> > GPIO_PORT_E, >> >> > GPIO_PORT_F, >> >> > GPIO_PORT_MAX, >> >> > } GPIO_PORT; >> >> > >> >> > Thanks in advance for any input. >> >> > >> >> > -- mario >> >> > >> >> > >> >> > Paul G. Tobey [eMVP] wrote: >> >> >> What GPIO method calls? >> >> >> >> >> >> Paul T. >> >> >> >> >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> >> >> news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... >> >> >> > Hi, >> >> >> > >> >> >> > Has anyone had any success in accessing (reading and writing) the >> >> >> > GPIOs >> >> >> > in a Freescale i.MX21 (ADS21 board) from a managed code >> >> >> > application? >> >> >> > The problem that I have is that regardless of which port >> >> >> > parameter I >> >> >> > pass in the GPIO method calls, the GPIO driver always take Port_A >> >> >> > as >> >> >> > default. The rest of the parameters are passed correctly. Any >> >> >> > inputs >> >> >> > or suggestions on how to fix this is appreciated. Thanks. >> >> >> > >> >> >> > I am not sure if this is the correct forum, but I did not get any >> >> >> > response after posting the same question in the freescale site >> >> >> > for >> >> >> > almost two weeks. >> >> >> > >> >> >> > >> >> >> > -- mario >> >> >> > >> >> > >> > > |
|
|
|
#9 |
|
Guest
Posts: n/a
|
Hi Paul,
Sorry, what I meant by "did not work" was that regardless of what value I sent as Port (GPIO_PORT_B, C, D, E or MAX) I still see that the value passed for Port is GPIO_PORT_A. I see this by breaking on the driver, and GPIO_PORT_A is the value that shows up when I place the cursor on top of Port or through Quick Watch. The value that is returned is wrong because it is looking at the different port that I have selected. I still have to try to call the method from an umanaged application. Thanks. -- mario Paul G. Tobey [eMVP] wrote: > Sorry, "did not work" is useless information. What value did you pass? > What was returned in the byte? What do you get when you pass the same > values from unmanaged code? > > Paul T. > > "Mario" <alphatommy@hotmail.com> wrote in message > news:1158794169.432339.250470@i42g2000cwa.googlegroups.com... > > Hi Paul, > > > > I could try using byte for return value. On the GPIO_PORT, I have > > tried Int32 before, but it did not work. Thanks. > > > > -- mario > > > > > > Paul G. Tobey [eMVP] wrote: > >> Well, that return type is wrong. Clearly you should be returning some > >> 8-bit > >> value, which you aren't. Try 'byte'; it's a good choice. > >> > >> Try also, for now, just making the GPIO_PORT parameter an Int32 and > >> passing > >> the right value as an integer to it. Does that work? > >> > >> Paul T. > >> > >> > >> "Mario" <alphatommy@hotmail.com> wrote in message > >> news:1158791251.466377.92460@m7g2000cwm.googlegroups.com... > >> > Hi Paul, > >> > > >> > For the method INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, > >> > GPIO_PORT port, UINT32 signal) > >> > > >> > I did the following: > >> > > >> > [DllImport ("mx21ddk.dll")] //mx21ddk.dll contains the methods that > >> > I am calling > >> > public static extern Int16 DDKGetGpioSignalState(IntPtr gpiohandle, > >> > GPIO_PORT port, UInt32 signal); > >> > > >> > The reason why I used Int16 is because there is no Int16 in C#. > >> > > >> > //GPIO in C# > >> > public enum > >> > { > >> > GPIO_PORT_A, > >> > GPIO_PORT_B, > >> > GPIO_PORT_C, > >> > GPIO_PORT_D, > >> > GPIO_PORT_E, > >> > GPIO_PORT_F, > >> > GPIOPORTMAX > >> > } > >> > > >> > Please let me know if you see any errors. Thanks. > >> > > >> > mario > >> > > >> > > >> > Paul G. Tobey [eMVP] wrote: > >> >> Those don't appear to be standard DDK calls to me, but I'm no expert > >> >> on > >> >> any > >> >> i.MX21 BSPs. How have you P/Invoked them? GPIOHANDLE is probably an > >> >> IntPtr, GPIO_PORT you can probably create an enum for that corresponds > >> >> directly to what the C/C++ code uses, UINT32 is pretty obvious, > >> >> 'uint', > >> >> etc. > >> >> What value, integer value, are you passing in the GPIO_PORT > >> >> parameters? > >> >> > >> >> Paul T. > >> >> > >> >> "Mario" <alphatommy@hotmail.com> wrote in message > >> >> news:1158785258.148715.111740@i42g2000cwa.googlegroups.com... > >> >> > Hi Paul, > >> >> > > >> >> > I have tried the following methods (their signatures are as follow): > >> >> > > >> >> > 1. INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT > >> >> > port, > >> >> > UINT32 signal) > >> >> > 2. void DDKSetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT > >> >> > port, > >> >> > UINT32 signal, UINT8 state, BOOL bInPowerMode) > >> >> > > >> >> > 3. UINT32 DDKGetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, > >> >> > UINT32 signalMask) > >> >> > > >> >> > 4. void DDKSetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT port, > >> >> > UINT32 signalMask, UINT32 stateMask) > >> >> > > >> >> > GPIO_PORT is defined in the driver header as: > >> >> > > >> >> > typedef enum { > >> >> > GPIO_PORT_A, > >> >> > GPIO_PORT_B, > >> >> > GPIO_PORT_C, > >> >> > GPIO_PORT_D, > >> >> > GPIO_PORT_E, > >> >> > GPIO_PORT_F, > >> >> > GPIO_PORT_MAX, > >> >> > } GPIO_PORT; > >> >> > > >> >> > Thanks in advance for any input. > >> >> > > >> >> > -- mario > >> >> > > >> >> > > >> >> > Paul G. Tobey [eMVP] wrote: > >> >> >> What GPIO method calls? > >> >> >> > >> >> >> Paul T. > >> >> >> > >> >> >> "Mario" <alphatommy@hotmail.com> wrote in message > >> >> >> news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... > >> >> >> > Hi, > >> >> >> > > >> >> >> > Has anyone had any success in accessing (reading and writing) the > >> >> >> > GPIOs > >> >> >> > in a Freescale i.MX21 (ADS21 board) from a managed code > >> >> >> > application? > >> >> >> > The problem that I have is that regardless of which port > >> >> >> > parameter I > >> >> >> > pass in the GPIO method calls, the GPIO driver always take Port_A > >> >> >> > as > >> >> >> > default. The rest of the parameters are passed correctly. Any > >> >> >> > inputs > >> >> >> > or suggestions on how to fix this is appreciated. Thanks. > >> >> >> > > >> >> >> > I am not sure if this is the correct forum, but I did not get any > >> >> >> > response after posting the same question in the freescale site > >> >> >> > for > >> >> >> > almost two weeks. > >> >> >> > > >> >> >> > > >> >> >> > -- mario > >> >> >> > > >> >> > > >> > > > |
|
|
|
#10 |
|
Guest
Posts: n/a
|
OK, so forget about trying to P/Invoke with a managed enumeration. Declare
the parameter as an Int32 and pass the value that corresponds to some other port (1, 2, 3, whatever), and see what you get in that case. It would be useful to verify the size of the enumeration expected by the unmanaged code, also. I would expect it to be 32-bit, but I could be wrong about that. Paul T. "Mario" <alphatommy@hotmail.com> wrote in message news:1158870731.936903.11560@d34g2000cwd.googlegroups.com... > Hi Paul, > > Sorry, what I meant by "did not work" was that regardless of what value > I sent as Port (GPIO_PORT_B, C, D, E or MAX) I still see that the value > passed for Port is GPIO_PORT_A. I see this by breaking on the driver, > and GPIO_PORT_A is the value that shows up when I place the cursor on > top of Port or through Quick Watch. The value that is returned is > wrong because it is looking at the different port that I have selected. > I still have to try to call the method from an umanaged application. > Thanks. > > -- mario > > Paul G. Tobey [eMVP] wrote: >> Sorry, "did not work" is useless information. What value did you pass? >> What was returned in the byte? What do you get when you pass the same >> values from unmanaged code? >> >> Paul T. >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> news:1158794169.432339.250470@i42g2000cwa.googlegroups.com... >> > Hi Paul, >> > >> > I could try using byte for return value. On the GPIO_PORT, I have >> > tried Int32 before, but it did not work. Thanks. >> > >> > -- mario >> > >> > >> > Paul G. Tobey [eMVP] wrote: >> >> Well, that return type is wrong. Clearly you should be returning some >> >> 8-bit >> >> value, which you aren't. Try 'byte'; it's a good choice. >> >> >> >> Try also, for now, just making the GPIO_PORT parameter an Int32 and >> >> passing >> >> the right value as an integer to it. Does that work? >> >> >> >> Paul T. >> >> >> >> >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> >> news:1158791251.466377.92460@m7g2000cwm.googlegroups.com... >> >> > Hi Paul, >> >> > >> >> > For the method INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, >> >> > GPIO_PORT port, UINT32 signal) >> >> > >> >> > I did the following: >> >> > >> >> > [DllImport ("mx21ddk.dll")] //mx21ddk.dll contains the methods >> >> > that >> >> > I am calling >> >> > public static extern Int16 DDKGetGpioSignalState(IntPtr gpiohandle, >> >> > GPIO_PORT port, UInt32 signal); >> >> > >> >> > The reason why I used Int16 is because there is no Int16 in C#. >> >> > >> >> > //GPIO in C# >> >> > public enum >> >> > { >> >> > GPIO_PORT_A, >> >> > GPIO_PORT_B, >> >> > GPIO_PORT_C, >> >> > GPIO_PORT_D, >> >> > GPIO_PORT_E, >> >> > GPIO_PORT_F, >> >> > GPIOPORTMAX >> >> > } >> >> > >> >> > Please let me know if you see any errors. Thanks. >> >> > >> >> > mario >> >> > >> >> > >> >> > Paul G. Tobey [eMVP] wrote: >> >> >> Those don't appear to be standard DDK calls to me, but I'm no >> >> >> expert >> >> >> on >> >> >> any >> >> >> i.MX21 BSPs. How have you P/Invoked them? GPIOHANDLE is probably >> >> >> an >> >> >> IntPtr, GPIO_PORT you can probably create an enum for that >> >> >> corresponds >> >> >> directly to what the C/C++ code uses, UINT32 is pretty obvious, >> >> >> 'uint', >> >> >> etc. >> >> >> What value, integer value, are you passing in the GPIO_PORT >> >> >> parameters? >> >> >> >> >> >> Paul T. >> >> >> >> >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> >> >> news:1158785258.148715.111740@i42g2000cwa.googlegroups.com... >> >> >> > Hi Paul, >> >> >> > >> >> >> > I have tried the following methods (their signatures are as >> >> >> > follow): >> >> >> > >> >> >> > 1. INT8 DDKGetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT >> >> >> > port, >> >> >> > UINT32 signal) >> >> >> > 2. void DDKSetGpioSignalState(GPIOHANDLE gpiohandle, GPIO_PORT >> >> >> > port, >> >> >> > UINT32 signal, UINT8 state, BOOL bInPowerMode) >> >> >> > >> >> >> > 3. UINT32 DDKGetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT >> >> >> > port, >> >> >> > UINT32 signalMask) >> >> >> > >> >> >> > 4. void DDKSetGpioSignals(GPIOHANDLE gpiohandle, GPIO_PORT >> >> >> > port, >> >> >> > UINT32 signalMask, UINT32 stateMask) >> >> >> > >> >> >> > GPIO_PORT is defined in the driver header as: >> >> >> > >> >> >> > typedef enum { >> >> >> > GPIO_PORT_A, >> >> >> > GPIO_PORT_B, >> >> >> > GPIO_PORT_C, >> >> >> > GPIO_PORT_D, >> >> >> > GPIO_PORT_E, >> >> >> > GPIO_PORT_F, >> >> >> > GPIO_PORT_MAX, >> >> >> > } GPIO_PORT; >> >> >> > >> >> >> > Thanks in advance for any input. >> >> >> > >> >> >> > -- mario >> >> >> > >> >> >> > >> >> >> > Paul G. Tobey [eMVP] wrote: >> >> >> >> What GPIO method calls? >> >> >> >> >> >> >> >> Paul T. >> >> >> >> >> >> >> >> "Mario" <alphatommy@hotmail.com> wrote in message >> >> >> >> news:1158076582.805617.137440@i42g2000cwa.googlegroups.com... >> >> >> >> > Hi, >> >> >> >> > >> >> >> >> > Has anyone had any success in accessing (reading and writing) >> >> >> >> > the >> >> >> >> > GPIOs >> >> >> >> > in a Freescale i.MX21 (ADS21 board) from a managed code >> >> >> >> > application? >> >> >> >> > The problem that I have is that regardless of which port >> >> >> >> > parameter I >> >> >> >> > pass in the GPIO method calls, the GPIO driver always take >> >> >> >> > Port_A >> >> >> >> > as >> >> >> >> > default. The rest of the parameters are passed correctly. >> >> >> >> > Any >> >> >> >> > inputs >> >> >> >> > or suggestions on how to fix this is appreciated. Thanks. >> >> >> >> > >> >> >> >> > I am not sure if this is the correct forum, but I did not get >> >> >> >> > any >> >> >> >> > response after posting the same question in the freescale site >> >> >> >> > for >> >> >> >> > almost two weeks. >> >> >> >> > >> >> >> >> > >> >> >> >> > -- mario >> >> >> >> > >> >> >> > >> >> > >> > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

