Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
507 kaklik 1
/*---------------------------------------------------------------------------
2
   Extended itoa, puts and printf                    (C)ChaN, 2006
3
 
4
-----------------------------------------------------------------------------*/
5
 
6
#ifndef XITOA
7
#define XITOA
8
 
9
#include <avr/pgmspace.h>
10
#include "xitoa.S"
11
 
12
extern void (*xfunc_out)(char);
13
 
14
/* This is a pointer to user defined output function. It must be initialized
15
   before using this modle.
16
*/
17
 
18
void xputc(char chr);
19
 
20
/* This is a stub function to forward outputs to user defined output function.
21
   All outputs from this module are output via this function.
22
*/
23
 
24
 
25
/*-----------------------------------------------------------------------------*/
26
void xputs(const prog_char *string);
27
 
28
/*  The string placed in the ROM is forwarded to xputc() directly.
29
*/
30
 
31
 
32
/*-----------------------------------------------------------------------------*/
33
void xitoa(long value, char radix, char width);
34
 
35
/* Extended itoa().
36
 
37
      value  radix  width   output
38
        100     10      6   "   100"
39
        100     10     -6   "000100"
40
        100     10      0   "100"
41
 4294967295     10      0   "4294967295"
42
 4294967295    -10      0   "-1"
43
     655360     16     -8   "000A0000"
44
       1024     16      0   "400"
45
       0x55      2     -8   "01010101"
46
*/
47
 
48
 
49
/*-----------------------------------------------------------------------------*/
50
void xprintf(const prog_char *format, ...);
51
 
52
/* Format string is placed in the ROM. The format flags is similar to printf().
53
 
54
   %[flag][width][size]type
55
 
56
   flag
57
     A '0' means filled with '0' when output is shorter than width.
58
     ' ' is used in default. This is effective only numeral type.
59
   width
60
     Minimum width in decimal number. This is effective only numeral type.
61
     Default width is zero.
62
   size
63
     A 'l' means the argument is long(32bit). Default is short(16bit).
64
     This is effective only numeral type.
65
   type
66
     'c' : Character, argument is the value
67
     's' : String placed on the RAM, argument is the pointer
68
     'S' : String placed on the ROM, argument is the pointer
69
     'd' : Signed decimal, argument is the value
70
     'u' : Unsigned decimal, argument is the value
71
     'X' : Hex decimal, argument is the value
72
     'b' : Binary, argument is the value
73
     '%' : '%'
74
 
75
*/
76
 
77
 
78
/*-----------------------------------------------------------------------------*/
79
char xatoi(char **str, long *ret);
80
 
81
/* Get value of the numeral string. 
82
 
83
  str
84
    Pointer to pointer to source string
85
 
86
    "0b11001010" binary
87
    "0377" octal
88
    "0xff800" hexdecimal
89
    "1250000" decimal
90
    "-25000" decimal
91
 
92
  ret
93
    Pointer to return value
94
*/
95
 
96
#endif	/* XITOA */
97