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

Header file of MAX22196 Driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_util.h"
Include dependency graph for max22196.h:

Classes

struct  max22196_init_param
 
struct  max22196_desc
 

Macros

#define MAX22196_FRAME_SIZE   2
 
#define MAX22196_CHANNELS   8
 
#define MAX22194_CHANNELS   4
 
#define MAX22196_CHN_CNT_RESET   0
 
#define MAX22196_DI_STATE_REG   0x00
 
#define MAX22196_FAULT1_REG   0x01
 
#define MAX22196_F1MASK_REG   0x02
 
#define MAX22196_CFG_REG(x)
 
#define MAX22196_GLOBALCFG_REG   0x0B
 
#define MAX22196_LED_REG   0x0C
 
#define MAX22196_FAULT2_REG   0x0D
 
#define MAX22196_F2MASK_REG   0x0E
 
#define MAX22196_START_STOP_REG   0x0F
 
#define MAX22196_CNT_LSB_REG(x)
 
#define MAX22196_CNT_MSB_REG(x)
 
#define MAX22196_ADDR_MASK   NO_OS_GENMASK(7, 6)
 
#define MAX22196_REG_ADDR_MASK   NO_OS_GENMASK(5, 1)
 
#define MAX22196_RW_MASK   NO_OS_BIT(0)
 
#define MAX22196_DI_STATE_MASK(x)
 
#define MAX22196_HITHR_MASK   NO_OS_BIT(7)
 
#define MAX22196_SOURCE_MASK   NO_OS_BIT(6)
 
#define MAX22196_CURR_MASK   NO_OS_GENMASK(5, 4)
 
#define MAX22196_FLTEN_MASK   NO_OS_BIT(3)
 
#define MAX22196_DELAY_MASK   NO_OS_GENMASK(2, 0)
 
#define MAX22196_CNT_MASK(x)
 
#define MAX22196_CFG_MASK   (NO_OS_BIT(7) | NO_OS_GENMASK(5, 4))
 
#define MAX22196_LSB_MASK   NO_OS_GENMASK(7, 0)
 
#define MAX22196_MSB_MASK   NO_OS_GENMASK(15, 8)
 
#define MAX22196_CNT_BYTE_MASK   NO_OS_GENMASK(7, 0)
 
#define MAX22196_FAULT_MASK(x)
 
#define MAX22196_GLOBAL_MASK(x)
 
#define MAX22196_FAULT2_MASK   NO_OS_GENMASK(4, 0)
 
#define MAX22196_FILTER_CLRFLT_MASK   NO_OS_BIT(3)
 

Enumerations

enum  max22196_chip_id {
  ID_MAX22194 ,
  ID_MAX22196
}
 
enum  max22196_fault_mask {
  MAX22196_GLOBAL_REFDISHTCFG ,
  MAX22196_FAULT1_VMLOW ,
  MAX22196_FAULT1_V24UV ,
  MAX22196_FAULT1_TEMPALM ,
  MAX22196_FAULT1_OTSHDN1 ,
  MAX22196_FAULT1_FAULT2 ,
  MAX22196_FAULT2_RFDIS ,
  MAX22196_FAULT2_RFDIO ,
  MAX22196_FAULT2_OTSHDN2 ,
  MAX22196_FAULT2_SPI8CLK ,
  MAX22196_FAULT2_VAUV
}
 
enum  max22196_global_cfg {
  MAX22196_GLOBAL_FSPICLR = 4 ,
  MAX22196_GLOBAL_LED9 ,
  MAX22196_GLOBAL_LEDINT ,
  MAX22196_GLOBAL_GPO
}
 
enum  max22196_mode {
  MAX22196_SINK_MODE ,
  MAX22196_SOURCE_MODE
}
 
enum  max22196_delay {
  MAX22196_DELAY_50US ,
  MAX22196_DELAY_100US ,
  MAX22196_DELAY_400US ,
  MAX22196_DELAY_800US ,
  MAX22196_DELAY_1600US ,
  MAX22196_DELAY_3200US ,
  MAX22196_DELAY_128000US ,
  MAX22196_DELAY_20MS
}
 
enum  max22196_curr {
  MAX22196_HTL_MODE ,
  MAX22196_1X_CURRENT ,
  MAX22196_3X_CURRENT ,
  MAX22196_TTL_OP_OFF
}
 

Functions

int max22196_reg_write (struct max22196_desc *, uint32_t, uint32_t)
 MAX22196 register write function.
 
int max22196_reg_read (struct max22196_desc *, uint32_t, uint32_t *)
 MAX22196 register read function.
 
int max22196_reg_update (struct max22196_desc *, uint32_t, uint32_t, uint32_t)
 
  • MAX22196 register update function

 
int max22196_set_mode (struct max22196_desc *, uint32_t, enum max22196_mode)
 
  • MAX22196 function that helps setting the mode of the device.

 
int max22196_chan_cfg (struct max22196_desc *, uint32_t, uint32_t, enum max22196_curr)
 
  • MAX22196 channel configuration function

 
int max22196_filter_set (struct max22196_desc *, uint32_t, uint32_t, uint32_t, enum max22196_delay)
 
  • MAX22196 filter set function

 
int max22196_filter_get (struct max22196_desc *, uint32_t, uint32_t *, uint32_t *, enum max22196_delay *)
 
  • MAX22196 filter get function

 
int max22196_fault_mask_set (struct max22196_desc *, enum max22196_fault_mask, bool)
 Set fault mask bits in the fault mask registers.
 
int max22196_fault_mask_get (struct max22196_desc *, enum max22196_fault_mask, bool *)
 Get fault mask bits from the fault mask registers.
 
int max22196_global_cfg (struct max22196_desc *, enum max22196_global_cfg, bool)
 Set global configuration.
 
int max22196_set_chan_cnt (struct max22196_desc *, uint32_t, uint16_t)
 
  • MAX22196 channel counter set function

 
int max22196_get_chan_cnt (struct max22196_desc *, uint32_t, uint16_t *)
 MAX22196 channel counter get function.
 
int max22196_init (struct max22196_desc **, struct max22196_init_param *)
 Initialize and configure the MAX22196 device.
 
int max22196_remove (struct max22196_desc *)
 Free the resources allocated during init.
 

Detailed Description

Header 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.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ MAX22194_CHANNELS

#define MAX22194_CHANNELS   4

◆ MAX22196_ADDR_MASK

#define MAX22196_ADDR_MASK   NO_OS_GENMASK(7, 6)

◆ MAX22196_CFG_MASK

#define MAX22196_CFG_MASK   (NO_OS_BIT(7) | NO_OS_GENMASK(5, 4))

◆ MAX22196_CFG_REG

#define MAX22196_CFG_REG ( x)
Value:
(0x03 + (x))

◆ MAX22196_CHANNELS

#define MAX22196_CHANNELS   8

◆ MAX22196_CHN_CNT_RESET

#define MAX22196_CHN_CNT_RESET   0

◆ MAX22196_CNT_BYTE_MASK

#define MAX22196_CNT_BYTE_MASK   NO_OS_GENMASK(7, 0)

◆ MAX22196_CNT_LSB_REG

#define MAX22196_CNT_LSB_REG ( x)
Value:
(0x10 + 2 * (x))

◆ MAX22196_CNT_MASK

#define MAX22196_CNT_MASK ( x)
Value:
#define NO_OS_BIT(x)
Definition no_os_util.h:23

◆ MAX22196_CNT_MSB_REG

#define MAX22196_CNT_MSB_REG ( x)
Value:
(0x11 + 2 * (x))

◆ MAX22196_CURR_MASK

#define MAX22196_CURR_MASK   NO_OS_GENMASK(5, 4)

◆ MAX22196_DELAY_MASK

#define MAX22196_DELAY_MASK   NO_OS_GENMASK(2, 0)

◆ MAX22196_DI_STATE_MASK

#define MAX22196_DI_STATE_MASK ( x)
Value:

◆ MAX22196_DI_STATE_REG

#define MAX22196_DI_STATE_REG   0x00

◆ MAX22196_F1MASK_REG

#define MAX22196_F1MASK_REG   0x02

◆ MAX22196_F2MASK_REG

#define MAX22196_F2MASK_REG   0x0E

◆ MAX22196_FAULT1_REG

#define MAX22196_FAULT1_REG   0x01

◆ MAX22196_FAULT2_MASK

#define MAX22196_FAULT2_MASK   NO_OS_GENMASK(4, 0)

◆ MAX22196_FAULT2_REG

#define MAX22196_FAULT2_REG   0x0D

