write.c File Reference


Detailed Description

System-specific implementation of the __write function used by the standard library.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file write.c.

#include <yfuns.h>
#include <avr32/io.h>
#include "usart.h"

Go to the source code of this file.

Functions

size_t __write (int handle, const unsigned char *buffer, size_t size)
 Writes a number of bytes, at most size, from the memory area pointed to by buffer.

Variables

_STD_BEGIN __no_init volatile
avr32_usart_t *volatile 
stdio_usart_base
 Pointer to the base of the USART module instance to use for stdio.


Function Documentation

size_t __write ( int  handle,
const unsigned char *  buffer,
size_t  size 
)

Writes a number of bytes, at most size, from the memory area pointed to by buffer.

If buffer is zero then __write performs flushing of internal buffers, if any. In this case, handle can be -1 to indicate that all handles should be flushed.

Parameters:
handle File handle to write to.
buffer Pointer to buffer to read bytes to write from.
size Number of bytes to write.
Returns:
The number of bytes written, or _LLIO_ERROR on failure.

Definition at line 75 of file write.c.

References stdio_usart_base.

00076 {
00077   size_t nChars = 0;
00078 
00079   if (buffer == 0)
00080   {
00081     // This means that we should flush internal buffers.
00082     return 0;
00083   }
00084 
00085   // This implementation only writes to stdout and stderr.
00086   // For all other file handles, it returns failure.
00087   if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR)
00088   {
00089     return _LLIO_ERROR;
00090   }
00091 
00092   for (; size != 0; --size)
00093   {
00094     if (usart_putchar(stdio_usart_base, *buffer++) < 0)
00095     {
00096       return _LLIO_ERROR;
00097     }
00098 
00099     ++nChars;
00100   }
00101 
00102   return nChars;
00103 }


Variable Documentation

_STD_BEGIN __no_init volatile avr32_usart_t* volatile stdio_usart_base

Pointer to the base of the USART module instance to use for stdio.

Definition at line 59 of file write.c.

Referenced by __low_level_init(), __read(), and __write().


Generated on Thu Dec 17 20:02:02 2009 for AVR32 UC3 - FreeRTOS Real Time Kernel by  doxygen 1.5.5