Choco OS  V.0.16.9.0
Join to the chocolate world
Interrupts Module

Module for definitions and types of interrupts. More...

Data Structures

struct  oC_InterruptData_t
 structure with data for interrupts More...
 

Macros

#define oC_InterruptType_(TYPE_NAME)
 Returns value from oC_InterruptType_t. It is an index of interrupt type.
 
#define oC_InterruptIndex_(BASE_NAME, TYPE_NAME)
 Returns value from oC_InterruptIndex_t. It is an index of interrupt in interrupts vector.
 
#define oC_InterruptNumber_(BASE_NAME, TYPE_NAME)
 Returns value from oC_InterruptNumber_t.
 
#define oC_InterruptBaseAddress_(BASE_NAME, TYPE_NAME)
 Returns value from oC_InterruptBaseAddress_t. More...
 
#define oc_InterruptHandlerName(BASE_NAME, TYPE_NAME)
 returns name of interrupt function More...
 
#define oC_InterruptHandlerPrototype(BASE_NAME, TYPE_NAME)
 returns handler prototype of interrupt handler More...
 
#define oC_InterruptHandlerWeakPrototype(BASE_NAME, TYPE_NAME)
 creates weak interrupt handler prototype. Not for user usage
 
#define oC_InterruptHandler(BASE_NAME, TYPE_NAME)
 Define handler for interrupt. More...
 
#define oC_DefaultInterruptHandler
 Creates prototype of default interrupt handler. More...
 
#define oC_DefaultInterruptHandlerPrototype
 Creates special prototype for default interrupt handler. Not for user usage.
 
#define oC_ResetInterruptHandlerName
 Name of reset handler. Not for user usage.
 
#define oC_ResetInterruptHandler
 Prototype for reset handler. Not for user usage.
 
#define oC_ResetInterruptHandlerPrototype
 Prototype of reset handler. Not for user usage.
 

Typedefs

typedef void(* oC_InterruptHandler_t) (void)
 Stores interrupt handler pointer. More...
 

Enumerations

Variables

oC_InterruptHandler_t oC_UnexpectedInterruptHandler
 Handler for unexpected interrupts. More...
 
const oC_InterruptData_t oC_InterruptData [oC_InterruptIndex_NumberOfElements]
 Data for interrupts.
 

Detailed Description

Macro Definition Documentation

#define oC_DefaultInterruptHandler

The macro creates prototype for default interrupt handler. This handler is called, when an interrupt occurs, but the handler is not set.

Example of usage:

// Assume, that we have SPI0 , SPI1 and SPI2
// We must define prototypes for these interrupts
extern oC_InterruptHandlerPrototype(SPI0,PeripheralInterrupt);
extern oC_InterruptHandlerPrototype(SPI1,PeripheralInterrupt);
extern oC_InterruptHandlerPrototype(SPI2,PeripheralInterrupt);
// Definition of default interrupt handler
// Handler of interrupt for SPI0
oC_InterruptHandler(SPI0,PeripheralInterrupt)
{
printf("Handler for SPI0 exist!\n\r");
}
// Handler of interrupt for SPI1
oC_InterruptHandler(SPI1,PeripheralInterrupt)
{
printf("Handler for SPI1 exist!\n\r");
}
// Main entry of function
void main(void)
{
// Taking pointers of interrupts handlers
oC_InterruptHandler_t SPI0Interrupt = oC_InterruptHandlerName(SPI0 , PeripheralInterrupt);
oC_InterruptHandler_t SPI1Interrupt = oC_InterruptHandlerName(SPI1 , PeripheralInterrupt);
oC_InterruptHandler_t SPI2Interrupt = oC_InterruptHandlerName(SPI2 , PeripheralInterrupt);
// Taking pointers of default interrupt handler
oC_InterruptHandler_t DefaultInterrupt = oC_DEFAULT_INTERRUPT_HANDLER_NAME;
// Simulating SPI0 interrupt - SPI0 handler will be called
SPI0Interrupt();
// Simulating SPI1 interrupt - SPI1 handler will be called
SPI1Interrupt();
// Simulating SPI2 interrupt - Default interrupt handler will be called
SPI2Interrupt();
if(SPI2Interrupt == DefaultInterrupt)
{
printf("SPI2 handler is not set!\n\r);
}
}

Definition at line 226 of file oc_interrupts.h.

#define oC_InterruptBaseAddress_ (   BASE_NAME,
  TYPE_NAME 
)

Returns value from oC_InterruptBaseAddress_t (address of base address for register map, that the interrupt is connected to - just base address from the parameter)

Parameters
BASE_NAMEName of base address from the oc_ba_defs.h file
TYPE_NAMEName of the interrupt type

Definition at line 81 of file oc_interrupts.h.

#define oC_InterruptHandler (   BASE_NAME,
  TYPE_NAME 
)

This macro should be used for definition of interrupt handler. Look for example below for more details.

Parameters
BASE_NAMEName of base address from the oc_ba_defs.h file
TYPE_NAMEName of the interrupt type

Example of usage:

// Definition of interrupt handler for SPI0 base address
oC_InterruptHandler(SPI0,PeripheralInterrupt)
{
// code for handling SPI0 interrupt
}

Definition at line 167 of file oc_interrupts.h.

#define oc_InterruptHandlerName (   BASE_NAME,
  TYPE_NAME 
)

The macro returns name of an interrupt handler. It is not interrupt prototype, just the name.

Parameters
BASE_NAMEName of base address from the oc_ba_defs.h file
TYPE_NAMEName of the interrupt type

Here is some example:

// Definition of interrupt handler prototype
extern oC_InterruptHandlerPrototype(SPI0,PeripheralInterrupt);
// Taking pointer of interrupt handler
oC_InterruptHandler_t SPIInterrupt = oC_InterruptHandlerName(SPI0 , PeripheralInterrupt);
// Checking if the pointer is set to default interrupt handler
if(SPIInterrupt == oC_DEFAULT_INTERRUPT_HANDLER_NAME)
{
// If it is, it does mean, that the interrupt handler is not set
printf("Handler for SPI0 is not set!\n\r");
}

Definition at line 110 of file oc_interrupts.h.

#define oC_InterruptHandlerPrototype (   BASE_NAME,
  TYPE_NAME 
)

The macro returns full prototype for an interrupt function. The type of this prototype should be the same as oC_InterruptHandler_t type.

Parameters
BASE_NAMEName of base address from the oc_ba_defs.h file
TYPE_NAMEName of the interrupt type

Some example:

// Prototype for the interrupt function
extern oC_InterruptHandlerPrototype(SPI0,PeripheralInterrupt);
void main(void)
{
// Taking pointer of interrupt handler
oC_InterruptHandler_t SPIInterrupt = oC_InterruptHandlerName(SPI0 , PeripheralInterrupt);
printf("Simulating an SPI0 interrupt...\n\r");
// Simulating SPI0 interrupt
SPIInterrupt();
}

Definition at line 139 of file oc_interrupts.h.

Typedef Documentation

typedef void(* oC_InterruptHandler_t) (void)

The type is for storing interrupt handler pointers. Here is an example of usage:

// We must define prototypes for these interrupts
extern oC_InterruptHandlerPrototype(SPI0,PeripheralInterrupt);
extern oC_InterruptHandlerPrototype(SPI1,PeripheralInterrupt);
extern oC_InterruptHandlerPrototype(SPI2,PeripheralInterrupt);
// Taking pointers of interrupts handlers
oC_InterruptHandler_t SPI0Interrupt = oC_InterruptHandlerName(SPI0 , PeripheralInterrupt);
oC_InterruptHandler_t SPI1Interrupt = oC_InterruptHandlerName(SPI1 , PeripheralInterrupt);
oC_InterruptHandler_t SPI2Interrupt = oC_InterruptHandlerName(SPI2 , PeripheralInterrupt);

Definition at line 362 of file oc_interrupts.h.

Enumeration Type Documentation

Each interrupt must be defined with connection of base address for register map. If some interrupt is not specific for base address, then it should be defined as system interrupt. In this case, the base address of such interrupt will be set to oC_BaseAddress_System

Definition at line 334 of file oc_interrupts.h.

The type is for storing index of interrupt in global interrupt vector array.

Definition at line 299 of file oc_interrupts.h.

The type is for storing number of interrupt in system (Unique number, ID in the machine). This is required for #MCS functions.

Definition at line 316 of file oc_interrupts.h.

The type is for storing interrupt type. Thanks to this type, it is possible to distinguish more interrupts connected to the same register map base address.

Example of usage:

// Taking type of interrupt
oC_InterruptType_t peripheralInterrupt = oC_InterruptType_(PeripheralInterrupt);

Definition at line 283 of file oc_interrupts.h.

Variable Documentation

oC_InterruptHandler_t oC_UnexpectedInterruptHandler

This variable stores handler for unexpected interrupt handler. This handler will be called, if some interrupt occurs, but the handler is not defined.

To use it just set it to correct handler pointer.

Example of usage:

void UnexpectedInterruptHandler(void)
{
printf("Unexpected interrupt occurs\n\r");
}

Definition at line 43 of file oc_interrupts.c.