no-OS
Loading...
Searching...
No Matches
iio_maxm86161.h File Reference

Header file for MAXM86161 IIO driver. More...

#include "iio.h"
#include "maxm86161.h"
#include "no_os_circular_buffer.h"
Include dependency graph for iio_maxm86161.h:

Classes

struct  maxm86161_iio_desc
 
struct  maxm86161_iio_init_param
 

Macros

#define MAXM86161_ATTR(_name, _priv)
 
#define MAXM86161_ATTR_RO(_name, _priv)
 

Functions

int maxm86161_iio_init (struct maxm86161_iio_desc **iio_desc, struct maxm86161_iio_init_param *init_param)
 Initialize the MAXM86161 IIO device descriptor.
 
int maxm86161_iio_remove (struct maxm86161_iio_desc *iio_desc)
 Free resources allocated by maxm86161_iio_init().
 
int maxm86161_iio_get_dev_descriptor (struct maxm86161_iio_desc *iio_desc, struct iio_device **iio_dev)
 Retrieve the IIO device structure from the IIO descriptor.
 
void maxm86161_iio_fifo_irq_handler (void *ctx)
 FIFO almost-full interrupt handler for the MAXM86161 IIO device.
 

Detailed Description

Header file for MAXM86161 IIO driver.

Author
Jan Carlo Roleda (janca.nosp@m.rlo..nosp@m.roled.nosp@m.a@an.nosp@m.alog..nosp@m.com)

Copyright 2026(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ MAXM86161_ATTR

#define MAXM86161_ATTR ( _name,
_priv )
Value:
{ \
.name = _name, \
.show = maxm86161_iio_get_attr, \
.store = maxm86161_iio_set_attr, \
.priv = _priv, \
}

◆ MAXM86161_ATTR_RO

#define MAXM86161_ATTR_RO ( _name,
_priv )
Value:
{ \
.name = _name, \
.show = maxm86161_iio_get_attr, \
.store = NULL, \
.priv = _priv, \
}
#define NULL
Definition wrapper.h:64

Function Documentation

◆ maxm86161_iio_fifo_irq_handler()

void maxm86161_iio_fifo_irq_handler ( void * ctx)

FIFO almost-full interrupt handler for the MAXM86161 IIO device.

Invoked by the driver-level IRQ dispatcher when the FIFO almost-full (A_FULL) condition is asserted. It queries the current FIFO sample count, clamps it to the physical FIFO depth, reads the pending samples from the device, decodes each sample (tag + 24-bit data) and writes the raw data words into the IIO circular buffer for later consumption by the submit callback. Samples that fail to decode are skipped. The function returns silently on any error or when there are no samples to read.

Parameters
ctx- Opaque context pointer to the MAXM86161 IIO descriptor (struct maxm86161_iio_desc *).

◆ maxm86161_iio_get_dev_descriptor()

int maxm86161_iio_get_dev_descriptor ( struct maxm86161_iio_desc * iio_desc,
struct iio_device ** iio_dev )

Retrieve the IIO device structure from the IIO descriptor.

Provides access to the underlying struct iio_device so it can be registered with the IIO framework.

Parameters
iio_desc- IIO descriptor.
iio_dev- Pointer that receives the address of the IIO device structure.
Returns
0 on success, -EINVAL if iio_desc or iio_dev is NULL.

◆ maxm86161_iio_init()

int maxm86161_iio_init ( struct maxm86161_iio_desc ** iio_desc,
struct maxm86161_iio_init_param * init_param )

Initialize the MAXM86161 IIO device descriptor.

Allocates the IIO descriptor, initializes the underlying MAXM86161 driver device, sets up the FIFO circular buffer, configures the FIFO watermark and registers the FIFO almost-full interrupt handler. The IRQ must be enabled in the driver init parameters for IIO operation. On failure, all previously acquired resources are released before returning.

Parameters
iio_desc- Pointer that receives the address of the allocated IIO descriptor on success.
init_param- Initialization parameters, including the driver init parameters and the FIFO watermark level.
Returns
0 on success, negative error code otherwise: -EINVAL if arguments are invalid or IRQ is not enabled, -ENOMEM if descriptor allocation fails, or a propagated error from the driver/FIFO/IRQ setup.

◆ maxm86161_iio_remove()

int maxm86161_iio_remove ( struct maxm86161_iio_desc * iio_desc)

Free resources allocated by maxm86161_iio_init().

Detaches the FIFO almost-full callback from the driver-level IRQ dispatcher, removes the FIFO circular buffer, removes the underlying MAXM86161 driver device and frees the IIO descriptor.

Parameters
iio_desc- IIO descriptor to free.
Returns
0 on success, -EINVAL if iio_desc is NULL.