ADC Functions

This section describes the ADC functions. They are used to control and monitor the ADC module of a DLN-series adapter.Actual control of the device is performed by use of commands and responses. Each function utilizes respective commands and responses. You can send such commands directly if necessary.

Rating: 
Голосов пока нет

DlnAdcEnable() Function

The DlnAdcEnable() function activates the corresponding ADC port of your DLN-series adapter. This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcEnable(
    HDLN handle, 
    uint8_t port,
    uint16_t* conflict
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to be activated.

conflict

A pointer to an unsigned 16-bit integer. The integer will be filled with the number of the conflicted pin, if any.A conflict arises if a pin is already assigned to another module of the DLN-series adapter and cannot be used for the ADC module. To fix this a user has to disconnect a pin from a module that it has been assigned to and call the DlnAdcEnable() function once again. In case there still are conflicted pins, only the number of the next one will be returned.

Return Value
DLN_RES_SUCCESS

The operation completed successfully and I2C master port was successfully disabled.

DlnAdcDisable() Function

The DlnAdcDisable() function deactivates the specified ADC port of your DLN-series adapter. This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcDisable(
    HDLN handle,
    uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to be deactivated.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcIsEnabled() Function

The DlnAdcIsEnabled() function retrieve information, whether the specified ADC port is activated. This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcIsEnabled(
    HDLN handle,
    uint8_t port,
    uint8_t* enabled
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to retrieve the information from.

enabled

A pointer to an unsigned 8-bit integer. The integer will be filled with the information whether the specified ADC port is activated. There are two possible values:

  • 0 or DLN_ADC_DISABLED - ADC port is deactivated.

  • 1 or DLN_ADC_ENABLED - ADC port is activated.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcChannelEnable() Function

The DlnAdcChannelEnable() function activates the specified channel from the corresponding ADC port of your DLN-series adapter. This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcChannelEnable(
    HDLN handle,
    uint8_t port,
    uint8_t channel
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to be used.

channel

A number of the channel to be enabled.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcChannelDisable() Function

The DlnAdcChannelEnable() function deactivates the specified channel from the corresponding ADC port of your DLN-series adapter.

This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcChannelDisable(
    HDLN handle,
    uint8_t port,
    uint8_t channel
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to be used.

channel

A number of the channel to be disabled.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcChannelIsEnabled() Function

The DlnAdcChannelIsEnabled() retrieves information, whether the specified ADC channel is activated. This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcChannelIsEnabled(
   HDLN handle, 
   uint8_t port,
   uint8_t channel,
   uint8_t* enabled
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to retrieve the information from.

channel

A number of the ADC channel to retrieve the information from.

enabled

A pointer to an unsigned 8-bit integer. The integer will be filled with the information whether the specified ADC channel is activated. There are two possible values:

  • 0 or DLN_ADC_DISABLED - ADC channel is deactivated.

  • 1 or DLN_ADC_ENABLED - ADC channel is activated.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcGetPortCount() Function

The DlnAdcGetPortCount() function retrieves the number of ADC ports available in your DLN-series adapter. This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcGetPortCount(
    HDLN handle,
    uint8_t* count
);
Parameters
handle

A handle to the DLN-series adapter.

count

A pointer to an unsigned 8-bit integer. The integer will be filled with the number of available ADC ports after the function execution.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcGetChannelCount() Function

The DlnAdcGetChannelCount() function retrieves the number of ADC channels, available in the specified ADC-port of your DLN-series adapter.This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcGetChannelCount(
    HDLN handle,
    uint8_t port,
    uint8_t* count
);
Parameters
handle

A handle to the DLN-series adapter.

port

An ADC port to retrieve the number of channels from.

count

A pointer to an unsigned 8-bit integer. The integer will be filled with the available number of channels in the specified ADC port of the DLN-series adapter.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcChannelSetCfg() Function

The DlnAdcChannelSetCfg() function changes the configuration of a single GPIO pin and set the conditions of DLN_ADC_CONDITION_MET_EV event generation. This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcChannelSetCfg(
   HDLN handle, 
   uint8_t port,
   uint8_t channel,
   uint8_t eventType,
   uint16_t eventPeriod,
   uint16_t thresholdLow,
   uint16_t thresholdHigh
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to be configured.

channel

A number of the ADC channel to be configured.

eventType

Must contain the event generation condition for the ADC channel. The following values are available:

ValueDescription

0 or DLN_ADC_EVENT_NONE

No events are generated for the current channel.

1 or DLN_ADC_EVENT_BELOW

Events are generated when voltage level on the ADC channel crosses the lower threshold.

2 or DLN_ADC_EVENT_LEVEL_ABOVE

Events are generated when voltage level on the ADC channel crosses the higher threshold.

3 or DLN_ADC_EVENT_OUTSIDE

Events are generated when voltage level on the ADC channel falls outside of the specified range between thresholds.

4 or DLN_ADC_EVENT_INSIDE

Events are generated when voltage level on the ADC channel falls within the specified range between thresholds.

5 or DLN_ADC_EVENT_ALWAYS

Events are sent periodically with predefined repeat interval. The non-zero interval must be specified for this event type.

eventPeriod

Must contain the repeat interval for DLN_ADC_CONDITION_MET_EV event generation on the pin. The repeat interval is set in ms (1 to 65,535ms). If the repeat interval is set to 0, the DLN-series adapter will send a single event when the level on the line changes to meet the specified conditions.

thresholdLow

The lower threshold value, specified in bits.

thresholdHigh

The higher threshold value specified in bits.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcChannelGetCfg() Function

The DlnAdcChannelGetCfg() function retrieves the current configuration settings of a single ADC channel.

This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcChannelGetCfg(
    HDLN handle,
    uint8_t port, 
    uint8_t channel,
    uint8_t* eventType,
    uint16_t* eventPeriod,
    uint16_t* thresholdLow,
    uint16_t* thresholdHigh
 );
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to retrieve the information from.

channel

A number of the ADC channel to retrieve the information from.

eventType

A pointer to an unsigned 8-bit integer. The integer will be filled the currently set event generation condition for the ADC channel after the function execution. The following values are available:

ValueDescription

0 or DLN_ADC_EVENT_NONE

No events are generated for the current channel.

1 or DLN_ADC_EVENT_BELOW

Events are generated when voltage level on the ADC channel crosses the lower threshold.

2 or DLN_ADC_EVENT_LEVEL_ABOVE

Events are generated when voltage level on the ADC channel crosses the higher threshold.

3 or DLN_ADC_EVENT_OUTSIDE

Events are generated when voltage level on the ADC channel falls outside of the specified range between thresholds.

4 or DLN_ADC_EVENT_INSIDE

Events are generated when voltage level on the ADC channel falls within the specified range between thresholds.

5 or DLN_ADC_EVENT_ALWAYS

Events are sent periodically with predefined repeat interval. The non-zero interval must be specified for this event type.

eventPeriod

A pointer to an unsigned 16-bit integer. The integer will be filled with the repeat interval for DLN_ADC_CONDITION_MET_EV event generation on the pin after the function execution. The repeat interval is set in ms (1 to 65,535ms). If the repeat interval is set to 0, the DLN-series adapter will send a single event when the level on the line changes to meet the specified conditions.

thresholdLow

A pointer to an unsigned 16-bit integer. The integer will be filled with the lower voltage threshold value, specified in bits, after the function execution.

thresholdHigh

A pointer to an unsigned 16-bit integer. The integer will be filled with the higher voltage threshold value, specified in bits, after the function execution.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcSetResolution() Function

The DlnAdcSetResolution() function sets the ADC resolution value of your DLN-series adapter. This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcSetResolution(
    HDLN handle,
    uint8_t port,
    uint8_t resolution
 );
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to be configured.

resolution

The new resolution in bits. For the list of compatible values see table below.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcGetResolution() Function

The DlnAdcGetResolution() function retrieves the currently set ADC resolution of your DLN-series adapter.

This function is defined in the dln_adc.h file.

Syntax
C/C++
 DLN_RESULT DlnAdcGetResolution(
   HDLN handle,
   uint8_t port,
   uint8_t* resolution
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to retrieve the information from.

resolution

The current ADC resolution in bits.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcGetSupportedResolutions() Function

The DlnAdcGetSupportedResolutions() function returns all supported resolution values for connected DLN-series adapter.

This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcGetSupportedResolutions(
    HDLN handle, 
    uint8_t port, 
    DLN_ADC_RESOLUTIONS *supportedResolutions
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to be used.

supportedResolutions

Pointer to DLN_ADC_RESOLUTIONS structure, which will be filled by supported resolution values.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcGetValue() Function

The DlnAdcGetValue() function retrieves current voltage on the specified ADC channel of your DLN-series adapter.

This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcGetValue(
    HDLN handle,
    uint8_t port,
    uint8_t channel,
    uint16_t* value
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to retrieve the information from.

channel

A number of the ADC channel to retrieve the information from.

value

A pointer to an unsigned 8-bit integer. The integer will be filled with the voltage level on the specified ADC channel.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcGetAllValues() Function

The DlnAdcGetAllValues() function retrieves current voltage values from all enabled ADC channels of your DLN-series adapter.

This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcGetAllValues( 
   HDLN handle,
   uint8_t port,
   uint16_t* channelMask,
   uint16_t* values
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to retrieve the information from.

channelMask

A pointer to an unsigned 16-bit integer. This integer will be filled with a bit mask, each of the bits corresponding to an ADC channel of the port. This parameter contains currently enabled ADC channels of your DLN-series device.

values

A pointer to an unsigned 16-bit integer. This integer will be filled with a bit mask, each of the bits corresponding to an ADC value of the ADC channel of the port.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.

DlnAdcGetSupportedEventTypes() Function

The DlnAdcGetSupportedEventTypes() function returns all supported ADC event types for opened DLN-series adapter.

This function is defined in the dln_adc.h file.

Syntax
C/C++
DLN_RESULT DlnAdcGetSupportedEventTypes(
    HDLN handle, 
    uint8_t port, 
    DLN_ADC_EVENT_TYPES *supportedEventTypes
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the ADC port to be used.

supportedEventTypes

Pointer to DLN_ADC_EVENT_TYPES structure, which will be filled by supported event type values.

Return Value
DLN_RES_SUCCESS

Function was successfully executed.