On Time RTOS-32 Documentation
Welcome
RTTarget-32
RTKernel-32
RTKernel-32 Programming Manual
Introduction
Multitasking, Real-Time, and RTKernel-32
Module RTKernel-32
Alternate APIs for RTKernel-32
Supplemental Modules
RTKernel-32 Drivers
Demo Programs
Advanced Topics
RTKernel-32's Debug Version
How to Create Threads
Interrupt Handling
Installing Shared Interrupt Handlers
Interrupt Handler for RTKSetIRQHandler
Avoid Polling
Preemptive or Cooperative Multitasking?
Waiting for Several Events
Avoid Large Message Types
Mutual Exclusion
Avoid Time Slicing
Cyclic Tasks (Timer)
Priorities
Starting Objects' Methods as Tasks
Performance and Interrupt Response Times
Multiprocessor Applications
OpenMP
Task Switches in Cooperative Scheduling
Writing Custom Kernel Drivers
Using the FPU in Interrupt Handlers
Typical Error Sources
Error and Information Messages
RTKernel-32 Reference Manual
RTFiles-32
RTIP-32
RTPEG-32
RTUSB-32
|
Interrupt Handler for RTKSetIRQHandler
This method of installing interrupt handler is deprecated. Please see section Installing Shared Interrupt Handlers for the recommended method.
An interrupt handler to be installed with RTKSetIRQHandler should have the following structure:
- It should be declared as a void C/C++ function without parameters.
- While accepting the interrupt, the processor has masked all interrupts. To reenable interrupts of higher priorities, the handler should call RTKEnableInterrupts as its first statement.
- Subsequently, the hardware that has generated the interrupt should be serviced, if required. The handler can communicate with other tasks using mechanisms that cannot lead to blocking task switches.
- Finally, RTKIRQEnd should be called.
Example:
#define IRQ 3
void RTKAPI IntHandler(void) // high level interrupt handler in C
{
char Data;
RTKEnableInterrupts(); // allow higher level interrupts
RTIn(IOBASE+LSR); // clear line status errors
Data = RTIn(IOBASE+RXB); // get the received byte
RTKPutCond(Buffer, &Data); // and insert in mailbox
RTKIRQEnd(IRQ); // done
}
...
int main(void)
{
...
RTKSetIRQHandler(IRQ, IntHandler); // install handler
RTKEnableIRQ(IRQ); // enable IRQ
// program device to start sending interrupts here
...
RTKDisableIRQ(IRQ); // disable IRQ
...
}
Interrupt Handling
Installing Shared Interrupt Handlers
|