Previous

Next

Bottom

Contents

Glossary

Index

 

CF1 User's Manual

Console I/O Functions

May 1999

Revision 1.03

 Persistor Instruments Inc.
© 1998 All rights reserved.

Quick Reference Table

CIOkbhit

CIOkbflush

CIOgetch

CIOputch

CIOputflush

CIOgetstr

CIOputstr

CIOprintf

CIOhexdump

Primary Console Macro Functions

cdrain

cgetc

cgetq

cgets

chexdump

ciflush

coflush

cprintf

cputc

cputs

Legacy/Compatability Macro Functions

getch

getstr

hexdump

kbflush

kbhit

putch

putflush

putstr

uprintf

Background

The Console I/O functions provide patchable low level access to your routines that interact with a user through a console interface. By default, all of these functions work through the onboard 68338 SCI (Serial Controller Interface), and all the PicoDOS command shell functions work through CIO functions, as do the default standard library console functions.

Macro Functions
getch -- Wait for and return the next byte

This function will wait for and retrieve the next incoming byte on the main UART.

Prototype:

short getch(void);

Definition:

#include <cf1bios.h>

Returns:

The character gotten from the UART is returned in the low byte of the short and the high byte contains error codes.

Notes:

getch() is a macro to SCIRxGetChar()
See STDIO Warning.
See Error Codes.

Timing:

Dependent on the serial line and buffer conditions.

kbflush -- Empty the input buffer and return

kbflush() will empty the receive buffer and return immediately regardless of buffer contents or buffering mode.

Prototype:

void kbflush(void);

Definition:

#include <cf1bios.h>

Notes:

kbflush() is a macro to (SCIRxGetCharWaitIdle(1) != 1)
See STDIO Warning.

Timing:

Dependent on the serial line and buffer conditions.

kbhit -- Detect the availability of a character on the UART

This function returns nonzero if there is a character available to receive on the main serial port. It's behavior depends also on the buffering mode currently in effect. In interrupt-driven mode, kbhit() should return the number of characters available. In polled mode, kbhit() will return either 0 or non zero if there is a character available.

Prototype:

short kbhit(void);

Definition:

#include <cf1bios.h>

Returns:

Returns true if there is a character available, false if there is not. (see notes)

Notes:

kbhit() is a macro to SCIRxQueuedCount()
See STDIO Warning.

Timing:

approx. 6 µsec @ 16MHz

putch -- Writes a byte out the main UART

This command takes the LSB of data and puts it in the transmit queue of the main UART. If the SCI is in polled mode, putch() will wait for the transmit queue to be empty and then write the LSB of data to the main UART. The MSB of data is always ignored.

Prototype:

void putch(ushort data);

Definition:

#include <cf1bios.h>

Inputs:

data is a ushort, the LSB of which is the character you wish to transmit.

Notes:

putch(c) is a macro to SCITxPutChar(c)
See STDIO Warning.

Timing:

Depends upon baud rate.

putflush -- Wait for all transmission to complete.

This will wait for the transmit buffer to be empty and then return. Behavior is the same regardless of buffering mode, however timing may vary.

Prototype:

void putflush (void);

Definition:

#include <cf1bios.h>

Notes:

putflush() is a macro to SCITxWaitCompletion()
See STDIO Warning.

Timing:

Depends on buffering mode, buffer conditions, and baud rate.

putstr -- Write a NULL terminated string to the main UART

Writes the NULL terminated string pointed to by str to the transmit queue of the main UART. putstr() will not append any characters to the end of any string passed to it, however it will replace any "newline" characters (/n) already in the string with CRLF sequences before inserting it into the buffer.

Prototype:

void putstr (const char *str);

Definition:

#include <cf1bios.h>

Inputs:

str is a pointer to a NULL terminated string.

Notes:

putstr(s) is a macro to SCITxPutStr(s)
See STDIO Warning.

Timing:

Depends on baud rate and buffering mode.

uprintf -- A clone of stdio's printf without floating point support

Provides the same functionality as the ANSI C library function printf() with respect to the main UART, excepting floating point number display support. The types float, double and long long, cannot be output by uprintf(). Full documentation of the printf() function and its many format specifiers and conventions is beyond the scope of this BIOS manual, please see an ANSI function reference for a more detailed description of printf() usage.

Prototype:

void uprintf (const char *format, ...);

Definition:

#include <cf1bios.h>

Inputs:

See ANSI C documentation of printf function arguments and behavior.

Notes:

uprintf() is a macro to SCITxPrintf ()
See STDIO Warning.

Timing:

Depends on arguments, buffering mode, buffer conditions and baud rate.

 

Previous

Next

Top

Contents

Glossary

Index

Tel: 508-759-6434

Fax: 508-759-6436

Copyright (C) 1998 Persistor Instruments Inc. - All Rights Reserved