no-OS
Classes | Macros | Functions
max31343.h File Reference
#include <stdint.h>
#include <string.h>
#include "no_os_util.h"
#include "no_os_i2c.h"
Include dependency graph for max31343.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  max31343_time_stamp
 Structure holding the date parameters. More...
 
struct  max31343_init_param
 max31343 Device initialization parameters. More...
 
struct  max31343_dev
 max31343 Device structure. More...
 

Macros

#define MAX31343_I2C_ADDRESS   0x68
 
#define MAX31343_R_STATUS   0x00
 
#define MAX31343_R_INT_EN   0x01
 
#define MAX31343_R_RTC_RESET   0x02
 
#define MAX31343_R_CFG1   0x03
 
#define MAX31343_R_CFG2   0x04
 
#define MAX31343_R_TIMER_CONFIG   0x05
 
#define MAX31343_R_SECONDS   0x06
 
#define MAX31343_R_MINUTES   0x07
 
#define MAX31343_R_HOURS   0x08
 
#define MAX31343_R_DAY   0x09
 
#define MAX31343_R_DATE   0x0A
 
#define MAX31343_R_MONTH   0x0B
 
#define MAX31343_R_YEAR   0x0C
 
#define MAX31343_R_ALM1_SEC   0x0D
 
#define MAX31343_R_ALM1_MIN   0x0E
 
#define MAX31343_R_ALM1_HRS   0x0F
 
#define MAX31343_R_ALM1DAY_DATE   0x10
 
#define MAX31343_R_ALM1_MON   0x11
 
#define MAX31343_R_ALM1_YEAR   0x12
 
#define MAX31343_R_ALM2_MIN   0x13
 
#define MAX31343_R_ALM2_HRS   0x14
 
#define MAX31343_R_ALM2DAY_DATE   0x15
 
#define MAX31343_R_TIMER_COUNT   0x16
 
#define MAX31343_R_TIMER_INIT   0x17
 
#define MAX31343_R_PWR_MGMT   0x18
 
#define MAX31343_R_TRICKLE   0x19
 
#define MAX31343_R_TEMP_MSB   0x1A
 
#define MAX31343_R_TEMP_LSB   0x1B
 
#define MAX31343_R_TS_CONFIG   0x1C
 
#define MAX31343_R_RAM_REG_START   0x22
 
#define MAX31343_R_RAM_REG_END   0x61
 
#define MAX31343_F_STATUS_A1F   NO_OS_BIT(0)
 
#define MAX31343_F_STATUS_A2F   NO_OS_BIT(1)
 
#define MAX31343_F_STATUS_TIF   NO_OS_BIT(2)
 
#define MAX31343_F_STATUS_TSF   NO_OS_BIT(3)
 
#define MAX31343_F_STATUS_PFAIL   NO_OS_BIT(5)
 
#define MAX31343_F_STATUS_OSF   NO_OS_BIT(6)
 
#define MAX31343_F_STATUS_PSDECT   NO_OS_BIT(7)
 
#define MAX31343_F_INT_EN_A1IE   NO_OS_BIT(0)
 
#define MAX31343_F_INT_EN_A2IE   NO_OS_BIT(1)
 
#define MAX31343_F_INT_EN_TIE   NO_OS_BIT(2)
 
#define MAX31343_F_INT_EN_TSIE   NO_OS_BIT(3)
 
#define MAX31343_F_INT_EN_PFAILE   NO_OS_BIT(5)
 
#define MAX31343_F_INT_EN_DOSF   NO_OS_BIT(6)
 
#define MAX31343_F_RTC_RESET_SWRST   NO_OS_BIT(0)
 
#define MAX31343_F_CFG1_ENOSC   NO_OS_BIT(1)
 
#define MAX31343_F_CFG1_I2C_TIMEOUT   NO_OS_BIT(3)
 
#define MAX31343_F_CFG1_DATA_RET   NO_OS_BIT(4)
 
#define MAX31343_F_CFG2_SQW_HZ   NO_OS_BIT(0)
 
#define MAX31343_F_CFG2_CLKO_HZ   NO_OS_BIT(3)
 
#define MAX31343_F_CFG2_ENCLKO   NO_OS_BIT(7)
 
#define MAX31343_F_TIMER_CONFIG_TFS   NO_OS_BIT(0)
 
#define MAX31343_F_TIMER_CONFIG_TRPT   NO_OS_BIT(2)
 
#define MAX31343_F_TIMER_CONFIG_TPAUSE   NO_OS_BIT(3)
 
#define MAX31343_F_TIMER_CONFIG_TE   NO_OS_BIT(4)
 
#define MAX31343_F_PWR_MGMT_DMAN_SEL   NO_OS_BIT(2)
 
#define MAX31343_F_PWR_MGMT_D_VBACK_SEL   NO_OS_BIT(3)
 
#define MAX31343_F_PWR_MGMT_PFVT   NO_OS_BIT(4)
 
#define MAX31343_F_TRICKLE_D_TRICKLE   NO_OS_BIT(0)
 
#define MAX31343_F_TRICKLE_TCHE   NO_OS_BIT(4)
 
#define MAX31343_F_TS_CONFIG_TTSINT   NO_OS_BIT(3)
 
#define MAX31343_F_TS_CONFIG_ONESHOT_MODE   NO_OS_BIT(6)
 
#define MAX31343_F_TS_CONFIG_AUTO_MODE   NO_OS_BIT(7)
 

Functions

