first commit
This commit is contained in:
commit
0ef2017d18
28 files changed
+1882
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
void utils_delay_ms(uint32_t ms)
|
||||
{
|
||||
vTaskDelay(pdMS_TO_TICKS(ms));
|
||||
}
|
||||
|
||||
uint32_t utils_get_tick_ms(void)
|
||||
{
|
||||
return (uint32_t)(xTaskGetTickCount() * portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
void utils_trim(char *str)
|
||||
{
|
||||
if (!str) return;
|
||||
|
||||
char *start = str;
|
||||
while (*start && isspace((unsigned char)*start)) start++;
|
||||
|
||||
if (*start == '\0') {
|
||||
*str = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
char *end = start + strlen(start) - 1;
|
||||
while (end > start && isspace((unsigned char)*end)) end--;
|
||||
|
||||
size_t len = end - start + 1;
|
||||
memmove(str, start, len);
|
||||
str[len] = '\0';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void utils_delay_ms(uint32_t ms);
|
||||
uint32_t utils_get_tick_ms(void);
|
||||
void utils_trim(char *str);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user