no-OS
Classes | Macros | Enumerations | Functions
max9611.h File Reference

Header file of max9611 Family Driver. More...

#include <stdint.h>
#include <stdlib.h>
#include "no_os_i2c.h"
#include "no_os_util.h"
#include "no_os_error.h"
#include "no_os_delay.h"
Include dependency graph for max9611.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  max9611_dev
 
struct  max9611_init_param
 

Macros

#define MAX9611_MUX_MASK   NO_OS_GENMASK(2, 0)
 
#define MAX9611_MODE_MASK   NO_OS_GENMASK(7, 5)
 
#define MAX9611_RAW_DATA_MASK   NO_OS_GENMASK(15, 4)
 
#define MAX9611_SHDN_MASK   NO_OS_BIT(3)
 
#define MAX9611_LR_MASK   NO_OS_BIT(4)
 
#define MAX9611_DTIME_MASK   NO_OS_BIT(3)
 
#define MAX9611_RTIME_MASK   NO_OS_BIT(2)
 
#define MAX9611_CSA_MSB   0x00
 
#define MAX9611_CSA_LSB   0x01
 
#define MAX9611_RSP_MSB   0x02
 
#define MAX9611_RSP_LSB   0x03
 
#define MAX9611_OUT_MSB   0x04
 
#define MAX9611_OUT_LSB   0x05
 
#define MAX9611_SET_MSB   0x06
 
#define MAX9611_SET_LSB   0x07
 
#define MAX9611_TMP_MSB   0x08
 
#define MAX9611_TMP_LSB   0x09
 
#define MAX9611_CTR1   0x0A
 
#define MAX9611_CTR2   0x0B
 
#define MAX9611_OUT_OF_BOUNDS   0x0C
 

Enumerations

enum  max9611_data {
  MAX9611_DATA_CSA,
  MAX9611_DATA_RSP,
  MAX9611_DATA_OUT,
  MAX9611_DATA_SET,
  MAX9611_DATA_TMP
}
 
enum  max9611_addr_lvls {
  MAX9611_ZERO_VCC,
  MAX9611_33_VCC,
  MAX9611_66_VCC,
  MAX9611_100_VCC
}
 
enum  max9611_delay_time {
  MAX9611_1MS,
  MAX9611_100US
}
 
enum  max9611_retry_time {
  MAX9611_50MS,
  MAX9611_10MS
}
 
enum  max9611_mux_conf {
  MAX9611_CONF_SENSE_1X,
  MAX9611_CONF_SENSE_4X,
  MAX9611_CONF_SENSE_8X,
  MAX9611_CONF_IN_COM_MODE,
  MAX9611_CONF_OUT_ADC,
  MAX9611_CONF_SET_ADC,
  MAX9611_CONF_TEMP,
  MAX9611_FAST_MODE
}
 
enum  max9611_mode_conf {
  MAX9611_NORMAL_MODE = 0x0,
  MAX9611_OPAMP_MODE = 0x3,
  MAX9611_COMPARATOR_MODE = 0x7
}
 

Functions

int max9611_addr_gen (struct max9611_init_param *device_ip, enum max9611_addr_lvls a0, enum max9611_addr_lvls a1)
 Generates slave address based on A1 and A0 pin values. More...
 
int max9611_init (struct max9611_dev **device, struct max9611_init_param init_param)
 Initializes the communication peripheral and checks if the device is present. More...
 
int max9611_remove (struct max9611_dev *dev)
 Free the resources allocated by max538x_init(). More...
 
int max9611_read (struct max9611_dev *dev, uint8_t addr, uint8_t bytes, uint8_t *read_data)
 Reads data from device register (I2C) More...
 
int max9611_write (struct max9611_dev *dev, uint8_t addr, uint8_t bytes, uint8_t *write_data)
 Writes data to device register (I2C) More...
 
int max9611_reg_update (struct max9611_dev *dev, uint8_t addr, int update_mask, int update_val)
 Update selected I2C register contents. More...
 
int max9611_set_mode (struct max9611_dev *dev, enum max9611_mode_conf mode)
 Configures MAX9611 operating mode. More...
 
int max9611_get_mode (struct max9611_dev *dev, enum max9611_mode_conf *mode)
 Get the MAX9611 operating mode. More...
 
int max9611_set_mux (struct max9611_dev *dev, enum max9611_mux_conf mux)
 Configures the internal MUX settings. More...
 
int max9611_get_mux (struct max9611_dev *dev, enum max9611_mux_conf *mux)
 Get the internal MUX settings. More...
 
int max9611_shutdown (struct max9611_dev *dev, bool is_shdn)
 Device shutdown or power up. More...
 
int max9611_set_lr (struct max9611_dev *dev, bool is_normal)
 Configure LR bit operation. More...
 
int max9611_get_lr (struct max9611_dev *dev, bool *lr)
 Get LR bit value. More...
 
int max9611_set_delay (struct max9611_dev *dev, enum max9611_delay_time dtime)
 Configures MAX9611 delay time. More...
 
