no-OS
Loading...
Searching...
No Matches
adiol100.c File Reference

Implementation of ADIOL100 Driver. More...

#include "adiol100.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_print_log.h"
#include "no_os_spi.h"
#include <errno.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for adiol100.c:

Functions

int adiol100_read_revid (struct adiol100_dev *dev, uint16_t *rev_id)
 Read the chip RevisionID register.
 
int adiol100_read_devid (struct adiol100_dev *dev, uint16_t *dev_id)
 Read the chip DeviceID register.
 
int adiol100_setup_clock (struct adiol100_dev *dev, uint8_t clock_src, uint8_t clk_div)
 Configure the clock source, divider, and enable clock output.
 
int adiol100_init (struct adiol100_dev **dev, struct adiol100_init_param *ip)
 Initialize the ADIOL100 device.
 
int adiol100_remove (struct adiol100_dev *dev)
 Free resources allocated by adiol100_init().
 
int adiol100_read (struct adiol100_dev *dev, uint16_t reg, uint16_t *value)
 Read a 16-bit register. Handles paged access automatically.
 
int adiol100_write (struct adiol100_dev *dev, uint16_t reg, uint16_t value)
 Write a 16-bit register. Handles paged access automatically.
 
int adiol100_update (struct adiol100_dev *dev, uint16_t reg, uint16_t mask, uint16_t value)
 Read-modify-write a register using a bit mask.
 
int adiol100_load_msg (struct adiol100_dev *dev, enum adiol100_channel ch, const uint8_t *data, uint8_t txbytes, uint8_t rxbytes, enum adiol100_keep_msg keep)
 Load IO-Link payload into TxFIFO without triggering CQSend.
 
int adiol100_send_msg (struct adiol100_dev *dev, enum adiol100_channel ch)
 Assert CQSend to trigger transmission of the message in the TxFIFO.
 
int adiol100_load_and_send_msg (struct adiol100_dev *dev, enum adiol100_channel ch, uint8_t *data, uint8_t txbytes, uint8_t rxbytes, enum adiol100_keep_msg keep, uint16_t framctrl1)
 Load IO-Link payload into TxFIFO and trigger CQSend in one SPI burst.
 
int adiol100_read_msg (struct adiol100_dev *dev, enum adiol100_channel ch, uint8_t *data, uint8_t data_len)
 Read device response from RxFIFO, stripping the MsgID/RxBytesAct header.
 
int adiol100_read_channel_burst (struct adiol100_dev *dev, enum adiol100_channel ch, uint16_t *rxstat, uint16_t *irq, uint16_t *status, uint8_t *data, uint8_t data_len)
 Burst-read RxFIFOStat, Interrupt, Status, and RxFIFO in one SPI cycle.
 
int adiol100_global_reset (struct adiol100_dev *dev)
 Disable global interrupts, clear trigger, read-clear all IRQ registers, and turn off all LEDs.
 
int adiol100_reset_tx_fifo (struct adiol100_dev *dev, enum adiol100_channel ch)
 Reset the transmit FIFO for a channel.
 
int adiol100_reset_rx_fifo (struct adiol100_dev *dev, enum adiol100_channel ch)
 Reset the receive FIFO for a channel.
 
int adiol100_reset_channel (struct adiol100_dev *dev, enum adiol100_channel ch)
 Assert CHANRST to reset all channel-specific registers.
 
int adiol100_config_cq (struct adiol100_dev *dev, enum adiol100_channel ch, enum adiol100_cq_mode mode, enum adiol100_cq_drv drv_en, enum adiol100_sink_sel sink_sel, enum adiol100_cq_slew_rate slew_rate, enum adiol100_iec3th iec3th, enum adiol100_source_sink source_sink, enum adiol100_glitch_filter glitch_filter, enum adiol100_cq_npn npn, enum adiol100_cq_ext cq_ext, enum adiol100_inv_cq inv_cq, enum adiol100_cq_txen txen)
 Configure the CQ driver.
 
int adiol100_config_cq_protection (struct adiol100_dev *dev, enum adiol100_channel ch, enum adiol100_cq_current_limit current_limit, enum adiol100_blanking_time blanking, enum adiol100_autoretry_timeout retry_tmo, enum adiol100_autoretry retry_en, enum adiol100_voltage_threshold tx_vthr_h, enum adiol100_voltage_threshold tx_vthr_l, enum adiol100_voltage_threshold rx_vthr_h, enum adiol100_voltage_threshold rx_vthr_l)
 Configure CQ protection: current limit, blanking, thresholds, autoretry.
 
int adiol100_config_lp (struct adiol100_dev *dev, enum adiol100_channel ch, enum adiol100_lp_en enable, enum adiol100_lp_rev rev_en)
 Configure the L+ sensor supply: enable and reverse polarity protection.
 
int adiol100_config_lp_protection (struct adiol100_dev *dev, enum adiol100_channel ch, uint8_t cl_nom, uint8_t pwr_max, uint8_t curr_max, uint8_t curr_min, uint8_t ol_timeout, uint8_t cl_timeout, uint8_t slope, uint8_t slope_bl, uint8_t ar_time, uint8_t ar_count)
 Configure L+ FET protection: current, power, timeouts, slope, retry.
 
int adiol100_config_cq_protection_ext (struct adiol100_dev *dev, enum adiol100_channel ch, uint8_t cl_nom, uint8_t pwr_max, uint8_t curr_max, uint8_t curr_min, uint8_t ol_timeout, uint8_t cl_timeout, uint8_t slope, uint8_t slope_bl, uint8_t ar_time, uint8_t ar_count)
 Configure CQ external high-side FET protection.
 
int adiol100_config_di (struct adiol100_dev *dev, enum adiol100_channel ch, enum adiol100_iec3th iec3th, enum adiol100_source_sink source_sink, enum adiol100_sink_sel sink_sel, enum adiol100_glitch_filter glitch_filter, enum adiol100_inv_di inv_di)
 Configure the digital input (DICfgA/B).
 
int adiol100_config_framer (struct adiol100_dev *dev, enum adiol100_channel ch, enum adiol100_ins_chks ins_chks, enum adiol100_framer framer_en, enum adiol100_ckt_err_inh ckt_err_inh, enum adiol100_msg_repeat msg_repeat, enum adiol100_bdelay bdelay, uint8_t ddelay, enum adiol100_tsize_err_inh tsize_err_inh, enum adiol100_uart_par uart_par, enum adiol100_uart_baud uart_baud, enum adiol100_uart_en uart_en, enum adiol100_safe_pulse_det safe_pulse_det)
 Configure the IO-Link framer (FramCtrl1 + FramCtrl2).
 
int adiol100_wakeup_request (struct adiol100_dev *dev, enum adiol100_channel ch)
 Generate a wake-up pulse (WURQ) on a channel.
 
int adiol100_clear_estcom_fails (struct adiol100_dev *dev, enum adiol100_channel ch)
 Clear the establish-communication fail counter in StatusA/B.
 
int adiol100_config_trigger (struct adiol100_dev *dev, enum adiol100_channel ch, enum adiol100_auto_cycler_dis auto_cycler_dis, enum adiol100_trig_val trig_val, enum adiol100_trig_en trig_en)
 Configure trigger assignment for a channel.
 
int adiol100_fire_trigger (struct adiol100_dev *dev, enum adiol100_trig_val trig_val)
 Fire an SPI trigger to start transmission on matching channels.
 
int adiol100_led_sync (struct adiol100_dev *dev)
 Synchronize LED drivers across multiple devices.
 
int adiol100_set_burst_len (struct adiol100_dev *dev, enum adiol100_channel ch, uint8_t write_len, uint8_t read_len)
 Set the SPI burst length for FIFO access.
 
int adiol100_get_comrt (struct adiol100_dev *dev, enum adiol100_channel ch, uint8_t *comrt)
 Get the communication rate determined by EstCom (COM1/2/3).
 
int adiol100_set_cycle_tmr (struct adiol100_dev *dev, enum adiol100_channel ch, uint8_t value)
 Set the IO-Link cycle timer value.
 
int adiol100_get_cycle_tmr (struct adiol100_dev *dev, enum adiol100_channel ch, uint16_t *value)
 Get the current cycle timer register value.
 
int adiol100_enable_cycle_timer (struct adiol100_dev *dev, enum adiol100_channel ch)
 Enable the cycle timer for autonomous cyclic operation.
 
int adiol100_disable_cycle_timer (struct adiol100_dev *dev, enum adiol100_channel ch)
 Disable the cycle timer.
 
int adiol100_get_channel_irq (struct adiol100_dev *dev, enum adiol100_channel ch, uint16_t *flags)
 Read and accumulate channel interrupt flags.
 
int adiol100_get_global_irq (struct adiol100_dev *dev, uint16_t *flags)
 Read and accumulate global interrupt flags.
 
void adiol100_clear_channel_irq (struct adiol100_dev *dev, enum adiol100_channel ch, uint16_t mask)
 Clear specific bits from the accumulated channel interrupt flags.
 
void adiol100_clear_global_irq (struct adiol100_dev *dev, uint16_t mask)
 Clear specific bits from the accumulated global interrupt flags.
 
int adiol100_enable_global_irq (struct adiol100_dev *dev, uint16_t mask)
 Set the global interrupt enable mask.
 
int adiol100_enable_channel_irq (struct adiol100_dev *dev, enum adiol100_channel ch, uint16_t mask)
 Set the channel interrupt enable mask.
 
int adiol100_get_fifo_status (struct adiol100_dev *dev, enum adiol100_channel ch, uint16_t *flags)
 Read the RxFIFO status register (level + error flags).
 
int adiol100_get_status (struct adiol100_dev *dev, enum adiol100_channel ch, uint16_t *flags)
 Read the channel status register.
 
int adiol100_config_watchdog (struct adiol100_dev *dev, enum adiol100_wdg_timebase timebase, uint8_t time, enum adiol100_wdg_mode mode, enum adiol100_wdg_en enable, enum adiol100_wdg_lock lock)
 Configure the watchdog timer.
 
int adiol100_clear_watchdog (struct adiol100_dev *dev)
 Clear the watchdog timer (write-1-to-clear).
 
int adiol100_read_adc_global (struct adiol100_dev *dev, enum adiol100_adc_global source, uint16_t *value)
 Read a raw 13-bit global ADC measurement (V24 voltage or temperature).
 
int adiol100_read_adc_chan (struct adiol100_dev *dev, enum adiol100_adc_chan source, enum adiol100_channel ch, uint16_t *value)
 Read a raw 13-bit per-channel ADC measurement (CQ/LP voltage or current).
 
int adiol100_reset_adc_stats (struct adiol100_dev *dev)
 Reset all ADC min/max statistics (V24, Temp, CQ and LP for both channels).
 
int adiol100_set_led_brightness (struct adiol100_dev *dev, enum adiol100_led led, enum adiol100_led_brightness red_bgt, enum adiol100_led_brightness green_bgt)
 Set the brightness for one LED.
 
int adiol100_set_led_sequence (struct adiol100_dev *dev, enum adiol100_led led, enum adiol100_led_seq red_seq, enum adiol100_led_seq green_seq)
 Set the blink sequence for one LED.
 
int adiol100_set_led_mode (struct adiol100_dev *dev, enum adiol100_led led, enum adiol100_led_mode mode)
 Set the operating mode for one LED.
 
int adiol100_reset_leds (struct adiol100_dev *dev)
 Turn off all four LEDs by clearing their sequences and resetting modes.
 
int adiol100_estcom (struct adiol100_dev *dev, enum adiol100_channel ch)
 Run EstablishCommunication: reset FIFOs, set EstCom, poll for result.
 

Detailed Description

Implementation of ADIOL100 Driver.

Author
Liviu Stan (liviu.nosp@m..sta.nosp@m.n@ana.nosp@m.log..nosp@m.com)

Copyright 2026(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ adiol100_clear_channel_irq()

void adiol100_clear_channel_irq ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint16_t mask )

Clear specific bits from the accumulated channel interrupt flags.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
mask- Bitmask of flags to clear.

◆ adiol100_clear_estcom_fails()

int adiol100_clear_estcom_fails ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Clear the establish-communication fail counter in StatusA/B.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_clear_global_irq()

void adiol100_clear_global_irq ( struct adiol100_dev * dev,
uint16_t mask )

Clear specific bits from the accumulated global interrupt flags.

Parameters
dev- The device structure.
mask- Bitmask of flags to clear.

◆ adiol100_clear_watchdog()

int adiol100_clear_watchdog ( struct adiol100_dev * dev)

Clear the watchdog timer (write-1-to-clear).

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_cq()

int adiol100_config_cq ( struct adiol100_dev * dev,
enum adiol100_channel ch,
enum adiol100_cq_mode mode,
enum adiol100_cq_drv drv_en,
enum adiol100_sink_sel sink_sel,
enum adiol100_cq_slew_rate slew_rate,
enum adiol100_iec3th iec3th,
enum adiol100_source_sink source_sink,
enum adiol100_glitch_filter glitch_filter,
enum adiol100_cq_npn npn,
enum adiol100_cq_ext cq_ext,
enum adiol100_inv_cq inv_cq,
enum adiol100_cq_txen txen )

Configure the CQ driver.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
mode- Push-pull or open-drain driver mode.
drv_en- Enable or disable the CQ driver.
sink_sel- Input sink/source current level.
slew_rate- CQ output slew rate.
iec3th- IEC 61131-2 type 2/3 threshold (0 for IO-Link).
source_sink- Current source or sink on CQ.
glitch_filter- CQ receiver glitch filter.
npn- NPN/PNP mode (ignored if push-pull).
cq_ext- Use external high-side FET.
inv_cq- Invert CQ output polarity.
txen- CQ transmitter enable (SIO only, 0 with framer).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_cq_protection()

int adiol100_config_cq_protection ( struct adiol100_dev * dev,
enum adiol100_channel ch,
enum adiol100_cq_current_limit current_limit,
enum adiol100_blanking_time blanking,
enum adiol100_autoretry_timeout retry_tmo,
enum adiol100_autoretry retry_en,
enum adiol100_voltage_threshold tx_vthr_h,
enum adiol100_voltage_threshold tx_vthr_l,
enum adiol100_voltage_threshold rx_vthr_h,
enum adiol100_voltage_threshold rx_vthr_l )

Configure CQ protection: current limit, blanking, thresholds, autoretry.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
current_limit- CQ driver current limit.
blanking- Current limit blanking time.
retry_tmo- Autoretry timeout after current limit event.
retry_en- Enable or disable autoretry.
tx_vthr_h- CQ transmit high voltage threshold.
tx_vthr_l- CQ transmit low voltage threshold.
rx_vthr_h- CQ receive high voltage threshold.
rx_vthr_l- CQ receive low voltage threshold.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_cq_protection_ext()

int adiol100_config_cq_protection_ext ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint8_t cl_nom,
uint8_t pwr_max,
uint8_t curr_max,
uint8_t curr_min,
uint8_t ol_timeout,
uint8_t cl_timeout,
uint8_t slope,
uint8_t slope_bl,
uint8_t ar_time,
uint8_t ar_count )

Configure CQ external high-side FET protection.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
cl_nom- Nominal current limit (CQExtCfg, 8-bit, 20mA/step with 10mOhm Rsense).
pwr_max- Maximum power dissipation (8-bit, 1W/step).
curr_max- Maximum current (8-bit, 20mA/step).
curr_min- Minimum current at turn-on (8-bit, 20mA/step).
ol_timeout- Overload timeout (8-bit, 2ms/step).
cl_timeout- Current limit timeout (8-bit, 2ms/step).
slope- Minimum voltage slope (8-bit, 19.5V/s per step).
slope_bl- Slope blanking time (8-bit, 2ms/step).
ar_time- Autoretry time (6-bit, 25ms/step).
ar_count- Autoretry count (4-bit, 0 = unlimited).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_di()

