setIntrFlags
determines the setting of the
interrupt identification register according to which interrupts are
currently pending (in intrPending
).
genIntr
generates an interrupt by marking the
corresponding interrupt as pending if the interrupt is enabled and
setting the interrupt identification register flags
appropriately. In this implementation, no external signal is
generated (see Chapter 10 for details of
generating an interrupt signal).
clrIntr
clears the interrupt pending flag (no
need to check if the interrupt is enabled in this case) and sets the
appropriate interrupt identification register flags. Again there is
no external signal generated in this implementation.
A set of functions are provided to set, clear and test bits in registers. Using these makes the code much more readable[4].
[4]
Many programmers use #define
d macros for
functions such as these. However such macros have no
encapsulation (they can be used by anyone including the header)
and have a nasty habit of clashing with other programs macros. By
using functions, the functions can be made private to the
UartSC
class alone.
A modern C++ compiler will often generate code in line for such
small functions, so they will be implemented as efficiently as
if they had been #define
d as macros. Indeed
the added type information gives the potential for greater
optimization.