Digital Entity

See the Digital Entity for generic information.

group DigitalEntity

Interface to digital entities on BrainStem modules. Digital entities have the following 5 possibilities: Digital Input, Digital Output, RCServo Input, RCServo Output, and HighZ. Other capabilities may be available and not all pins support all configurations. Please see the product datasheet.

void digital_setConfiguration(unsigned int *id, struct Result *result, const int index, const unsigned char configuration)

Set the digital configuration to one of the available 5 states.

The result parameter will output the following fields:

Note

Some configurations are only supported on specific pins.

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Output object containing result code.

  • index – The index of the entity in question.

  • configuration – The configuration to be applied

    • Digital Input: digitalConfigurationInput = 0

    • Digital Output: digitalConfigurationOutput = 1

    • RCServo Input: digitalConfigurationRCServoInput = 2

    • RCServo Output: digitalConfigurationRCServoOutput = 3

    • High Z State: digitalConfigurationHiZ = 4

    • Digital Input: digitalConfigurationInputPullUp = 0

    • Digital Input: digitalConfigurationInputNoPull = 4

    • Digital Input: digitalConfigurationInputPullDown = 5

void digital_getConfiguration(unsigned int *id, struct Result *result, const int index)

Get the digital configuration.

The result parameter will output the following fields:

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Output object containing result code and the requested value if successful.

  • index – The index of the entity in question.

void digital_setState(unsigned int *id, struct Result *result, const int index, const unsigned char state)

Set the logical state.

The result parameter will output the following fields:

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Output object containing result code.

  • index – The index of the entity in question.

  • state – The state to be set. 0 is logic low, 1 is logic high.

void digital_getState(unsigned int *id, struct Result *result, const int index)

Get the state.

The result parameter will output the following fields:

Note

If in high Z state an error will be returned.

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Output object containing result code and the requested value if successful.

  • index – The index of the entity in question.

void digital_setStateAll(unsigned int *id, struct Result *result, const int index, const unsigned int state)

Sets the logical state of all available digitals based on the bit mapping. Number of digitals varies across BrainStem modules. Refer to the datasheet for the capabilities of your module.

The result parameter will output the following fields:

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Output object containing result code.

  • index – The index of the entity in question.

  • state – The state to be set for all digitals in a bit mapped representation. 0 is logic low, 1 is logic high. Where bit 0 = digital 0, bit 1 = digital 1 etc.

void digital_getStateAll(unsigned int *id, struct Result *result, const int index)

Gets the logical state of all available digitals in a bit mapped representation. Number of digitals varies across BrainStem modules. Refer to the datasheet for the capabilities of your module.

The result parameter will output the following fields:

  • error: Common EntityClass Return Values common entity return value

  • value: The state of all digitals where bit 0 = digital 0, bit 1 = digital 1 etc. 0 is logic low, 1 is logic high.

Parameters:
  • id – ID assigned through “module_createStem”

  • result – Output object containing result code and the requested value if successful.

  • index – The index of the entity in question.