Log measurements on SD card added on DISCO-L476VG board acceleration, omega, compass & 5 Analog values
Dependencies: BSP_DISCO_L476VG COMPASS_DISCO_L476VG ConfigFile GYRO_DISCO_L476VG SDFileSystem mbed
Diff: util.h
- Revision:
- 0:0861bf46efe4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util.h Fri Feb 12 20:54:38 2016 +0000 @@ -0,0 +1,35 @@ +#ifndef UTIL +#define UTIL +#include "mbed.h" + +/* +** reverse string in place +*/ +void reverse(char *s) { +char *j; +int c; + + j = s + strlen(s) - 1; + while(s < j) { + c = *s; + *s++ = *j; + *j-- = c; + } +} + + void itoa(int n, char s[]) + { + int i, sign; + + if ((sign = n) < 0) /* record sign */ + n = -n; /* make n positive */ + i = 0; + do { /* generate digits in reverse order */ + s[i++] = n % 10 + '0'; /* get next digit */ + } while ((n /= 10) > 0); /* delete it */ + if (sign < 0) + s[i++] = '-'; + s[i] = '\0'; + reverse(s); + } + #endif \ No newline at end of file