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

add:task挂起和恢复
update:可以获取任意个数的随机数

alienwalker пре 4 година
родитељ
комит
db77595ff1

+ 1 - 0
application/src/luat_base_air105.c

@@ -204,6 +204,7 @@ static const luaL_Reg loadedlibs[] = {
 #endif
 #ifdef LUAT_USE_W5500
   {"w5500", luaopen_w5500},
+  {"network", luaopen_network_adapter},
 #endif
   {"usbapp", luaopen_usbapp},
   {"audio", luaopen_multimedia_audio},

+ 17 - 5
application/src/luat_crypto_air105.c

@@ -28,13 +28,25 @@
 int luat_crypto_trng(char* buff, size_t len) {
     size_t t = 0;
     uint32_t tmp[4];
+    int i;
+    char *temp = tmp;
     while (len > t) {
         RNG_GetData(tmp);
-        BytesPutLe32(&buff[t], tmp[0]);
-        BytesPutLe32(&buff[t + 4], tmp[1]);
-        BytesPutLe32(&buff[t + 8], tmp[2]);
-        BytesPutLe32(&buff[t + 12], tmp[3]);
-        t += 16;
+        if ((len - t) >=16)
+        {
+        	memcpy(buff + t, temp, 16);
+        	t += 16;
+        }
+        else
+        {
+        	i = 0;
+        	while (len > t)
+        	{
+        		buff[t] = temp[i];
+        		t++;
+        		i++;
+        	}
+        }
     }
     return 0;
 }

+ 2 - 0
bsp/common/include/bsp_common.h

@@ -298,6 +298,8 @@ void OS_MutexLock(HANDLE Sem);
 int32_t OS_MutexLockWtihTime(HANDLE Sem, uint32_t TimeoutMs);
 void OS_MutexRelease(HANDLE Sem);
 void OS_MutexDelete(HANDLE Sem);
+void OS_SuspendTask(HANDLE taskHandle);
+void OS_ResumeTask(HANDLE taskHandle);
 #endif
 uint32_t OS_EnterCritical(void);
 void OS_ExitCritical(uint32_t Critical);

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

@@ -360,6 +360,30 @@ void OS_MutexDelete(HANDLE Sem)
 {
 	vSemaphoreDelete(Sem);
 }
+
+void OS_SuspendTask(HANDLE taskHandle)
+{
+	if (taskHandle)
+	{
+		vTaskSuspend(taskHandle);
+	}
+	else
+	{
+		vTaskSuspendAll();
+	}
+}
+
+void OS_ResumeTask(HANDLE taskHandle)
+{
+	if (taskHandle)
+	{
+		vTaskResume(taskHandle);
+	}
+	else
+	{
+		xTaskResumeAll();
+	}
+}
 #endif
 static uint8_t prvOSRunFlag;
 extern const uint32_t __os_heap_start;