00001 /* 00002 * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")" 00003 * All rights reserved. 00004 * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University) 00005 * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University) 00006 * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University) 00007 * 00008 * Permission to use, copy, modify, and distribute this software and its 00009 * documentation for any purpose, without fee, and without written agreement is 00010 * hereby granted, provided that the above copyright notice, the following 00011 * two paragraphs and the authors appear in all copies of this software. 00012 * 00013 * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR 00014 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00015 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS" 00016 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 * 00018 * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00021 * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO 00022 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." 00023 * 00024 * Please maintain this header in its entirety when copying/modifying 00025 * these files. 00026 * 00027 * 00028 */ 00029 00030 /************************************************************************ 00031 * esos_pic24_irq.c 00032 ************************************************************************ 00033 * User provided (HW-specific) ES_OS routines for individual IRQs 00034 * 00035 * NOTE: The actual handler ISR (the one that the CPU will vector to 00036 * does NOT go in this file. The real HW handler for the user 00037 * IRQs goes in the file esos_p18_uisr.c 00038 * 00039 * This allows us to emulate the p18 hardware on PCs since 00040 * goofy INTERRUPT keywords are kept away from this code. 00041 */ 00042 00043 #include "esos_pic24_irq.h" 00044 00045 /* 00046 * User must provide a routine to setup the user (low-priority) IRQs 00047 * This routine must only init the user IRQs.... It can not disable 00048 * or other mess with IRQs beyond its purview because they may be 00049 * being used to generate the system tick. 00050 */ 00051 void _esos_hw_InitUserInterrupts(void) { 00052 // Set all possible user IRQs to the lowest priority (0) 00053 // However, ESOS may use a few IRQs for its own purposes, so 00054 // preserve them. 00055 // 00056 // At this time, ESOS for PIC24 family uses T1, U1TX, U1RX 00057 uint8 u8_T1IP, u8_U1TXIP, u8_U1RXIP; 00058 uint8 u8_i; 00059 uint16* pu16_IpcPtr; 00060 00061 u8_T1IP = _T1IP; 00062 u8_U1RXIP = _U1RXIP; 00063 u8_U1TXIP = _U1TXIP; 00064 00065 // Set all IRQs to 0 (ZERO) IP level 00066 pu16_IpcPtr = (uint16*) &IPC0; 00067 for (u8_i=0; u8_i<=17; u8_i++) { 00068 *pu16_IpcPtr=0; 00069 pu16_IpcPtr++; 00070 } 00071 00072 // restore the ESOS IRQ IP levels 00073 _T1IP = u8_T1IP; 00074 _U1RXIP = u8_U1RXIP; 00075 _U1TXIP = u8_U1TXIP; 00076 00077 } // end _esos_hw_InitUserInterrupts() 00078 00079 void _esos_hw_DoNothingIsr(void) { 00080 /* 00081 DO NOTHING.... DON'T CALL PRINTF. 00082 It makes the image HUGE!!! 00083 printf("Doing nothing, of course!\n\r"); 00084 printf("PIR1 register is: %x\n\r", PIR1); 00085 printf("PIR2 register is: %x\n\r", PIR2); 00086 printf("INTCON3 register is: %x\n\r", INTCON3); 00087 */ 00088 //BIT_CLEAR( INTCON3, 0); // INTCON3bits.INT1IF = 0; 00089 00090 } // end _esos_hw_DoNothingIsr()