00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00083 #include <dev/irqreg.h>
00084
00089
00090 static int AvrUart0TxIrqCtl(int cmd, void *param);
00091
00092 IRQ_HANDLER sig_UART0_TRANS = {
00093 #ifdef NUT_PERFMON
00094 0,
00095 #endif
00096 NULL,
00097 NULL,
00098 AvrUart0TxIrqCtl
00099 };
00100
00116 static int AvrUart0TxIrqCtl(int cmd, void *param)
00117 {
00118 int rc = 0;
00119 u_int *ival = (u_int *) param;
00120 int enabled = bit_is_set(UCR, TXCIE);
00121
00122
00123 cbi(UCR, TXCIE);
00124
00125 switch (cmd) {
00126 case NUT_IRQCTL_INIT:
00127 enabled = 0;
00128 case NUT_IRQCTL_CLEAR:
00129
00130 sbi(USR, TXC);
00131 break;
00132 case NUT_IRQCTL_STATUS:
00133 if (bit_is_set(USR, TXC)) {
00134 *ival = 1;
00135 } else {
00136 *ival = 0;
00137 }
00138 if (enabled) {
00139 *ival |= 0x80;
00140 }
00141 break;
00142 case NUT_IRQCTL_ENABLE:
00143 enabled = 1;
00144 break;
00145 case NUT_IRQCTL_DISABLE:
00146 enabled = 0;
00147 break;
00148 case NUT_IRQCTL_GETPRIO:
00149 *ival = 16;
00150 break;
00151 #ifdef NUT_PERFMON
00152 case NUT_IRQCTL_GETCOUNT:
00153 *ival = (u_int) sig_UART0_TRANS.ir_count;
00154 sig_UART0_TRANS.ir_count = 0;
00155 break;
00156 #endif
00157 default:
00158 rc = -1;
00159 break;
00160 }
00161
00162
00163 if (enabled) {
00164 sbi(UCR, TXCIE);
00165 }
00166 return rc;
00167 }
00168
00169 #if defined(SIG_UART0_TRANS) || defined(iv_USART0_TX)
00170
00174 #ifdef __IMAGECRAFT__
00175 #pragma interrupt_handler SIG_UART0_TRANS:iv_USART0_TX
00176 #endif
00177 NUTSIGNAL(SIG_UART0_TRANS, sig_UART0_TRANS)
00178 #elif defined(SIG_USART0_TRANS)
00179
00180 NUTSIGNAL(SIG_USART0_TRANS, sig_UART0_TRANS)
00181
00182 #else
00183
00187 #ifdef __IMAGECRAFT__
00188 #pragma interrupt_handler SIG_UART_TRANS:iv_UART_TX
00189 #endif
00190 NUTSIGNAL(SIG_UART_TRANS, sig_UART0_TRANS)
00191 #endif
00192