int adiol100_config_di ( struct adiol100_dev * dev,
enum adiol100_channel ch,
enum adiol100_iec3th iec3th,
enum adiol100_source_sink source_sink,
enum adiol100_sink_sel sink_sel,
enum adiol100_glitch_filter glitch_filter,
enum adiol100_inv_di inv_di )

Configure the digital input (DICfgA/B).

Parameters
dev- The device structure.
ch- Channel selection (A or B).
iec3th- IEC 61131-2 type 2/3 threshold select.
source_sink- Current sink or source select.
sink_sel- Sink/source current level.
glitch_filter- Glitch filter setting.
inv_di- Invert DI logic output.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_framer()

int adiol100_config_framer ( struct adiol100_dev * dev,
enum adiol100_channel ch,
enum adiol100_ins_chks ins_chks,
enum adiol100_framer framer_en,
enum adiol100_ckt_err_inh ckt_err_inh,
enum adiol100_msg_repeat msg_repeat,
enum adiol100_bdelay bdelay,
uint8_t ddelay,
enum adiol100_tsize_err_inh tsize_err_inh,
enum adiol100_uart_par uart_par,
enum adiol100_uart_baud uart_baud,
enum adiol100_uart_en uart_en,
enum adiol100_safe_pulse_det safe_pulse_det )

Configure the IO-Link framer (FramCtrl1 + FramCtrl2).

Parameters
dev- The device structure.
ch- Channel selection (A or B).
ins_chks- Enable or disable checksum insertion.
framer_en- Enable or disable the framer.
ckt_err_inh- Suppress or send message on CKT error.
msg_repeat- Auto-repeat last message if FIFO not reloaded.
bdelay- Additional byte delay (0–3 TBIT).
ddelay- Device answer delay. Wait time = 4 + ddelay * 2 TBIT. Set 3 for IO-Link standard (10 TBIT). Range 0–255.
tsize_err_inh- Inhibit TX size error checking.
uart_par- UART parity bit enable.
uart_baud- UART baud rate (ignored in IO-Link mode).
uart_en- UART mode enable (0 for IO-Link mode).
safe_pulse_det- Enable safety pulse detection.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_lp()

int adiol100_config_lp ( struct adiol100_dev * dev,
enum adiol100_channel ch,
enum adiol100_lp_en enable,
enum adiol100_lp_rev rev_en )

Configure the L+ sensor supply: enable and reverse polarity protection.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
enable- Enable or disable L+ supply.
rev_en- Enable or disable reverse polarity protection.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_lp_protection()

int adiol100_config_lp_protection ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint8_t cl_nom,
uint8_t pwr_max,
uint8_t curr_max,
uint8_t curr_min,
uint8_t ol_timeout,
uint8_t cl_timeout,
uint8_t slope,
uint8_t slope_bl,
uint8_t ar_time,
uint8_t ar_count )

Configure L+ FET protection: current, power, timeouts, slope, retry.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
cl_nom- Nominal current limit (LPCfg, 8-bit, 20mA/step with 10mOhm Rsense).
pwr_max- Maximum power dissipation (8-bit, 1W/step).
curr_max- Maximum current (8-bit, 20mA/step).
curr_min- Minimum current at turn-on (8-bit, 20mA/step).
ol_timeout- Overload timeout (8-bit, 2ms/step).
cl_timeout- Current limit timeout (8-bit, 2ms/step).
slope- Minimum voltage slope (8-bit, 19.5V/s per step).
slope_bl- Slope blanking time (8-bit, 2ms/step).
ar_time- Autoretry time (6-bit, 25ms/step).
ar_count- Autoretry count (4-bit, 0 = unlimited).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_trigger()

int adiol100_config_trigger ( struct adiol100_dev * dev,
enum adiol100_channel ch,
enum adiol100_auto_cycler_dis auto_cycler_dis,
enum adiol100_trig_val trig_val,
enum adiol100_trig_en trig_en )

Configure trigger assignment for a channel.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
auto_cycler_dis- Auto-disable cycler on COMLOST.
trig_val- Trigger value (0–15). 0 is global trigger.
trig_en- Enable SPI-based trigger synchronization.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_config_watchdog()

int adiol100_config_watchdog ( struct adiol100_dev * dev,
enum adiol100_wdg_timebase timebase,
uint8_t time,
enum adiol100_wdg_mode mode,
enum adiol100_wdg_en enable,
enum adiol100_wdg_lock lock )

Configure the watchdog timer.

Parameters
dev- The device structure.
timebase- Timer tick period (100us, 500us, or 2ms).
time- Timeout multiplier (6-bit, 0–63).
mode- SPI activity reset or explicit clear.
enable- Enable or disable the watchdog.
lock- Lock the watchdog configuration.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_disable_cycle_timer()

int adiol100_disable_cycle_timer ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Disable the cycle timer.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_enable_channel_irq()

int adiol100_enable_channel_irq ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint16_t mask )

Set the channel interrupt enable mask.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
mask- Bitmask of interrupts to enable.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_enable_cycle_timer()

int adiol100_enable_cycle_timer ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Enable the cycle timer for autonomous cyclic operation.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_enable_global_irq()

int adiol100_enable_global_irq ( struct adiol100_dev * dev,
uint16_t mask )

Set the global interrupt enable mask.

Parameters
dev- The device structure.
mask- Bitmask of interrupts to enable.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_estcom()

int adiol100_estcom ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Run EstablishCommunication: reset FIFOs, set EstCom, poll for result.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 on success, -ENODEV if no device responded, -ETIMEDOUT on timeout.

◆ adiol100_fire_trigger()

int adiol100_fire_trigger ( struct adiol100_dev * dev,
enum adiol100_trig_val trig_val )

Fire an SPI trigger to start transmission on matching channels.

Parameters
dev- The device structure.
trig_val- Trigger value (0–15).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_get_channel_irq()

int adiol100_get_channel_irq ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint16_t * flags )

Read and accumulate channel interrupt flags.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
flags- Pointer to store the accumulated interrupt flags.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_get_comrt()

int adiol100_get_comrt ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint8_t * comrt )

Get the communication rate determined by EstCom (COM1/2/3).

Parameters
dev- The device structure.
ch- Channel selection (A or B).
comrt- Pointer to store the COM rate value (1, 2, or 3).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_get_cycle_tmr()

int adiol100_get_cycle_tmr ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint16_t * value )

Get the current cycle timer register value.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
value- Pointer to store the cycle timer value.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_get_fifo_status()

int adiol100_get_fifo_status ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint16_t * flags )

Read the RxFIFO status register (level + error flags).

Parameters
dev- The device structure.
ch- Channel selection (A or B).
flags- Pointer to store the status flags.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_get_global_irq()

int adiol100_get_global_irq ( struct adiol100_dev * dev,
uint16_t * flags )

Read and accumulate global interrupt flags.

Parameters
dev- The device structure.
flags- Pointer to store the accumulated interrupt flags.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_get_status()

int adiol100_get_status ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint16_t * flags )

Read the channel status register.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
flags- Pointer to store the status flags.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_global_reset()

int adiol100_global_reset ( struct adiol100_dev * dev)

Disable global interrupts, clear trigger, read-clear all IRQ registers, and turn off all LEDs.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_init()

int adiol100_init ( struct adiol100_dev ** dev,
struct adiol100_init_param * ip )

Initialize the ADIOL100 device.

Parameters
dev- Pointer to the device descriptor (allocated internally).
ip- Initialization parameters (SPI, address, clock).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_led_sync()

int adiol100_led_sync ( struct adiol100_dev * dev)

Synchronize LED drivers across multiple devices.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_load_and_send_msg()

int adiol100_load_and_send_msg ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint8_t * data,
uint8_t txbytes,
uint8_t rxbytes,
enum adiol100_keep_msg keep,
uint16_t framctrl1 )

Load IO-Link payload into TxFIFO and trigger CQSend in one SPI burst.

Writes TxFIFO data followed by FramCtrl1 (with CQSend asserted) in a single SPI transaction using register auto-increment. Caller must set burst length via adiol100_set_burst_len() and provide the current FramCtrl1 register value before calling.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
data- IO-Link payload bytes (MC + CKT + OD).
txbytes- Number of payload bytes to transmit.
rxbytes- Number of response bytes expected from the device (including CKS).
keep- Retain message in TxFIFO for cyclic re-sending.
framctrl1- Current FramCtrl1 register value (framer config bits).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_load_msg()

int adiol100_load_msg ( struct adiol100_dev * dev,
enum adiol100_channel ch,
const uint8_t * data,
uint8_t txbytes,
uint8_t rxbytes,
enum adiol100_keep_msg keep )

Load IO-Link payload into TxFIFO without triggering CQSend.

Caller must set burst length via adiol100_set_burst_len() before calling.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
data- IO-Link payload bytes (MC + CKT + OD).
txbytes- Number of payload bytes to transmit.
rxbytes- Number of response bytes expected from the device (including CKS).
keep- Retain message in TxFIFO for cyclic re-sending.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_read()

int adiol100_read ( struct adiol100_dev * dev,
uint16_t reg,
uint16_t * value )

Read a 16-bit register. Handles paged access automatically.

Parameters
dev- The device structure.
reg- Register address (0x1Fxx for paged registers).
value- Pointer to store the read value.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_read_adc_chan()

int adiol100_read_adc_chan ( struct adiol100_dev * dev,
enum adiol100_adc_chan source,
enum adiol100_channel ch,
uint16_t * value )

Read a raw 13-bit per-channel ADC measurement (CQ/LP voltage or current).

Parameters
dev- The device structure.
source- Per-channel ADC source (CQ_VOLT/CUR or LP_VOLT/CUR with MIN/MAX).
ch- Channel selection (A or B).
value- Raw 13-bit value (2's complement).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_read_adc_global()

int adiol100_read_adc_global ( struct adiol100_dev * dev,
enum adiol100_adc_global source,
uint16_t * value )

Read a raw 13-bit global ADC measurement (V24 voltage or temperature).

Parameters
dev- The device structure.
source- Global ADC source (V24_VOLT/MIN/MAX or TEMP/MIN/MAX).
value- Raw 13-bit value (2's complement).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_read_channel_burst()

int adiol100_read_channel_burst ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint16_t * rxstat,
uint16_t * irq,
uint16_t * status,
uint8_t * data,
uint8_t data_len )

Burst-read RxFIFOStat, Interrupt, Status, and RxFIFO in one SPI cycle.

Uses register auto-increment from RxFIFOStat (0x01/0x11) through Status (0x03/0x13), then into the RxFIFO (0x04/0x14) for the configured burst read length. Reading the Interrupt register clears its flags. Caller must set burst length via adiol100_set_burst_len() before calling.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
rxstat- Pointer to store RxFIFOStat (level + error flags).
irq- Pointer to store Interrupt flags (read-to-clear).
status- Pointer to store Status register.
data- Buffer to store RxFIFO response bytes (after MsgID/RxBytesAct header).
data_len- Number of response bytes to read from the FIFO.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_read_devid()

int adiol100_read_devid ( struct adiol100_dev * dev,
uint16_t * dev_id )

Read the chip DeviceID register.

Parameters
dev- The device structure.
dev_id- Pointer to store the device ID value.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_read_msg()

int adiol100_read_msg ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint8_t * data,
uint8_t data_len )

Read device response from RxFIFO, stripping the MsgID/RxBytesAct header.

Caller must set burst length via adiol100_set_burst_len() before calling.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
data- Buffer to store response bytes.
data_len- Number of response bytes to read from the FIFO.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_read_revid()

int adiol100_read_revid ( struct adiol100_dev * dev,
uint16_t * rev_id )

Read the chip RevisionID register.

