Projekt

Allgemein

Profil

Interrupts » Historie » Version 3

Maximilian Seesslen, 30.06.2023 18:30

1 1 Maximilian Seesslen
h1. Interrupts
2
3
Der Overhead soll moeglichst gering gehalten werden.
4
Daher werden nur Informationen fuer Peripheri-Interrupts gehalten, die auch verwendet werden.
5 2 Maximilian Seesslen
Dynamische Arrays fuer Interrupt-Objekte gibt es nicht mehr sondern nur einzelne Pointer auf verwendete 
6 1 Maximilian Seesslen
Interrupt-Objekte. Durch das explizite Aktivieren von ISRs werden nicht benutzte Pointer durch den Linker eliminiert.
7 2 Maximilian Seesslen
Der fuer eine Peripherie verwendete Interrupt-Objekt-Pointer kann in der Config-Struktur angegeben sein.
8
Eine Interrupt-Klasse ist nicht notwendig.
9 1 Maximilian Seesslen
10
Beispiel:
11
12
<pre><code class="cpp">
13
CUart *interruptUart1=nullptr;
14
CUart *interruptUart2=nullptr;
15
16
INTERRUPT_IMPL(UART2)
17
{
18
   callInterrupt(uart2);
19
};
20 2 Maximilian Seesslen
21
CUart::interrupt()
22
{
23
   HAL_UART_INTERRUPT( m_pHandler );
24
}
25 1 Maximilian Seesslen
26
SUartConfig configBlockUart2
27
{
28
   .interrupt=interruptUart2,
29
};
30
</code></pre>
31 3 Maximilian Seesslen
32
h1. Callbacks
33
34
The callback functions called via HAL unfortunately do not provide an way to deliver an user data, e.g. an pointer to the uart object.
35
So the object has to be determined in the callback function. But we dont want pointers for all unused periphery. Only the used objects
36
should have an pointer.
37
So the pointers are put into a special section. The compiler/linker can eliminate unused pointers as they are not referenced anywhere
38
like it would be when they appear in the config structure of the periphery.
39
With the help of a additional biwak linker script, the callback function can find the object pointer.
40
41
h1. Input interrupts
42
43
An EXTI object has an virtual interrupt() method. As long as you just inherit from CInput, you can just implement your own interrupt(),
44
like CButton does.
45
When the application is more complex, the CInput-object may already exist. In that case there is the signal "interruptSignal". Connect it
46
to an method of your application class and do whatever has to be done there.
47
48
Another possibility is to hook an input decoder (CInputDecoder). This approach is meant for fast input bursts like single wire sensors or 
49
infrared remotes.