no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
iio_pqm.c File Reference
#include "iio_pqm.h"
Include dependency graph for iio_pqm.c:

Macros

#define PQM_VOLTAGE_CHANNEL(_idx, _scan_idx, _name)
 
#define PQM_CURRENT_CHANNEL(_idx, _scan_idx, _name)
 
#define PQM_EVENT_CHANNEL(_idx, _scan_idx, _name, _attrb_def)
 
#define EVENT_COMMON_ATTR
 

Functions

int read_pqm_attr (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
 Read a pqm device attribute.
 
int write_pqm_attr (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
 Write a pqm device attribute.
 
int read_ch_attr (void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
 Read a channel attribute.
 
int32_t read_samples (struct iio_device_data *dev_data)
 function for reading samples from the device.
 
int32_t pqm_trigger_handler (struct iio_device_data *dev_data)
 Handles trigger: reads one data-set and writes it to the buffer.
 

Variables

volatile bool configChanged = false
 
volatile bool processData = true
 
struct iio_attribute voltage_pqm_attributes []
 
struct iio_attribute current_pqm_attributes []
 
struct iio_attribute global_pqm_attributes []
 
struct iio_attribute event_pqm_dips_attribute []
 
struct iio_attribute event_pqm_swell_attribute []
 
struct iio_attribute event_pqm_rvc_attribute []
 
struct iio_attribute event_pqm_intrpr_attribute []
 
struct scan_type pqm_scan_type
 
struct iio_device pqm_iio_descriptor
 

Macro Definition Documentation

◆ EVENT_COMMON_ATTR

#define EVENT_COMMON_ATTR
Value:
{ \
.name = "countEvent", \
.show = read_ch_attr, \
.priv = CHAN_EVENT_COUNT, \
}, \
{ \
.name = "startTime", \
.show = read_ch_attr, \
}, \
{ \
.name = "endTime", \
.show = read_ch_attr, \
}, \
{ \
.name = "durationInCycles", \
.show = read_ch_attr, \
}
int read_ch_attr(void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t attr_id)
Read a channel attribute.
Definition iio_pqm.c:343
#define CHAN_EVENT_DURATION_IN_CYCL
Definition iio_pqm.h:96
#define CHAN_EVENT_START_TIME
Definition iio_pqm.h:94
#define CHAN_EVENT_END_TIME
Definition iio_pqm.h:95
#define CHAN_EVENT_COUNT
Definition iio_pqm.h:93

◆ PQM_CURRENT_CHANNEL

#define PQM_CURRENT_CHANNEL ( _idx,
_scan_idx,
_name )
Value:
{ \
.name = _name, .ch_type = IIO_CURRENT, .channel = _idx, \
.scan_index = _scan_idx, .indexed = true, .scan_type = &pqm_scan_type, \
.attributes = current_pqm_attributes, .ch_out = false \
}
struct scan_type pqm_scan_type
Definition iio_pqm.c:1023
struct iio_attribute current_pqm_attributes[]
Definition iio_pqm.c:743
@ IIO_CURRENT
Definition iio_types.h:57

◆ PQM_EVENT_CHANNEL

#define PQM_EVENT_CHANNEL ( _idx,
_scan_idx,
_name,
_attrb_def )
Value:
{ \
.name = _name, .ch_type = IIO_COUNT, .channel = _idx, \
.scan_index = _scan_idx, .indexed = true, \
.scan_type = 0, .attributes = _attrb_def, \
.ch_out = true \
}
@ IIO_COUNT
Definition iio_types.h:69

◆ PQM_VOLTAGE_CHANNEL

#define PQM_VOLTAGE_CHANNEL ( _idx,
_scan_idx,
_name )
Value:
{ \
.name = _name, .ch_type = IIO_VOLTAGE, .channel = _idx, \
.scan_index = _scan_idx, .indexed = true, .scan_type = &pqm_scan_type, \
.attributes = voltage_pqm_attributes, .ch_out = false \
}
struct iio_attribute voltage_pqm_attributes[]
Definition iio_pqm.c:662
@ IIO_VOLTAGE
Definition iio_types.h:56

Function Documentation

◆ pqm_trigger_handler()

int32_t pqm_trigger_handler ( struct iio_device_data * dev_data)

Handles trigger: reads one data-set and writes it to the buffer.

Parameters
dev_data- The iio device data structure.
Returns
ret - Result of the handling procedure. In case of success, the size of the written data is returned.

◆ read_ch_attr()