Parameters
dev- The device structure.
rev_id- Pointer to store the revision ID value.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_remove()

int adiol100_remove ( struct adiol100_dev * dev)

Free resources allocated by adiol100_init().

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_reset_adc_stats()

int adiol100_reset_adc_stats ( struct adiol100_dev * dev)

Reset all ADC min/max statistics (V24, Temp, CQ and LP for both channels).

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_reset_channel()

int adiol100_reset_channel ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Assert CHANRST to reset all channel-specific registers.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_reset_leds()

int adiol100_reset_leds ( struct adiol100_dev * dev)

Turn off all four LEDs by clearing their sequences and resetting modes.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_reset_rx_fifo()

int adiol100_reset_rx_fifo ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Reset the receive FIFO for a channel.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_reset_tx_fifo()

int adiol100_reset_tx_fifo ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Reset the transmit FIFO for a channel.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_send_msg()

int adiol100_send_msg ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Assert CQSend to trigger transmission of the message in the TxFIFO.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_set_burst_len()

int adiol100_set_burst_len ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint8_t write_len,
uint8_t read_len )

Set the SPI burst length for FIFO access.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
write_len- Number of bytes in the write burst.
read_len- Number of bytes in the read burst.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_set_cycle_tmr()

int adiol100_set_cycle_tmr ( struct adiol100_dev * dev,
enum adiol100_channel ch,
uint8_t value )

Set the IO-Link cycle timer value.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
value- IO-Link encoded cycle time byte.
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_set_led_brightness()

int adiol100_set_led_brightness ( struct adiol100_dev * dev,
enum adiol100_led led,
enum adiol100_led_brightness red_bgt,
enum adiol100_led_brightness green_bgt )

Set the brightness for one LED.

Parameters
dev- The device structure.
led- LED index (1–4).
red_bgt- Red brightness (see enum adiol100_led_brightness).
green_bgt- Green brightness (see enum adiol100_led_brightness).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_set_led_mode()

int adiol100_set_led_mode ( struct adiol100_dev * dev,
enum adiol100_led led,
enum adiol100_led_mode mode )

Set the operating mode for one LED.

Parameters
dev- The device structure.
led- LED index (1–4).
mode- Operating mode (see enum adiol100_led_mode).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_set_led_sequence()

int adiol100_set_led_sequence ( struct adiol100_dev * dev,
enum adiol100_led led,
enum adiol100_led_seq red_seq,
enum adiol100_led_seq green_seq )

Set the blink sequence for one LED.

Parameters
dev- The device structure.
led- LED index (1–4).
red_seq- Red blink pattern (see enum adiol100_led_seq or custom).
green_seq- Green blink pattern (see enum adiol100_led_seq or custom).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_setup_clock()

int adiol100_setup_clock ( struct adiol100_dev * dev,
uint8_t clock_src,
uint8_t clk_div )

Configure the clock source, divider, and enable clock output.

Parameters
dev- The device structure.
clock_src- Clock source selection (internal, crystal, or external).
clk_div- Clock divider (ClkDiv[1:0]).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_update()

int adiol100_update ( struct adiol100_dev * dev,
uint16_t reg,
uint16_t mask,
uint16_t value )

Read-modify-write a register using a bit mask.

Parameters
dev- The device structure.
reg- Register address.
mask- Bit mask of the field to modify.
value- New value (pre-shifted to match mask position).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_wakeup_request()

int adiol100_wakeup_request ( struct adiol100_dev * dev,
enum adiol100_channel ch )

Generate a wake-up pulse (WURQ) on a channel.

Parameters
dev- The device structure.
ch- Channel selection (A or B).
Returns
0 in case of success, negative error code otherwise.

◆ adiol100_write()

int adiol100_write ( struct adiol100_dev * dev,
uint16_t reg,
uint16_t value )

Write a 16-bit register. Handles paged access automatically.

Parameters
dev- The device structure.
reg- Register address (0x1Fxx for paged registers).
value- The value to write.
Returns
0 in case of success, negative error code otherwise.