sw_limits: Add documentation
Add documentation for the software limits module. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
3c41387928
commit
580b94e4d7
2
Doxyfile
2
Doxyfile
|
@ -780,7 +780,7 @@ RECURSIVE = YES
|
|||
|
||||
EXCLUDE = config.h src/libsigrok-internal.h src/session_driver.c
|
||||
EXCLUDE += src/std.c src/drivers.c src/ezusb.c src/fallback.c
|
||||
EXCLUDE += src/soft-trigger.c src/usb.c
|
||||
EXCLUDE += src/soft-trigger.c src/usb.c src/sw_limits.c
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Software limits helper functions
|
||||
* @internal
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
@ -25,12 +31,32 @@
|
|||
#include <libsigrok/libsigrok.h>
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/**
|
||||
* Initialize a software limit instance
|
||||
*
|
||||
* Must be called before any other operations are performed on a struct
|
||||
* sr_sw_limits and should typically be called after the data structure has been
|
||||
* allocated.
|
||||
*
|
||||
* @param limits the software limit instance to initialize
|
||||
*/
|
||||
SR_PRIV void sr_sw_limits_init(struct sr_sw_limits *limits)
|
||||
{
|
||||
limits->limit_samples = 0;
|
||||
limits->limit_msec = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get software limit configuration
|
||||
*
|
||||
* Retrieve the currently configured software limit for the specified key.
|
||||
* Should be called from the drivers config_get() callback.
|
||||
*
|
||||
* @param limits software limit instance
|
||||
* @param key config item key
|
||||
* @param data config item data
|
||||
* @return SR_ERR_NA if @p key is not a supported limit, SR_OK otherwise
|
||||
*/
|
||||
SR_PRIV int sr_sw_limits_config_get(struct sr_sw_limits *limits, uint32_t key,
|
||||
GVariant **data)
|
||||
{
|
||||
|
@ -48,6 +74,17 @@ SR_PRIV int sr_sw_limits_config_get(struct sr_sw_limits *limits, uint32_t key,
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set software limit configuration
|
||||
*
|
||||
* Configure software limit for the specified key. Should be called from the
|
||||
* drivers config_set() callback.
|
||||
*
|
||||
* @param limits software limit instance
|
||||
* @param key config item key
|
||||
* @param data config item data
|
||||
* @return SR_ERR_NA if @p key is not a supported limit, SR_OK otherwise
|
||||
*/
|
||||
SR_PRIV int sr_sw_limits_config_set(struct sr_sw_limits *limits, uint32_t key,
|
||||
GVariant *data)
|
||||
{
|
||||
|
@ -65,12 +102,30 @@ SR_PRIV int sr_sw_limits_config_set(struct sr_sw_limits *limits, uint32_t key,
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new data acquisition session
|
||||
*
|
||||
* Resets the internal accounting for all software limits. Usually should be
|
||||
* called from the drivers acquisition_start() callback.
|
||||
*
|
||||
* @param limits software limits instance
|
||||
*/
|
||||
SR_PRIV void sr_sw_limits_acquisition_start(struct sr_sw_limits *limits)
|
||||
{
|
||||
limits->samples_read = 0;
|
||||
limits->start_time = g_get_monotonic_time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any of the configured software limits has been reached
|
||||
*
|
||||
* Usually should be called at the end of the drivers work function after all
|
||||
* processing has been done.
|
||||
*
|
||||
* @param limits software limits instance
|
||||
* @returns TRUE if any of the software limits has been reached and the driver
|
||||
* should stop data acquisition, otherwise FALSE.
|
||||
*/
|
||||
SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits)
|
||||
{
|
||||
if (limits->limit_samples) {
|
||||
|
@ -89,6 +144,17 @@ SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the amount samples that have been read
|
||||
*
|
||||
* Update the amount of samples that have been read in the current data
|
||||
* acquisition run. For each invocation @p samples_read will be accumulated and
|
||||
* once the configured sample limit has been reached sr_sw_limits_check() will
|
||||
* return TRUE.
|
||||
*
|
||||
* @param limits software limits instance
|
||||
* @param samples_read the amount of samples that have been read
|
||||
*/
|
||||
SR_PRIV void sr_sw_limits_update_samples_read(struct sr_sw_limits *limits,
|
||||
uint64_t samples_read)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue