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

Header file of MAX22190 Driver. More...

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

Classes

struct  max22190_init_param
 
struct  max22190_desc
 

Macros

#define MAX22190_FRAME_SIZE   2
 
#define MAX22190_CHANNELS   8
 
#define MAX22190_FAULT2_ENABLES   5
 
#define MAX22190_WIRE_BREAK_REG   0x0
 
#define MAX22190_DIGITAL_INPUT_REG   0x2
 
#define MAX22190_FAULT1_REG   0x4
 
#define MAX22190_FILTER_IN_REG(x)
 
#define MAX22190_CONFIG_REG   0x18
 
#define MAX22190_INPUT_EN_REG   0x1A
 
#define MAX22190_FAULT2_REG   0x1C
 
#define MAX22190_FAULT2_EN_REG   0x1E
 
#define MAX22190_GPO_REG   0x22
 
#define MAX22190_FAULT1_EN_REG   0x24
 
#define MAX22190_NO_OP_REG   0x26
 
#define MAX22190_CH_STATE_MASK(x)
 
#define MAX22190_DELAY_MASK   NO_OS_GENMASK(2, 0)
 
#define MAX22190_FBP_MASK   NO_OS_BIT(3)
 
#define MAX22190_WBE_MASK   NO_OS_BIT(4)
 
#define MAX22190_RW_MASK   NO_OS_BIT(7)
 
#define MAX22190_ADDR_MASK   NO_OS_GENMASK(6, 0)
 
#define MAX22190_ALARM_MASK   NO_OS_GENMASK(4, 3)
 
#define MAX22190_POR_MASK   NO_OS_BIT(6)
 
#define MAX22190_FAULT_MASK(x)
 
#define MAX22190_FAULT2_WBE_MASK   NO_OS_BIT(4)
 
#define MAX22190_FAULT2_EN_MASK   NO_OS_GENMASK(5, 0)
 
#define MAX22190_CFG_REFDI_MASK   NO_OS_BIT(0)
 
#define MAX22190_CFG_CLRF_MASK   NO_OS_BIT(3)
 
#define MAX22190_CFG_24VF_MASK   NO_OS_BIT(4)
 

Enumerations

enum  max22190_ch_state {
  MAX22190_CH_OFF ,
  MAX22190_CH_ON
}
 
enum  max22190_delay {
  MAX22190_DELAY_50US ,
  MAX22190_DELAY_100US ,
  MAX22190_DELAY_400US ,
  MAX22190_DELAY_800US ,
  MAX22190_DELAY_1800US ,
  MAX22190_DELAY_3200US ,
  MAX22190_DELAY_12800US ,
  MAX22190_DELAY_20MS
}
 
enum  max22190_fault_enable {
  MAX22190_FAULT1_WBGE ,
  MAX22190_FAULT1_24VME ,
  MAX22190_FAULT1_24VLE ,
  MAX22190_FAULT1_ALRMT1E ,
  MAX22190_FAULT1_ALRMT2E ,
  MAX22190_FAULT1_FAULT2E ,
  MAX22190_FAULT2_RFWBSE ,
  MAX22190_FAULT2_RFWBOE ,
  MAX22190_FAULT2_RFDISE ,
  MAX22190_FAULT2_RFDIOE ,
  MAX22190_FAULT2_OTSHDNE ,
  MAX22190_FAULT2_FAULT8CKE ,
  MAX22190_CFG_24VF ,
  MAX22190_CFG_REFDI_SH_ENA
}
 

Functions

int max22190_filter_set (struct max22190_desc *, uint32_t, uint32_t, uint32_t, enum max22190_delay)
 Set filter delay, wite break detection and if the filter is used or bypassed.
 
int max22190_filter_get (struct max22190_desc *, uint32_t, uint32_t *, uint32_t *, enum max22190_delay *)
 Get filter delay, wite break detection and if the filter is used or bypassed.
 
int max22190_chan_state (struct max22190_desc *, uint32_t, enum max22190_ch_state)
 Switch selected channel's state to disabled or enabled.
 
int max22190_wbe_get (struct max22190_desc *, uint32_t, bool *)
 Get Wire Break detection for requested channel.
 
int max22190_wbe_set (struct max22190_desc *, uint32_t, bool)
 Set Wire Break detection for requested channel.
 
int max22190_fault_enable_set (struct max22190_desc *, enum max22190_fault_enable, bool)
 Set fault enable in the fault registers.
 
int max22190_fault_enable_get (struct max22190_desc *, enum max22190_fault_enable, bool *)
 Get fault enable from the fault registers.
 
int max22190_reg_read (struct max22190_desc *, uint32_t, uint32_t *)
 Register read function for MAX22190.
 
int max22190_reg_write (struct max22190_desc *, uint32_t, uint32_t)
 Register write function for MAX22190.
 
int max22190_reg_update (struct max22190_desc *, uint32_t, uint32_t, uint32_t)
 Register update function for MAX22190.
 
