Преглед изворни кода

Merge branch 'master' of https://gitee.com/openLuat/luatos-soc-air105

Wendal Chen пре 3 година
родитељ
комит
a951ac6b18

+ 118 - 0
Third_Party/ZBAR/src/binarize.c

@@ -598,6 +598,124 @@ unsigned char *qr_binarize(const unsigned char *_img,int _width,int _height){
 #endif
 #endif
   return(mask);
   return(mask);
 }
 }
+
+unsigned char *qr_binarize2(unsigned char *_img, int _width, int _height) {
+	unsigned char *mask = NULL;
+	if (_width > 0 && _height > 0) {
+		unsigned      *col_sums;
+		int            logwindw;
+		int            logwindh;
+		int            windw;
+		int            windh;
+		int            y0offs;
+		int            y1offs;
+		unsigned       g;
+		int            x;
+		int            y;
+		int				r_line = 0;
+		int				w_line = 0;
+		int				line_cnt = 0;
+		int				line_max = 0;
+		int				line_offset = 0;
+		/*We keep the window size fairly large to ensure it doesn't fit completely
+		   inside the center of a finder pattern of a version 1 QR code at full
+		   resolution.*/
+		for (logwindw = 4; logwindw < 8 && (1 << logwindw) < (_width + 7 >> 3); logwindw++);
+		for (logwindh = 4; logwindh < 8 && (1 << logwindh) < (_height + 7 >> 3); logwindh++);
+		windw = 1 << logwindw;
+		windh = 1 << logwindh;
+		col_sums = (unsigned *)malloc(_width * sizeof(*col_sums));
+		mask = (unsigned char *)malloc(((windh >> 1) + 2)*_width * sizeof(*mask));
+		line_max = (windh >> 1) + 2;
+		/*Initialize sums down each column.*/
+		for (x = 0; x < _width; x++) {
+			g = _img[x];
+			col_sums[x] = (g << logwindh - 1) + g;
+		}
+		for (y = 1; y < (windh >> 1); y++) {
+			y1offs = QR_MINI(y, _height - 1)*_width;
+			for (x = 0; x < _width; x++) {
+				g = _img[y1offs + x];
+				col_sums[x] += g;
+			}
+		}
+		for (y = 0; y < _height; y++) {
+			unsigned m;
+			int      x0;
+			int      x1;
+			/*Initialize the sum over the window.*/
+			m = (col_sums[0] << logwindw - 1) + col_sums[0];
+			for (x = 1; x < (windw >> 1); x++) {
+				x1 = QR_MINI(x, _width - 1);
+				m += col_sums[x1];
+			}
+			for (x = 0; x < _width; x++) {
+				/*Perform the test against the threshold T = (m/n)-D,
+				   where n=windw*windh and D=3.*/
+				g = _img[y*_width + x];
+				mask[w_line*_width + x] = -(g + 3 << logwindw + logwindh < m) & 0xFF;
+				/*Update the window sum.*/
+				if (x + 1 < _width) {
+					x0 = QR_MAXI(0, x - (windw >> 1));
+					x1 = QR_MINI(x + (windw >> 1), _width - 1);
+					m += col_sums[x1] - col_sums[x0];
+				}
+			}
+			w_line++;
+			line_cnt++;
+			if (w_line >= line_max)
+			{
+				w_line = 0;
+			}
+			/*Update the column sums.*/
+			if (y + 1 < _height) {
+				y0offs = QR_MAXI(0, y - (windh >> 1))*_width;
+				y1offs = QR_MINI(y + (windh >> 1), _height - 1)*_width;
+				for (x = 0; x < _width; x++) {
+					col_sums[x] -= _img[y0offs + x];
+					col_sums[x] += _img[y1offs + x];
+				}
+				if (y0offs)
+				{
+					memcpy(&_img[line_offset * _width], &mask[r_line *_width], _width);
+					r_line++;
+					line_offset++;
+					line_cnt--;
+					if (r_line >= line_max)
+					{
+						r_line = 0;
+					}
+				}
+			}
+			else
+			{
+				for (int i = 0; i < line_cnt; i++)
+				{
+					memcpy(&_img[line_offset * _width], &mask[r_line *_width], _width);
+					r_line++;
+					line_offset++;
+					if (r_line >= line_max)
+					{
+						r_line = 0;
+					}
+				}
+			}
+		}
+		free(col_sums);
+		free(mask);
+		mask = _img;
+	}
+#if defined(QR_DEBUG)
+	{
+		FILE *fout;
+		fout = fopen("binary.png", "wb");
+		image_write_png(_img, _width, _height, fout);
+		fclose(fout);
+	}
+#endif
+	return(mask);
+}
+
 #endif
 #endif
 
 
 #if defined(TEST_BINARIZE)
 #if defined(TEST_BINARIZE)

