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

Basic example for LTC4284 project. More...

#include <stdlib.h>
#include "basic_example.h"
#include "common_data.h"
#include "ltc4284.h"
#include "no_os_delay.h"
#include "no_os_print_log.h"
#include "no_os_error.h"
#include "no_os_i2c.h"
#include "no_os_util.h"
#include "maxim_i2c.h"
Include dependency graph for basic_example.c:

Macros

#define MAX_TRANSIENT_FAULT_RETRIES   3 /* Allow 3 retries for transient faults */
 
#define MAX_POWER_DISCREPANCY_PCT   10 /* 10% tolerance for power validation */
 
#define MONITORING_TIMEOUT_SEC   3600 /* 1 hour monitoring timeout */
 
#define MAX_CURRENT_LIMIT_MA   60000 /* 60A absolute max for DC2470A */
 

Functions

int basic_example_main (void)
 Production-safe basic example for LTC4284.
 

Detailed Description

Basic example for LTC4284 project.

Author
Carlos Jones Jr carlo.nosp@m.sjr..nosp@m.jones.nosp@m.@ana.nosp@m.log.c.nosp@m.om
Christopher de Guzman chris.nosp@m.toph.nosp@m.er.de.nosp@m.guzm.nosp@m.an@an.nosp@m.alog.nosp@m..com

Copyright 2026(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ MAX_CURRENT_LIMIT_MA

#define MAX_CURRENT_LIMIT_MA   60000 /* 60A absolute max for DC2470A */

◆ MAX_POWER_DISCREPANCY_PCT

#define MAX_POWER_DISCREPANCY_PCT   10 /* 10% tolerance for power validation */

◆ MAX_TRANSIENT_FAULT_RETRIES

#define MAX_TRANSIENT_FAULT_RETRIES   3 /* Allow 3 retries for transient faults */

◆ MONITORING_TIMEOUT_SEC

#define MONITORING_TIMEOUT_SEC   3600 /* 1 hour monitoring timeout */

Function Documentation

◆ basic_example_main()

int basic_example_main ( void )

Production-safe basic example for LTC4284.

basic example main execution.

SAFETY FEATURES DEMONSTRATED:

  1. Current Limit Verification
    • Validates V_ILIM register matches configuration
    • Checks maximum current is within hardware limits
    • Prevents operation with dangerous current limits
  2. Limited Fault Retry
    • Uses 1 retry for transient faults (not unlimited)
    • Prevents thermal cycling on persistent faults
    • Software tracking limits retries to 3 attempts
  3. Selective Fault Clearing
    • Hardware faults (FET_BAD, FET_SHORT) -> latch off permanently
    • Transient faults (OC, UV, OV) -> limited retry only
    • Never auto-retry hardware damage conditions
  4. FET Status Validation
    • Checks SYSTEM_STATUS before reading VOUT
    • Prevents floating ADC pin readings (82V bug)
    • Reports FET state clearly to user
  5. Power Cross-Validation
    • Compares chip power register to V×I calculation
    • Detects configuration errors (dividers, RSENSE)
    • Warns on >10% discrepancy
  6. Timeout Protection
    • 1-hour monitoring limit (not infinite loop)
    • Exits cleanly on I2C errors
    • Suitable for production deployment
  7. Clear Safety Messaging
    • Explains why faults are critical
    • Guides user on required actions
    • Prevents dangerous auto-recovery

IMPORTANT FOR PRODUCTION ADAPTATION:

  • DO NOT increase retry limits without understanding risks
  • DO NOT clear FET_BAD or FET_SHORT faults automatically
  • DO verify current limit before enabling FETs
  • DO implement watchdog timer for production systems
  • DO add energy overflow detection for billing systems
Returns
0 on success, negative error code on failure