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

Committer:
flowh
Date:
2016-02-13
Revision:
2:f53340e49cc0
Parent:
0:0861bf46efe4

File content as of revision 2:f53340e49cc0:

#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