no-OS
Loading...
Searching...
No Matches
ltc7871.c File Reference

Source file for the LTC7871 Driver. More...

#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_print_log.h"
#include "ltc7871.h"
Include dependency graph for ltc7871.c:

Functions

uint8_t ltc7871_get_pec_byte (uint8_t *data, uint8_t len)
 Compute the PEC.
 
int ltc7871_reg_read (struct ltc7871_dev *dev, uint8_t reg, uint8_t *data)
 Register Read.
 
int ltc7871_reg_write (struct ltc7871_dev *dev, uint8_t reg, uint8_t data)
 Register Write.
 
int ltc7871_reg_write_mask (struct ltc7871_dev *dev, uint8_t address, uint8_t mask, uint8_t data)
 Write to LTC7871 device register with mask.
 
int ltc7871_get_mfr_fault (struct ltc7871_dev *dev, uint8_t status, bool *value)
 gets mfr fault bit.
 
int ltc7871_get_mfr_oc_fault (struct ltc7871_dev *dev, uint8_t status, bool *value)
 gets status for overcurrent condition status.
 
int ltc7871_get_mfr_noc_fault (struct ltc7871_dev *dev, uint8_t status, bool *value)
 gets status for negative overcurrent fault condition status.
 
int ltc7871_get_mfr_config1_setting (struct ltc7871_dev *dev, uint8_t config, uint8_t *value)
 gets configuration of the controller programmed by the pins.
 
int ltc7871_get_mfr_config2_setting (struct ltc7871_dev *dev, uint8_t config, uint8_t *value)
 gets configuration of the controller programmed by the pins.
 
int ltc7871_get_mfr_status (struct ltc7871_dev *dev, uint8_t status_mask, bool *status)
 gets status.
 
int ltc7871_reset (struct ltc7871_dev *dev)
 Reset all R/W registers.
 
int ltc7871_clear_pec_fault (struct ltc7871_dev *dev)
 Clear PEC fault bit.
 
int ltc7871_read_pec_fault (struct ltc7871_dev *dev, bool *value)
 Read PEC fault bit.
 
int ltc7871_set_write_protect (struct ltc7871_dev *dev, bool value)
 set write protect bit.
 
int ltc7871_is_write_protected (struct ltc7871_dev *dev, bool *value)
 Read Write Protect bit for IDAC registers, and MFR_SSFM register.
 
int ltc7871_get_mfr_idac_vlow (struct ltc7871_dev *dev, int8_t *value)
 get the current DAC value to program the VLOW voltage.
 
int ltc7871_set_mfr_idac_vlow (struct ltc7871_dev *dev, int8_t value)
 stores the current DAC value to program the VLOW voltage.
 
int ltc7871_get_mfr_idac_vhigh (struct ltc7871_dev *dev, int8_t *value)
 get the current DAC value to program the VHIGH voltage.
 
int ltc7871_set_mfr_idac_vhigh (struct ltc7871_dev *dev, int8_t value)
 stores the current DAC value to program the VHIGH voltage.
 
int ltc7871_get_mfr_idac_setcur (struct ltc7871_dev *dev, int8_t *value)
 get the current DAC value to program the sourcing current of the SETCUR pin.
 
int ltc7871_set_mfr_idac_setcur (struct ltc7871_dev *dev, int8_t value)
 stores the current DAC value to program the sourcing current of the SETCUR pin.
 
int ltc7871_get_freq_spread_range (struct ltc7871_dev *dev, uint8_t *value)
 Get Frequency Spread Range.
 
int ltc7871_set_freq_spread_range (struct ltc7871_dev *dev, enum ltc7871_ssfm_fsr value)
 Set Frequency Spread Range.
 
int ltc7871_get_mod_freq (struct ltc7871_dev *dev, uint8_t *value)
 Get Modulation Signal Frequency.
 
int ltc7871_set_mod_freq (struct ltc7871_dev *dev, enum ltc7871_ssfm_msf value)
 Set Modulation Signal Frequency.
 
int ltc7871_set_pwmen_pin (struct ltc7871_dev *dev, uint8_t value)
 Set PWMEN pin of LTC7871 device.
 
int ltc7871_get_pwmen_pin (struct ltc7871_dev *dev, uint8_t *value)
 Get EN pin of LTC7871 device.
 
int ltc7871_init (struct ltc7871_dev **device, struct ltc7871_init_param *init_param)
 Initialize the LTC7871 device.
 
int ltc7871_remove (struct ltc7871_dev *dev)
 Free the resources allocated by the LT7871_init()
 

Detailed Description

Source file for the LTC7871 Driver.

Author
Aldrin Abacan (aldri.nosp@m.n.ab.nosp@m.acan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2024(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ ltc7871_clear_pec_fault()

int ltc7871_clear_pec_fault ( struct ltc7871_dev * dev)

Clear PEC fault bit.

Parameters
dev- LTC7871 device descriptor
Returns
0 in case of success, negative error code otherwise

◆ ltc7871_get_freq_spread_range()

int ltc7871_get_freq_spread_range ( struct ltc7871_dev * dev,
uint8_t * value )

Get Frequency Spread Range.

Parameters
dev- LTC7871 device descriptor
value- Frequencey Spread range
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_config1_setting()

int ltc7871_get_mfr_config1_setting ( struct ltc7871_dev * dev,
uint8_t config,
uint8_t * value )

gets configuration of the controller programmed by the pins.

Parameters
dev- LTC7871 device descriptor
config- configuration to get.
value- status value to be returned.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_config2_setting()

int ltc7871_get_mfr_config2_setting ( struct ltc7871_dev * dev,
uint8_t config,
uint8_t * value )

gets configuration of the controller programmed by the pins.

Parameters
dev- LTC7871 device descriptor
config- configuration to get.
value- status value to be returned.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_fault()

int ltc7871_get_mfr_fault ( struct ltc7871_dev * dev,
uint8_t status,
bool * value )

gets mfr fault bit.

Parameters
dev- LTC7871 device descriptor
status- m askfault status to get.
value- status value to be returned.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_idac_setcur()

int ltc7871_get_mfr_idac_setcur ( struct ltc7871_dev * dev,
int8_t * value )

get the current DAC value to program the sourcing current of the SETCUR pin.

Parameters
dev- LTC7871 device descriptor
value- DAC Value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_idac_vhigh()

int ltc7871_get_mfr_idac_vhigh ( struct ltc7871_dev * dev,
int8_t * value )

get the current DAC value to program the VHIGH voltage.

Parameters
dev- LTC7871 device descriptor
value- DAC Value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_idac_vlow()

int ltc7871_get_mfr_idac_vlow ( struct ltc7871_dev * dev,
int8_t * value )

get the current DAC value to program the VLOW voltage.

Parameters
dev- LTC7871 device descriptor
value- DAC Value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_noc_fault()

int ltc7871_get_mfr_noc_fault ( struct ltc7871_dev * dev,
uint8_t status,
bool * value )

gets status for negative overcurrent fault condition status.

Parameters
dev- LTC7871 device descriptor
status- mask fault status to get. (0-5)
value- status value to be returned.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_oc_fault()

int ltc7871_get_mfr_oc_fault ( struct ltc7871_dev * dev,
uint8_t status,
bool * value )

gets status for overcurrent condition status.

Parameters
dev- LTC7871 device descriptor
status- mask fault status to get. (0-5)
value- status value to be returned.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mfr_status()

int ltc7871_get_mfr_status ( struct ltc7871_dev * dev,
uint8_t status_mask,
bool * status )

gets status.

Parameters
dev- LTC7871 device descriptor
status_mask- status mask to be acquire.
status- status value.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_mod_freq()

int ltc7871_get_mod_freq ( struct ltc7871_dev * dev,
uint8_t * value )

Get Modulation Signal Frequency.

Parameters
dev- LTC7871 device descriptor
value- Modulation signal frequency value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_get_pec_byte()

uint8_t ltc7871_get_pec_byte ( uint8_t * data,
uint8_t len )

Compute the PEC.

Parameters
data- Data buffer.
len- Buffer length.
Returns
8-bit CRC value

◆ ltc7871_get_pwmen_pin()

int ltc7871_get_pwmen_pin ( struct ltc7871_dev * dev,
uint8_t * value )

Get EN pin of LTC7871 device.

Parameters
dev- LTC7871 device descriptor
value- EN pin value.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_init()

int ltc7871_init ( struct ltc7871_dev ** device,
struct ltc7871_init_param * init_param )

Initialize the LTC7871 device.

Parameters
device- LTC7871 device descriptor
init_param- Initialization parameter containing information about the LTC7871 device to be initialized.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_is_write_protected()

int ltc7871_is_write_protected ( struct ltc7871_dev * dev,
bool * value )

Read Write Protect bit for IDAC registers, and MFR_SSFM register.

Parameters
dev- LTC7871 device descriptor
value- value of write protect bit
Returns
0 in case of success, negative error code otherwise

◆ ltc7871_read_pec_fault()

int ltc7871_read_pec_fault ( struct ltc7871_dev * dev,
bool * value )

Read PEC fault bit.

Parameters
dev- LTC7871 device descriptor
value- fault bit value.
Returns
0 in case of success, negative error code otherwise

◆ ltc7871_reg_read()

int ltc7871_reg_read ( struct ltc7871_dev * dev,
uint8_t reg,
uint8_t * data )

Register Read.

Parameters
dev- The device structure
reg- The register value
data- The data read from the device.
Returns
0 in case of success, negative code otherwise

◆ ltc7871_reg_write()

int ltc7871_reg_write ( struct ltc7871_dev * dev,
uint8_t reg,
uint8_t data )

Register Write.

Parameters
dev- The device structure
reg- The register value
data- The data written to the device
Returns
0 in case of success, negative code otherwise

◆ ltc7871_reg_write_mask()

int ltc7871_reg_write_mask ( struct ltc7871_dev * dev,
uint8_t address,
uint8_t mask,
uint8_t data )

Write to LTC7871 device register with mask.

Parameters
dev- LTC7871 device descriptor
address- Register address.
mask- Mask to be applied.
data- Data to be written.
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_remove()

int ltc7871_remove ( struct ltc7871_dev * dev)

Free the resources allocated by the LT7871_init()

Parameters
dev- LTC7871 device descriptor
Returns
- 0 in case of succes, negative error code otherwise

◆ ltc7871_reset()

int ltc7871_reset ( struct ltc7871_dev * dev)

Reset all R/W registers.

Parameters
dev- LTC7871 device descriptor
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_set_freq_spread_range()

int ltc7871_set_freq_spread_range ( struct ltc7871_dev * dev,
enum ltc7871_ssfm_fsr value )

Set Frequency Spread Range.

Parameters
dev- LTC7871 device descriptor
value- Frequency Spread Range value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_set_mfr_idac_setcur()

int ltc7871_set_mfr_idac_setcur ( struct ltc7871_dev * dev,
int8_t value )

stores the current DAC value to program the sourcing current of the SETCUR pin.

Parameters
dev- LTC7871 device descriptor
value- DAC value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_set_mfr_idac_vhigh()

int ltc7871_set_mfr_idac_vhigh ( struct ltc7871_dev * dev,
int8_t value )

stores the current DAC value to program the VHIGH voltage.

Parameters
dev- LTC7871 device descriptor
value- DAC value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_set_mfr_idac_vlow()

int ltc7871_set_mfr_idac_vlow ( struct ltc7871_dev * dev,
int8_t value )

stores the current DAC value to program the VLOW voltage.

Parameters
dev- LTC7871 device descriptor
value- DAC value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_set_mod_freq()

int ltc7871_set_mod_freq ( struct ltc7871_dev * dev,
enum ltc7871_ssfm_msf value )

Set Modulation Signal Frequency.

Parameters
dev- LTC7871 device descriptor
value- Modulation signal frequency value
Returns
0 in case of succes, negative error code otherwise

◆ ltc7871_set_pwmen_pin()

int ltc7871_set_pwmen_pin ( struct ltc7871_dev * dev,
uint8_t value )

Set PWMEN pin of LTC7871 device.

Parameters
dev- LTC7871 device descriptor
valueSet SWEN pin of LTC7871 device.
Returns
- 0 in case of succes, negative error code otherwise

◆ ltc7871_set_write_protect()

int ltc7871_set_write_protect ( struct ltc7871_dev * dev,
bool value )

set write protect bit.

Parameters
dev- LTC7871 device descriptor
value- 1 if enable wp, 0 if disable
Returns
0 in case of success, negative error code otherwise