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

Implementation of LTC6953 Driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "no_os_spi.h"
#include "no_os_error.h"
Include dependency graph for ltc6953.h:

Classes

struct  ltc6953_channel_spec
 Output channel configuration. More...
 
struct  ltc6953_init_param
 LTC6953 Initialization Parameters structure. More...
 
struct  ltc6953_dev
 LTC6953 Device Descriptor. More...
 

Macros

#define LTC6953_NUM_REGADDR   57
 
#define LTC6953_REG_VCO_STATUS   0x00
 
#define LTC6953_REG_STAT   0x01
 
#define LTC6953_REG_PD_CTL   0x02
 
#define LTC6953_REG_CHAN_POWER_DOWN(x)
 
#define LTC6953_REG_TEMP   0x05
 
#define LTC6953_REG_SYNC_CONFIG   0x0B
 
#define LTC6953_REG_OUTPUT_DIVIDER(x)
 
#define LTC6953_REG_OUTPUT_CONFIG(x)
 
#define LTC6953_REG_DDEL_HIGH(x)
 
#define LTC6953_REG_DDEL_LOW(x)
 
#define LTC6953_REG_ADEL(x)
 
#define LTC6953_REG_CHIP_INFO   0x38
 
#define LTC6953_VCOOK_MSK   NO_OS_BIT(2)
 
#define LTC6953_NVCOOK_MSK   NO_OS_BIT(3)
 
#define LTC6953_INVSTAT_MSK   NO_OS_BIT(7)
 
#define LTC6953_STAT_OUT_MSK   NO_OS_GENMASK(6, 0)
 
#define LTC6953_PDALL_MSK   NO_OS_BIT(7)
 
#define LTC6953_PDVCOPK_MSK   NO_OS_BIT(5)
 
#define LTC6953_FILTV_MSK   NO_OS_BIT(1)
 
#define LTC6953_POR_MSK   NO_OS_BIT(0)
 
#define LTC6953_PD_MSK(ch)
 
#define LTC6953_PD(ch, x)
 
#define LTC6953_TEMPO_MSK   NO_OS_BIT(7)
 
#define LTC6953_EZMD_MSK   NO_OS_BIT(4)
 
#define LTC6953_SRQMD_MSK   NO_OS_BIT(3)
 
#define LTC6953_SYSCT_MSK   NO_OS_GENMASK(2, 1)
 
#define LTC6953_SSRQ_MSK   NO_OS_BIT(0)
 
#define LTC6953_MP_MSK   NO_OS_GENMASK(7, 3)
 
#define LTC6953_MD_MSK   NO_OS_GENMASK(2, 0)
 
#define LTC6953_SRQEN_MSK   NO_OS_BIT(7)
 
#define LTC6953_MODE_MSK   NO_OS_GENMASK(6, 5)
 
#define LTC6953_OINV_MSK   NO_OS_BIT(4)
 
#define LTC6953_DDEL_HIGH_MSK   NO_OS_GENMASK(3, 0)
 
#define LTC6953_DDEL_LOW_MSK   NO_OS_GENMASK(7, 0)
 
#define LTC6953_ADEL_MSK   NO_OS_GENMASK(5, 0)
 
#define LTC6953_REV_MSK   NO_OS_GENMASK(7, 4)
 
#define LTC6953_PART_MSK   NO_OS_GENMASK(3, 0)
 
#define LTC6953_NUM_CHAN   11
 
#define LTC6953_OUT_DIV_MIN   1
 
#define LTC6953_OUT_DIV_MAX   1048576
 
#define LTC6953_X_MAX   127
 
#define LTC6953_ADDRX   0
 
#define LTC6953_DXMSB   1
 
#define LTC6953_NUMBITS   2
 
#define LTC6953_R_ONLY   3
 
#define LTC6953_SPI_WRITE_CMD   0x00
 
#define LTC6953_SPI_READ_CMD   0x01
 
#define LTC6953_SPI_ADDR_CMD(x)
 
#define LTC6953_BUFF_SIZE_BYTES   2
 
#define LTC6953_DUMMY_BYTES   0x00
 

Functions

int ltc6953_init (struct ltc6953_dev **dev, struct ltc6953_init_param *init_param)
 Initializes the SPI communication with LTC6953.
 
int ltc6953_remove (struct ltc6953_dev *dev)
 Free resources allocated for LTC6953.
 
int ltc6953_reset (struct ltc6953_dev *dev)
 Software reset of the device.
 
int ltc6953_write (struct ltc6953_dev *dev, uint8_t addr, uint16_t data)
 Writes data to LTC6953 over SPI.
 
int ltc6953_read (struct ltc6953_dev *dev, uint8_t addr, uint8_t *data)
 Read device register.
 
int ltc6953_update (struct ltc6953_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
 Update LTC6953 register.
 
int ltc6953_power_down_all (struct ltc6953_dev *dev, bool is_pwdn)
 Powers down all LTC6953 output channels.
 
int ltc6953_enable_filter (struct ltc6953_dev *dev, bool is_en)
 Enable LTC6953 VCO Input filter.
 
int ltc6953_power_down_vco (struct ltc6953_dev *dev, bool is_pwdn)
 Powers down LTC6953 VCO Input channel.
 
int ltc6953_set_output_divider (struct ltc6953_dev *dev, uint32_t channel, uint32_t divider)
 Set output divider for LTC6953 output channel.
 
int ltc6953_power_mode (struct ltc6953_dev *dev, uint32_t channel, int32_t mode)
 Set LTC6953 Channel Power Mode.
 
int ltc6953_enable_sync (struct ltc6953_dev *dev, uint32_t channel, bool enable)
 Set LTC6953 Channel Sync mode.
 
int ltc6953_set_digital_delay (struct ltc6953_dev *dev, uint32_t channel, uint16_t delay)
 Set digital delay/phase of LTC6953 output channel.
 
int ltc6953_set_analog_delay (struct ltc6953_dev *dev, uint32_t channel, uint16_t delay)
 Set analog delay/phase of LTC6953 output channel.
 
int ltc6953_set_mode (struct ltc6953_dev *dev, uint32_t channel, uint8_t mode)
 Set LTC6953 output channel mode.
 
int ltc6953_invert_output (struct ltc6953_dev *dev, uint32_t channel, bool is_invert)
 Set LTC6953 output channel inversion.
 
int ltc6953_ezsync_mode (struct ltc6953_dev *dev, bool is_en)
 Set LTC6953 EZSYNC mode.
 
int ltc6953_sync_mode (struct ltc6953_dev *dev, bool is_en)
 Set LTC6953 SRQ mode.
 
int ltc6953_ssrq_mode (struct ltc6953_dev *dev, bool is_en)
 Set LTC6953 SSRQ mode.
 
int ltc6953_num_pulse (struct ltc6953_dev *dev, uint8_t num_pulse)
 Set LTC6953 SYSCT/Num pulse value.
 
int ltc6953_enable_temp_stat (struct ltc6953_dev *dev, bool is_en)
 Set LTC6953 TEMPO value.
 
int ltc6953_vco_status (struct ltc6953_dev *dev, bool *is_ok)
 Read LTC6953 Check VCO Input stats.
 
int ltc6953_get_invstat (struct ltc6953_dev *dev, bool *status)
 Read LTC6953 INVSTAT bit.
 
int ltc6953_set_invstat (struct ltc6953_dev *dev, bool status)
 Write LTC6953 INVSTAT bit.
 
int ltc6953_set_x (struct ltc6953_dev *dev, uint8_t x)
 Set LTC6953 x bitfield status.
 
int ltc6953_get_x (struct ltc6953_dev *dev, uint8_t *x)
 Set LTC6953 x bitfield status.
 
int ltc6953_read_rev (struct ltc6953_dev *dev, uint8_t *rev)
 Read LTC6953 Part number.
 
int ltc6953_read_part (struct ltc6953_dev *dev, uint8_t *part)
 Read LTC6953 Part number.
 

Detailed Description

Implementation of LTC6953 Driver.

Author
MTinaco (marie.nosp@m.l.ti.nosp@m.naco@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2023-2024(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ LTC6953_ADDRX

#define LTC6953_ADDRX   0

◆ LTC6953_ADEL_MSK

#define LTC6953_ADEL_MSK   NO_OS_GENMASK(5, 0)

◆ LTC6953_BUFF_SIZE_BYTES

#define LTC6953_BUFF_SIZE_BYTES   2

◆ LTC6953_DDEL_HIGH_MSK

#define LTC6953_DDEL_HIGH_MSK   NO_OS_GENMASK(3, 0)

◆ LTC6953_DDEL_LOW_MSK

#define LTC6953_DDEL_LOW_MSK   NO_OS_GENMASK(7, 0)

◆ LTC6953_DUMMY_BYTES

#define LTC6953_DUMMY_BYTES   0x00

◆ LTC6953_DXMSB

#define LTC6953_DXMSB   1

◆ LTC6953_EZMD_MSK

#define LTC6953_EZMD_MSK   NO_OS_BIT(4)

◆ LTC6953_FILTV_MSK

#define LTC6953_FILTV_MSK   NO_OS_BIT(1)

◆ LTC6953_INVSTAT_MSK

#define LTC6953_INVSTAT_MSK   NO_OS_BIT(7)

◆ LTC6953_MD_MSK

#define LTC6953_MD_MSK   NO_OS_GENMASK(2, 0)

◆ LTC6953_MODE_MSK

#define LTC6953_MODE_MSK   NO_OS_GENMASK(6, 5)

◆ LTC6953_MP_MSK

#define LTC6953_MP_MSK   NO_OS_GENMASK(7, 3)

◆ LTC6953_NUM_CHAN

#define LTC6953_NUM_CHAN   11

◆ LTC6953_NUM_REGADDR

#define LTC6953_NUM_REGADDR   57

◆ LTC6953_NUMBITS

#define LTC6953_NUMBITS   2

◆ LTC6953_NVCOOK_MSK

#define LTC6953_NVCOOK_MSK   NO_OS_BIT(3)

◆ LTC6953_OINV_MSK

#define LTC6953_OINV_MSK   NO_OS_BIT(4)

◆ LTC6953_OUT_DIV_MAX

#define LTC6953_OUT_DIV_MAX   1048576

◆ LTC6953_OUT_DIV_MIN

#define LTC6953_OUT_DIV_MIN   1

◆ LTC6953_PART_MSK

#define LTC6953_PART_MSK   NO_OS_GENMASK(3, 0)

◆ LTC6953_PD

#define LTC6953_PD ( ch,
x )
Value:
#define LTC6953_PD_MSK(ch)
Definition ltc6953.h:50
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)

◆ LTC6953_PD_MSK

#define LTC6953_PD_MSK ( ch)
Value:
((ch) & NO_OS_GENMASK(1, 0)) * 2 + 1, \
((ch) & NO_OS_GENMASK(1, 0)) * 2)
#define NO_OS_GENMASK(h, l)
Definition no_os_util.h:60

◆ LTC6953_PDALL_MSK

#define LTC6953_PDALL_MSK   NO_OS_BIT(7)

◆ LTC6953_PDVCOPK_MSK

#define LTC6953_PDVCOPK_MSK   NO_OS_BIT(5)

◆ LTC6953_POR_MSK

#define LTC6953_POR_MSK   NO_OS_BIT(0)

◆ LTC6953_R_ONLY

#define LTC6953_R_ONLY   3

◆ LTC6953_REG_ADEL

#define LTC6953_REG_ADEL ( x)
Value:
0x0F + (x * 4)

◆ LTC6953_REG_CHAN_POWER_DOWN

#define LTC6953_REG_CHAN_POWER_DOWN ( x)
Value:
0x03 + (x / 4)

◆ LTC6953_REG_CHIP_INFO

#define LTC6953_REG_CHIP_INFO   0x38

◆ LTC6953_REG_DDEL_HIGH

#define LTC6953_REG_DDEL_HIGH ( x)
Value:
0x0D + (x * 4)

◆ LTC6953_REG_DDEL_LOW

#define LTC6953_REG_DDEL_LOW ( x)
Value:
0x0E + (x * 4)

◆ LTC6953_REG_OUTPUT_CONFIG

#define LTC6953_REG_OUTPUT_CONFIG ( x)
Value:
0x0D + (x * 4)

◆ LTC6953_REG_OUTPUT_DIVIDER

#define LTC6953_REG_OUTPUT_DIVIDER ( x)
Value:
0x0C + (x * 4)

◆ LTC6953_REG_PD_CTL

#define LTC6953_REG_PD_CTL   0x02

◆ LTC6953_REG_STAT

#define LTC6953_REG_STAT   0x01

◆ LTC6953_REG_SYNC_CONFIG

#define LTC6953_REG_SYNC_CONFIG   0x0B

◆ LTC6953_REG_TEMP

#define LTC6953_REG_TEMP   0x05

◆ LTC6953_REG_VCO_STATUS

#define LTC6953_REG_VCO_STATUS   0x00

◆ LTC6953_REV_MSK

#define LTC6953_REV_MSK   NO_OS_GENMASK(7, 4)

◆ LTC6953_SPI_ADDR_CMD

#define LTC6953_SPI_ADDR_CMD ( x)
Value:
((x) << 1)

◆ LTC6953_SPI_READ_CMD

#define LTC6953_SPI_READ_CMD   0x01

◆ LTC6953_SPI_WRITE_CMD

