ESOS32
ESOSOn32-bitProcessors
esos_stm32l4_irq.c
Go to the documentation of this file.
1 /*
2  * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
3  * All rights reserved.
4  * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
5  * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
6  * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation for any purpose, without fee, and without written agreement is
10  * hereby granted, provided that the above copyright notice, the following
11  * two paragraphs and the authors appear in all copies of this software.
12  *
13  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
15  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
16  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17  *
18  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
23  *
24  * Please maintain this header in its entirety when copying/modifying
25  * these files.
26  *
27  *
28  */
29 
30 
38 /************************************************************************
39  * esos_pic24_irq.c
40  ************************************************************************
41  * User provided (HW-specific) ES_OS routines for individual IRQs
42  *
43  * NOTE: The actual handler ISR (the one that the CPU will vector to
44  * does NOT go in this file. The real HW handler for the user
45  * IRQs goes in the file esos_p18_uisr.c
46  *
47  * This allows us to emulate the p18 hardware on PCs since
48  * goofy INTERRUPT keywords are kept away from this code.
49  */
50 
51 #include "esos_pic24_irq.h"
52 
53 /*
54  * User must provide a routine to setup the user (low-priority) IRQs
55  * This routine must only init the user IRQs.... It can not disable
56  * or other mess with IRQs beyond its purview because they may be
57  * being used to generate the system tick.
58  */
59 void _esos_hw_InitUserInterrupts(void) {
60  // Set all possible user IRQs to the lowest priority (0)
61  // However, ESOS may use a few IRQs for its own purposes, so
62  // preserve them.
63  //
64  // At this time, ESOS for PIC24 family uses T1, U1TX, U1RX
65  uint8_t u8_T1IP, u8_U1TXIP, u8_U1RXIP;
66  uint8_t u8_i;
67  uint16_t* pu16_IpcPtr;
68 
69  u8_T1IP = _T1IP;
70  u8_U1RXIP = _U1RXIP;
71  u8_U1TXIP = _U1TXIP;
72 
73  // Set all IRQs to 0 (ZERO) IP level
74  pu16_IpcPtr = (uint16_t*) &IPC0;
75  for (u8_i=0; u8_i<=17; u8_i++) {
76  *pu16_IpcPtr=0;
77  pu16_IpcPtr++;
78  }
79 
80  // restore the ESOS IRQ IP levels
81  _T1IP = u8_T1IP;
82  _U1RXIP = u8_U1RXIP;
83  _U1TXIP = u8_U1TXIP;
84 
85 } // end _esos_hw_InitUserInterrupts()
86 
87 void _esos_hw_DoNothingIsr(void) {
88  /*
89  DO NOTHING.... DON'T CALL PRINTF.
90  It makes the image HUGE!!!
91  printf("Doing nothing, of course!\n\r");
92  printf("PIR1 register is: %x\n\r", PIR1);
93  printf("PIR2 register is: %x\n\r", PIR2);
94  printf("INTCON3 register is: %x\n\r", INTCON3);
95  */
96  //BIT_CLEAR( INTCON3, 0); // INTCON3bits.INT1IF = 0;
97 
98 } // end _esos_hw_DoNothingIsr()