This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ppc40x hal_delay_us patch


On Wed, 2005-05-18 at 20:48 +0200, Peter Korsgaard wrote:
> Hi,
> 
> The following little patch removes a double initialization in
> hal_ppc40x_delay_us and makes it work correctly if system clock is
> different than 100 Hz.

I like it this way better - the calculations will end up exactly
the same as before and the way it's written tells you why it's
being done this way:

  delay_period = ((_period / ((CYGNUM_HAL_RTC_NUMERATOR/1000) / CYGNUM_HAL_RTC_DENOMINATOR)) * us);

  _period = timer value for system clock (represented in ns)
  (CYGNUM_HAL_RTC_NUMERATOR/1000) = scale to us (raw value is ns)

  _period/CLOCK_CALCULATION = timer value for 1 us

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]