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
00087 #include <dev/irqreg.h>
00088
00093
00094 #if defined(SIG_UART1_TRANS) || defined(iv_USART1_TX) || defined(SIG_USART1_TRANS)
00095
00096 static int AvrUart1TxIrqCtl(int cmd, void *param);
00097
00098 IRQ_HANDLER sig_UART1_TRANS = {
00099 #ifdef NUT_PERFMON
00100 0,
00101 #endif
00102 NULL,
00103 NULL,
00104 AvrUart1TxIrqCtl
00105 };
00106
00122 static int AvrUart1TxIrqCtl(int cmd, void *param)
00123 {
00124 int rc = 0;
00125 unsigned int *ival = (unsigned int *) param;
00126 int_fast8_t enabled = bit_is_set(UCSR1B, TXCIE1);
00127
00128
00129 cbi(UCSR1B, TXCIE1);
00130
00131 switch (cmd) {
00132 case NUT_IRQCTL_INIT:
00133 enabled = 0;
00134 case NUT_IRQCTL_CLEAR:
00135
00136 sbi(UCSR1A, TXC1);
00137 break;
00138 case NUT_IRQCTL_STATUS:
00139 if (bit_is_set(UCSR1A, TXC1)) {
00140 *ival = 1;
00141 } else {
00142 *ival = 0;
00143 }
00144 if (enabled) {
00145 *ival |= 0x80;
00146 }
00147 break;
00148 case NUT_IRQCTL_ENABLE:
00149 enabled = 1;
00150 break;
00151 case NUT_IRQCTL_DISABLE:
00152 enabled = 0;
00153 break;
00154 case NUT_IRQCTL_GETPRIO:
00155 *ival = 16;
00156 break;
00157 #ifdef NUT_PERFMON
00158 case NUT_IRQCTL_GETCOUNT:
00159 *ival = (unsigned int) sig_UART1_TRANS.ir_count;
00160 sig_UART1_TRANS.ir_count = 0;
00161 break;
00162 #endif
00163 default:
00164 rc = -1;
00165 break;
00166 }
00167
00168
00169 if (enabled) {
00170 sbi(UCSR1B, TXCIE1);
00171 }
00172 return rc;
00173 }
00174
00178 #if defined(SIG_UART1_TRANS) || defined(iv_USART1_TX)
00179 #ifdef __IMAGECRAFT__
00180 #pragma interrupt_handler SIG_UART1_TRANS:iv_USART1_TX
00181 #endif
00182 NUTSIGNAL(SIG_UART1_TRANS, sig_UART1_TRANS)
00183 #elif defined(SIG_USART1_TRANS)
00184 NUTSIGNAL(SIG_USART1_TRANS, sig_UART1_TRANS)
00185 #endif
00186
00187 #endif
00188