int wait_for_ready( void ) { int d = gpio_hrdy( ); int count = 0; while ( d == 0 && count < WAIT_MAX) { d = gpio_hrdy( ); count++; } if (d == 0 || count >= WAIT_MAX) { DBG("not ready %d!\n", count); } return count; }
int wait_for_ready( void ) { int d = gpio_hrdy( ); int count = 0; while ( d == 0 ) { if (++count >= WAIT_MAX) { reset(); count = 0; } d = gpio_hrdy( ); } return count; }
/// This function may cause deadlock. Make sure you call this function /// correctly. Otherwise use wait_for_ready instead. This function is introduced /// to solve screen update problem. We may have a better way later. int wait_until_ready( void ) { // TODO, change the usleep to nanosleep later. static const int MAX = 40; int d = gpio_hrdy( ); int count = 0; while ( d == 0 && count < MAX) { USLEEP(100 * 1000); d = gpio_hrdy( ); count++; } if (d == 0) { DBG("Still not ready, should not happen"); } return count; }