Embedded Port Pins Library - configuration file. More...
Go to the source code of this file.
Macros | |
#define | EPPL_TARGET avr8 |
Target platform. More... | |
#define | EPPL_HOTPINS EPPL_NP |
Hot Pins. More... | |
Embedded Port Pins Library - configuration file.
):
If you look at our generated code now, you will see, that the line that maps temperature value to output pins, is protected by calling cli instruction. After operation is finished the interrupt state is set back to the state before instruction execution.
The blocking code is not needed inside the interrupt. You can use instructions with FromISR postfix (eppl_mapOutFromISR) in interrupt to prevent generating the interrupt blocking code. The other option is to set the EPPL_HOTPINS value to EPPL_NP (Not A Pin) before the interrupt runtime. For more details go to Hot Pins concept in multi-threaded applications section.
When you just specify the pins list in EPPL_HOTPINS definition the library will protect any access to any register that belongs to unsafe port. In many programs it is not needed. It is quite common that procedure inside the interrupt modifies just one register and only that register needs to be protected. You can give to the library more information to optimize the code better.
You may do so by using EPPL_SR macro. This macro is normally used for pins reinitialization, inside the eppl_reinit macro. Using it you can specify what kind of pins value changing we can expect.
In our example binary clock, all pins inside interrupt are work in Push-Pull mode and only its state is changed. It means that for the AVR microcontroller only the PORT registers have to be protected. We can modify any DDR register without fear.
For our example you could use more specific Hot Pins definition like below:
Notice that in the EPPL_HOTPINS definition when you list possible ways of pins states changes, the direction of the changes is not important, so the code below:
Is equivalent to the following code:
You can list one pin more than once in EPPL_HOTPINS definition. It gives you the possibility to inform the library that some pin is for example expected to change state in interrupt but also... for example change the direction:
It may look as if the presented Hot Pins concept is usable only in systems where we have two threads:
And moreover: Interrupts may always break main loop. Main loop may never break interrupts.
But the presented idea is much more flexible. In the example above we have set EPPL_HOTPINS constant in eppl_config.h file. But the EPPL_HOTPINS value is not set globally for the library. The macros are written that way that the value of EPPL_HOTPINS is checked at the point of any macro usage. It means that you can define different values for Hot Pins constant for different files. You can also undefine and then define completely different value at any point of the file.
Look at the example code below: