Call external drivers

For example the driver Laser defined by the file laser.hpp uses the driver Xadc defined by the file xadc.hpp:

Usage

To call the driver Xadc from the driver Laser:

  • include xadc.hpp file
  • use ctx.get in the driver Laser constructor
  • return Xadc object

Example

#include <xadc.hpp>
public:
    Laser(Context& ctx)
    : ctl(ctx.mm.get<mem::control>())
    , sts(ctx.mm.get<mem::status>())
    , xadc(ctx.get<Xadc>())
  private:
    Memory<mem::control>& ctl;
    Memory<mem::status>& sts;
    Xadc& xadc;


Important note

Be careful not to introduce circular dependencies in the constructors.

See also