#include <stdint.h>
#include <stdlib.h>
#define MAX_THREADS 128
typedef struct {
osThreadId threadId;
uint32_t uniqueId;
} ThreadMapping;
ThreadMapping threadMappings[MAX_THREADS];
uint32_t nextUniqueId = 1;
uint32_t getThreadUniqueId(osThreadId threadId) {
for (int i = 0; i < MAX_THREADS; i++) {
if (threadMappings[i].threadId == threadId) {
return threadMappings[i].uniqueId;
}
}
// If thread ID not found, add new mapping
for (int i = 0; i < MAX_THREADS; i++) {
if (threadMappings[i].threadId == NULL) {
threadMappings[i].threadId = threadId;
threadMappings[i].uniqueId = nextUniqueId++;
return threadMappings[i].uniqueId;
}
}
// Handle case where no space is left for new threads
// This can be expanded based on your application's requirements
return 0;
}
#include <stdint.h>
#include <stdlib.h>
#define MAX_THREADS 128
typedef struct {
osThreadId threadId;
uint32_t uniqueId;
} ThreadMapping;
ThreadMapping threadMappings[MAX_THREADS];
uint32_t nextUniqueId = 1;
uint32_t getThreadUniqueId(osThreadId threadId) {
for (int i = 0; i < MAX_THREADS; i++) {
if (threadMappings[i].threadId == threadId) {
return threadMappings[i].uniqueId;
}
}
// If thread ID not found, add new mapping
for (int i = 0; i < MAX_THREADS; i++) {
if (threadMappings[i].threadId == NULL) {
threadMappings[i].threadId = threadId;
threadMappings[i].uniqueId = nextUniqueId++;
return threadMappings[i].uniqueId;
}
}
// Handle case where no space is left for new threads
// This can be expanded based on your application's requirements
return 0;
}