![]() |
no-OS
|
Implementation of LTC4284 Driver. More...
#include <stdlib.h>#include <string.h>#include <errno.h>#include "ltc4284.h"#include "no_os_delay.h"#include "no_os_units.h"#include "no_os_alloc.h"#include "no_os_print_log.h"#include "no_os_util.h"Functions | |
| int | ltc4284_read_byte (struct ltc4284_dev *dev, uint8_t reg, uint8_t *val) |
| Read a single byte from LTC4284 register. | |
| int | ltc4284_write_byte (struct ltc4284_dev *dev, uint8_t cmd, uint8_t val) |
| Write a single byte to LTC4284 register. | |
| int | ltc4284_read_word (struct ltc4284_dev *dev, uint8_t reg, uint16_t *val) |
| Read a 16-bit word from LTC4284 (big-endian) | |
| int | ltc4284_write_word (struct ltc4284_dev *dev, uint8_t reg, uint16_t val) |
| Write a 16-bit word to LTC4284 (big-endian) | |
| int | ltc4284_update_bits (struct ltc4284_dev *dev, uint8_t reg, uint8_t mask, uint8_t val) |
| Update register bits with mask. | |
| int | ltc4284_init (struct ltc4284_dev **device, const struct ltc4284_init_param *init_param) |
| Initialize the LTC4284 device. | |
| int | ltc4284_remove (struct ltc4284_dev *dev) |
| Remove the LTC4284 device and free resources. | |
| int | ltc4284_read_vin (struct ltc4284_dev *dev, uint32_t *vin_mv) |
| Read input voltage (VPWR) | |
| int | ltc4284_read_iin (struct ltc4284_dev *dev, uint32_t *iin_ma) |
| Read input current (SENSE) | |
| int | ltc4284_read_vds (struct ltc4284_dev *dev, uint32_t *vds_mv) |
| Read drain-to-source voltage across the external MOSFET. | |
| int | ltc4284_read_vout (struct ltc4284_dev *dev, uint32_t *vout_mv) |
| Read output bus voltage delivered to the load. | |
| int | ltc4284_read_power (struct ltc4284_dev *dev, uint32_t *power_mw) |
| Read power consumption. | |
| int | ltc4284_read_energy (struct ltc4284_dev *dev, uint64_t *energy_code) |
| Read cumulative energy accumulator. | |
| int | ltc4284_enable_fet (struct ltc4284_dev *dev, bool enable) |
| Enable or disable FET drivers. | |
| int | ltc4284_clear_faults (struct ltc4284_dev *dev) |
| Clear all fault conditions. | |
| int | ltc4284_read_status (struct ltc4284_dev *dev, uint8_t *status) |
| Read system status register. | |
| int | ltc4284_get_fault (struct ltc4284_dev *dev, uint8_t *faults) |
| Get current fault conditions. | |
| int | ltc4284_arm_fault_log (struct ltc4284_dev *dev) |
| Arm the LTC4284 fault-log capture into EEPROM. | |
| int | ltc4284_restore_from_eeprom (struct ltc4284_dev *dev) |
| Restore configuration from EEPROM. | |
| int | ltc4284_set_ilim_mv (struct ltc4284_dev *dev, uint8_t mv) |
| Set steady-state V_ILIM in millivolts. | |
| int | ltc4284_set_foldback (struct ltc4284_dev *dev, uint8_t code) |
| Set current-limit foldback factor. | |
| int | ltc4284_set_oc_retry (struct ltc4284_dev *dev, uint8_t code) |
| Set overcurrent retry policy. | |
Implementation of LTC4284 Driver.
Copyright 2026(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| int ltc4284_arm_fault_log | ( | struct ltc4284_dev * | dev | ) |
Arm the LTC4284 fault-log capture into EEPROM.
| dev | - Device descriptor |
Sets FAULT_LOG_ENABLE (bit 7) in FAULT_LOG_CONTROL (0x90). The chip captures the fault + ADC snapshot into EEPROM on the next fault event; poll FAULT_LOG_DONE (bit 4) to detect completion. The EEPROM write itself is signalled by EEPROM_BUSY in SYSTEM_STATUS.
| int ltc4284_clear_faults | ( | struct ltc4284_dev * | dev | ) |
Clear all fault conditions.
| dev | - Device descriptor |
| int ltc4284_enable_fet | ( | struct ltc4284_dev * | dev, |
| bool | enable ) |
Enable or disable FET drivers.
| dev | - Device descriptor |
| enable | - True to enable, false to disable |
| int ltc4284_get_fault | ( | struct ltc4284_dev * | dev, |
| uint8_t * | faults ) |
Get current fault conditions.
| dev | - Device descriptor |
| faults | - Pointer to store fault byte |
| int ltc4284_init | ( | struct ltc4284_dev ** | device, |
| const struct ltc4284_init_param * | init_param ) |
Initialize the LTC4284 device.
| device | - Pointer to device descriptor pointer |
| init_param | - Initialization parameters |
| int ltc4284_read_byte | ( | struct ltc4284_dev * | dev, |
| uint8_t | reg, | ||
| uint8_t * | val ) |
Read a single byte from LTC4284 register.
| dev | - Device descriptor |
| reg | - Register address |
| val | - Pointer to store read value |
| int ltc4284_read_energy | ( | struct ltc4284_dev * | dev, |
| uint64_t * | energy_code ) |
Read cumulative energy accumulator.
| dev | - Device descriptor |
| energy_code | - Pointer to store the raw 48-bit accumulator value |
Returns the raw 48-bit ENERGY accumulator code from registers 0x7A..0x7F (datasheet p.51), not a physical energy in millijoules. The physical conversion requires the ADC conversion time (t_conv, datasheet Table 12) and the sense-resistor value; callers can observe accumulation over time but must apply the conversion themselves.
| int ltc4284_read_iin | ( | struct ltc4284_dev * | dev, |
| uint32_t * | iin_ma ) |
Read input current (SENSE)
| dev | - Device descriptor |
| iin_ma | - Pointer to store current in milliamps |
| int ltc4284_read_power | ( | struct ltc4284_dev * | dev, |
| uint32_t * | power_mw ) |
Read power consumption.
| dev | - Device descriptor |
| power_mw | - Pointer to store power in milliwatts |
| int ltc4284_read_status | ( | struct ltc4284_dev * | dev, |
| uint8_t * | status ) |
Read system status register.
| dev | - Device descriptor |
| status | - Pointer to store status byte |
| int ltc4284_read_vds | ( | struct ltc4284_dev * | dev, |
| uint32_t * | vds_mv ) |
Read drain-to-source voltage across the external MOSFET.
Reads the DRAIN ADC register (0x65). The value is V_DRAIN referenced to VEE (the chip's ground = supply-side -48V), which equals the V_DS across the external hot-swap MOSFET. Under normal conduction V_DS ~= I * Rds_on (a few mV to tens of mV). When the FET is off, V_DS rises to approximately VIN, and inductive transients can push it further and peg the ADC at full-scale (drain_divider * 2.048 V, e.g. 81.92 V for a 40:1 divider).
| dev | - Device descriptor |
| vds_mv | - Pointer to store V_DS in millivolts |
| int ltc4284_read_vin | ( | struct ltc4284_dev * | dev, |
| uint32_t * | vin_mv ) |
Read input voltage (VPWR)
| dev | - Device descriptor |
| vin_mv | - Pointer to store voltage in millivolts |
| int ltc4284_read_vout | ( | struct ltc4284_dev * | dev, |
| uint32_t * | vout_mv ) |
Read output bus voltage delivered to the load.
Computed as VIN - V_DS. This is the actual bus voltage the load sees, not a raw ADC register. When the FET is conducting, VOUT ~= VIN. When the FET is off, VOUT collapses toward 0 (the load is disconnected).
| dev | - Device descriptor |
| vout_mv | - Pointer to store output voltage in millivolts |
| int ltc4284_read_word | ( | struct ltc4284_dev * | dev, |
| uint8_t | reg, | ||
| uint16_t * | val ) |
Read a 16-bit word from LTC4284 (big-endian)
| dev | - Device descriptor |
| reg | - Register address |
| val | - Pointer to store read value |
| int ltc4284_remove | ( | struct ltc4284_dev * | dev | ) |
Remove the LTC4284 device and free resources.
| dev | - Device descriptor |
| int ltc4284_restore_from_eeprom | ( | struct ltc4284_dev * | dev | ) |
Restore configuration from EEPROM.
| dev | - Device descriptor |
| int ltc4284_set_foldback | ( | struct ltc4284_dev * | dev, |
| uint8_t | code ) |
Set current-limit foldback factor.
| dev | - Device descriptor |
| code | - Foldback code (0: 100%, 1: 50%, 2: 20%, 3: 10%) |
| int ltc4284_set_ilim_mv | ( | struct ltc4284_dev * | dev, |
| uint8_t | mv ) |
Set steady-state V_ILIM in millivolts.
| dev | - Device descriptor |
| mv | - Desired V_ILIM in millivolts (15..30 mV) |
| int ltc4284_set_oc_retry | ( | struct ltc4284_dev * | dev, |
| uint8_t | code ) |
Set overcurrent retry policy.
| dev | - Device descriptor |
| code | - Retry code (0: latch-off, 1: 1 retry, 2: 7 retries, 3: unlimited) |
| int ltc4284_update_bits | ( | struct ltc4284_dev * | dev, |
| uint8_t | reg, | ||
| uint8_t | mask, | ||
| uint8_t | val ) |
Update register bits with mask.
| dev | - Device descriptor |
| reg | - Register address |
| mask | - Bit mask |
| val | - New value for masked bits |
| int ltc4284_write_byte | ( | struct ltc4284_dev * | dev, |
| uint8_t | cmd, | ||
| uint8_t | val ) |
Write a single byte to LTC4284 register.
| dev | - Device descriptor |
| cmd | - Command byte which contains register address |
| val | - Value to write |
| int ltc4284_write_word | ( | struct ltc4284_dev * | dev, |
| uint8_t | reg, | ||
| uint16_t | val ) |
Write a 16-bit word to LTC4284 (big-endian)
| dev | - Device descriptor |
| reg | - Register address |
| val | - Value to write |