+ 3 - 3
Third_Party/ZBAR/src/qrdec.c

@@ -3933,8 +3933,8 @@ int _zbar_qr_decode (qr_reader *reader,
     qr_svg_centers(centers, ncenters);
     qr_svg_centers(centers, ncenters);
 
 
     if(ncenters >= 3) {
     if(ncenters >= 3) {
-        void *bin = qr_binarize(img->data, img->width, img->height);
-
+//		void *bin = qr_binarize(img->data, img->width, img->height);
+    	void *bin = qr_binarize2(img->data, img->width, img->height);
         qr_code_data_list qrlist;
         qr_code_data_list qrlist;
         qr_code_data_list_init(&qrlist);
         qr_code_data_list_init(&qrlist);
 
 
@@ -3945,7 +3945,7 @@ int _zbar_qr_decode (qr_reader *reader,
             nqrdata = qr_code_data_list_extract_text(&qrlist, iscn, img);
             nqrdata = qr_code_data_list_extract_text(&qrlist, iscn, img);
 
 
         qr_code_data_list_clear(&qrlist);
         qr_code_data_list_clear(&qrlist);
-        free(bin);
+//        free(bin);
     }
     }
     svg_group_end();
     svg_group_end();
 
 

+ 1 - 1
application/include/luat_conf_bsp.h

@@ -23,7 +23,7 @@
 #ifndef LUAT_CONF_BSP
 #ifndef LUAT_CONF_BSP
 #define LUAT_CONF_BSP
 #define LUAT_CONF_BSP
 
 
-#define LUAT_BSP_VERSION "V0007"
+#define LUAT_BSP_VERSION "V0008"
 
 
 
 
 #define LUAT_USE_FS_VFS 1
 #define LUAT_USE_FS_VFS 1

+ 48 - 55
application/src/luat_camera_air105.c

@@ -49,8 +49,7 @@ typedef struct
 	uint16_t Width;
 	uint16_t Width;
 	uint16_t Height;
 	uint16_t Height;
 	uint8_t DataBytes;
 	uint8_t DataBytes;
-	uint8_t IsDecode;
-	uint8_t BufferFull;
+	uint8_t IsDecoding;
 	uint8_t JPEGQuality;
 	uint8_t JPEGQuality;
 	uint8_t CaptureMode;
 	uint8_t CaptureMode;
 	uint8_t CaptureWait;
 	uint8_t CaptureWait;
@@ -122,7 +121,7 @@ static int32_t Camera_SaveJPEGDone(void *pData, void *pParam)
 }
 }
 
 
 void DecodeQR_CBDataFun(uint8_t *Data, uint32_t Len){
 void DecodeQR_CBDataFun(uint8_t *Data, uint32_t Len){
-    prvCamera.IsDecode = 0;
+    prvCamera.IsDecoding = 0;
     rtos_msg_t msg = {0};
     rtos_msg_t msg = {0};
 	if (Data){
 	if (Data){
         msg.handler = l_camera_handler;
         msg.handler = l_camera_handler;
@@ -231,64 +230,32 @@ static int32_t prvCamera_DCMICB(void *pData, void *pParam){
         Buffer_Struct *RxBuf = (Buffer_Struct *)pData;
         Buffer_Struct *RxBuf = (Buffer_Struct *)pData;
         if (!pData)
         if (!pData)
         {
         {
-            if (!prvCamera.DataCache)
+            if (!prvCamera.DataCache && !prvCamera.IsDecoding)
             {
             {
                 prvCamera.DataCache = malloc(prvCamera.TotalSize);
                 prvCamera.DataCache = malloc(prvCamera.TotalSize);
-                prvCamera.BufferFull = 0;
             }
             }
-            else
+            else if (prvCamera.DataCache)
             {
             {
-                if (prvCamera.TotalSize != prvCamera.CurSize)
-                {
-    //				DBG_ERR("%d, %d", prvCamera.CurSize, prvCamera.TotalSize);
-                }
-                else if (!prvCamera.IsDecode)
-                {
-                    prvCamera.IsDecode = 1;
-                    if (draw_lcd)
-                        Camera_DrawLcd(prvCamera.DataCache, zbar_scan);
-                    Core_DecodeQR(prvCamera.DataCache, prvCamera.Width, prvCamera.Height,  DecodeQR_CBDataFun);
-                    prvCamera.DataCache = malloc(prvCamera.TotalSize);
-                    prvCamera.BufferFull = 0;
-                }
-                else
-                {
-                    prvCamera.BufferFull = 1;
-                }
+            	if (draw_lcd) {
+            	    Camera_DrawLcd(prvCamera.DataCache, zbar_scan);
+            	}
+            	Core_DecodeQR(prvCamera.DataCache, prvCamera.Width, prvCamera.Height,  DecodeQR_CBDataFun);
+            	prvCamera.DataCache = NULL;
+            	prvCamera.IsDecoding = 1;
             }
             }
             prvCamera.CurSize = 0;
             prvCamera.CurSize = 0;
             return 0;
             return 0;
         }
         }
         if (prvCamera.DataCache)
         if (prvCamera.DataCache)
         {
         {
-            if (prvCamera.BufferFull)
-            {
-                if (!prvCamera.IsDecode){
-                    prvCamera.IsDecode = 1;
-                    if (draw_lcd)
-                        Camera_DrawLcd(prvCamera.DataCache, zbar_scan);
-                    Core_DecodeQR(prvCamera.DataCache, prvCamera.Width, prvCamera.Height,  DecodeQR_CBDataFun);
-                    prvCamera.DataCache = malloc(prvCamera.TotalSize);
-                    prvCamera.BufferFull = 0;
-                    prvCamera.CurSize = 0;
-                }else{
-                    return 0;
-                }
+            memcpy(&prvCamera.DataCache[prvCamera.CurSize], RxBuf->Data, RxBuf->MaxLen * 4);
+            prvCamera.CurSize += RxBuf->MaxLen * 4;
+            if (prvCamera.TotalSize < prvCamera.CurSize){
+                DBG_ERR("%d,%d", prvCamera.TotalSize, prvCamera.CurSize);
+                prvCamera.CurSize = 0;
             }
             }
         }
         }
-        else
-        {
-            prvCamera.DataCache = malloc(prvCamera.TotalSize);
-            prvCamera.BufferFull = 0;
-            prvCamera.CurSize = 0;
-            prvCamera.IsDecode = 0;
-        }
-        memcpy(&prvCamera.DataCache[prvCamera.CurSize], RxBuf->Data, RxBuf->MaxLen * 4);
-        prvCamera.CurSize += RxBuf->MaxLen * 4;
-        if (prvCamera.TotalSize < prvCamera.CurSize){
-            DBG_ERR("%d,%d", prvCamera.TotalSize, prvCamera.CurSize);
-            prvCamera.CurSize = 0;
-        }
+
         return 0;
         return 0;
     }
     }
 }
 }
@@ -318,8 +285,18 @@ int luat_camera_init(luat_camera_conf_t *conf){
     memcpy(&camera_conf, conf, sizeof(luat_camera_conf_t));
     memcpy(&camera_conf, conf, sizeof(luat_camera_conf_t));
     lcd_conf = conf->lcd_conf;
     lcd_conf = conf->lcd_conf;
     draw_lcd = conf->draw_lcd;
     draw_lcd = conf->draw_lcd;
-    prvCamera.Width = lcd_conf->w;
-    prvCamera.Height = lcd_conf->h;
+    if (lcd_conf)
+    {
+        prvCamera.Width = lcd_conf->w;
+        prvCamera.Height = lcd_conf->h;
+    }
+    else
+    {
+        prvCamera.Width = camera_conf.sensor_width;
+        prvCamera.Height = camera_conf.sensor_height;
+        draw_lcd = 0;
+    }
+
     if (conf->zbar_scan == 1){
     if (conf->zbar_scan == 1){
         prvCamera.DataCache = NULL;
         prvCamera.DataCache = NULL;
 
 
@@ -361,13 +338,29 @@ int luat_camera_start(int id)
 		free(prvCamera.DataCache);
 		free(prvCamera.DataCache);
 	}
 	}
     if (camera_conf.zbar_scan == 0){
     if (camera_conf.zbar_scan == 0){
-        DCMI_SetCROPConfig(1, (camera_conf.sensor_height-lcd_conf->h)/2, ((camera_conf.sensor_width-lcd_conf->w)/2)*2, lcd_conf->h - 1, 2*lcd_conf->w - 1);
-        DCMI_CaptureSwitch(1, 0, lcd_conf->w, lcd_conf->h, 2, &prvCamera.drawVLen);
+    	if (lcd_conf)
+    	{
+            DCMI_SetCROPConfig(1, (camera_conf.sensor_height-lcd_conf->h)/2, ((camera_conf.sensor_width-lcd_conf->w)/2)*2, lcd_conf->h - 1, 2*lcd_conf->w - 1);
+            DCMI_CaptureSwitch(1, 0, lcd_conf->w, lcd_conf->h, 2, &prvCamera.drawVLen);
+    	}
+    	else
+    	{
+    		DCMI_SetCROPConfig(0, 0, 0, 0, 0);
+    		DCMI_CaptureSwitch(1, 0, camera_conf.sensor_width, camera_conf.sensor_height, 2, &prvCamera.drawVLen);
+    	}
         prvCamera.CaptureMode = 0;
         prvCamera.CaptureMode = 0;
         prvCamera.VLen = 0;
         prvCamera.VLen = 0;
     }else if(camera_conf.zbar_scan == 1){
     }else if(camera_conf.zbar_scan == 1){
-        DCMI_SetCROPConfig(1, (camera_conf.sensor_height-prvCamera.Height)/2, ((camera_conf.sensor_width-prvCamera.Width)/2)*prvCamera.DataBytes, prvCamera.Height - 1, prvCamera.DataBytes*prvCamera.Width - 1);
-        DCMI_CaptureSwitch(1, 0,lcd_conf->w, lcd_conf->h, prvCamera.DataBytes, &prvCamera.drawVLen);
+    	if (lcd_conf)
+    	{
+    		DCMI_SetCROPConfig(1, (camera_conf.sensor_height-prvCamera.Height)/2, ((camera_conf.sensor_width-prvCamera.Width)/2)*prvCamera.DataBytes, prvCamera.Height - 1, prvCamera.DataBytes*prvCamera.Width - 1);
+    		DCMI_CaptureSwitch(1, 0,lcd_conf->w, lcd_conf->h, prvCamera.DataBytes, &prvCamera.drawVLen);
+    	}
+    	else
+    	{
+    		DCMI_SetCROPConfig(0, 0, 0, 0, 0);
+    		DCMI_CaptureSwitch(1, 0, camera_conf.sensor_width, camera_conf.sensor_height, prvCamera.DataBytes, &prvCamera.drawVLen);
+    	}
     }
     }
     prvCamera.NewDataFlag = 0;
     prvCamera.NewDataFlag = 0;
     Timer_StartMS(prvCamera.CheckTimer, 1000, 1);
     Timer_StartMS(prvCamera.CheckTimer, 1000, 1);

+ 4 - 2
bsp/air105/hal/core_dac.c

@@ -56,7 +56,7 @@ static int32_t DAC_DMADoneCB(void *pData, void *pParam)
 
 
 static int32_t DAC_DummyCB(void *pData, void *pParam)
 static int32_t DAC_DummyCB(void *pData, void *pParam)
 {
 {
-	DBG("!");
+//	DBG("!");
 	return 0;
 	return 0;
 }
 }
 
 
@@ -133,7 +133,8 @@ uint8_t DAC_CheckRun(uint8_t DAC_ID)
 
 
 void DAC_Stop(uint8_t DAC_ID)
 void DAC_Stop(uint8_t DAC_ID)
 {
 {
-
+	DMA_StopStream(prvDAC.DMATxStream);
+	prvDAC.Callback = DAC_DummyCB;
 	while (DAC->DAC_CR1 & (1 << 29));
 	while (DAC->DAC_CR1 & (1 << 29));
 	DAC_ForceStop(DAC_ID);
 	DAC_ForceStop(DAC_ID);
 }
 }
@@ -144,5 +145,6 @@ void DAC_ForceStop(uint8_t DAC_ID)
 	DAC->DAC_CR1 |= (1 << 4);
 	DAC->DAC_CR1 |= (1 << 4);
 	DAC->DAC_CR1 &= ~0x04;
 	DAC->DAC_CR1 &= ~0x04;
 	PM_SetHardwareRunFlag(PM_HW_DAC_0 + DAC_ID, 0);
 	PM_SetHardwareRunFlag(PM_HW_DAC_0 + DAC_ID, 0);
+	prvDAC.IsBusy = 0;
 //	PM_SetHardwareRunFlag(PM_HW_DAC_0, 0);
 //	PM_SetHardwareRunFlag(PM_HW_DAC_0, 0);
 }
 }

