#include "pic24_all.h"
#include <stdio.h>
Go to the source code of this file.
Defines | |
#define | SERIAL_BREAK_CR |
#define | SERIAL_BREAK_NL |
#define | _LIBC_FUNCTION __attribute__((__weak__, __section__(".libc"))) |
#define | SUCCESS 0 |
#define | FAIL -1 |
#define | CHAR_ACCESS 0x4000 |
#define | DATA_ACCESS 0x8000 |
#define | READ_ACCESS 0x0 |
#define | WRITE_ACCESS 0x1 |
#define | READ_WRITE_ACCESS 0x2 |
#define | ACCESS_RW_MASK 0x3 |
#define | ACCESS_SET_OPEN DATA_ACCESS |
#define | DEFAULT_BAUDRATE1 DEFAULT_BAUDRATE |
#define | DEFAULT_BAUDRATE2 DEFAULT_BAUDRATE |
#define | DEFAULT_BAUDRATE3 DEFAULT_BAUDRATE |
#define | DEFAULT_BAUDRATE4 DEFAULT_BAUDRATE |
#define | MAX_ALLOWED_HANDLES (NUM_UART_MODS+3) |
#define | RANGECK_HANDLE(xxhandlexx) ((xxhandlexx >= 0) && (xxhandlexx < MAX_ALLOWED_HANDLES)) |
Enumerations | |
enum | ALLOWED_HANDLES { HANDLE_STDIN = 0, HANDLE_STDOUT = 1, HANDLE_STDERR = 2, HANDLE_UART1, HANDLE_UART2, HANDLE_UART3, HANDLE_UART4 } |
Functions | |
static int16 | stdioOpen (void) |
int _LIBC_FUNCTION | open (const char *name, int access, int mode) |
int _LIBC_FUNCTION | read (int handle, void *buffer, unsigned int len) |
int _LIBC_FUNCTION | write (int handle, void *buffer, unsigned int len) |
int _LIBC_FUNCTION | close (int handle) |
long _LIBC_FUNCTION | lseek (int handle, long offset, int origin) |
Variables | |
struct { | |
void(* pfnv_outChar )() | |
uint8(* pfn_inChar )() | |
uint16 u16_read_access | |
uint16 u16_write_access | |
} | FILES [MAX_ALLOWED_HANDLES] |
file1 = fopen("uart1", "r"); // uart1 open for reading text using file1 file2 = fopen("uart1", "wb"); // uart1 open for writing binary using file2 fprintf(file2, "Enter string:\n"); // binary - no "\n" substituion allowed - see open() fscanf(file1, "%s", buffer);
file3 = fopen("uart1", "r+"); // uart1 open for reading and writing text using file3 fseek(file3, 0, SEEK_END); // move to end of file for output - or use rewind() fprintf(file3, "Enter string:\n"); // text - may substitute for "\n" - see open() fseek(file3, 0, SEEK_SET); // move to start of file for input - or use rewind() fscanf(file3, "%s", buffer);
Definition in file pic24_stdio_uart.c.
int _LIBC_FUNCTION close | ( | int | handle | ) |
Stub required by fclose().
handle | not used. |
Definition at line 373 of file pic24_stdio_uart.c.
long _LIBC_FUNCTION lseek | ( | int | handle, | |
long | offset, | |||
int | origin | |||
) |
Stub required by rewind() and fseek().
handle | not used. | |
offset | not used. | |
origin | not used. |
Definition at line 386 of file pic24_stdio_uart.c.
int _LIBC_FUNCTION open | ( | const char * | name, | |
int | access, | |||
int | mode | |||
) |
Initiate I/O on UART specified by name
name | of file (UART) to open. Limited to "stdin", "stdout", "stderr", "uart1", "uart2", "uart3", and "uart4". UART number specified by __C30_UART is reserved and can only be opened as stdin, stdout, and stderr. | |
access | is a bit field. Default, 0x0, is for binary read. Set it to include 0x4000 for character translation mode: input - possible break on '\r' and '\n' - See SERIAL_BREAK_NL and SERIAL_BREAK_CR. output - possible substitutions for '\n' - See SERIAL_EOL_CR and SERIAL_EOL_CR_LF. If desired, OR it with 0x1 for write, or 0x2 for read and write. | |
mode | not used |
Definition at line 216 of file pic24_stdio_uart.c.
int _LIBC_FUNCTION read | ( | int | handle, | |
void * | buffer, | |||
unsigned int | len | |||
) |
Input len characters from UART specified for handle to buffer. Uses mode specified via open(). If handle is for stdin, calls open() with character translation read access as needed.
handle | specifies UART to read from. | |
buffer | storage for read characters. | |
len | maximum number of characters to read. |
Definition at line 297 of file pic24_stdio_uart.c.
static int16 stdioOpen | ( | void | ) | [static] |
Check __C30_UART for the UART to use. If set to 1, for example, then set up stdin, stdout, and stderr for UART1 and call configUART1() if not currently enabled.
Definition at line 143 of file pic24_stdio_uart.c.
int _LIBC_FUNCTION write | ( | int | handle, | |
void * | buffer, | |||
unsigned int | len | |||
) |
Output len characters from buffer to UART specified for handle. Uses mode specified via open(). If handle is for stdout or stderr, calls open() with character translation write access as needed.
handle | specifies UART to write to. | |
buffer | contains characters to write. | |
len | number of characters to write. |
Definition at line 336 of file pic24_stdio_uart.c.