summaryrefslogtreecommitdiff
path: root/src/stlink-lib/helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stlink-lib/helper.c')
-rw-r--r--src/stlink-lib/helper.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/stlink-lib/helper.c b/src/stlink-lib/helper.c
index 1f0f71b..1e756f1 100644
--- a/src/stlink-lib/helper.c
+++ b/src/stlink-lib/helper.c
@@ -1,27 +1,34 @@
-#include <helper.h>
-
-#include <stddef.h>
-#include <stdlib.h>
+/*
+ * File: helper.c
+ *
+ * General helper functions
+ */
#ifdef STLINK_HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <sys_time.h>
-#endif
+#endif // STLINK_HAVE_SYS_TIME_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "helper.h"
-unsigned time_ms() {
+uint32_t time_ms() {
struct timeval tv;
gettimeofday(&tv, NULL);
- return (unsigned)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
+ return (uint32_t)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
}
-int arg_parse_freq(const char *str) {
+int32_t arg_parse_freq(const char *str) {
char *tail;
- int value = (int)strtol(str, &tail, 10);
+ int32_t value = (int32_t)strtol(str, &tail, 10);
- if ((tail[0] == 'm' || tail[0] == 'M') && tail[1] == '\0') {
+ if (tail[0] == 'M' && tail[1] == '\0') {
value = value*1000;
- } else if (((tail[0] != 'k' && tail[0] != 'K') || tail[1] != '\0') && tail[0] != '\0') {
+ } else if ((tail[0] != 'k' || tail[1] != '\0') && tail[0] != '\0') {
return -1;
}