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

Implementation file for the LTC4296 Driver. More...

#include <stdio.h>
#include <errno.h>
#include "ltc4296.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_print_log.h"
#include "no_os_util.h"
Include dependency graph for ltc4296.c:

Functions

int ltc4296_reg_read (struct ltc4296_dev *dev, uint8_t reg, uint16_t *data)
 Register Read.
 
int ltc4296_reg_write (struct ltc4296_dev *dev, uint8_t reg, uint16_t data)
 Register Write.
 
int ltc4296_reset (struct ltc4296_dev *dev)
 Software reset.
 
int ltc4296_get_port_addr (enum ltc4296_port port_no, enum ltc4296_port_reg_offset_e port_offset, uint8_t *port_addr)
 Get port address.
 
int ltc4296_clear_global_faults (struct ltc4296_dev *dev)
 Clear global faults.
 
int ltc4296_clear_ckt_breaker (struct ltc4296_dev *dev)
 Clear circuit break faults.
 
int ltc4296_read_global_faults (struct ltc4296_dev *dev, uint16_t *g_events)
 Read global faults.
 
int ltc4296_unlock (struct ltc4296_dev *dev)
 Device unlock.
 
int ltc4296_is_locked (struct ltc4296_dev *dev, enum ltc4296_state *state)
 Check device state.
 
int ltc4296_read_gadc (struct ltc4296_dev *dev, int *port_voltage_mv)
 Read global ADC.
 
int ltc4296_set_gadc_vin (struct ltc4296_dev *dev)
 Set the global ADC to measure voltage.
 
int ltc4296_is_vin_valid (struct ltc4296_dev *dev, int port_vin_mv, enum ltc4296_board_class ltcboard_class, bool *vin_valid)
 Check if input voltage is valid.
 
int ltc4296_is_vout_valid (struct ltc4296_dev *dev, int port_vout_mv, enum ltc4296_board_class ltcboard_class, bool *vout_valid)
 Check if output voltage is valid.
 
int ltc4296_disable_gadc (struct ltc4296_dev *dev)
 Disable the global ADC.
 
int ltc4296_read_port_events (struct ltc4296_dev *dev, enum ltc4296_port port_no, uint16_t *port_events)
 Read Port Events.
 