int max22190_init (struct max22190_desc **, struct max22190_init_param *)
 MAX22190 Initialization function.
 
int max22190_remove (struct max22190_desc *)
 Free the resources allocated by initialization.
 

Detailed Description

Header file of MAX22190 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

◆ MAX22190_ADDR_MASK

#define MAX22190_ADDR_MASK   NO_OS_GENMASK(6, 0)

◆ MAX22190_ALARM_MASK

#define MAX22190_ALARM_MASK   NO_OS_GENMASK(4, 3)

◆ MAX22190_CFG_24VF_MASK

#define MAX22190_CFG_24VF_MASK   NO_OS_BIT(4)

◆ MAX22190_CFG_CLRF_MASK

#define MAX22190_CFG_CLRF_MASK   NO_OS_BIT(3)

◆ MAX22190_CFG_REFDI_MASK

#define MAX22190_CFG_REFDI_MASK   NO_OS_BIT(0)

◆ MAX22190_CH_STATE_MASK

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

◆ MAX22190_CHANNELS

#define MAX22190_CHANNELS   8

◆ MAX22190_CONFIG_REG

#define MAX22190_CONFIG_REG   0x18

◆ MAX22190_DELAY_MASK

#define MAX22190_DELAY_MASK   NO_OS_GENMASK(2, 0)

◆ MAX22190_DIGITAL_INPUT_REG

#define MAX22190_DIGITAL_INPUT_REG   0x2

◆ MAX22190_FAULT1_EN_REG

#define MAX22190_FAULT1_EN_REG   0x24

◆ MAX22190_FAULT1_REG

#define MAX22190_FAULT1_REG   0x4

◆ MAX22190_FAULT2_EN_MASK

#define MAX22190_FAULT2_EN_MASK   NO_OS_GENMASK(5, 0)

◆ MAX22190_FAULT2_EN_REG

#define MAX22190_FAULT2_EN_REG   0x1E

◆ MAX22190_FAULT2_ENABLES

#define MAX22190_FAULT2_ENABLES   5

◆ MAX22190_FAULT2_REG

#define MAX22190_FAULT2_REG   0x1C

◆ MAX22190_FAULT2_WBE_MASK

#define MAX22190_FAULT2_WBE_MASK   NO_OS_BIT(4)

◆ MAX22190_FAULT_MASK

#define MAX22190_FAULT_MASK ( x)
Value:

◆ MAX22190_FBP_MASK

#define MAX22190_FBP_MASK   NO_OS_BIT(3)

◆ MAX22190_FILTER_IN_REG

#define MAX22190_FILTER_IN_REG ( x)
Value:
(0x6 + (2 * (x)))

◆ MAX22190_FRAME_SIZE

#define MAX22190_FRAME_SIZE   2

◆ MAX22190_GPO_REG

#define MAX22190_GPO_REG   0x22

◆ MAX22190_INPUT_EN_REG

#define MAX22190_INPUT_EN_REG   0x1A

◆ MAX22190_NO_OP_REG

#define MAX22190_NO_OP_REG   0x26

◆ MAX22190_POR_MASK

#define MAX22190_POR_MASK   NO_OS_BIT(6)

◆ MAX22190_RW_MASK

#define MAX22190_RW_MASK   NO_OS_BIT(7)

◆ MAX22190_WBE_MASK

#define MAX22190_WBE_MASK   NO_OS_BIT(4)

◆ MAX22190_WIRE_BREAK_REG

#define MAX22190_WIRE_BREAK_REG   0x0

Enumeration Type Documentation

◆ max22190_ch_state

Enumerator
MAX22190_CH_OFF 
MAX22190_CH_ON 

◆ max22190_delay

Enumerator
MAX22190_DELAY_50US 
MAX22190_DELAY_100US 
MAX22190_DELAY_400US 
MAX22190_DELAY_800US 
MAX22190_DELAY_1800US 
MAX22190_DELAY_3200US 
MAX22190_DELAY_12800US 
MAX22190_DELAY_20MS 

◆ max22190_fault_enable

Enumerator
MAX22190_FAULT1_WBGE 
MAX22190_FAULT1_24VME 
MAX22190_FAULT1_24VLE 
MAX22190_FAULT1_ALRMT1E 
MAX22190_FAULT1_ALRMT2E 
MAX22190_FAULT1_FAULT2E 
MAX22190_FAULT2_RFWBSE 
MAX22190_FAULT2_RFWBOE 
MAX22190_FAULT2_RFDISE 
MAX22190_FAULT2_RFDIOE 
MAX22190_FAULT2_OTSHDNE 
MAX22190_FAULT2_FAULT8CKE 
MAX22190_CFG_24VF 
MAX22190_CFG_REFDI_SH_ENA 

Function Documentation

◆ max22190_chan_state()

int max22190_chan_state ( struct max22190_desc * desc,
uint32_t ch,
enum max22190_ch_state state )

Switch selected channel's state to disabled or enabled.

Switch the state of a specific channel to disabled/enabled.

