4.4 Class Design
Strip 1 Strip 2 Strip 3
Strip 19 Strip 20
Figure 4.13 The Black Spot double buffering scheme involves copying image frame in parts to two buffers using a Direct Memory Access (DMA) peripheral. One buffer is accessed by the DMA while the other is accessed by the firmware.
Buffer 1 Buffer 2
Image Sensor Frame
Image strips copied by DMA controller
Notes on coding conventions
The firmware is written to incorporate OO principles whenever possible.
vention was developed to imitate classes in OO languages. Structures are used to represent classes and function pointers used to represent class methods. Object references are point-
ers to these structures.
The implementation is event driven. Events are implemented using function pointers. While this is not a true event, as only one consumer can subscribe to the event, it is suffi- cient for this implementation.
In the implementation of the firmware there is not any dynamic memory allocation. This was an implementation decision to improve the robustness of the code. voiding using dynamic memory allows the memory requirements of the firmware to be almost entirely determined at compile time. This avoids the situation of algorithms failing due to memory
There is one case where memory is still dynamically allocated and this is for the stack. When a function is called a stack frame is created that holds the previous DSP state be- fore the function call. If too many nested functions are called this could result in a stack overflow. There are not any recursive function calls so this should not be an issue.