ESOS32
ESOSOn32-bitProcessors
esos_irq.c
Go to the documentation of this file.
1 /*
2  * "Copyright (c) 2019 J. W. Bruce ("AUTHOR(S)")"
3  * All rights reserved.
4  * (J. W. Bruce, jwbruce_AT_tntech.edu, Tennessee Tech University)
5  *
6  * Permission to use, copy, modify, and distribute this software and its
7  * documentation for any purpose, without fee, and without written agreement is
8  * hereby granted, provided that the above copyright notice, the following
9  * two paragraphs and the authors appear in all copies of this software.
10  *
11  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
12  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
13  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
14  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15  *
16  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
17  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
19  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
20  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
21  *
22  * Please maintain this header in its entirety when copying/modifying
23  * these files.
24  *
25  *
26  */
27 
28 
36 /************************************************************************
37  * esos_irq.c
38  ************************************************************************
39  * ES_OS file for (hardware independent) IRQ routines
40  */
41 
42 #include "esos_irq.h"
43 
44 void (*__esos_IsrFcns[NUM_USER_IRQS])(void);
45 
46 void esos_InitUserInterrupts(void) {
47  uint8_t i;
48 
49  // initialize the os ISR fcn ptrs to point to a benign ISR
50  for (i=0; i<NUM_USER_IRQS; i++) {
51  esos_UnregisterUserInterrupt(i);
52  }
53  _esos_hw_InitUserInterrupts();
54 } // end osInitInterrupts()
55 
56 void esos_UnregisterUserInterrupt( uint8_t u8IrqIndex ) {
57  // disassociate and unregister the p2f function with the IRQ given
58  // in u8IrqIndex
59  if (u8IrqIndex < NUM_USER_IRQS) {
60  esos_DisableUserInterrupt( u8IrqIndex );
61  __esos_IsrFcns[u8IrqIndex] = _esos_DoNothingIsr;
62  } // end if
63 } // end osUnregisterUserIsr()
64 
65 void esos_RegisterUserInterrupt( uint8_t u8IrqIndex, void (*p2f)(void) ) {
66  // associate and register the p2f function with the IRQ given
67  // in u8IrqIndex
68  if (u8IrqIndex < NUM_USER_IRQS) {
69  __esos_IsrFcns[u8IrqIndex] = p2f;
70  }
71 } // end osRegisterUserIsr()
72 
73 void esos_EnableVerifiedUserInterrupt( uint8_t u8IrqIndex ) {
74  // do ESOS checks on UserInterrupt and if all is well
75  // call the user-provided HW specific routine
76  if ((__esos_IsrFcns[u8IrqIndex] != NULLPTR) && ( __esos_IsrFcns[u8IrqIndex] != _esos_DoNothingIsr))
77  _esos_hw_EnableUserInterrupt( u8IrqIndex );
78 } // end esos_EnableUserInterrupt()
79 
80 void esos_ExecuteUserIsr( uint8_t u8IrqIndex ) {
81  __esos_IsrFcns[u8IrqIndex]();
82 } // esos_ExecuteUserIsr
83 
84 void _esos_DoNothingIsr(void) {
85  _esos_hw_DoNothingIsr();
86 } // end _esos_DoNothingIsr()
esos_irq.h
NULLPTR
#define NULLPTR
Definition: all_generic.h:435