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
util.h@2:f53340e49cc0, 2016-02-13 (annotated)
- Committer:
- flowh
- Date:
- Sat Feb 13 14:48:40 2016 +0000
- Revision:
- 2:f53340e49cc0
- Parent:
- 0:0861bf46efe4
Save on SD Card at up to at least 100Hz Acceleration, rotation velocity, compass and 5 AI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
flowh | 0:0861bf46efe4 | 1 | #ifndef UTIL |
flowh | 0:0861bf46efe4 | 2 | #define UTIL |
flowh | 0:0861bf46efe4 | 3 | #include "mbed.h" |
flowh | 0:0861bf46efe4 | 4 | |
flowh | 0:0861bf46efe4 | 5 | /* |
flowh | 0:0861bf46efe4 | 6 | ** reverse string in place |
flowh | 0:0861bf46efe4 | 7 | */ |
flowh | 0:0861bf46efe4 | 8 | void reverse(char *s) { |
flowh | 0:0861bf46efe4 | 9 | char *j; |
flowh | 0:0861bf46efe4 | 10 | int c; |
flowh | 0:0861bf46efe4 | 11 | |
flowh | 0:0861bf46efe4 | 12 | j = s + strlen(s) - 1; |
flowh | 0:0861bf46efe4 | 13 | while(s < j) { |
flowh | 0:0861bf46efe4 | 14 | c = *s; |
flowh | 0:0861bf46efe4 | 15 | *s++ = *j; |
flowh | 0:0861bf46efe4 | 16 | *j-- = c; |
flowh | 0:0861bf46efe4 | 17 | } |
flowh | 0:0861bf46efe4 | 18 | } |
flowh | 0:0861bf46efe4 | 19 | |
flowh | 0:0861bf46efe4 | 20 | void itoa(int n, char s[]) |
flowh | 0:0861bf46efe4 | 21 | { |
flowh | 0:0861bf46efe4 | 22 | int i, sign; |
flowh | 0:0861bf46efe4 | 23 | |
flowh | 0:0861bf46efe4 | 24 | if ((sign = n) < 0) /* record sign */ |
flowh | 0:0861bf46efe4 | 25 | n = -n; /* make n positive */ |
flowh | 0:0861bf46efe4 | 26 | i = 0; |
flowh | 0:0861bf46efe4 | 27 | do { /* generate digits in reverse order */ |
flowh | 0:0861bf46efe4 | 28 | s[i++] = n % 10 + '0'; /* get next digit */ |
flowh | 0:0861bf46efe4 | 29 | } while ((n /= 10) > 0); /* delete it */ |
flowh | 0:0861bf46efe4 | 30 | if (sign < 0) |
flowh | 0:0861bf46efe4 | 31 | s[i++] = '-'; |
flowh | 0:0861bf46efe4 | 32 | s[i] = '\0'; |
flowh | 0:0861bf46efe4 | 33 | reverse(s); |
flowh | 0:0861bf46efe4 | 34 | } |
flowh | 0:0861bf46efe4 | 35 | #endif |