Changeset 5e649e5 in rtems


Ignore:
Timestamp:
Jun 22, 2010, 8:41:08 AM (10 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
0596902
Parents:
58eccd0
Message:

2010-06-22 Arnout Vandecappelle <arnout@…>

PR 1579/misc

  • libchip/i2c/spi-sd-card.c: Gradually increasing sleep times when waiting for write to finish.
Location:
c/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/ChangeLog

    r58eccd0 r5e649e5  
     12010-06-22      Arnout Vandecappelle <arnout@mind.be>
     2
     3        PR 1579/misc
     4        * libchip/i2c/spi-sd-card.c: Gradually increasing sleep times when
     5        waiting for write to finish.
     6
    172010-06-22      Arnout Vandecappelle <arnout@mind.be>
    28
  • c/src/libchip/i2c/spi-sd-card.c

    r58eccd0 r5e649e5  
    374374           FIXME should actually look at R2W_FACTOR for non-HC cards. */
    375375        int retries = e->n_ac_max * 25 / 10;
     376        /* n_ac_max/100 is supposed to be the average waiting time. To
     377           approximate this, we start with waiting n_ac_max/250 and
     378           gradually increase the waiting time. */
     379        int wait_time_bytes = (retries + 149) / 150;
    376380        while (e->busy) {
    377381                /* Query busy tokens */
     
    390394                        return -RTEMS_TIMEOUT;
    391395                }
    392                 n = SD_CARD_COMMAND_SIZE;
    393396
    394397                if (e->schedule_if_busy) {
    395                         /* Invoke the scheduler */
    396                         rtems_task_wake_after( RTEMS_YIELD_PROCESSOR);
     398                        uint64_t wait_time_us = wait_time_bytes;
     399                        wait_time_us *= 8000000;
     400                        wait_time_us /= e->transfer_mode.baudrate;
     401                        rtems_task_wake_after( RTEMS_MICROSECONDS_TO_TICKS(wait_time_us));
     402                        retries -= wait_time_bytes;
     403                        wait_time_bytes = wait_time_bytes * 15 / 10;
     404                } else {
     405                        n = SD_CARD_COMMAND_SIZE;
    397406                }
    398407        }
Note: See TracChangeset for help on using the changeset viewer.