Go to the documentation of this file.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
00080 #include <dev/irqreg.h>
00081
00086
00087 #if defined(SIG_UART1_RECV) || defined(iv_USART1_RX) || defined(SIG_USART1_RECV)
00088
00089 static int AvrUart1RxIrqCtl(int cmd, void *param);
00090
00091 IRQ_HANDLER sig_UART1_RECV = {
00092 #ifdef NUT_PERFMON
00093 0,
00094 #endif
00095 NULL,
00096 NULL,
00097 AvrUart1RxIrqCtl
00098 };
00099
00115 static int AvrUart1RxIrqCtl(int cmd, void *param)
00116 {
00117 int rc = 0;
00118 unsigned int *ival = (unsigned int *) param;
00119 int_fast8_t enabled = bit_is_set(UCSR1B, RXCIE1);
00120 uint8_t bval;
00121
00122
00123 cbi(UCSR1B, RXCIE1);
00124
00125 switch (cmd) {
00126 case NUT_IRQCTL_INIT:
00127 enabled = 0;
00128 case NUT_IRQCTL_CLEAR:
00129
00130 bval = inb(UDR1);
00131 bval = inb(UDR1);
00132 break;
00133 case NUT_IRQCTL_STATUS:
00134 if (bit_is_set(UCSR1A, RXC1)) {
00135 *ival = 1;
00136 } else {
00137 *ival = 0;
00138 }
00139 if (enabled) {
00140 *ival |= 0x80;
00141 }
00142 break;
00143 case NUT_IRQCTL_ENABLE:
00144 enabled = 1;
00145 break;
00146 case NUT_IRQCTL_DISABLE:
00147 enabled = 0;
00148 break;
00149 case NUT_IRQCTL_GETPRIO:
00150 *ival = 16;
00151 break;
00152 #ifdef NUT_PERFMON
00153 case NUT_IRQCTL_GETCOUNT:
00154 *ival = (unsigned int) sig_UART1_RECV.ir_count;
00155 sig_UART1_RECV.ir_count = 0;
00156 break;
00157 #endif
00158 default:
00159 rc = -1;
00160 break;
00161 }
00162
00163
00164 if (enabled) {
00165 sbi(UCSR1B, RXCIE1);
00166 }
00167 return rc;
00168 }
00169
00173 #if defined(SIG_UART1_RECV) || defined(iv_USART1_RX)
00174 #ifdef __IMAGECRAFT__
00175 #pragma interrupt_handler SIG_UART1_RECV:iv_USART1_RX
00176 #endif
00177 NUTSIGNAL(SIG_UART1_RECV, sig_UART1_RECV)
00178 #elif defined(SIG_USART1_RECV)
00179 NUTSIGNAL(SIG_USART1_RECV, sig_UART1_RECV)
00180 #endif
00181
00182 #endif
00183