ih_timer3_compb.c
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
00087 #include <dev/irqreg.h>
00088
00089 #if defined(MCU_AT90CAN128) || defined(MCU_ATMEGA2560) || defined(MCU_ATMEGA2561)
00090 #define INT_MASK_REG TIMSK3
00091 #define INT_STATUS_REG TIFR3
00092 #define INT_ENABLE_BIT OCIE3B
00093 #define INT_STATUS_BIT OCF3B
00094 #define INT_PRIORITY 11
00095 #else
00096 #define INT_MASK_REG ETIMSK
00097 #define INT_STATUS_REG ETIFR
00098 #define INT_ENABLE_BIT OCIE3B
00099 #define INT_STATUS_BIT OCF3B
00100 #define INT_PRIORITY 11
00101 #endif
00102
00107
00108 #if defined(SIG_OUTPUT_COMPARE3B) || defined(iv_TIMER3_COMPB)
00109
00110 static int AvrTimer3CompBIrqCtl(int cmd, void *param);
00111
00112 IRQ_HANDLER sig_OUTPUT_COMPARE3B = {
00113 #ifdef NUT_PERFMON
00114 0,
00115 #endif
00116 NULL,
00117 NULL,
00118 AvrTimer3CompBIrqCtl
00119 };
00120
00136 static int AvrTimer3CompBIrqCtl(int cmd, void *param)
00137 {
00138 int rc = 0;
00139 unsigned int *ival = (unsigned int *) param;
00140 int_fast8_t enabled = bit_is_set(INT_MASK_REG, INT_ENABLE_BIT);
00141
00142
00143 cbi(INT_MASK_REG, INT_ENABLE_BIT);
00144
00145 switch (cmd) {
00146 case NUT_IRQCTL_INIT:
00147 enabled = 0;
00148 case NUT_IRQCTL_CLEAR:
00149
00150 outb(INT_STATUS_REG, _BV(INT_STATUS_BIT));
00151 break;
00152 case NUT_IRQCTL_STATUS:
00153 if (bit_is_set(INT_STATUS_REG, INT_STATUS_BIT)) {
00154 *ival = 1;
00155 } else {
00156 *ival = 0;
00157 }
00158 if (enabled) {
00159 *ival |= 0x80;
00160 }
00161 break;
00162 case NUT_IRQCTL_ENABLE:
00163 enabled = 1;
00164 break;
00165 case NUT_IRQCTL_DISABLE:
00166 enabled = 0;
00167 break;
00168 case NUT_IRQCTL_GETPRIO:
00169 *ival = INT_PRIORITY;
00170 break;
00171 #ifdef NUT_PERFMON
00172 case NUT_IRQCTL_GETCOUNT:
00173 *ival = (unsigned int) sig_OUTPUT_COMPARE3B.ir_count;
00174 sig_OUTPUT_COMPARE3B.ir_count = 0;
00175 break;
00176 #endif
00177 default:
00178 rc = -1;
00179 break;
00180 }
00181
00182
00183 if (enabled) {
00184 sbi(INT_MASK_REG, INT_ENABLE_BIT);
00185 }
00186 return rc;
00187 }
00188
00192 #ifdef __IMAGECRAFT__
00193 #pragma interrupt_handler SIG_OUTPUT_COMPARE3B:iv_TIMER3_COMPB
00194 #endif
00195 NUTSIGNAL(SIG_OUTPUT_COMPARE3B, sig_OUTPUT_COMPARE3B)
00196 #endif
00197