Parameters
desc- MAX22190 device descriptor.
ch- Channel to disable/enable(0 based).
state- The state requested.
Returns
0 in case of success, negative error code otherwise.

◆ max22190_fault_enable_get()

int max22190_fault_enable_get ( struct max22190_desc * desc,
enum max22190_fault_enable fault_enable,
bool * enabled )

Get fault enable from the fault registers.

Get fault enable bit from the fault registers.

Parameters
desc- MAX22190 device descriptor
fault_enable- Specific fault enable to read
enabled- State of the selected enable (0 for disabled, 1 for enabled)
Returns
0 in case of succes, negative error code otherwise

◆ max22190_fault_enable_set()

int max22190_fault_enable_set ( struct max22190_desc * desc,
enum max22190_fault_enable fault_enable,
bool enabled )

Set fault enable in the fault registers.

Set fault enable bit in the fault registers.

Parameters
desc- MAX22190 device descriptor
fault_enable- Specific fault enable to write
enabled- State of the selected enable (0 for disabled, 1 for enabled)
Returns
0 in case of succes, negative error code otherwise

◆ max22190_filter_get()

int max22190_filter_get ( struct max22190_desc * desc,
uint32_t ch,
uint32_t * clrf,
uint32_t * fbp,
enum max22190_delay * delay )

Get filter delay, wite break detection and if the filter is used or bypassed.

Get filter values for specific channel.

Parameters
desc- MAX22190 device descriptor.
ch- The channel to which the filter corresponds(0 based).
clrf- Filter operation (0 - normal operation, 1 - filters fixed at mid -scale value for the chosen delay).
fbp- Filter usage(used - 0, bypassed - 1).
delay- Filter delay.
Returns
0 in case of success, negative error code otherwise.

◆ max22190_filter_set()

int max22190_filter_set ( struct max22190_desc * desc,
uint32_t ch,
uint32_t clrf,
uint32_t fbp,
enum max22190_delay delay )

Set filter delay, wite break detection and if the filter is used or bypassed.

Set filter values for specific channel.

Parameters
desc- MAX22190 device descriptor.
ch- The channel to which the filter corresponds(0 based).
clrf- Filter operation (0 - normal operation, 1 - filters fixed at mid -scale value for the chosen delay).
fbp- Filter usage(used - 0, bypassed - 1).
delay- Filter delay.
Returns
0 in case of success, negative error code otherwise.

◆ max22190_init()

int max22190_init ( struct max22190_desc ** desc,
struct max22190_init_param * param )

MAX22190 Initialization function.

Initialize and configure the MAX14916 device.

Parameters
desc- MAX22190 device descriptor.
param- MAX22190 initalization parameter.
Returns
0 in case of success, negative error code otherwise.

◆ max22190_reg_read()

int max22190_reg_read ( struct max22190_desc * desc,
uint32_t addr,
uint32_t * val )

Register read function for MAX22190.

Read the register of the MAX22190 device.

Parameters
desc- MAX22190 device descriptor.
addr- Register address from which data is read.
val- The value received from the read operation.
Returns
0 in case of success, negative error code otherwise.

◆ max22190_reg_update()

int max22190_reg_update ( struct max22190_desc * desc,
uint32_t addr,
uint32_t mask,
uint32_t val )

Register update function for MAX22190.

Update the register of the MAX22190 device.

Parameters
desc- MAX22190 device descriptor.
addr- Register valueto wich data is updated.
mask- Corresponding mask to the data that will be updated.
val- Updated value to be written in the register at update.
Returns
0 in case of success, negative error code otherwise.

◆ max22190_reg_write()

int max22190_reg_write ( struct max22190_desc * desc,
uint32_t addr,
uint32_t val )

Register write function for MAX22190.

Write the register of the MAX22190 device.

Parameters
desc- MAX22190 device descriptor.
addr- Register value to which data is written.
val- Value which is to be written to requested register.
Returns
0 in case of success, negative error code otherwise.

◆ max22190_remove()

int max22190_remove ( struct max22190_desc * desc)

Free the resources allocated by initialization.

Free the resources allocated by the initalization function.

Parameters
desc- MAX22190 device descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ max22190_wbe_get()

int max22190_wbe_get ( struct max22190_desc * desc,
uint32_t ch,
bool * enabled )

Get Wire Break detection for requested channel.

Get the Wire Break detection state of a specific channel.

Parameters
desc- MAX22190 device descriptor.
ch- Channel to read the WBE from.
enabled- State of the WBE for the specific channel returned after reading the register.
Returns
0 in case of succes, negative error code otherwise.

◆ max22190_wbe_set()

int max22190_wbe_set ( struct max22190_desc * desc,
uint32_t ch,
bool enabled )

Set Wire Break detection for requested channel.

Set the Wire Break detection for specific channel.

Parameters
desc- MAX22190 device descriptor.
ch- Channel to set the WBE to.
enabled- State of the WBE for the specific channel to be set.
Returns
0 in case of succes, negative error code otherwise.