int ltc4296_clear_port_events (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Clear Port Events.
 
int ltc4296_read_port_status (struct ltc4296_dev *dev, enum ltc4296_port port_no, uint16_t *port_status)
 Read Port Status.
 
int ltc4296_is_port_disabled (struct ltc4296_dev *dev, enum ltc4296_port port_no, enum ltc4296_port_status *port_chk)
 Check if port is enabled/disabled.
 
int ltc4296_port_disable (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Check if port is disabled.
 
int ltc4296_is_port_deliver_pwr (struct ltc4296_dev *dev, enum ltc4296_port port_no, enum ltc4296_pse_status *pwr_status)
 Check if port delivers power.
 
int ltc4296_is_port_pwr_stable (struct ltc4296_dev *dev, enum ltc4296_port port_no, bool *pwr_status)
 Check if port has stable power.
 
int ltc4296_read_port_adc (struct ltc4296_dev *dev, enum ltc4296_port port_no, int *port_i_out_ma)
 Read port ADC.
 
int ltc4296_port_prebias (struct ltc4296_dev *dev, enum ltc4296_port port_no, enum ltc4296_config mode)
 Stimulate valid wake-up signature for a port.
 
int ltc4296_port_en (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Enable specific port.
 
int ltc4296_port_en_and_classification (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Enable specific port and classify.
 
int ltc4296_set_port_mfvs (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Set port to maintain full voltage signature.
 
int ltc4296_set_port_pwr (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Set port to power mode.
 
int ltc4296_force_port_pwr (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Force port to power mode.
 
int ltc4296_port_pwr_available (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Set port is able to source power.
 
int ltc4296_set_gadc_vout (struct ltc4296_dev *dev, enum ltc4296_port port_no)
 Configure Global ADC to read output voltage.
 
int ltc4296_print_global_faults (uint16_t g_events)
 Print global faults.
 
int ltc4296_print_port_events (enum ltc4296_port port_no, uint16_t port_events)
 Print port events.
 
int ltc4296_chk_global_events (struct ltc4296_dev *dev)
 Check global events.
 
int ltc4296_chk_port_events (struct ltc4296_dev *dev, enum ltc4296_port ltc4296_p)
 Check port events.
 
int ltc4296_init (struct ltc4296_dev **device, struct ltc4296_init_param *init_param)
 Device initialization.
 
int ltc4296_remove (struct ltc4296_dev *dev)
 Free allocated resources.
 

Variables

int ltc4296_spoe_vol_range_mv [12][2]
 
char * ltc4296_class_str [12][25]
 

Detailed Description

Implementation file for the LTC4296 Driver.

Author
Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.com)

Copyright 2024(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ ltc4296_chk_global_events()

int ltc4296_chk_global_events ( struct ltc4296_dev * dev)

Check global events.

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

◆ ltc4296_chk_port_events()

int ltc4296_chk_port_events ( struct ltc4296_dev * dev,
enum ltc4296_port ltc4296_p )

Check port events.

Parameters
dev- The device structure
ltc4296_p- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_clear_ckt_breaker()

int ltc4296_clear_ckt_breaker ( struct ltc4296_dev * dev)

Clear circuit break faults.

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

◆ ltc4296_clear_global_faults()

int ltc4296_clear_global_faults ( struct ltc4296_dev * dev)

Clear global faults.

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

◆ ltc4296_clear_port_events()

int ltc4296_clear_port_events ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Clear Port Events.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_disable_gadc()

int ltc4296_disable_gadc ( struct ltc4296_dev * dev)

Disable the global ADC.

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

◆ ltc4296_force_port_pwr()

int ltc4296_force_port_pwr ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Force port to power mode.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_get_port_addr()

int ltc4296_get_port_addr ( enum ltc4296_port port_no,
enum ltc4296_port_reg_offset_e port_offset,
uint8_t * port_addr )

Get port address.

Parameters
port_no- The port number
port_offset- The port offset
port_addr- The port address
Returns
0 in case of success, negative code otherwise

◆ ltc4296_init()

int ltc4296_init ( struct ltc4296_dev ** device,
struct ltc4296_init_param * init_param )

Device initialization.

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

◆ ltc4296_is_locked()

int ltc4296_is_locked ( struct ltc4296_dev * dev,
enum ltc4296_state * state )

Check device state.

Parameters
dev- The device structure
state- The state of the device
Returns
0 in case of success, negative code otherwise

◆ ltc4296_is_port_deliver_pwr()

int ltc4296_is_port_deliver_pwr ( struct ltc4296_dev * dev,
enum ltc4296_port port_no,
enum ltc4296_pse_status * pwr_status )

Check if port delivers power.

Parameters
dev- The device structure
port_no- The port number
pwr_status- The PSE Status of the port
Returns
0 in case of success, negative code otherwise

◆ ltc4296_is_port_disabled()

int ltc4296_is_port_disabled ( struct ltc4296_dev * dev,
enum ltc4296_port port_no,
enum ltc4296_port_status * port_chk )

Check if port is enabled/disabled.

Parameters
dev- The device structure
port_no- The port number
port_chk- The port is enabled/disabled
Returns
0 in case of success, negative code otherwise

◆ ltc4296_is_port_pwr_stable()

int ltc4296_is_port_pwr_stable ( struct ltc4296_dev * dev,
enum ltc4296_port port_no,
bool * pwr_status )

Check if port has stable power.

Parameters
dev- The device structure
port_no- The port number
pwr_status- The power status
Returns
0 in case of success, negative code otherwise

◆ ltc4296_is_vin_valid()

int ltc4296_is_vin_valid ( struct ltc4296_dev * dev,
int port_vin_mv,
enum ltc4296_board_class ltcboard_class,
bool * vin_valid )

Check if input voltage is valid.

Parameters
dev- The device structure
port_vin_mv- The input voltage in mV
ltcboard_class- The board class
vin_valid- Valid input voltage
Returns
0 in case of success, negative code otherwise

◆ ltc4296_is_vout_valid()

int ltc4296_is_vout_valid ( struct ltc4296_dev * dev,
int port_vout_mv,
enum ltc4296_board_class ltcboard_class,
bool * vout_valid )

Check if output voltage is valid.

Parameters
dev- The device structure
port_vout_mv- The output voltage in mV
ltcboard_class- The board class
vout_valid- Valid input voltage
Returns
0 in case of success, negative code otherwise

◆ ltc4296_port_disable()

int ltc4296_port_disable ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Check if port is disabled.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_port_en()

int ltc4296_port_en ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Enable specific port.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_port_en_and_classification()

int ltc4296_port_en_and_classification ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Enable specific port and classify.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_port_prebias()

int ltc4296_port_prebias ( struct ltc4296_dev * dev,
enum ltc4296_port port_no,
enum ltc4296_config mode )

Stimulate valid wake-up signature for a port.

Parameters
dev- The device structure
port_no- The port number
mode- The device configuration mode
Returns
0 in case of success, negative code otherwise

◆ ltc4296_port_pwr_available()

int ltc4296_port_pwr_available ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Set port is able to source power.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_print_global_faults()

int ltc4296_print_global_faults ( uint16_t g_events)

Print global faults.

Parameters
g_events- The global events data
Returns
0 in case of success, negative code otherwise

◆ ltc4296_print_port_events()

int ltc4296_print_port_events ( enum ltc4296_port port_no,
uint16_t port_events )

Print port events.

Parameters
port_no- The port number
port_events- The port events data
Returns
0 in case of success, negative code otherwise

◆ ltc4296_read_gadc()

int ltc4296_read_gadc ( struct ltc4296_dev * dev,
int * port_voltage_mv )

Read global ADC.

Parameters
dev- The device structure
port_voltage_mv- The port voltage in mV
Returns
0 in case of success, negative code otherwise

◆ ltc4296_read_global_faults()

int ltc4296_read_global_faults ( struct ltc4296_dev * dev,
uint16_t * g_events )

Read global faults.

Parameters
dev- The device structure
g_events- The global events data read
Returns
0 in case of success, negative code otherwise

◆ ltc4296_read_port_adc()

int ltc4296_read_port_adc ( struct ltc4296_dev * dev,
enum ltc4296_port port_no,
int * port_i_out_ma )

Read port ADC.

Parameters
dev- The device structure
port_no- The port number
port_i_out_ma- The port current in mA.
Returns
0 in case of success, negative code otherwise

◆ ltc4296_read_port_events()

int ltc4296_read_port_events ( struct ltc4296_dev * dev,
enum ltc4296_port port_no,
uint16_t * port_events )

Read Port Events.

Parameters
dev- The device structure
port_no- The port number
port_events- The port events read
Returns
0 in case of success, negative code otherwise

◆ ltc4296_read_port_status()

int ltc4296_read_port_status ( struct ltc4296_dev * dev,
enum ltc4296_port port_no,
uint16_t * port_status )

Read Port Status.

Parameters
dev- The device structure
port_no- The port number
port_status- The port status
Returns
0 in case of success, negative code otherwise

◆ ltc4296_reg_read()

int ltc4296_reg_read ( struct ltc4296_dev * dev,
uint8_t reg,
uint16_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

◆ ltc4296_reg_write()

int ltc4296_reg_write ( struct ltc4296_dev * dev,
uint8_t reg,
uint16_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

◆ ltc4296_remove()

int ltc4296_remove ( struct ltc4296_dev * dev)

Free allocated resources.

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

◆ ltc4296_reset()

int ltc4296_reset ( struct ltc4296_dev * dev)

Software reset.

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

◆ ltc4296_set_gadc_vin()

int ltc4296_set_gadc_vin ( struct ltc4296_dev * dev)

Set the global ADC to measure voltage.

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

◆ ltc4296_set_gadc_vout()

int ltc4296_set_gadc_vout ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Configure Global ADC to read output voltage.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_set_port_mfvs()

int ltc4296_set_port_mfvs ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Set port to maintain full voltage signature.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_set_port_pwr()

int ltc4296_set_port_pwr ( struct ltc4296_dev * dev,
enum ltc4296_port port_no )

Set port to power mode.

Parameters
dev- The device structure
port_no- The port number
Returns
0 in case of success, negative code otherwise

◆ ltc4296_unlock()

int ltc4296_unlock ( struct ltc4296_dev * dev)

Device unlock.

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

Variable Documentation

◆ ltc4296_class_str

char* ltc4296_class_str[12][25]
Initial value:
= { {"SPOE CLASS 10"},
{"SPOE CLASS 11"},
{"SPOE CLASS 12"},
{"SPOE CLASS 13"},
{"SPOE CLASS 14"},
{"SPOE CLASS 15"},
{"APL CLASS A"},
{"APL CLASS A"},
{"APL CLASS C"},
{"APL CLASS 3"},
{"BOARD PRODUCTION TEST"},
{"APL CLASS A"}
}

◆ ltc4296_spoe_vol_range_mv

int ltc4296_spoe_vol_range_mv[12][2]
Initial value:
= { {20000, 30000},
{20000, 30000},
{20000, 30000},
{50000, 58000},
{50000, 58000},
{50000, 58000},
{9600, 15000},
{9600, 15000},
{9600, 15000},
{46000, 50000},
{9600, 15000},
{9600, 15000}
}