int max9611_get_delay (struct max9611_dev *dev, enum max9611_delay_time *dtime)
 Get MAX9611 configured delay time. More...
 
int max9611_set_retry (struct max9611_dev *dev, enum max9611_retry_time rtime)
 Configures MAX9611 retry time. More...
 
int max9611_get_retry (struct max9611_dev *dev, enum max9611_retry_time *rtime)
 Get MAX9611 configured retry time. More...
 
int max9611_get_raw (struct max9611_dev *dev, uint16_t *raw)
 Receive data from ADC (single value only). More...
 

Detailed Description

Header file of max9611 Family Driver.

Author
MSosa (marcp.nosp@m.aolo.nosp@m..sosa.nosp@m.@ana.nosp@m.log.c.nosp@m.om)
JSanbuen (jose..nosp@m.sanb.nosp@m.uenav.nosp@m.entu.nosp@m.ra@an.nosp@m.alog.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.

Macro Definition Documentation

◆ MAX9611_CSA_LSB

#define MAX9611_CSA_LSB   0x01

◆ MAX9611_CSA_MSB

#define MAX9611_CSA_MSB   0x00

◆ MAX9611_CTR1

#define MAX9611_CTR1   0x0A

◆ MAX9611_CTR2

#define MAX9611_CTR2   0x0B

◆ MAX9611_DTIME_MASK

#define MAX9611_DTIME_MASK   NO_OS_BIT(3)

◆ MAX9611_LR_MASK

#define MAX9611_LR_MASK   NO_OS_BIT(4)

◆ MAX9611_MODE_MASK

#define MAX9611_MODE_MASK   NO_OS_GENMASK(7, 5)

◆ MAX9611_MUX_MASK

#define MAX9611_MUX_MASK   NO_OS_GENMASK(2, 0)

◆ MAX9611_OUT_LSB

#define MAX9611_OUT_LSB   0x05

◆ MAX9611_OUT_MSB

#define MAX9611_OUT_MSB   0x04

◆ MAX9611_OUT_OF_BOUNDS

#define MAX9611_OUT_OF_BOUNDS   0x0C

◆ MAX9611_RAW_DATA_MASK

#define MAX9611_RAW_DATA_MASK   NO_OS_GENMASK(15, 4)

◆ MAX9611_RSP_LSB

#define MAX9611_RSP_LSB   0x03

◆ MAX9611_RSP_MSB

#define MAX9611_RSP_MSB   0x02

◆ MAX9611_RTIME_MASK

#define MAX9611_RTIME_MASK   NO_OS_BIT(2)

◆ MAX9611_SET_LSB

#define MAX9611_SET_LSB   0x07

◆ MAX9611_SET_MSB

#define MAX9611_SET_MSB   0x06

◆ MAX9611_SHDN_MASK

#define MAX9611_SHDN_MASK   NO_OS_BIT(3)

◆ MAX9611_TMP_LSB

#define MAX9611_TMP_LSB   0x09

◆ MAX9611_TMP_MSB

#define MAX9611_TMP_MSB   0x08

Enumeration Type Documentation

◆ max9611_addr_lvls

Enumerator
MAX9611_ZERO_VCC 
MAX9611_33_VCC 
MAX9611_66_VCC 
MAX9611_100_VCC 

◆ max9611_data

Enumerator
MAX9611_DATA_CSA 
MAX9611_DATA_RSP 
MAX9611_DATA_OUT 
MAX9611_DATA_SET 
MAX9611_DATA_TMP 

◆ max9611_delay_time

Enumerator
MAX9611_1MS 
MAX9611_100US 

◆ max9611_mode_conf

Enumerator
MAX9611_NORMAL_MODE 
MAX9611_OPAMP_MODE 
MAX9611_COMPARATOR_MODE 

◆ max9611_mux_conf

Enumerator
MAX9611_CONF_SENSE_1X 
MAX9611_CONF_SENSE_4X 
MAX9611_CONF_SENSE_8X 
MAX9611_CONF_IN_COM_MODE 
MAX9611_CONF_OUT_ADC 
MAX9611_CONF_SET_ADC 
MAX9611_CONF_TEMP 
MAX9611_FAST_MODE 

◆ max9611_retry_time

Enumerator
MAX9611_50MS 
MAX9611_10MS 

Function Documentation

◆ max9611_addr_gen()

int max9611_addr_gen ( struct max9611_init_param device_ip,
enum max9611_addr_lvls  a0,
enum max9611_addr_lvls  a1 
)

Generates slave address based on A1 and A0 pin values.

Parameters
device_ip- init param structure
a0- A0 logic level
a1- A1 logic level
Returns
addr - Computed slave ID

◆ max9611_get_delay()

int max9611_get_delay ( struct max9611_dev dev,
enum max9611_delay_time dtime 
)

Get MAX9611 configured delay time.

Parameters
dev- The device structure.
dtime- Pointer to store delay time read
Returns
- 0 if successful, error otherwise.

◆ max9611_get_lr()

int max9611_get_lr ( struct max9611_dev dev,
bool lr 
)

Get LR bit value.

Parameters
dev- The device structure.
lr- Pointer to store LR bit value
Returns
- 0 if successful, error otherwise.

◆ max9611_get_mode()

int max9611_get_mode ( struct max9611_dev dev,
enum max9611_mode_conf mode 
)

Get the MAX9611 operating mode.

Parameters
dev- The device structure.
mode- Pointer to store the obtained mode
Returns
- 0 if successful, error otherwise.

◆ max9611_get_mux()

int max9611_get_mux ( struct max9611_dev dev,
enum max9611_mux_conf mux 
)

Get the internal MUX settings.

Parameters
dev- The device structure.
mux- Pointer to store the obtained mux config
Returns
- 0 if successful, error otherwise.

◆ max9611_get_raw()

int max9611_get_raw ( struct max9611_dev dev,
uint16_t *  raw 
)

Receive data from ADC (single value only).

Parameters
dev- The device structure.
raw- Pointer to store the raw 12-bit ADC reading
Returns
- 0 if successful, error otherwise.

◆ max9611_get_retry()

int max9611_get_retry ( struct max9611_dev dev,
enum max9611_retry_time rtime 
)

Get MAX9611 configured retry time.

Parameters
dev- The device structure.
rtime- Pointer to store retry time read
Returns
- 0 if successful, error otherwise.

◆ max9611_init()

int max9611_init ( struct max9611_dev **  device,
struct max9611_init_param  init_param 
)

Initializes the communication peripheral and checks if the device is present.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
ret - The result of the initialization procedure. Example: -1 - I2C peripheral wasn't initialized or the device is not present. 0 - I2C peripheral was initialized and the device is present.

◆ max9611_read()

int max9611_read ( struct max9611_dev dev,
uint8_t  addr,
uint8_t  bytes,
uint8_t *  read_data 
)

Reads data from device register (I2C)

Parameters
dev- The device structure.
addr- Starting / selected register address.
bytes- Number of bytes to read from starting register address
read_data- Read data buffer
Returns
- 0 if I2C read is successful, error otherwise.
Here is the caller graph for this function:

◆ max9611_reg_update()

int max9611_reg_update ( struct max9611_dev dev,
uint8_t  addr,
int  update_mask,
int  update_val 
)

Update selected I2C register contents.

Parameters
dev- The device structure.
addr- Starting / selected register address.
update_mask- Mask to update to selected register bit/s
update_val- Value used to update on selected register
Returns
- 0 if I2C write is successful, error otherwise.
Here is the caller graph for this function:

◆ max9611_remove()

int max9611_remove ( struct max9611_dev dev)

Free the resources allocated by max538x_init().

Parameters
dev- The device structure.
Returns
ret - The result of the remove procedure.

◆ max9611_set_delay()

int max9611_set_delay ( struct max9611_dev dev,
enum max9611_delay_time  dtime 
)

Configures MAX9611 delay time.

Parameters
dev- The device structure.
dtime- Delay option
Returns
- 0 if successful, error otherwise.

◆ max9611_set_lr()

int max9611_set_lr ( struct max9611_dev dev,
bool  is_normal 
)

Configure LR bit operation.

Parameters
dev- The device structure.
is_normal- Set true for normal operation. False otherwise (refer to LR bit in data sheet)
Returns
- 0 if successful, error otherwise.

◆ max9611_set_mode()

int max9611_set_mode ( struct max9611_dev dev,
enum max9611_mode_conf  mode 
)

Configures MAX9611 operating mode.

Parameters
dev- The device structure.
mode- MODE configuration
Returns
- 0 if successful, error otherwise.

◆ max9611_set_mux()

int max9611_set_mux ( struct max9611_dev dev,
enum max9611_mux_conf  mux 
)

Configures the internal MUX settings.

Parameters
dev- The device structure.
mux- MUX configuration
Returns
- 0 if successful, error otherwise.

◆ max9611_set_retry()

int max9611_set_retry ( struct max9611_dev dev,
enum max9611_retry_time  rtime 
)

Configures MAX9611 retry time.

Parameters
dev- The device structure.
rtime- Retry time option
Returns
- 0 if successful, error otherwise.

◆ max9611_shutdown()

int max9611_shutdown ( struct max9611_dev dev,
bool  is_shdn 
)

Device shutdown or power up.

Parameters
dev- The device structure.
is_shdn- Set to true to shutdown device, false otherwise
Returns
- 0 if successful, error otherwise.

◆ max9611_write()

int max9611_write ( struct max9611_dev dev,
uint8_t  addr,
uint8_t  bytes,
uint8_t *  write_data 
)

Writes data to device register (I2C)

Parameters
dev- The device structure.
addr- Starting / selected register address.
bytes- Number of bytes to write from starting register address
write_data- Write data buffer
Returns
- 0 if I2C write is successful, error otherwise.
Here is the caller graph for this function: