public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
* hal/arm/at91/../var_io.h: HAL_ARM_AT91_GPIO_GET
@ 2008-11-21 15:41 Jürgen Lambrecht
  2008-11-21 16:01 ` Nick Garnett
  0 siblings, 1 reply; 4+ messages in thread
From: Jürgen Lambrecht @ 2008-11-21 15:41 UTC (permalink / raw)
  To: ecos-devel

Hello,

The current implementation of HAL_ARM_AT91_GPIO_GET in 
hal/arm/at91/../var_io.h uses the AT91_PIO_PDSR register.
But, "Reading the I/O line levels requires the clock of the PIO 
Controller to be enabled". So if you forget to enable the related PIO 
clock, this HAL_ARM_AT91_GPIO_GET always fails!
Therefore, I propose to use the AT91_PIO_ODSR register.
Anyhow, the added value of PDSR over ODSR is small I think:
-with ODSR you read the value you want this pin to be
-with PDSR you read the actual (physical) value of this pin
They are only different if there is a hardware problem..

So, to remove the burden of enabling also the relevant PIO clock, and to 
save power, I propose to use ODSR.
If you agree, I will add a patch.

Kind regards,
Jürgen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: hal/arm/at91/../var_io.h: HAL_ARM_AT91_GPIO_GET
  2008-11-21 15:41 hal/arm/at91/../var_io.h: HAL_ARM_AT91_GPIO_GET Jürgen Lambrecht
@ 2008-11-21 16:01 ` Nick Garnett
  2008-11-21 16:24   ` Jürgen Lambrecht
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Garnett @ 2008-11-21 16:01 UTC (permalink / raw)
  To: Jürgen Lambrecht; +Cc: ecos-devel

Jürgen Lambrecht <J.Lambrecht@televic.com> writes:

> Hello,
> 
> The current implementation of HAL_ARM_AT91_GPIO_GET in
> hal/arm/at91/../var_io.h uses the AT91_PIO_PDSR register.
> But, "Reading the I/O line levels requires the clock of the PIO
> Controller to be enabled". So if you forget to enable the related PIO
> clock, this HAL_ARM_AT91_GPIO_GET always fails!
> Therefore, I propose to use the AT91_PIO_ODSR register.
> Anyhow, the added value of PDSR over ODSR is small I think:
> -with ODSR you read the value you want this pin to be
> -with PDSR you read the actual (physical) value of this pin
> They are only different if there is a hardware problem..

Without reading the documentaion: the ODSR give you the contents of
the output latch, while PDSR reads the line value.  ODSR and PDSR
should agree for output pins, but for inputs the ODSR may differ from
the line level, since it is no longer connected to the pin and pin is
being driven to its current level by some external device.

Also, surely if you are using a GPIO port you should be enabling its
clock. I would consider not doing that a programming error.


-- 
Nick Garnett                                      eCos Kernel Architect
eCosCentric Limited    http://www.eCosCentric.com      The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.     Tel: +44 1223 245571
Registered in England and Wales:                        Reg No: 4422071

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: hal/arm/at91/../var_io.h: HAL_ARM_AT91_GPIO_GET
  2008-11-21 16:01 ` Nick Garnett
@ 2008-11-21 16:24   ` Jürgen Lambrecht
  2008-11-21 16:42     ` Nick Garnett
  0 siblings, 1 reply; 4+ messages in thread
From: Jürgen Lambrecht @ 2008-11-21 16:24 UTC (permalink / raw)
  To: Nick Garnett; +Cc: ecos-devel

Nick Garnett wrote:
> Jürgen Lambrecht <J.Lambrecht@televic.com> writes:
>
>   
>> Hello,
>>
>> The current implementation of HAL_ARM_AT91_GPIO_GET in
>> hal/arm/at91/../var_io.h uses the AT91_PIO_PDSR register.
>> But, "Reading the I/O line levels requires the clock of the PIO
>> Controller to be enabled". So if you forget to enable the related PIO
>> clock, this HAL_ARM_AT91_GPIO_GET always fails!
>> Therefore, I propose to use the AT91_PIO_ODSR register.
>> Anyhow, the added value of PDSR over ODSR is small I think:
>> -with ODSR you read the value you want this pin to be
>> -with PDSR you read the actual (physical) value of this pin
>> They are only different if there is a hardware problem..
>>     
>
> Without reading the documentaion: the ODSR give you the contents of
> the output latch, while PDSR reads the line value.  ODSR and PDSR
> should agree for output pins, but for inputs the ODSR may differ from
> the line level, since it is no longer connected to the pin and pin is
> being driven to its current level by some external device.
>   
Indeed. So in general, my proposition is wrong.
I then propose to make an "OUT" version of that macro.
> Also, surely if you are using a GPIO port you should be enabling its
> clock. I would consider not doing that a programming error.
>   
No, only for an input you must enable the PIO clock: the PIO clock is 
then used to sample the input signal.
For an output, you just write the output register from your application, 
using the application clock.

Kind regards,
Jürgen
>
> --
> Nick Garnett                                      eCos Kernel Architect
> eCosCentric Limited    http://www.eCosCentric.com      The eCos experts
> Barnwell House, Barnwell Drive, Cambridge, UK.     Tel: +44 1223 245571
> Registered in England and Wales:                        Reg No: 4422071
>
>   


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: hal/arm/at91/../var_io.h: HAL_ARM_AT91_GPIO_GET
  2008-11-21 16:24   ` Jürgen Lambrecht
@ 2008-11-21 16:42     ` Nick Garnett
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Garnett @ 2008-11-21 16:42 UTC (permalink / raw)
  To: Jürgen Lambrecht; +Cc: ecos-devel

Jürgen Lambrecht <J.Lambrecht@televic.com> writes:

> Nick Garnett wrote:
> > Jürgen Lambrecht <J.Lambrecht@televic.com> writes:
> >
> >
> >> Hello,
> >>
> >> The current implementation of HAL_ARM_AT91_GPIO_GET in
> >> hal/arm/at91/../var_io.h uses the AT91_PIO_PDSR register.
> >> But, "Reading the I/O line levels requires the clock of the PIO
> >> Controller to be enabled". So if you forget to enable the related PIO
> >> clock, this HAL_ARM_AT91_GPIO_GET always fails!
> >> Therefore, I propose to use the AT91_PIO_ODSR register.
> >> Anyhow, the added value of PDSR over ODSR is small I think:
> >> -with ODSR you read the value you want this pin to be
> >> -with PDSR you read the actual (physical) value of this pin
> >> They are only different if there is a hardware problem..
> >>
> >
> > Without reading the documentaion: the ODSR give you the contents of
> > the output latch, while PDSR reads the line value.  ODSR and PDSR
> > should agree for output pins, but for inputs the ODSR may differ from
> > the line level, since it is no longer connected to the pin and pin is
> > being driven to its current level by some external device.
> >
> Indeed. So in general, my proposition is wrong.
> I then propose to make an "OUT" version of that macro.
> > Also, surely if you are using a GPIO port you should be enabling its
> > clock. I would consider not doing that a programming error.
> >
> No, only for an input you must enable the PIO clock: the PIO clock is
> then used to sample the input signal.
> For an output, you just write the output register from your
> application, using the application clock.

OK. In that case a macro that reads back the value set in the output
register might make sense.

Of course one can make the argument that since your code must have set
this value initially, it shouldn't have to read it back to know what
it is. However, I appreciate that code is not always structured to
allow you to do that.


-- 
Nick Garnett                                      eCos Kernel Architect
eCosCentric Limited    http://www.eCosCentric.com      The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.     Tel: +44 1223 245571
Registered in England and Wales:                        Reg No: 4422071

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-21 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-21 15:41 hal/arm/at91/../var_io.h: HAL_ARM_AT91_GPIO_GET Jürgen Lambrecht
2008-11-21 16:01 ` Nick Garnett
2008-11-21 16:24   ` Jürgen Lambrecht
2008-11-21 16:42     ` Nick Garnett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).