⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avr_stdio.h

📁 tinyos2.0版本驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
#define __SSTR	0x0004		/* this is an sprintf/snprintf string */#define __SPGM	0x0008		/* fmt string is in progmem */#define __SERR	0x0010		/* found error */#define __SEOF	0x0020		/* found EOF */#define __SUNGET 0x040		/* ungetc() happened */#define __SMALLOC 0x80		/* handle is malloc()ed */#if 0/* possible future extensions, will require uint16_t flags */#define __SRW	0x0100		/* open for reading & writing */#define __SLBF	0x0200		/* line buffered */#define __SNBF	0x0400		/* unbuffered */#define __SMBF	0x0800		/* buf is from malloc */#endif	int	size;		/* size of buffer */	int	len;		/* characters read or written so far */	int	(*put)(char, struct __file *);	/* function to write one char to device */	int	(*get)(struct __file *);	/* function to read one char from device */	void	*udata;		/* User defined and accessible data. */};#endif /* not __DOXYGEN__ *//*@{*//**   \c FILE is the opaque structure that is passed around between the   various standard IO functions.*/#define FILE	struct __file/**   Stream that will be used as an input stream by the simplified   functions that don't take a \c stream argument.   The first stream opened with read intent using \c fdevopen()   will be assigned to \c stdin.*/#define stdin (__iob[0])/**   Stream that will be used as an output stream by the simplified   functions that don't take a \c stream argument.   The first stream opened with write intent using \c fdevopen()   will be assigned to both, \c stdin, and \c stderr.*/#define stdout (__iob[1])/**   Stream destined for error output.  Unless specifically assigned,   identical to \c stdout.   If \c stderr should point to another stream, the result of   another \c fdevopen() must be explicitly assigned to it without   closing the previous \c stderr (since this would also close   \c stdout).*/#define stderr (__iob[2])/**   \c EOF declares the value that is returned by various standard IO   functions in case of an error.  Since the AVR platform (currently)   doesn't contain an abstraction for actual files, its origin as   "end of file" is somewhat meaningless here.*/#define EOF	(-1)/** This macro inserts a pointer to user defined data into a FILE    stream object.    The user data can be useful for tracking state in the put and get    functions supplied to the fdevopen() function. */#define fdev_set_udata(stream, u) do { (stream)->udata = u; } while(0)/** This macro retrieves a pointer to user defined data from a FILE    stream object. */#define fdev_get_udata(stream) ((stream)->udata)#if defined(__DOXYGEN__)/**   \brief Setup a user-supplied buffer as an stdio stream   This macro takes a user-supplied buffer \c stream, and sets it up   as a stream that is valid for stdio operations, similar to one that   has been obtained dynamically from fdevopen(). The buffer to setup   must be of type FILE.   The arguments \c put and \c get are identical to those that need to   be passed to fdevopen().   The \c rwflag argument can take one of the values _FDEV_SETUP_READ,   _FDEV_SETUP_WRITE, or _FDEV_SETUP_RW, for read, write, or read/write   intent, respectively.   \note No assignments to the standard streams will be performed by   fdev_setup_stream().  If standard streams are to be used, these   need to be assigned by the user.  See also under   \ref stdio_without_malloc "Running stdio without malloc()". */#define fdev_setup_stream(stream, put, get, rwflag)#else  /* !DOXYGEN */#define fdev_setup_stream(stream, p, g, f) \	do { \		(stream)->put = p; \		(stream)->get = g; \		(stream)->flags = f; \		(stream)->udata = 0; \	} while(0)#endif /* DOXYGEN */#define _FDEV_SETUP_READ  __SRD	/**< fdev_setup_stream() with read intent */#define _FDEV_SETUP_WRITE __SWR	/**< fdev_setup_stream() with write intent */#define _FDEV_SETUP_RW    (__SRD|__SWR)	/**< fdev_setup_stream() with read/write intent *//** * Return code for an error condition during device read. * * To be used in the get function of fdevopen(). */#define _FDEV_ERR (-1)/** * Return code for an end-of-file condition during device read. * * To be used in the get function of fdevopen(). */#define _FDEV_EOF (-2)#if defined(__DOXYGEN__)/**   \brief Initializer for a user-supplied stdio stream   This macro acts similar to fdev_setup_stream(), but it is to be   used as the initializer of a variable of type FILE.   The remaining arguments are to be used as explained in   fdev_setup_stream(). */#define FDEV_SETUP_STREAM(put, get, rwflag)#else  /* !DOXYGEN */#define FDEV_SETUP_STREAM(p, g, f) \	{ \		.put = p, \		.get = g, \		.flags = f, \		.udata = 0, \	}#endif /* DOXYGEN */#ifdef __cplusplusextern "C" {#endif#if !defined(__DOXYGEN__)/* * Doxygen documentation can be found in fdevopen.c. */extern struct __file *__iob[];#if defined(__STDIO_FDEVOPEN_COMPAT_12)/* * Declare prototype for the discontinued version of fdevopen() that * has been in use up to avr-libc 1.2.x.  The new implementation has * some backwards compatibility with the old version. */extern FILE *fdevopen(int (*__put)(char), int (*__get)(void),                      int __opts __attribute__((unused)));#else  /* !defined(__STDIO_FDEVOPEN_COMPAT_12) *//* New prototype for avr-libc 1.4 and above. */extern FILE *fdevopen(int (*__put)(char, FILE*), int (*__get)(FILE*));#endif /* defined(__STDIO_FDEVOPEN_COMPAT_12) */#endif /* not __DOXYGEN__ *//**   This function closes \c stream, and disallows and further   IO to and from it.   When using fdevopen() to setup the stream, a call to fclose() is   needed in order to free the internal resources allocated.   If the stream has been set up using fdev_setup_stream() or   FDEV_SETUP_STREAM(), use fdev_close() instead.   It currently always returns 0 (for success).*/extern int	fclose(FILE *__stream);/**   This macro frees up any library resources that might be associated   with \c stream.  It should be called if \c stream is no longer   needed, right before the application is going to destroy the   \c stream object itself.   (Currently, this macro evaluates to nothing, but this might change   in future versions of the library.)*/#if defined(__DOXYGEN__)# define fdev_close()#else# define fdev_close() ((void)0)#endif/**   \c vfprintf is the central facility of the \c printf family of   functions.  It outputs values to \c stream under control of a   format string passed in \c fmt.  The actual values to print are   passed as a variable argument list \c ap.   \c vfprintf returns the number of characters written to \c stream,   or \c EOF in case of an error.  Currently, this will only happen   if \c stream has not been opened with write intent.   The format string is composed of zero or more directives: ordinary   characters (not \c %), which are copied unchanged to the output   stream; and conversion specifications, each of which results in   fetching zero or more subsequent arguments.  Each conversion   specification is introduced by the \c % character.  The arguments must   properly correspond (after type promotion) with the conversion   specifier.  After the \c %, the following appear in sequence:   - Zero or more of the following flags:      <ul>      <li> \c # The value should be converted to an "alternate form".  For            c, d, i, s, and u conversions, this option has no effect.            For o conversions, the precision of the number is            increased to force the first character of the output            string to a zero (except if a zero value is printed with            an explicit precision of zero).  For x and X conversions,            a non-zero result has the string `0x' (or `0X' for X            conversions) prepended to it.</li>      <li> \c 0 (zero) Zero padding.  For all conversions, the converted            value is padded on the left with zeros rather than blanks.            If a precision is given with a numeric conversion (d, i,            o, u, i, x, and X), the 0 flag is ignored.</li>      <li> \c - A negative field width flag; the converted value is to be            left adjusted on the field boundary.  The converted value            is padded on the right with blanks, rather than on the            left with blanks or zeros.  A - overrides a 0 if both are            given.</li>      <li> ' ' (space) A blank should be left before a positive number            produced by a signed conversion (d, or i).</li>      <li> \c + A sign must always be placed before a number produced by a            signed conversion.  A + overrides a space if both are            used.</li>      </ul>         -   An optional decimal digit string specifying a minimum field width.       If the converted value has fewer characters than the field width, it       will be padded with spaces on the left (or right, if the left-adjust

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -