pic_therm

PIC16F877A and BME280 thermometer
git clone git://git.margiolis.net/pic_therm.git
Log | Files | Refs | README | LICENSE

util.c (379B)


      1 #include "util.h"
      2 
      3 /*
      4  * To avoid reversing the string, the caller has to provide a pointer to the
      5  * end of the string.
      6  */
      7 char *
      8 itoa(char *s, int n)
      9 {
     10 	*s = '\0';
     11 	if (n == 0)
     12 		*--s = '0';
     13 	for (; n; n /= 10)
     14 		*--s = n % 10 + '0';
     15 	return (s);
     16 }
     17 
     18 void *
     19 memset(void *dst, int v, int len)
     20 {
     21 	unsigned char *dst0;
     22 
     23 	dst0 = dst;
     24 	while (len--)
     25 		*dst0++ = v;
     26 	return (dst);
     27 }