Обновление

This commit is contained in:
cfif 2026-04-06 17:22:26 +03:00
parent 4f932cc556
commit 26f5f8f523
2 changed files with 7 additions and 16 deletions

View File

@ -16,9 +16,7 @@ void Adc_0_Init(tAdcTask *env,
env->gpios = gpios; env->gpios = gpios;
env->isRandomSecuritySeed = false; env->queueRandom = osMessageQueueNew(10, 4, NULL);
env->queueRandom = osMessageQueueNew(1, 4, NULL);
InitThreadAtrStatic(&env->thread.attr, "Adc0", env->thread.controlBlock, env->thread.stack, InitThreadAtrStatic(&env->thread.attr, "Adc0", env->thread.controlBlock, env->thread.stack,
osPriorityNormal); osPriorityNormal);
@ -97,7 +95,11 @@ static _Noreturn void Adc0_Thread(tAdcTask *env) {
env->ADC_isUpdate = true; env->ADC_isUpdate = true;
} }
if (env->isRandomSecuritySeed) {
uint32_t count = osMessageQueueGetSpace(env->queueRandom);
if (count) {
uint32_t seed = 0; uint32_t seed = 0;
for (uint8_t i = 0; i < 28; ++i) { for (uint8_t i = 0; i < 28; ++i) {
@ -109,8 +111,6 @@ static _Noreturn void Adc0_Thread(tAdcTask *env) {
} }
osStatus_t status = osMessageQueuePut(env->queueRandom, &seed, 0, 0U); osStatus_t status = osMessageQueuePut(env->queueRandom, &seed, 0, 0U);
env->isRandomSecuritySeed = false;
} }
@ -126,16 +126,9 @@ static _Noreturn void Adc0_Thread(tAdcTask *env) {
uint32_t getRandom32(tAdcTask *env) { uint32_t getRandom32(tAdcTask *env) {
if (osMutexAcquire(env->access, 1000) == osOK) {
env->isRandomSecuritySeed = true;
osMutexRelease(env->access);
} else {
return 0;
}
uint32_t random = 0; uint32_t random = 0;
osStatus_t status = osMessageQueueGet(env->queueRandom, &random, 0, 1000); osStatus_t status = osMessageQueueGet(env->queueRandom, &random, 0, 1500);
if (status == osOK) { if (status == osOK) {
return random; return random;

View File

@ -78,8 +78,6 @@ typedef struct {
uint8_t ADC0_BTS5120_2EKA_Channel; uint8_t ADC0_BTS5120_2EKA_Channel;
bool ADC_isUpdate; bool ADC_isUpdate;
bool isRandomSecuritySeed;
osMessageQueueId_t queueRandom; osMessageQueueId_t queueRandom;
struct { struct {