# HG changeset patch # User asl # Date 1143144155 0 # Node ID 77e15aa6332676e492f7b91c8cedf5fe93a004f9 # Parent 02b2b5ad1fefddbb4cadb6c0ad466ae47fa81e55 * src/timer_pit.c (hal_delay_us): Start the PIT if it is not running when hal_delay_us is called. This happens when the kernel is not used. Problem found by Oliver Munz diff --git a/packages/hal/arm/at91/var/current/ChangeLog b/packages/hal/arm/at91/var/current/ChangeLog --- a/packages/hal/arm/at91/var/current/ChangeLog +++ b/packages/hal/arm/at91/var/current/ChangeLog @@ -1,3 +1,9 @@ +2006-03-23 Andrew Lunn + + * src/timer_pit.c (hal_delay_us): Start the PIT if it is not + running when hal_delay_us is called. This happens when the kernel + is not used. Problem found by Oliver Munz. + 2006-03-10 Oliver Munz * src/hal_diag.c (cyg_hal_plf_serial_isr): Change the #ifdefs to diff --git a/packages/hal/arm/at91/var/current/src/timer_pit.c b/packages/hal/arm/at91/var/current/src/timer_pit.c --- a/packages/hal/arm/at91/var/current/src/timer_pit.c +++ b/packages/hal/arm/at91/var/current/src/timer_pit.c @@ -105,7 +105,14 @@ void hal_delay_us(cyg_int32 usecs) { cyg_int64 ticks; cyg_uint32 val1, val2; - cyg_uint32 piv; + cyg_uint32 pimr; + + // Check that the PIT is running. If not start it. + HAL_READ_UINT32((AT91_PITC + AT91_PITC_PIMR),pimr); + if (!(pimr & AT91_PITC_PIMR_PITEN)) { + HAL_WRITE_UINT32((AT91_PITC + AT91_PITC_PIMR), + 0xffff | AT91_PITC_PIMR_PITEN); + } // Calculate how many PIT ticks the required number of microseconds // equate to. We do this calculation in 64 bit arithmetic to avoid @@ -118,8 +125,6 @@ void hal_delay_us(cyg_int32 usecs) // why, please let me know! ticks = ticks / 3; - HAL_READ_UINT32(AT91_PITC + AT91_PITC_PIMR, piv); - while (ticks > 0) { hal_clock_read(&val1); do {