+ 2 - 5
bsp/audio/src/audio_ll_drv.c

@@ -39,10 +39,7 @@ static int32_t prvAudio_DACCB(void *pData, void *pParam)
 	}
 	}
 	free(OldBlock->uPV.pu8);
 	free(OldBlock->uPV.pu8);
 	free(OldBlock);
 	free(OldBlock);
-	if (!pStream->IsPause)
-	{
-		pStream->CB(pStream, NULL);
-	}
+	pStream->CB(pStream, NULL);
 	if (llist_empty(&pStream->DataHead))
 	if (llist_empty(&pStream->DataHead))
 	{
 	{
 		pStream->IsHardwareRun = 0;
 		pStream->IsHardwareRun = 0;
@@ -203,7 +200,7 @@ static int32_t prvAudio_WriteDACRaw(Audio_StreamStruct *pStream, uint8_t *pByteD
 	Critical = OS_EnterCritical();
 	Critical = OS_EnterCritical();
 	llist_add_tail(&Block->Node, &pStream->DataHead);
 	llist_add_tail(&Block->Node, &pStream->DataHead);
 	OS_ExitCritical(Critical);
 	OS_ExitCritical(Critical);
-	if (!pStream->IsHardwareRun)
+	if (!pStream->IsHardwareRun && !pStream->IsPause)
 	{
 	{
 		return prvAudio_RunDAC(pStream);
 		return prvAudio_RunDAC(pStream);
 	}
 	}

+ 150 - 0
bsp/common/src/bsp_common.c

@@ -1682,3 +1682,153 @@ uint32_t BSP_Swap32(uint32_t n)
 {
 {
   return (uint32_t)PP_HTONL(n);
   return (uint32_t)PP_HTONL(n);
 }
 }
+
+uint32_t utf8_to_unicode(uint8_t *string, uint32_t len, void *out, uint8_t is_only_16)
+{
+	uint32_t i = 0;
+	uint32_t result = 0;
+	uint8_t bit, n;
+	if (is_only_16)
+	{
+		uint16_t *buf = (uint16_t *)out;
+		while (i < len)
+		{
+			if (string[i] & 0x80)
+			{
+				if (!(string[i] & (1 << 5)))
+				{
+					n = 2;
+					buf[result] = string[i] & ((1 << 5) - 1);
+				}
+				else
+				{
+					buf[result] = string[i] & ((1 << 4) - 1);
+					n = 3;
+				}
+
+				for (bit = 1; bit < n; bit++)
+				{
+					buf[result] = (buf[result] << 6) | (string[i + bit] & 0x3f);
+				}
+				i += n;
+			}
+			else
+			{
+				buf[result] = string[i];
+				i++;
+			}
+			result++;
+		}
+	}
+	else
+	{
+		uint8_t table[7] = {0, 0, 0x1f, 0x0f, 0x07, 0x03, 0x01};
+		uint32_t *buf = (uint32_t *)out;
+		while (i < len)
+		{
+			if (string[i] & 0x80)
+			{
+				n = 7;
+				for (bit = 5; bit >= 1; bit--)
+				{
+					if (!(string[i] & (1 << bit)))
+					{
+						n -= bit;
+						break;
+					}
+				}
+				if (n >= 7)
+				{
+					return result;
+				}
+				buf[result] = string[i] & table[n];
+
+				for (bit = 1; bit < n; bit++)
+				{
+					buf[result] = (buf[result] << 6) | (string[i + bit] & 0x3f);
+				}
+				i += n;
+			}
+			else
+			{
+				buf[result] = string[i];
+				i++;
+			}
+			result++;
+		}
+	}
+	return result;
+}
+
+uint32_t unicode_to_utf8(void *in, uint32_t unicodelen, uint8_t *out, uint8_t is_only_16)
+{
+	uint32_t i = 0;
+	uint32_t result = 0;
+	uint8_t bit, n;
+	if (is_only_16)
+	{
+		uint16_t *buf = (uint16_t *)in;
+		while (i < unicodelen)
+		{
+			if (buf[i] <= 0x007f)
+			{
+				out[result] = buf[i];
+
+				result++;
+			}
+			else
+			{
+				if (buf[i] >> 12)
+				{
+					out[result + 2] = (buf[i] & 0x3f) | 0x80;
+					out[result + 1] = ((buf[i] >> 6) & 0x3f) | 0x80;
+					out[result] = 0xe0 | (buf[i] >> 12);
+					result += 3;
+				}
+				else
+				{
+					out[result + 1] = (buf[i] & 0x3f) | 0x80;
+					out[result] = 0xc0 | (buf[i] >> 6);
+					result += 2;
+				}
+			}
+			i++;
+		}
+
+	}
+	else
+	{
+		uint8_t table[7] = {0,0,0xc0,0xe0, 0xf0, 0xf8, 0xfc};
+		uint8_t pos[7] = {0,0,6,12,18,24,30};
+		uint32_t *buf = (uint32_t *)in;
+		while (i < unicodelen)
+		{
+			if (buf[i] <= 0x007f)
+			{
+				out[result] = buf[i];
+
+				result++;
+			}
+			else
+			{
+				n = 6;
+				for (bit = 1; bit < 6; bit++)
+				{
+					if (!(buf[i] >> ((bit + 1) * 6)))
+					{
+						n = bit + 1;
+						break;
+					}
+				}
+				out[result] = table[n] | (buf[i] >> pos[n]);
+				for (bit = 1; bit < n; bit++)
+				{
+					out[result + bit] = ( (buf[i] >> ((n - bit - 1) * 6)) & 0x3f) | 0x80;
+				}
+				result += n;
+			}
+			i++;
+		}
+	}
+	return result;
+}

+ 4 - 4
bsp/common/src/core_usb_app.c

@@ -388,7 +388,7 @@ static char prvCore_HIDCustomReportDescriptor[34] = {
 	    0x09, 0x00,                    // USAGE (Undefined)
 	    0x09, 0x00,                    // USAGE (Undefined)
 	    0xa1, 0x01,                    // COLLECTION (Application)
 	    0xa1, 0x01,                    // COLLECTION (Application)
 	    0x09, 0x00,                    //   USAGE (Undefined)
 	    0x09, 0x00,                    //   USAGE (Undefined)
-	    0x95, USB_HID_KB_DATA_CACHE,      //   REPORT_COUNT (32)
+	    0x95, USB_HID_KB_DATA_CACHE,      //   REPORT_COUNT (8)
 	    0x75, 0x08,      			   //   REPORT_SIZE (8)
 	    0x75, 0x08,      			   //   REPORT_SIZE (8)
 	    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
 	    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
 	    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
 	    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
@@ -396,7 +396,7 @@ static char prvCore_HIDCustomReportDescriptor[34] = {
 	    0x09, 0x00,                    //   USAGE (Undefined)
 	    0x09, 0x00,                    //   USAGE (Undefined)
 	    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
 	    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
 	    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
 	    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
-	    0x95, USB_HID_KB_DATA_CACHE,      //   REPORT_COUNT (32)
+	    0x95, USB_HID_KB_DATA_CACHE,      //   REPORT_COUNT (8)
 	    0x75, 0x08,                    //   REPORT_SIZE (8)
 	    0x75, 0x08,                    //   REPORT_SIZE (8)
 	    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
 	    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
 	    0xc0                           // END_COLLECTION
 	    0xc0                           // END_COLLECTION
@@ -1203,9 +1203,9 @@ void Core_VHIDSendRawData(uint8_t USB_ID, uint8_t *Data, uint32_t Len)
 	Virtual_HIDCtrlStruct *pVHID = &prvLuatOS_VirtualHID;
 	Virtual_HIDCtrlStruct *pVHID = &prvLuatOS_VirtualHID;
 	USB_StackEpIntOnOff(pVHID->USB_ID, pVHID->ToHostEpIndex, 0, 0);
 	USB_StackEpIntOnOff(pVHID->USB_ID, pVHID->ToHostEpIndex, 0, 0);
 	OS_BufferWrite(&pVHID->TxCacheBuf, Data, Len);
 	OS_BufferWrite(&pVHID->TxCacheBuf, Data, Len);
-	if (Len % prvCore_HIDCustomReportDescriptor[28])
+	if (Len % prvCore_HIDEndpointDesc[1].wMaxPacketSize[0])
 	{
 	{
-		OS_BufferWrite(&pVHID->TxCacheBuf, zero, prvCore_HIDCustomReportDescriptor[28] - (Len % prvCore_HIDCustomReportDescriptor[28]));
+		OS_BufferWrite(&pVHID->TxCacheBuf, zero, prvCore_HIDEndpointDesc[1].wMaxPacketSize[0] - (Len % prvCore_HIDEndpointDesc[1].wMaxPacketSize[0]));
 	}
 	}
 	Buffer_StaticInit(&pVHID->TxBuf, pVHID->TxCacheBuf.Data, pVHID->TxCacheBuf.Pos);
 	Buffer_StaticInit(&pVHID->TxBuf, pVHID->TxCacheBuf.Data, pVHID->TxCacheBuf.Pos);
 	OS_InitBuffer(&pVHID->TxCacheBuf, VIRTUAL_VHID_BUFFER_LEN);
 	OS_InitBuffer(&pVHID->TxCacheBuf, VIRTUAL_VHID_BUFFER_LEN);