◆ MAX22196_FAULT_MASK

#define MAX22196_FAULT_MASK ( x)
Value:

◆ MAX22196_FILTER_CLRFLT_MASK

#define MAX22196_FILTER_CLRFLT_MASK   NO_OS_BIT(3)

◆ MAX22196_FLTEN_MASK

#define MAX22196_FLTEN_MASK   NO_OS_BIT(3)

◆ MAX22196_FRAME_SIZE

#define MAX22196_FRAME_SIZE   2

◆ MAX22196_GLOBAL_MASK

#define MAX22196_GLOBAL_MASK ( x)
Value:

◆ MAX22196_GLOBALCFG_REG

#define MAX22196_GLOBALCFG_REG   0x0B

◆ MAX22196_HITHR_MASK

#define MAX22196_HITHR_MASK   NO_OS_BIT(7)

◆ MAX22196_LED_REG

#define MAX22196_LED_REG   0x0C

◆ MAX22196_LSB_MASK

#define MAX22196_LSB_MASK   NO_OS_GENMASK(7, 0)

◆ MAX22196_MSB_MASK

#define MAX22196_MSB_MASK   NO_OS_GENMASK(15, 8)

◆ MAX22196_REG_ADDR_MASK

#define MAX22196_REG_ADDR_MASK   NO_OS_GENMASK(5, 1)

◆ MAX22196_RW_MASK

#define MAX22196_RW_MASK   NO_OS_BIT(0)

◆ MAX22196_SOURCE_MASK

#define MAX22196_SOURCE_MASK   NO_OS_BIT(6)

◆ MAX22196_START_STOP_REG

#define MAX22196_START_STOP_REG   0x0F

Enumeration Type Documentation

◆ max22196_chip_id

Enumerator
ID_MAX22194 
ID_MAX22196 

◆ max22196_curr

Enumerator
MAX22196_HTL_MODE 
MAX22196_1X_CURRENT 
MAX22196_3X_CURRENT 
MAX22196_TTL_OP_OFF 

◆ max22196_delay

Enumerator
MAX22196_DELAY_50US 
MAX22196_DELAY_100US 
MAX22196_DELAY_400US 
MAX22196_DELAY_800US 
MAX22196_DELAY_1600US 
MAX22196_DELAY_3200US 
MAX22196_DELAY_128000US 
MAX22196_DELAY_20MS 

◆ max22196_fault_mask

Enumerator
MAX22196_GLOBAL_REFDISHTCFG 
MAX22196_FAULT1_VMLOW 
MAX22196_FAULT1_V24UV 
MAX22196_FAULT1_TEMPALM 
MAX22196_FAULT1_OTSHDN1 
MAX22196_FAULT1_FAULT2 
MAX22196_FAULT2_RFDIS 
MAX22196_FAULT2_RFDIO 
MAX22196_FAULT2_OTSHDN2 
MAX22196_FAULT2_SPI8CLK 
MAX22196_FAULT2_VAUV 

◆ max22196_global_cfg

Enumerator
MAX22196_GLOBAL_FSPICLR 
MAX22196_GLOBAL_LED9 
MAX22196_GLOBAL_LEDINT 
MAX22196_GLOBAL_GPO 

◆ max22196_mode

Enumerator
MAX22196_SINK_MODE 
MAX22196_SOURCE_MODE 

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

Set configuration for a specific channel.

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.

Get fault masks state for requested fault.

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.

Set fault masks for requested fault.

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

Read filter values for a specific channel.

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.

◆ 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

Set filter values for a specific channel.

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.

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

Read channel counter for a specific channel.

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.

Set global configurations manually if desired.

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.

Initialize the MAX22196 descriptor.

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.

◆ max22196_reg_read()

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

MAX22196 register read function.

Register read function for MAX22196.

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.

◆ max22196_reg_update()

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

  • MAX22196 register update function

Register update function for MAX22196.

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.

◆ max22196_reg_write()

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

MAX22196 register write function.

Register write function for MAX22196.

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.

◆ max22196_remove()

int max22196_remove ( struct max22196_desc * desc)

Free the resources allocated during init.

Remove the resources allocated at init.

Parameters
desc- device descriptor for the MAX14916 that will be initialized.
Returns
0 in case of success, negative error code otherwise.

◆ 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

Set channel counter for a specific channel.

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.

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

Set mode to a specific channel.

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.