User Tools

Site Tools


eeros_architecture:hal:feature_functions

This is an old revision of the document!


Feature Functions

All inputs and outputs of the HAL have a common set of properties and functions for reading or writing them. Some hardware channels have specific properties not common to other channels, e.g. a pulse width modulated output needs to be assigned its base frequency. Another example would be a digital to analog converter which has a calibration function which needs to be called upon request.
Feature functions are functions which are specific to a HAL object. They can be called by a user with

  void callOutputFeature(OutputInterface *obj, std::string featureName, ArgTypesOut... args);
  void callInputFeature(InputInterface *obj, std::string featureName, ArgTypesIn... args);

The parameter are as follows:

  1. OutputInterface / InputInterface: the HAL object
  2. featureName: name of the function as defined in the appropriate hardware wrapper library, see Hardware Libraries.
  3. args: arguments to this function

The following example shows how to set the frequency of a pulse width modulated output. This is usually done just once. Later the control system defines a peripheral output objects which is connected to our HAL object. The control system will then periodically write to this output and set the duty cycle.

  HAL& hal = HAL::instance();
  eeros::hal::Output<double>& pwm1 = *hal.getScalableOutput("pwm1");
  hal.callOutputFeature("pwm1", "setPwmFrequency", 100.0);
  ...
  PeripheralOutput<double> motorSpeed("pwm1");
  ...
eeros_architecture/hal/feature_functions.1493541046.txt.gz · Last modified: 2017/04/30 10:30 by graf