no-OS
Functions
max22196.c File Reference

Source file of MAX22196 Driver. More...

#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "max22196.h"
#include "no_os_util.h"
#include "no_os_alloc.h"
Include dependency graph for max22196.c:

Functions

int max22196_reg_write (struct max22196_desc *desc, uint32_t reg, uint32_t val)
 MAX22196 register write function. More...
 
int max22196_reg_read (struct max22196_desc *desc, uint32_t reg, uint32_t *val)
 MAX22196 register read function. More...
 
int max22196_reg_update (struct max22196_desc *desc, uint32_t reg, uint32_t mask, uint32_t val)
 
  • MAX22196 register update function
More...
 
int max22196_set_mode (struct max22196_desc *desc, uint32_t ch, enum max22196_mode mode)
 
  • MAX22196 function that helps setting the mode of the device.
More...
 
int max22196_chan_cfg (struct max22196_desc *desc, uint32_t ch, uint32_t hi_thr, enum max22196_curr curr)
 
  • MAX22196 channel configuration function
More...
 
int max22196_filter_set (struct max22196_desc *desc, uint32_t ch, uint32_t flt_en, uint32_t clr_filtr, enum max22196_delay delay)
 
  • MAX22196 filter set function
More...
 
int max22196_filter_get (struct max22196_desc *desc, uint32_t ch, uint32_t *flt_en, uint32_t *clr_filtr, enum max22196_delay *delay)
 
  • MAX22196 filter get function
More...
 
int max22196_fault_mask_set (struct max22196_desc *desc, enum max22196_fault_mask fault_mask, bool enabled)
 Set fault mask bits in the fault mask registers. More...
 
int max22196_fault_mask_get (struct max22196_desc *desc, enum max22196_fault_mask fault_mask, bool *enabled)
 Get fault mask bits from the fault mask registers. More...
 
int max22196_global_cfg (struct max22196_desc *desc, enum max22196_global_cfg global_cfg, bool enabled)
 Set global configuration. More...
 
int max22196_set_chan_cnt (struct max22196_desc *desc, uint32_t ch, uint16_t cnt_msb_lsb_bytes)
 
  • MAX22196 channel counter set function
More...
 
int max22196_get_chan_cnt (struct max22196_desc *desc, uint32_t ch, uint16_t *cnt_msb_lsb_bytes)
 MAX22196 channel counter get function. More...
 
int max22196_init (struct max22196_desc **desc, struct max22196_init_param *param)
 Initialize and configure the MAX22196 device. More...
 
int max22196_remove (struct max22196_desc *desc)
 Free the resources allocated during init. More...
 

Detailed Description

Source file of MAX22196 Driver.

Author
Radu Sabau (radu..nosp@m.saba.nosp@m.u@ana.nosp@m.log..nosp@m.com)

Copyright 2023(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

◆ max22196_chan_cfg()

int max22196_chan_cfg ( struct max22196_desc desc,
uint32_t  ch,
uint32_t  hi_thr,
enum max22196_curr  curr 
)

  • MAX22196 channel configuration function

Parameters
desc- The device descriptor for MAX22196.
ch- Channel for which the configuration is to be changed.
hi_thr- Voltage threshold(0 for inactive, 1 for active).
curr- Channel current to be set.
Returns
0 in case of succes, negative error code otherwise.

◆ max22196_fault_mask_get()

int max22196_fault_mask_get ( struct max22196_desc desc,
enum max22196_fault_mask  fault_mask,
bool enabled 
)

Get fault mask bits from the fault mask registers.

Parameters
desc- MAX22196 device descriptor.
fault_mask- Requested fault to get mask from.
enabled- Mask state to be read.
Returns
- 0 in case of succes, negative error code otherwise.

◆ max22196_fault_mask_set()

int max22196_fault_mask_set ( struct max22196_desc desc,
enum max22196_fault_mask  fault_mask,
bool  enabled 
)

Set fault mask bits in the fault mask registers.

Parameters
desc- MAX22196 device descriptor.
fault_mask- Requested fault to set mask to.
enabled- Mask state to be set.
Returns
- 0 in case of succes, negative error code otherwise.

◆ max22196_filter_get()

int max22196_filter_get ( struct max22196_desc desc,
uint32_t  ch,
uint32_t *  flt_en,
uint32_t *  clr_filtr,
enum max22196_delay delay 
)

  • MAX22196 filter get function

Parameters
desc- MAX22196 device descriptor.
ch- Channel from which the filter values are read.
flt_en- Variable through which the fillter's state is read.
clr_filtr- Clear the filter value and set to mid-scale delay.
delay- Filter delay value to be read for the MAX22196's specified channel.
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function:

◆ max22196_filter_set()

int max22196_filter_set ( struct max22196_desc desc,
uint32_t  ch,
uint32_t  flt_en,
uint32_t  clr_filtr,
enum max22196_delay  delay 
)

  • MAX22196 filter set function

Parameters
desc- MAX22196 device descriptor.
ch- Channel to which the filter values will be applied to.
flt_en- Filter enable value(0 for filter disabled, 1 for filter enable)
clr_filtr- Clear filter and set delay value to mid-scale.
delay- Filter delay to be set.
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function:

◆ max22196_get_chan_cnt()

int max22196_get_chan_cnt ( struct max22196_desc desc,
uint32_t  ch,
uint16_t *  cnt_msb_lsb_bytes 
)

MAX22196 channel counter get function.

Parameters
desc- MAX22196 device descriptor.
ch- Channel for which the channel counter is read.
cnt_msb_lsb_bytes- 8MSBs represent the MSB byte read from the specifc chanel's counter, 8LSBs represent the LSB byte.
Returns
0 in case of succes, negative error code otherwise.

◆ max22196_global_cfg()

int max22196_global_cfg ( struct max22196_desc desc,
enum max22196_global_cfg  global_cfg,
bool  enabled 
)

Set global configuration.

Parameters
desc- MAX22196 device descriptor.
global_cfg- Specifc configuration to be set.
enabled- State of the specific configuration.
Returns
0 in case of succes, negative error code otherwise.

◆ max22196_init()

int max22196_init ( struct max22196_desc **  desc,
struct max22196_init_param param 
)

Initialize and configure the MAX22196 device.

Parameters
desc- device descriptor for the MAX22196 that will be initialized.
param- initialization parameter for the device.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22196_reg_read()

int max22196_reg_read ( struct max22196_desc desc,
uint32_t  reg,
uint32_t *  val 
)

MAX22196 register read function.

Parameters
desc- The device descriptor for MAX22196.
reg- The register value where the data is read from.
val- The value returned from read.
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function:

◆ max22196_reg_update()

int max22196_reg_update ( struct max22196_desc desc,
uint32_t  reg,
uint32_t  mask,
uint32_t  val 
)

  • MAX22196 register update function

Parameters
desc- The device descriptor for MAX22196.
reg- The register to be updated.
mask- The specific mask where the value will be updated.
val- The value that is to be written to the mask.
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function:

◆ max22196_reg_write()

int max22196_reg_write ( struct max22196_desc desc,
uint32_t  reg,
uint32_t  val 
)

MAX22196 register write function.

Parameters
desc- The device descriptor for MAX22196.
reg- The register where the information is to be written.
val- The value to be written to reg.
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function:

◆ max22196_remove()

int max22196_remove ( struct max22196_desc desc)

Free the resources allocated during init.

Parameters
desc- device descriptor for the MAX14916 that will be initialized.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22196_set_chan_cnt()

int max22196_set_chan_cnt ( struct max22196_desc desc,
uint32_t  ch,
uint16_t  cnt_msb_lsb_bytes 
)

  • MAX22196 channel counter set function

Parameters
desc- MAX22196 device descriptor.
ch- MAX22196 channel to which the counter is set.
cnt_msb_lsb_bytes- 8MSBs represent the MSB byte to be written to the specifc chanel's counter, 8LSBs represent the LSB byte.
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function:

◆ max22196_set_mode()

int max22196_set_mode ( struct max22196_desc desc,
uint32_t  ch,
enum max22196_mode  mode 
)

  • MAX22196 function that helps setting the mode of the device.

Parameters
desc- The device descriptor for MAX22196
ch- The channel for which the mode will be set.
mode- The mode to be set.
Returns
0 in case of succes, negative error code otherwise.
Here is the caller graph for this function: