Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: USBDevice max32630fthr
Diff: Utilities/utils.cpp
- Revision:
- 5:795cffb6f01a
- Parent:
- 0:da5f5b56060a
--- a/Utilities/utils.cpp Thu Apr 12 13:04:59 2018 -0700
+++ b/Utilities/utils.cpp Thu May 24 14:40:48 2018 -0700
@@ -33,6 +33,7 @@
#include "utils.h"
#include <ctype.h>
+#include "Peripherals.h"
/*
* @brief Parse DeviceStudio get_reg command
@@ -82,7 +83,7 @@
int num_found = sscanf(num_start, "%x %x", &addr32, &val32);
if (num_found == 2) {
*addr = (uint8_t)addr32;
- *val = (uint8_t)val32;
+ *val = (uint16_t)val32;
return 0;
} else {
return -1;
@@ -96,9 +97,100 @@
int num_found = sscanf(num_start, "%x %x", &addr32, &val32);
if (num_found == 2) {
*addr = (uint8_t)addr32;
- *val = (uint8_t)val32;
+ *val = val32;
return 0;
} else {
return -1;
}
}
+
+int parse_cmd_data(const char* str, const char* cmd, uint8_t *vals, int vals_sz, bool hex)
+{
+ const char* sptr = str + strlen(cmd);
+ int found = 0;
+ int ssfound;
+ unsigned int val32;
+
+ while (found < vals_sz) {
+ while (*sptr != ' ' && *sptr != '\0') { sptr++; }
+ if (*sptr == '\0')
+ break;
+ sptr++;
+
+ if (hex)
+ ssfound = sscanf(sptr, "%x", &val32);
+ else
+ ssfound = sscanf(sptr, "%d", &val32);
+ if (ssfound != 1)
+ break;
+ *(vals + found) = (uint8_t)val32;
+ found++;
+ }
+
+ return found;
+}
+
+int parse_cmd_data(const char* str, const char* cmd, uint16_t *vals, int vals_sz, bool hex)
+{
+ const char* sptr = str + strlen(cmd);
+ int found = 0;
+ int ssfound;
+ unsigned int val32;
+
+ while (found < vals_sz) {
+ while (*sptr != ' ' && *sptr != '\0') { sptr++; }
+ if (*sptr == '\0')
+ break;
+ sptr++;
+
+ if (hex)
+ ssfound = sscanf(sptr, "%x", &val32);
+ else
+ ssfound = sscanf(sptr, "%d", &val32);
+ if (ssfound != 1)
+ break;
+ *(vals + found) = (uint16_t)val32;
+ found++;
+ }
+
+ return found;
+}
+
+int parse_cmd_data(const char* str, const char* cmd, uint32_t *vals, int vals_sz, bool hex)
+{
+ const char* sptr = str + strlen(cmd);
+ int found = 0;
+ int ssfound;
+
+ while (found < vals_sz) {
+ while (*sptr != ' ' && *sptr != '\0') { sptr++; }
+ if (*sptr == '\0')
+ break;
+ sptr++;
+
+ if (hex)
+ ssfound = sscanf(sptr, "%x", vals + found);
+ else
+ ssfound = sscanf(sptr, "%d", vals + found);
+ if (ssfound != 1)
+ break;
+ found++;
+ }
+
+ return found;
+}
+
+bool starts_with(const char* str1, const char* str2)
+{
+ while (*str1 && *str2) {
+ if (*str1 != *str2)
+ return false;
+ str1++;
+ str2++;
+ }
+
+ if (*str2)
+ return false;
+
+ return true;
+}
Heart Rate SpO2 Algorithm EvKit Health Monitor Development System Board MAXREFDES220