PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Help in accessing GPIOs in an i.MX21 (ADS21 board)

Reply

Help in accessing GPIOs in an i.MX21 (ADS21 board)

 
Thread Tools Rate Thread
Old 12-09-2006, 04:56 PM   #1
Mario
Guest
 
Posts: n/a
Default Help in accessing GPIOs in an i.MX21 (ADS21 board)


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

  Reply With Quote
Old 18-09-2006, 07:34 PM   #2
Paul G. Tobey [eMVP]
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
>



  Reply With Quote
Old 20-09-2006, 09:47 PM   #3
Mario
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
> >


  Reply With Quote
Old 20-09-2006, 09:58 PM   #4
Paul G. Tobey [eMVP]
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
>> >

>



  Reply With Quote
Old 20-09-2006, 11:27 PM   #5
Mario
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
> >> >

> >


  Reply With Quote
Old 20-09-2006, 11:39 PM   #6
Paul G. Tobey [eMVP]
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
>> >> >
>> >

>



  Reply With Quote
Old 21-09-2006, 12:16 AM   #7
Mario
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
> >> >> >
> >> >

> >


  Reply With Quote
Old 21-09-2006, 12:29 AM   #8
Paul G. Tobey [eMVP]
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
>> >> >> >
>> >> >
>> >

>



  Reply With Quote
Old 21-09-2006, 09:32 PM   #9
Mario
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
> >> >> >> >
> >> >> >
> >> >

> >


  Reply With Quote
Old 21-09-2006, 09:59 PM   #10
Paul G. Tobey [eMVP]
Guest
 
Posts: n/a
Default Re: Help in accessing GPIOs in an i.MX21 (ADS21 board)

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
>> >> >> >> >
>> >> >> >
>> >> >
>> >

>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off