Mercurial > ecos
changeset 2163:77e15aa63326
* 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
| author | asl |
|---|---|
| date | Thu, 23 Mar 2006 20:02:35 +0000 |
| parents | 02b2b5ad1fef |
| children | 6087f9ab81ec |
| files | packages/hal/arm/at91/var/current/ChangeLog packages/hal/arm/at91/var/current/src/timer_pit.c |
| diffstat | 2 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 <andrew.lunn@ascom.ch> + + * 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 <munz@speag.ch> * src/hal_diag.c (cyg_hal_plf_serial_isr): Change the #ifdefs to
--- 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 {