int max31343_reg_read (struct max31343_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
 Read device register. More...
 
int max31343_reg_write (struct max31343_dev *dev, uint8_t reg_addr, uint8_t reg_data)
 Write device register. More...
 
int max31343_update_bits (struct max31343_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_data)
 Update specific register bits. More...
 
int max31343_set_time_stamp (struct max31343_dev *dev, struct max31343_time_stamp ts)
 Set time stamp. More...
 
int max31343_reg_read_time_stamp (struct max31343_dev *dev, struct max31343_time_stamp *ts)
 Read time stamp. More...
 
int max31343_init (struct max31343_dev **device, struct max31343_init_param init_param)
 Initialize the device. More...
 
int max31343_remove (struct max31343_dev *dev)
 Remove the device and release resources. More...
 

Macro Definition Documentation

◆ MAX31343_F_CFG1_DATA_RET

#define MAX31343_F_CFG1_DATA_RET   NO_OS_BIT(4)

◆ MAX31343_F_CFG1_ENOSC

#define MAX31343_F_CFG1_ENOSC   NO_OS_BIT(1)

◆ MAX31343_F_CFG1_I2C_TIMEOUT

#define MAX31343_F_CFG1_I2C_TIMEOUT   NO_OS_BIT(3)

◆ MAX31343_F_CFG2_CLKO_HZ

#define MAX31343_F_CFG2_CLKO_HZ   NO_OS_BIT(3)

◆ MAX31343_F_CFG2_ENCLKO

#define MAX31343_F_CFG2_ENCLKO   NO_OS_BIT(7)

◆ MAX31343_F_CFG2_SQW_HZ

#define MAX31343_F_CFG2_SQW_HZ   NO_OS_BIT(0)

◆ MAX31343_F_INT_EN_A1IE

#define MAX31343_F_INT_EN_A1IE   NO_OS_BIT(0)

◆ MAX31343_F_INT_EN_A2IE

#define MAX31343_F_INT_EN_A2IE   NO_OS_BIT(1)

◆ MAX31343_F_INT_EN_DOSF

#define MAX31343_F_INT_EN_DOSF   NO_OS_BIT(6)

◆ MAX31343_F_INT_EN_PFAILE

#define MAX31343_F_INT_EN_PFAILE   NO_OS_BIT(5)

◆ MAX31343_F_INT_EN_TIE

#define MAX31343_F_INT_EN_TIE   NO_OS_BIT(2)

◆ MAX31343_F_INT_EN_TSIE

#define MAX31343_F_INT_EN_TSIE   NO_OS_BIT(3)

◆ MAX31343_F_PWR_MGMT_D_VBACK_SEL

#define MAX31343_F_PWR_MGMT_D_VBACK_SEL   NO_OS_BIT(3)

◆ MAX31343_F_PWR_MGMT_DMAN_SEL

#define MAX31343_F_PWR_MGMT_DMAN_SEL   NO_OS_BIT(2)

◆ MAX31343_F_PWR_MGMT_PFVT

#define MAX31343_F_PWR_MGMT_PFVT   NO_OS_BIT(4)

◆ MAX31343_F_RTC_RESET_SWRST

#define MAX31343_F_RTC_RESET_SWRST   NO_OS_BIT(0)

◆ MAX31343_F_STATUS_A1F

#define MAX31343_F_STATUS_A1F   NO_OS_BIT(0)

◆ MAX31343_F_STATUS_A2F

#define MAX31343_F_STATUS_A2F   NO_OS_BIT(1)

◆ MAX31343_F_STATUS_OSF

#define MAX31343_F_STATUS_OSF   NO_OS_BIT(6)

◆ MAX31343_F_STATUS_PFAIL

#define MAX31343_F_STATUS_PFAIL   NO_OS_BIT(5)

◆ MAX31343_F_STATUS_PSDECT

#define MAX31343_F_STATUS_PSDECT   NO_OS_BIT(7)

◆ MAX31343_F_STATUS_TIF

#define MAX31343_F_STATUS_TIF   NO_OS_BIT(2)

◆ MAX31343_F_STATUS_TSF

#define MAX31343_F_STATUS_TSF   NO_OS_BIT(3)

◆ MAX31343_F_TIMER_CONFIG_TE

#define MAX31343_F_TIMER_CONFIG_TE   NO_OS_BIT(4)

◆ MAX31343_F_TIMER_CONFIG_TFS

#define MAX31343_F_TIMER_CONFIG_TFS   NO_OS_BIT(0)

◆ MAX31343_F_TIMER_CONFIG_TPAUSE

#define MAX31343_F_TIMER_CONFIG_TPAUSE   NO_OS_BIT(3)

◆ MAX31343_F_TIMER_CONFIG_TRPT

#define MAX31343_F_TIMER_CONFIG_TRPT   NO_OS_BIT(2)

◆ MAX31343_F_TRICKLE_D_TRICKLE

#define MAX31343_F_TRICKLE_D_TRICKLE   NO_OS_BIT(0)

◆ MAX31343_F_TRICKLE_TCHE

#define MAX31343_F_TRICKLE_TCHE   NO_OS_BIT(4)

◆ MAX31343_F_TS_CONFIG_AUTO_MODE

#define MAX31343_F_TS_CONFIG_AUTO_MODE   NO_OS_BIT(7)

◆ MAX31343_F_TS_CONFIG_ONESHOT_MODE

#define MAX31343_F_TS_CONFIG_ONESHOT_MODE   NO_OS_BIT(6)

◆ MAX31343_F_TS_CONFIG_TTSINT

#define MAX31343_F_TS_CONFIG_TTSINT   NO_OS_BIT(3)

◆ MAX31343_I2C_ADDRESS

#define MAX31343_I2C_ADDRESS   0x68

◆ MAX31343_R_ALM1_HRS

#define MAX31343_R_ALM1_HRS   0x0F

◆ MAX31343_R_ALM1_MIN

#define MAX31343_R_ALM1_MIN   0x0E

◆ MAX31343_R_ALM1_MON

#define MAX31343_R_ALM1_MON   0x11

◆ MAX31343_R_ALM1_SEC

#define MAX31343_R_ALM1_SEC   0x0D

◆ MAX31343_R_ALM1_YEAR

#define MAX31343_R_ALM1_YEAR   0x12

◆ MAX31343_R_ALM1DAY_DATE

#define MAX31343_R_ALM1DAY_DATE   0x10

◆ MAX31343_R_ALM2_HRS

#define MAX31343_R_ALM2_HRS   0x14

◆ MAX31343_R_ALM2_MIN

#define MAX31343_R_ALM2_MIN   0x13

◆ MAX31343_R_ALM2DAY_DATE

#define MAX31343_R_ALM2DAY_DATE   0x15

◆ MAX31343_R_CFG1

#define MAX31343_R_CFG1   0x03

◆ MAX31343_R_CFG2

#define MAX31343_R_CFG2   0x04

◆ MAX31343_R_DATE

#define MAX31343_R_DATE   0x0A

◆ MAX31343_R_DAY

#define MAX31343_R_DAY   0x09

◆ MAX31343_R_HOURS

#define MAX31343_R_HOURS   0x08

◆ MAX31343_R_INT_EN

#define MAX31343_R_INT_EN   0x01

◆ MAX31343_R_MINUTES

#define MAX31343_R_MINUTES   0x07

◆ MAX31343_R_MONTH

#define MAX31343_R_MONTH   0x0B

◆ MAX31343_R_PWR_MGMT

#define MAX31343_R_PWR_MGMT   0x18

◆ MAX31343_R_RAM_REG_END

#define MAX31343_R_RAM_REG_END   0x61

◆ MAX31343_R_RAM_REG_START

#define MAX31343_R_RAM_REG_START   0x22

◆ MAX31343_R_RTC_RESET

#define MAX31343_R_RTC_RESET   0x02

◆ MAX31343_R_SECONDS

#define MAX31343_R_SECONDS   0x06

◆ MAX31343_R_STATUS

#define MAX31343_R_STATUS   0x00

◆ MAX31343_R_TEMP_LSB

#define MAX31343_R_TEMP_LSB   0x1B

◆ MAX31343_R_TEMP_MSB

#define MAX31343_R_TEMP_MSB   0x1A

◆ MAX31343_R_TIMER_CONFIG

#define MAX31343_R_TIMER_CONFIG   0x05

◆ MAX31343_R_TIMER_COUNT

#define MAX31343_R_TIMER_COUNT   0x16

◆ MAX31343_R_TIMER_INIT

#define MAX31343_R_TIMER_INIT   0x17

◆ MAX31343_R_TRICKLE

#define MAX31343_R_TRICKLE   0x19

◆ MAX31343_R_TS_CONFIG

#define MAX31343_R_TS_CONFIG   0x1C

◆ MAX31343_R_YEAR

#define MAX31343_R_YEAR   0x0C

Function Documentation

◆ max31343_init()

int max31343_init ( struct max31343_dev **  device,
struct max31343_init_param  init_param 
)

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
0 in case of success, negative error code otherwise.

◆ max31343_reg_read()

int max31343_reg_read ( struct max31343_dev dev,
uint8_t  reg_addr,
uint8_t *  reg_data 
)

Read device register.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The data read from the register.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max31343_reg_read_time_stamp()

int max31343_reg_read_time_stamp ( struct max31343_dev dev,
struct max31343_time_stamp ts 
)

Read time stamp.

Parameters
dev- The device structure.
ts- Structure holding the time stamp to read.
Returns
0 in case of success, negative error code otherwise.

◆ max31343_reg_write()

int max31343_reg_write ( struct max31343_dev dev,
uint8_t  reg_addr,
uint8_t  reg_data 
)

Write device register.

Parameters
dev-The device structure.
reg_addr- The register address.
reg_data- The data to be written.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max31343_remove()

int max31343_remove ( struct max31343_dev dev)

Remove the device and release resources.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ max31343_set_time_stamp()

int max31343_set_time_stamp ( struct max31343_dev dev,
struct max31343_time_stamp  ts 
)

Set time stamp.

Parameters
dev- The device structure.
ts- Structure holding the time stamp to be set.
Returns
0 in case of success, negative error code otherwise.

◆ max31343_update_bits()

int max31343_update_bits ( struct max31343_dev dev,
uint8_t  reg_addr,
uint8_t  mask,
uint8_t  reg_data 
)

Update specific register bits.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- Specific bits mask.
reg_data- The data to be written.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function: