00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #include <kernel.h> 00010 #include <uart.h> 00011 #include <device.h> 00012 00020 devcall uartControl(device *pdev, int func, unsigned char arg1, unsigned char arg2) 00021 { 00022 struct uart *puart = (struct uart *)pdev->controlblk; 00023 char temp; 00024 00025 switch (func) 00026 { 00027 00028 /* Set input mode flags: arg1 = flags to set */ 00029 /* return = old value of flags */ 00030 case UART_IOC_SETIFLAG: 00031 temp = puart->iflags & arg1; 00032 puart->iflags |= (arg1); 00033 return temp; 00034 00035 /* Clear input mode flags: arg1 = flags to clear */ 00036 /* return = old value of flags */ 00037 case UART_IOC_CLRIFLAG: 00038 temp = puart->iflags & arg1; 00039 puart->iflags &= ~(arg1); 00040 return temp; 00041 00042 /* Get input flags: return = current value of flags */ 00043 case UART_IOC_GETIFLAG: 00044 return puart->iflags; 00045 00046 /* Set output mode flags: arg1 = flags to set */ 00047 /* return = old value of flags */ 00048 case UART_IOC_SETOFLAG: 00049 temp = puart->oflags & arg1; 00050 puart->oflags |= (arg1); 00051 return temp; 00052 00053 /* Clear output mode flags: arg1 = flags to clear */ 00054 /* return = old value of flags */ 00055 case UART_IOC_CLROFLAG: 00056 temp = puart->oflags & arg1; 00057 puart->oflags &= ~(arg1); 00058 return temp; 00059 00060 /* Get output flags: return = current value of flags */ 00061 case UART_IOC_GETOFLAG: 00062 return puart->oflags; 00063 00064 /* Determine if the UART transmitter is idle, return TRUE if idle */ 00065 case UART_IOC_OUTPUT_IDLE: 00066 return puart->oidle; 00067 00068 } 00069 return SYSERR; 00070 }