no-OS
Macros | Functions | Variables
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. More...
 
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. More...
 
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. More...
 
int32_t read_samples (struct iio_device_data *dev_data)
 function for reading samples from the device. More...
 
int32_t pqm_trigger_handler (struct iio_device_data *dev_data)
 Handles trigger: reads one data-set and writes it to the buffer. More...
 

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, \
}

◆ 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 \
}

◆ 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 = &pqm_scan_type, .attributes = _attrb_def, \
.ch_out = true \
}

◆ 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 \
}

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,
},
}

◆ 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,
},
}

◆ event_pqm_swell_attribute

struct iio_attribute event_pqm_swell_attribute[]
Initial value:
= {
{
.name = "maxMag",
.show = read_ch_attr,
},
}

◆ 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,
.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,
}

◆ pqm_scan_type

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

◆ processData

volatile bool processData = true

◆ voltage_pqm_attributes

struct iio_attribute voltage_pqm_attributes[]
END_ATTRIBUTES_ARRAY
#define END_ATTRIBUTES_ARRAY
Definition: iio_types.h:116
IIO_COUNT
@ IIO_COUNT
Definition: iio_types.h:78
CHAN_EVENT_COUNT
#define CHAN_EVENT_COUNT
Definition: iio_pqm.h:101
current_pqm_attributes
struct iio_attribute current_pqm_attributes[]
Definition: iio_pqm.c:759
CHAN_EVENT_DELTA_U_SS
#define CHAN_EVENT_DELTA_U_SS
Definition: iio_pqm.h:108
CHAN_EVENT_DURATION_IN_CYCL
#define CHAN_EVENT_DURATION_IN_CYCL
Definition: iio_pqm.h:104
TOTAL_PQM_CHANNELS
#define TOTAL_PQM_CHANNELS
Definition: common_data.h:72
read_samples
int32_t read_samples(struct iio_device_data *dev_data)
function for reading samples from the device.
Definition: iio_pqm.c:629
EVENT_COMMON_ATTR
#define EVENT_COMMON_ATTR
Definition: iio_pqm.c:66
CHAN_EVENT_MIN_MAG
#define CHAN_EVENT_MIN_MAG
Definition: iio_pqm.h:105
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.
Definition: iio_pqm.c:648
global_pqm_attributes
struct iio_attribute global_pqm_attributes[]
Definition: iio_pqm.c:805
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:359
pqm_scan_type
struct scan_type pqm_scan_type
Definition: iio_pqm.c:1039
IIO_CURRENT
@ IIO_CURRENT
Definition: iio_types.h:66
IIO_VOLTAGE
@ IIO_VOLTAGE
Definition: iio_types.h:65
CHAN_EVENT_END_TIME
#define CHAN_EVENT_END_TIME
Definition: iio_pqm.h:103
CHAN_EVENT_DELTA_U_MAX
#define CHAN_EVENT_DELTA_U_MAX
Definition: iio_pqm.h:107
voltage_pqm_attributes
struct iio_attribute voltage_pqm_attributes[]
Definition: iio_pqm.c:678
CHAN_EVENT_MAX_MAG
#define CHAN_EVENT_MAX_MAG
Definition: iio_pqm.h:106
iio_channel::attributes
struct iio_attribute * attributes
Definition: iio_types.h:186
update_pqm_channels
int32_t update_pqm_channels(void *dev, uint32_t mask)
active pqm channels
Definition: basic_example.c:78
NULL
#define NULL
Definition: wrapper.h:64
close_pqm_channels
int32_t close_pqm_channels(void *dev)
close all channels
Definition: basic_example.c:91
CHAN_EVENT_START_TIME
#define CHAN_EVENT_START_TIME
Definition: iio_pqm.h:102