#define LTC6953_SPI_WRITE_CMD   0x00

◆ LTC6953_SRQEN_MSK

#define LTC6953_SRQEN_MSK   NO_OS_BIT(7)

◆ LTC6953_SRQMD_MSK

#define LTC6953_SRQMD_MSK   NO_OS_BIT(3)

◆ LTC6953_SSRQ_MSK

#define LTC6953_SSRQ_MSK   NO_OS_BIT(0)

◆ LTC6953_STAT_OUT_MSK

#define LTC6953_STAT_OUT_MSK   NO_OS_GENMASK(6, 0)

◆ LTC6953_SYSCT_MSK

#define LTC6953_SYSCT_MSK   NO_OS_GENMASK(2, 1)

◆ LTC6953_TEMPO_MSK

#define LTC6953_TEMPO_MSK   NO_OS_BIT(7)

◆ LTC6953_VCOOK_MSK

#define LTC6953_VCOOK_MSK   NO_OS_BIT(2)

◆ LTC6953_X_MAX

#define LTC6953_X_MAX   127

Function Documentation

◆ ltc6953_enable_filter()

int ltc6953_enable_filter ( struct ltc6953_dev * dev,
bool is_en )

Enable LTC6953 VCO Input filter.

LTC6953 Enable input filter

Parameters
dev- The device structure.
is_en- Set to True to enable input filter.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ ltc6953_enable_sync()

int ltc6953_enable_sync ( struct ltc6953_dev * dev,
uint32_t channel,
bool enable )

Set LTC6953 Channel Sync mode.

LTC6953 Enable single channel sync

Parameters
dev- The device structure.
channel- Output channel [0-10]
enable- Set to True to enable synchronization mode [SRQMD]
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_enable_temp_stat()

int ltc6953_enable_temp_stat ( struct ltc6953_dev * dev,
bool is_en )

Set LTC6953 TEMPO value.

LTC6953 Enable Temperature Measurement from STAT pin

Parameters
dev- The device structure.
is_en- TEMPO setting.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_ezsync_mode()

int ltc6953_ezsync_mode ( struct ltc6953_dev * dev,
bool is_en )

Set LTC6953 EZSYNC mode.

LTC6953 Set EZSYNC mode

Parameters
dev- The device structure.
is_en- Synchronization setting.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_get_invstat()

int ltc6953_get_invstat ( struct ltc6953_dev * dev,
bool * status )

Read LTC6953 INVSTAT bit.

LTC6953 Get INVSTAT bit

Parameters
dev- The device structure.
status- Container variable for INVSTAT pin.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_get_x()

int ltc6953_get_x ( struct ltc6953_dev * dev,
uint8_t * x )

Set LTC6953 x bitfield status.

LTC6953 Get X

Parameters
dev- The device structure.
x- Container value for x bitfield.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_init()

int ltc6953_init ( struct ltc6953_dev ** device,
struct ltc6953_init_param * init_param )

Initializes the SPI communication with LTC6953.

LTC6953 SPI Initialization

Parameters
device- the device structure.
init_param- the initialization parameters.
Returns
0 in case of success, negative error code otherwise.

◆ ltc6953_invert_output()

int ltc6953_invert_output ( struct ltc6953_dev * dev,
uint32_t channel,
bool is_invert )

Set LTC6953 output channel inversion.

LTC6953 Enable single channel output inversion

Parameters
dev- The device structure.
channel- Output channel [0-10].
is_invert- Inversion setting.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_num_pulse()

int ltc6953_num_pulse ( struct ltc6953_dev * dev,
uint8_t num_pulse )

Set LTC6953 SYSCT/Num pulse value.

LTC6953 Set SYSCT

Parameters
dev- The device structure.
num_pulse- Number of pulses.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_power_down_all()

int ltc6953_power_down_all ( struct ltc6953_dev * dev,
bool is_pwdn )

Powers down all LTC6953 output channels.

LTC6953 Power down all channels

Parameters
dev- The device structure.
is_pwdn- Set to True to power down all channels.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ ltc6953_power_down_vco()

int ltc6953_power_down_vco ( struct ltc6953_dev * dev,
bool is_pwdn )

Powers down LTC6953 VCO Input channel.

LTC6953 Power Down VCO input

Parameters
dev- The device structure.
is_pwdn- Set to True to power down input channel.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ ltc6953_power_mode()

int ltc6953_power_mode ( struct ltc6953_dev * dev,
uint32_t channel,
int32_t mode )

Set LTC6953 Channel Power Mode.

LTC6953 Set single channel power mode

Parameters
dev- The device structure.
channel- Output channel [0-10]
mode- Power mode [0-3]
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_read()

int ltc6953_read ( struct ltc6953_dev * dev,
uint8_t reg_addr,
uint8_t * data )

Read device register.

LTC6953 SPI Single byte Read register

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

◆ ltc6953_read_part()

int ltc6953_read_part ( struct ltc6953_dev * dev,
uint8_t * part )

Read LTC6953 Part number.

LTC6953 Get Part Number

Parameters
dev- The device structure.
part- container variable for Part number.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_read_rev()

int ltc6953_read_rev ( struct ltc6953_dev * dev,
uint8_t * rev )

Read LTC6953 Part number.

LTC6953 Get Revision Number

Parameters
dev- The device structure.
rev- container variable for Revision number.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_remove()

int ltc6953_remove ( struct ltc6953_dev * dev)

Free resources allocated for LTC6953.

LTC6953 Resource deallocation

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

◆ ltc6953_reset()

int ltc6953_reset ( struct ltc6953_dev * device)

Software reset of the device.

LTC6953 Power-on reset

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

◆ ltc6953_set_analog_delay()

int ltc6953_set_analog_delay ( struct ltc6953_dev * dev,
uint32_t channel,
uint16_t delay )

Set analog delay/phase of LTC6953 output channel.

LTC6953 Set single channel analog delay

Parameters
dev- The device structure.
channel- Output channel [0-10]
delay- 16-bit word for delay value
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_set_digital_delay()

int ltc6953_set_digital_delay ( struct ltc6953_dev * dev,
uint32_t channel,
uint16_t delay )

Set digital delay/phase of LTC6953 output channel.

LTC6953 Set single channel digital delay

Parameters
dev- The device structure.
channel- Output channel [0-10]
delay- 16-bit word for delay value
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_set_invstat()

int ltc6953_set_invstat ( struct ltc6953_dev * dev,
bool status )

Write LTC6953 INVSTAT bit.

LTC6953 Set INVSTAT bit

Parameters
dev- The device structure.
status- Container for INVSTAT value
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_set_mode()

int ltc6953_set_mode ( struct ltc6953_dev * dev,
uint32_t channel,
uint8_t mode )

Set LTC6953 output channel mode.

LTC6953 Set single channel mode

Parameters
dev- The device structure.
channel- Output channel [0-10]
mode- Output channel mode [0-3]
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_set_output_divider()

int ltc6953_set_output_divider ( struct ltc6953_dev * dev,
uint32_t channel,
uint32_t divider )

Set output divider for LTC6953 output channel.

LTC6953 Set single channel output divider

Parameters
dev- The device structure.
channel- Output channel [0-10]
divider- Divider setting
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_set_x()

int ltc6953_set_x ( struct ltc6953_dev * dev,
uint8_t x )

Set LTC6953 x bitfield status.

LTC6953 Set X

Parameters
dev- The device structure.
x- Value for x bitfield
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_ssrq_mode()

int ltc6953_ssrq_mode ( struct ltc6953_dev * dev,
bool is_en )

Set LTC6953 SSRQ mode.

LTC6953 Set SSRQ

Parameters
dev- The device structure.
is_en- Synchronization setting.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_sync_mode()

int ltc6953_sync_mode ( struct ltc6953_dev * dev,
bool is_en )

Set LTC6953 SRQ mode.

LTC6953 Set SRQ mode

Parameters
dev- The device structure.
is_en- Synchronization setting.
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_update()

int ltc6953_update ( struct ltc6953_dev * dev,
uint8_t reg_addr,
uint8_t mask,
uint8_t data )

Update LTC6953 register.

LTC6953 SPI Single byte Update register

Parameters
dev- The device structure.
reg_addr- The register address.
mask- Mask for specific register bits to be updated.
data- Data read from the device.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ ltc6953_vco_status()

int ltc6953_vco_status ( struct ltc6953_dev * dev,
bool * is_ok )

Read LTC6953 Check VCO Input stats.

LTC6953 Check VCO Input status

Parameters
dev- The device structure.
is_ok- True if VCOOK bit is 1, False if VCOOK bit is 0
Returns
Returns 0 in case of success or negative error code.

◆ ltc6953_write()

int ltc6953_write ( struct ltc6953_dev * dev,
uint8_t reg_addr,
uint16_t data )

Writes data to LTC6953 over SPI.

LTC6953 SPI Single byte Write register

Parameters
dev- The device structure.
reg_addr- The register address.
data- Data value to write.
Returns
Returns 0 in case of success or negative error code otherwise.