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
00086 #include <dev/irqreg.h>
00087
00092
00093 static int AvrUart0TxIrqCtl(int cmd, void *param);
00094
00095 IRQ_HANDLER sig_UART0_TRANS = {
00096 #ifdef NUT_PERFMON
00097 0,
00098 #endif
00099 NULL,
00100 NULL,
00101 AvrUart0TxIrqCtl
00102 };
00103
00119 static int AvrUart0TxIrqCtl(int cmd, void *param)
00120 {
00121 int rc = 0;
00122 u_int *ival = (u_int *) param;
00123 int_fast8_t enabled = bit_is_set(UCR, TXCIE);
00124
00125
00126 cbi(UCR, TXCIE);
00127
00128 switch (cmd) {
00129 case NUT_IRQCTL_INIT:
00130 enabled = 0;
00131 case NUT_IRQCTL_CLEAR:
00132
00133 sbi(USR, TXC);
00134 break;
00135 case NUT_IRQCTL_STATUS:
00136 if (bit_is_set(USR, TXC)) {
00137 *ival = 1;
00138 } else {
00139 *ival = 0;
00140 }
00141 if (enabled) {
00142 *ival |= 0x80;
00143 }
00144 break;
00145 case NUT_IRQCTL_ENABLE:
00146 enabled = 1;
00147 break;
00148 case NUT_IRQCTL_DISABLE:
00149 enabled = 0;
00150 break;
00151 case NUT_IRQCTL_GETPRIO:
00152 *ival = 16;
00153 break;
00154 #ifdef NUT_PERFMON
00155 case NUT_IRQCTL_GETCOUNT:
00156 *ival = (u_int) sig_UART0_TRANS.ir_count;
00157 sig_UART0_TRANS.ir_count = 0;
00158 break;
00159 #endif
00160 default:
00161 rc = -1;
00162 break;
00163 }
00164
00165
00166 if (enabled) {
00167 sbi(UCR, TXCIE);
00168 }
00169 return rc;
00170 }
00171
00172 #if defined(SIG_UART0_TRANS) || defined(iv_USART0_TX)
00173
00177 #ifdef __IMAGECRAFT__
00178 #pragma interrupt_handler SIG_UART0_TRANS:iv_USART0_TX
00179 #endif
00180 NUTSIGNAL(SIG_UART0_TRANS, sig_UART0_TRANS)
00181 #elif defined(SIG_USART0_TRANS)
00182
00183 NUTSIGNAL(SIG_USART0_TRANS, sig_UART0_TRANS)
00184
00185 #else
00186
00190 #ifdef __IMAGECRAFT__
00191 #pragma interrupt_handler SIG_UART_TRANS:iv_UART_TX
00192 #endif
00193 NUTSIGNAL(SIG_UART_TRANS, sig_UART0_TRANS)
00194 #endif
00195