Choco OS  V.0.16.9.0
Join to the chocolate world
oc_interrupts.c
Go to the documentation of this file.
1 
27 #include <oc_interrupts.h>
28 #include <oc_null.h>
29 #include <oc_lsf.h>
30 #include <oc_array.h>
31 
37 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________
38 
39 /* Pointer from linker */
40 extern const char __main_stack_end;
41 
42 /* Stores unexpected interrupt handler pointer - interface variable */
44 
45 /* Prototypes for special interrupt handlers */
48 
49 /* Creates weak prototypes for each interrupt */
50 #define CREATE_INTERRUPT_WEAK_PROTOTYPE( BASE_NAME , INTERRUPT_TYPE , INTERRUPT_NUMBER , VECTOR_NUMBER ) \
51  oC_InterruptHandlerWeakPrototype( BASE_NAME , INTERRUPT_TYPE );
52 oC_MACHINE_INTERRUPTS_LIST(CREATE_INTERRUPT_WEAK_PROTOTYPE)
53 #undef CREATE_INTERRUPT_WEAK_PROROTYPE
54 
55 /* Interrupts vector array */
56 void (*const vectors[])(void) __attribute__ ((section (".vectors"))) =
57 {
58  (void (*)(void))&__main_stack_end,
60 #define PUSH_INTERRUPT_TO_VECTOR( BASE_NAME , INTERRUPT_TYPE , INTERRUPT_NUMBER , VECTOR_NUMBER , ...) \
61  [VECTOR_NUMBER] = oc_InterruptHandlerName(BASE_NAME , INTERRUPT_TYPE) ,
62  oC_MACHINE_INTERRUPTS_LIST(PUSH_INTERRUPT_TO_VECTOR)
63 #undef PUSH_INTERRUPT_TO_VECTOR
64 };
65 
66 const oC_InterruptData_t oC_InterruptData[oC_InterruptIndex_NumberOfElements] = {
67 #define PUSH_INTERRUPT_TO_ARRAY( BASE_NAME , INTERRUPT_TYPE , INTERRUPT_NUMBER , VECTOR_NUMBER , ...) \
68  [VECTOR_NUMBER] = { .BaseAddress = oC_InterruptBaseAddress_(BASE_NAME,INTERRUPT_TYPE) , \
69  .Type = oC_InterruptType_(INTERRUPT_TYPE) ,\
70  .InterruptIndex = oC_InterruptIndex_(BASE_NAME , INTERRUPT_TYPE) ,\
71  .InterruptNumber= oC_InterruptNumber_(BASE_NAME , INTERRUPT_TYPE)\
72  } ,
73  oC_MACHINE_INTERRUPTS_LIST(PUSH_INTERRUPT_TO_ARRAY)
74 #undef PUSH_INTERRUPT_TO_ARRAY
75 };
76 
77 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________
78 
84 #define _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________
85 
86 //==========================================================================================================================================
97 //==========================================================================================================================================
99 {
100  const oC_InterruptData_t * data = NULL;
101 
102  oC_ARRAY_FOREACH_IN_ARRAY(oC_InterruptData,interruptData)
103  {
104  if(interruptData->BaseAddress == BaseAddress && interruptData->Type == InterruptType)
105  {
106  data = interruptData;
107  break;
108  }
109  }
110 
111  return data;
112 }
113 
114 #undef _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________
115 
116 
122 #define _________________________________________INTERRUPT_HANDLERS_SECTION_________________________________________________________________
123 
124 //==========================================================================================================================================
128 //==========================================================================================================================================
130 {
131  // Checking if pointer is correct, and calling unexpected interrupt handler
132  if(oC_LSF_IsCorrectAddress(oC_UnexpectedInterruptHandler))
133  {
135  }
136 }
137 
138 #undef _________________________________________INTERRUPT_HANDLERS_SECTION_________________________________________________________________
oC_InterruptHandler_t oC_UnexpectedInterruptHandler
Handler for unexpected interrupts.
Definition: oc_interrupts.c:43
#define oC_ResetInterruptHandlerPrototype
Prototype of reset handler. Not for user usage.
void(* oC_InterruptHandler_t)(void)
Stores interrupt handler pointer.
The file with interface for LSF module.
#define oC_ResetInterruptHandlerName
Name of reset handler. Not for user usage.
#define oC_MACHINE_INTERRUPTS_LIST(ADD_INTERRUPT)
Definition of interrupts.
structure with data for interrupts
#define oC_DefaultInterruptHandler
Creates prototype of default interrupt handler.
const oC_InterruptData_t * oC_Interrupt_GetData(oC_InterruptBaseAddress_t BaseAddress, oC_InterruptType_t InterruptType)
returns data pointer for interrupt
Definition: oc_interrupts.c:98
oC_InterruptType_t
Stores interrupt type.
#define oC_DefaultInterruptHandlerPrototype
Creates special prototype for default interrupt handler. Not for user usage.
oC_InterruptBaseAddress_t
Base address connected to the interrupt.
Static array definitions.
The file with interface interrupt module.
Definition of the null pointer.
const oC_InterruptData_t oC_InterruptData[oC_InterruptIndex_NumberOfElements]
Data for interrupts.
Definition: oc_interrupts.c:66
#define NULL
pointer to a zero
Definition: oc_null.h:37