Browse Source

removed dependency on sprintf which caused gcc to puke (shock and horror).

uses code from here:
http://groups.google.com/group/comp.lang.c/msg/66552ef8b04fe1ab?pli=1

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@119 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
master
timecop 13 years ago
parent
commit
c1cb4287b7
  1. 44
      baseflight.uvopt
  2. 5458
      obj/baseflight.hex
  3. 36
      src/cli.c

44
baseflight.uvopt

@ -161,21 +161,6 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>309</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218890</Address>
<ByteObject>0</ByteObject>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename></Filename>
<ExecCommand></ExecCommand>
<Expression>\\baseflight\src/cli.c\309</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>58</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134242932</Address>
@ -188,21 +173,6 @@
<ExecCommand></ExecCommand>
<Expression>\\baseflight\src/drv_mpu6050.c\58</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>316</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134218956</Address>
<ByteObject>0</ByteObject>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename></Filename>
<ExecCommand></ExecCommand>
<Expression>\\baseflight\src/cli.c\316</Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
@ -537,8 +507,8 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>296</TopLine>
<CurrentLine>314</CurrentLine>
<TopLine>1</TopLine>
<CurrentLine>1</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\cli.c</PathWithFileName>
<FilenameWithoutPath>cli.c</FilenameWithoutPath>
@ -549,10 +519,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<ColumnNumber>31</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>91</TopLine>
<CurrentLine>120</CurrentLine>
<TopLine>1</TopLine>
<CurrentLine>11</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\config.c</PathWithFileName>
<FilenameWithoutPath>config.c</FilenameWithoutPath>
@ -782,8 +752,8 @@
<Focus>0</Focus>
<ColumnNumber>22</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>85</TopLine>
<CurrentLine>111</CurrentLine>
<TopLine>34</TopLine>
<CurrentLine>46</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>.\src\drv_system.c</PathWithFileName>
<FilenameWithoutPath>drv_system.c</FilenameWithoutPath>

5458
obj/baseflight.hex
File diff suppressed because it is too large
View File

36
src/cli.c

@ -86,6 +86,40 @@ const clivalue_t valueTable[] = {
static void cliSetVar(const clivalue_t *var, const int32_t value);
static void cliPrintVar(const clivalue_t *var);
/*
** The following two functions together make up an itoa()
** implementation. Function i2a() is a 'private' function
** called by the public itoa() function.
**
** itoa() takes three arguments:
** 1) the integer to be converted,
** 2) a pointer to a character conversion buffer,
** 3) the radix for the conversion
** which can range between 2 and 36 inclusive
** range errors on the radix default it to base10
** Code from http://groups.google.com/group/comp.lang.c/msg/66552ef8b04fe1ab?pli=1
*/
static char *i2a(unsigned i, char *a, unsigned r)
{
if (i / r > 0)
a = i2a(i / r, a, r);
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % r];
return a + 1;
}
char *itoa(int i, char *a, int r)
{
if ((r < 2) || (r > 36))
r = 10;
if (i < 0) {
*a = '-';
*i2a(-(unsigned)i, a + 1, r) = 0;
} else
*i2a(i, a, r) = 0;
return a;
}
static void cliPrompt(void)
{
uartPrint("\r\n# ");
@ -259,7 +293,7 @@ static void cliPrintVar(const clivalue_t *var)
value = *(int16_t *)var->ptr;
break;
}
snprintf(buf, 16, "%d", value);
itoa(value, buf, 10);
uartPrint(buf);
}

Loading…
Cancel
Save