mirror of https://github.com/zrafa/xinu-avr.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
/* ttyputc.c - ttyputc */ |
|
|
|
#include <xinu.h> |
|
|
|
/*------------------------------------------------------------------------ |
|
* ttyputc - Write one character to a tty device (interrupts disabled) |
|
*------------------------------------------------------------------------ |
|
*/ |
|
devcall ttyputc( |
|
// struct dentry *devptr, /* Entry in device switch table */ |
|
const __flash struct dentry *devptr, /* Entry in device switch table */ |
|
char ch /* Character to write */ |
|
) |
|
{ |
|
struct ttycblk *typtr; /* Pointer to tty control block */ |
|
|
|
typtr = &ttytab[devptr->dvminor]; |
|
|
|
/* Handle output CRLF by sending CR first */ |
|
|
|
if ( ch==TY_NEWLINE && typtr->tyocrlf ) { |
|
ttyputc(devptr, TY_RETURN); |
|
} |
|
|
|
wait(typtr->tyosem); /* Wait for space in queue */ |
|
*typtr->tyotail++ = ch; |
|
|
|
/* Wrap around to beginning of buffer, if needed */ |
|
|
|
if (typtr->tyotail >= &typtr->tyobuff[TY_OBUFLEN]) { |
|
typtr->tyotail = typtr->tyobuff; |
|
} |
|
|
|
/* Start output in case device is idle */ |
|
|
|
ttykickout((struct uart_csreg *)devptr->dvcsr); |
|
|
|
return OK; |
|
}
|
|
|