/* Waits until the Si1133 is sleeping before proceeding.  */
static uint32_t SI1133_waitUntilSleep(void)
/* Waits until the Si1133 is sleeping before proceeding.  */
static uint32_t SI1133_waitUntilSleep(void)
{
   uint32_t ret;
   uint8_t response;
   uint8_t count = 0;
   uint32_t retval;
   retval = SI1133_OK;
   while( count < 5 )
   {
      ret = SI1133_registerRead( SI1133_REG_RESPONSE0, &response );
      if( ( response & SI1133_RSP0_CHIPSTAT_MASK ) == SI1133_RSP0_SLEEP ) {
         break;
      }
      if( ret != SI1133_OK ) {
         retval = SI1133_ERROR_SLEEP_FAILED;
         break;
      }
      count++;
   }
   return retval;
}