int read_ch_attr ( void * device,
char * buf,
uint32_t len,
const struct iio_ch_info * channel,
intptr_t attr_id )

Read a channel attribute.

Parameters
device- The iio device structure
buf- Buffer to be filled with requested data
len- Length of the received command buffer in bytes
channel- Command channel info
attr_id- attribute descriptor
Returns
- The length of the buffer in case of success, negative value otherwise

◆ read_pqm_attr()

int read_pqm_attr ( void * device,
char * buf,
uint32_t len,
const struct iio_ch_info * channel,
intptr_t attr_id )

Read a pqm device attribute.

Parameters
device- The iio device structure
buf- Buffer to be filled with requested data
len- Length of the received command buffer in bytes
channel- Command channel info
attr_id- attribute descriptor
Returns
- The length of the buffer in case of success, negative value otherwise

◆ read_samples()

int32_t read_samples ( struct iio_device_data * dev_data)

function for reading samples from the device.

Parameters
dev_data- The iio device data structure.
Returns
the number of read samples.

◆ write_pqm_attr()

int write_pqm_attr ( void * device,
char * buf,
uint32_t len,
const struct iio_ch_info * channel,
intptr_t attr_id )

Write a pqm device attribute.

Parameters
device- The iio device structure
buf- Buffer to be filled with requested data
len- Length of the received command buffer in bytes
channel- Command channel info
attr_id- attribute descriptor
Returns
- The length of the buffer in case of success, negative value otherwise

Variable Documentation

◆ configChanged

volatile bool configChanged = false

◆ current_pqm_attributes

struct iio_attribute current_pqm_attributes[]

◆ event_pqm_dips_attribute

struct iio_attribute event_pqm_dips_attribute[]
Initial value:
= {
{
.name = "minMag",
.show = read_ch_attr,
},
}
#define EVENT_COMMON_ATTR
Definition iio_pqm.c:58
#define CHAN_EVENT_MIN_MAG
Definition iio_pqm.h:97
#define END_ATTRIBUTES_ARRAY
Definition iio_types.h:107

◆ event_pqm_intrpr_attribute

struct iio_attribute event_pqm_intrpr_attribute[]
Initial value:

◆ event_pqm_rvc_attribute

struct iio_attribute event_pqm_rvc_attribute[]
Initial value:
= {
{
.name = "deltaUmax",
.show = read_ch_attr,
},
{
.name = "deltaUss",
.show = read_ch_attr,
},
}
#define CHAN_EVENT_DELTA_U_SS
Definition iio_pqm.h:100
#define CHAN_EVENT_DELTA_U_MAX
Definition iio_pqm.h:99

◆ event_pqm_swell_attribute

struct iio_attribute event_pqm_swell_attribute[]
Initial value:
= {
{
.name = "maxMag",
.show = read_ch_attr,
},
}
#define CHAN_EVENT_MAX_MAG
Definition iio_pqm.h:98

◆ global_pqm_attributes

struct iio_attribute global_pqm_attributes[]

◆ pqm_iio_descriptor

struct iio_device pqm_iio_descriptor
Initial value:
= {
.num_ch = TOTAL_PQM_CHANNELS,
.channels = iio_pqm_channels,
.attributes = global_pqm_attributes,
.debug_attributes = NULL,
.buffer_attributes = NULL,
.pre_enable = update_pqm_channels,
.post_disable = close_pqm_channels,
.trigger_handler = (int32_t(*)())pqm_trigger_handler,
.submit = (int32_t(*)())read_samples,
}
#define TOTAL_PQM_CHANNELS
Definition common_data.h:64
int32_t update_pqm_channels(void *dev, uint32_t mask)
active pqm channels
Definition basic_example.c:70
int32_t close_pqm_channels(void *dev)
close all channels
Definition basic_example.c:83
int32_t read_samples(struct iio_device_data *dev_data)
function for reading samples from the device.
Definition iio_pqm.c:613
struct iio_attribute global_pqm_attributes[]
Definition iio_pqm.c:789
int32_t pqm_trigger_handler(struct iio_device_data *dev_data)
Handles trigger: reads one data-set and writes it to the buffer.
Definition iio_pqm.c:632
#define NULL
Definition wrapper.h:64

◆ pqm_scan_type

struct scan_type pqm_scan_type
Initial value:
= {.sign = 's',
.realbits = 16,
.storagebits = 16,
.shift = 0,
.is_big_endian =
true
}

◆ processData

volatile bool processData = true

◆ voltage_pqm_attributes

struct iio_attribute voltage_pqm_attributes[]