libshell: update shell_ping()
make it faster
This commit is contained in:
@@ -1,12 +1,24 @@
|
|||||||
#include <shell_api.h>
|
#include <shell_api.h>
|
||||||
#include <sys/ksys.h>
|
#include <sys/ksys.h>
|
||||||
|
#include <sys/ksys.h>
|
||||||
|
|
||||||
|
#define SHELL_PING_TIMEOUT 10 // 0.1 sec
|
||||||
|
#define SHELL_PING_MIN_DELAY 1
|
||||||
|
|
||||||
int shell_ping()
|
int shell_ping()
|
||||||
{
|
{
|
||||||
*__shell_shm = SHELL_PING;
|
*__shell_shm = SHELL_PING;
|
||||||
|
|
||||||
_ksys_thread_yield();
|
_ksys_thread_yield(); // hope shell is fast enough
|
||||||
_ksys_delay(40);
|
|
||||||
|
|
||||||
return *__shell_shm == SHELL_OK;
|
size_t i = 0;
|
||||||
|
while (*__shell_shm != SHELL_OK){
|
||||||
|
if (i > (SHELL_PING_TIMEOUT / SHELL_PING_MIN_DELAY)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
_ksys_delay(SHELL_PING_MIN_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user