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

Implementation of CN0391 board support. More...

#include <stdlib.h>
#include "cn0391.h"
#include "no_os_thermocouple.h"
#include "no_os_rtd.h"
#include "no_os_alloc.h"
#include "no_os_error.h"
#include "no_os_print_log.h"
Include dependency graph for cn0391.c:

Functions

int cn0391_init (struct cn0391_dev **dev, struct cn0391_init_param *init_param)
 Initialize CN0391 device: set up AD7124 and configure IOUT.
 
int cn0391_remove (struct cn0391_dev *dev)
 Remove CN0391 device and free resources.
 
int cn0391_read_temperature (struct cn0391_dev *dev, uint8_t ch_idx, double *hot_junction_temp, double *cold_junction_temp, double *thermocouple_voltage, double *rtd_resistance)
 Perform a full temperature measurement cycle. Reads all 3 ADC channels (thermocouple, reference resistor, CJC RTD), computes cold junction temperature, cold junction compensation voltage, and hot junction temperature.
 

Detailed Description

Implementation of CN0391 board support.

Author
Mircea Vlasin (mirce.nosp@m.a.vl.nosp@m.asin@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2026(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ cn0391_init()

int cn0391_init ( struct cn0391_dev ** dev,
struct cn0391_init_param * init_param )

Initialize CN0391 device: set up AD7124 and configure IOUT.

Parameters
dev- Pointer to pointer to CN0391 device descriptor.
init_param- Initialization parameters.
Returns
0 on success, negative error code otherwise.
Here is the caller graph for this function:

◆ cn0391_read_temperature()

int cn0391_read_temperature ( struct cn0391_dev * dev,
uint8_t ch_idx,
double * hot_junction_temp,
double * cold_junction_temp,
double * thermocouple_voltage,
double * rtd_resistance )

Perform a full temperature measurement cycle. Reads all 3 ADC channels (thermocouple, reference resistor, CJC RTD), computes cold junction temperature, cold junction compensation voltage, and hot junction temperature.

Parameters
dev- CN0391 device descriptor.
ch_idx- IIO channel index (CN0391_CH0_ID..CN0391_CH3_ID).
hot_junction_temp- Pointer to store hot junction temperature (°C).
cold_junction_temp- Pointer to store cold junction temperature (°C).
thermocouple_voltage- Pointer to store thermocouple voltage (mV).
rtd_resistance- Pointer to store measured RTD resistance (Ohms).
Returns
0 on success, negative error code otherwise.
Here is the caller graph for this function:

◆ cn0391_remove()

int cn0391_remove ( struct cn0391_dev * dev)

Remove CN0391 device and free resources.

Parameters
dev- CN0391 device descriptor.
Returns
0 on success, negative error code otherwise.
Here is the caller graph for this function: