Add delay if IDE tried to lock FB

* Fix #27
This commit is contained in:
iabdalkader 2014-10-31 13:57:17 +02:00
parent 46bbb691ca
commit 899ec65507
3 changed files with 10 additions and 3 deletions

View File

@ -11,11 +11,11 @@
#include "mutex.h"
extern char _fb_base;
static struct framebuffer {
int w;
int h;
int w,h;
int bpp;
int ready;
mutex_t lock;
int lock_tried;
uint8_t pixels[];
// Note all instances of fb point to the same memory address.
}*fb = (struct framebuffer *) &_fb_base;

View File

@ -336,6 +336,10 @@ int sensor_snapshot(struct image *image)
/* unlock framebuffer mutex */
mutex_unlock(&fb->lock);
if (fb->lock_tried) {
systick_sleep(1);
}
return 0;
}

View File

@ -44,6 +44,7 @@ void usbdbg_clr_script()
{
script_ready =0;
vstr_reset(&script);
fb->lock_tried=0;
mutex_unlock(&fb->lock);
}
@ -128,7 +129,9 @@ void usbdbg_control(void *buffer, uint8_t request, uint16_t length)
((uint8_t*)buffer)[0] = 0;
} else {
// try to lock FB, return 1 if locked
((uint8_t*)buffer)[0] = mutex_try_lock(&fb->lock);
int locked = mutex_try_lock(&fb->lock);
fb->lock_tried = !locked;
((uint8_t*)buffer)[0] = locked;
}
break;