Simplified code a bit. Emulator does not work stable when replugging pixy.

This commit is contained in:
t-moe
2015-04-25 00:40:23 +02:00
parent 416883c15b
commit 3d1e4b2ef2
11 changed files with 24 additions and 51 deletions

View File

@@ -29,6 +29,10 @@ int pixy_frame_test();
//app event loop //app event loop
void app_process() { void app_process() {
system_process(); //Let the system handle it's pending events
//Note: The only way to detect that pixy has been disconnected is if a command fails. There's no pixy_is_connected method yet :'( //Note: The only way to detect that pixy has been disconnected is if a command fails. There's no pixy_is_connected method yet :'(
if(!pixy_connected) { //Pixy not connected if(!pixy_connected) { //Pixy not connected

View File

@@ -3,4 +3,4 @@
bool ll_system_init(); bool ll_system_init();
void ll_system_delay(uint32_t msec); void ll_system_delay(uint32_t msec);
void ll_system_process();

View File

@@ -6,10 +6,10 @@ bool system_init() {
return ll_system_init(); return ll_system_init();
} }
void system_delay(uint32_t msec) { void system_delay(uint32_t msec) {
ll_system_delay(msec); ll_system_delay(msec);
} }
void system_process() {
ll_system_process();
}

View File

@@ -3,3 +3,4 @@
bool system_init(); bool system_init();
void system_delay(uint32_t msec); void system_delay(uint32_t msec);
void system_process();

View File

@@ -55,6 +55,12 @@ bool ll_system_init(void)
return true; return true;
} }
void ll_system_process() {
USBH_Process(&USB_OTG_Core, &USB_Host);
}
void ll_system_delay(uint32_t msec) { void ll_system_delay(uint32_t msec) {
USB_OTG_BSP_mDelay(msec); USB_OTG_BSP_mDelay(msec);
} }

View File

@@ -1,23 +1,11 @@
#include "app.h" #include "app.h"
#include "usb_hcd_int.h"
#include "usbh_usr.h"
#include "usbh_core.h"
#include "usbh_msc_core.h"
extern USB_OTG_CORE_HANDLE USB_OTG_Core;
extern USBH_HOST USB_Host;
int main(void) int main(void)
{ {
app_init(); app_init();
while (1) while (1)
{ {
USBH_Process(&USB_OTG_Core, &USB_Host);
app_process(); app_process();
} }

View File

@@ -181,7 +181,6 @@ int USBH_LL_open() {
} }
//moved to common
cnt_int=0; cnt_int=0;
while(cnt_int<timeoutStartup) { //let pixy's led flashing pass while(cnt_int<timeoutStartup) { //let pixy's led flashing pass
USBH_Process(&USB_OTG_Core, &USB_Host); USBH_Process(&USB_OTG_Core, &USB_Host);

View File

@@ -1,8 +1,6 @@
#include "usbh_usr.h" #include "usbh_usr.h"
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
//#include "pixy.h"
USBH_Usr_cb_TypeDef USR_Callbacks = USBH_Usr_cb_TypeDef USR_Callbacks =
@@ -144,7 +142,6 @@ void USBH_USR_Configuration_DescAvailable(USBH_CfgDesc_TypeDef * cfgDesc,
void USBH_USR_Manufacturer_String(void *ManufacturerString) void USBH_USR_Manufacturer_String(void *ManufacturerString)
{ {
manufacturer_ok = strcmp((char*)ManufacturerString,"Charmed Labs") == 0; manufacturer_ok = strcmp((char*)ManufacturerString,"Charmed Labs") == 0;
/* callback for Manufacturer String */
} }
/** /**
@@ -155,7 +152,6 @@ void USBH_USR_Manufacturer_String(void *ManufacturerString)
void USBH_USR_Product_String(void *ProductString) void USBH_USR_Product_String(void *ProductString)
{ {
product_ok = strcmp((char*)ProductString,"Pixy") == 0; product_ok = strcmp((char*)ProductString,"Pixy") == 0;
/* callback for Product String */
} }
/** /**
@@ -166,7 +162,6 @@ void USBH_USR_Product_String(void *ProductString)
void USBH_USR_SerialNum_String(void *SerialNumString) void USBH_USR_SerialNum_String(void *SerialNumString)
{ {
serial_ok = strcmp((char*)SerialNumString,"DEMO 0.0") == 0; serial_ok = strcmp((char*)SerialNumString,"DEMO 0.0") == 0;
/* callback for SerialNum_String */
} }
/** /**
@@ -220,26 +215,8 @@ void USBH_USR_OverCurrentDetected (void)
* @param None * @param None
* @retval Staus * @retval Staus
*/ */
/*int colorind;
const uint32_t colors [] = {0xFF0000, 0x00FF00,0x0000FF,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF,0x000000};
const int num_colors = sizeof(colors)/sizeof(uint32_t);
*/
int USBH_USR_MSC_Application(void) int USBH_USR_MSC_Application(void)
{ {
/* if(colorind==0) {
pixy_led_set_max_current(5);
}
int32_t response;
int return_value;
return_value = pixy_command("led_set", INT32(colors[colorind++]), END_OUT_ARGS, &response, END_IN_ARGS);
colorind%=num_colors;
USB_OTG_BSP_mDelay(500);
*/
return 0; return 0;
} }
@@ -254,10 +231,3 @@ void USBH_USR_DeInit(void)
} }
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

Binary file not shown.

View File

@@ -1,4 +1,6 @@
#include <QThread> #include <QThread>
#include <QApplication>
extern "C" { extern "C" {
#include "ll_system.h" #include "ll_system.h"
} }
@@ -11,3 +13,7 @@ void ll_system_delay(uint32_t msec) {
QThread::msleep(msec); QThread::msleep(msec);
} }
void ll_system_process() {
QApplication::processEvents();
}

View File

@@ -10,7 +10,6 @@ extern "C" {
void app_loop() { void app_loop() {
while(!QApplication::closingDown()) { while(!QApplication::closingDown()) {
app_process(); app_process();
QApplication::processEvents();
} }
} }