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"
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
◆ 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 */ |
◆ basic_example_main()
| int basic_example_main |
( |
void | | ) |
|
Production-safe basic example for LTC4284.
basic example main execution.
SAFETY FEATURES DEMONSTRATED:
- Current Limit Verification
- Validates V_ILIM register matches configuration
- Checks maximum current is within hardware limits
- Prevents operation with dangerous current limits
- Limited Fault Retry
- Uses 1 retry for transient faults (not unlimited)
- Prevents thermal cycling on persistent faults
- Software tracking limits retries to 3 attempts
- 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
- FET Status Validation
- Checks SYSTEM_STATUS before reading VOUT
- Prevents floating ADC pin readings (82V bug)
- Reports FET state clearly to user
- Power Cross-Validation
- Compares chip power register to V×I calculation
- Detects configuration errors (dividers, RSENSE)
- Warns on >10% discrepancy
- Timeout Protection
- 1-hour monitoring limit (not infinite loop)
- Exits cleanly on I2C errors
- Suitable for production deployment
- 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