blob: 1234e2b255f01c148bee0e3beae6760265f351a3 [file]
#pragma once
#include "include/common_utility.hpp"
#include <fcntl.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <unistd.h>
namespace max34451
{
/**
* @brief Parses the status byte and returns a string representation.
*
* @param statusByte The status byte to be parsed.
* @return std::string The string representation of the status byte.
*/
std::string parserStatusByte(uint8_t statusByte);
/**
* @brief Parses the status word and returns a string representation.
*
* @param statusWord The status word to be parsed.
* @return std::string The string representation of the status word.
*/
std::string parserStatusWord(uint16_t statusWord);
/**
* @brief Parses the status Vout and returns a string representation.
*
* @param statusVout The status Vout to be parsed.
* @return std::string The string representation of the status Vout.
*/
std::string parserStatusVout(uint8_t statusVout);
/**
* @brief Parses the status Iout and returns a string representation.
*
* @param statusIout The status Iout to be parsed.
* @return std::string The string representation of the status Iout.
*/
std::string parserStatusIout(uint8_t statusIout);
/**
* @brief Parses the status Input and returns a string representation.
*
* @param statusInput The status Input to be parsed.
* @return std::string The string representation of the status Input.
*/
std::string parserStatusInput(uint8_t statusInput);
/**
* @brief Parses the status Temperature and returns a string representation.
*
* @param statusTemperature The status Temperature to be parsed.
* @return std::string The string representation of the status Temperature.
*/
std::string parserStatusTemperature(uint8_t statusTemperature);
/**
* @brief Parses the status Cml and returns a string representation.
*
* @param statusCml The status Cml to be parsed.
* @return std::string The string representation of the status Cml.
*/
std::string parserStatusCml(uint8_t statusCml);
/**
* @brief Loads the specified page on the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param page The page number.
*/
void loadPage(uint8_t bus, uint8_t devAddr, uint8_t page);
/**
* @brief Retrieves the status byte from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint8_t The status byte.
*/
uint8_t getStatusByte(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the status word from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The status word.
*/
uint16_t getStatusWord(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the status Vout from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint8_t The status Vout.
*/
uint8_t getStatusVout(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the status Iout from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint8_t The status Iout.
*/
uint8_t getStatusIout(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the status Input from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint8_t The status Input.
*/
uint8_t getStatusInput(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the status Temperature from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint8_t The status Temperature.
*/
uint8_t getStatusTemperature(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the status Cml from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint8_t The status Cml.
*/
uint8_t getStatusCml(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the On/Off configuration from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint8_t The On/Off configuration.
*/
uint8_t getOnOffConfig(uint8_t bus, uint8_t devAddr);
/**
* @brief Sets the write protect value on the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param value The write protect value.
*/
void setWriteProtect(uint8_t bus, uint8_t devAddr, uint8_t value);
/**
* @brief Reads the Vin value from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The Vin value.
*/
uint16_t readVin(uint8_t bus, uint8_t devAddr);
/**
* @brief Reads the Iin value from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The Iin value.
*/
uint16_t readIin(uint8_t bus, uint8_t devAddr);
/**
* @brief Reads the Vout value from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The Vout value.
*/
uint16_t readVout(uint8_t bus, uint8_t devAddr);
/**
* @brief Reads the Iout value from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The Iout value.
*/
uint16_t readIout(uint8_t bus, uint8_t devAddr);
/**
* @brief Reads the Temperature value from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The Temperature value.
*/
uint16_t readTemperature(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the Vout maximum value from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The Vout maximum value.
*/
uint16_t getVoutMax(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the Vout overvoltage fault limit from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The Vout overvoltage fault limit.
*/
uint16_t getVoutOvFaultLimit(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the Iout overcurrent fault limit from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The Iout overcurrent fault limit.
*/
uint16_t getIoutOcFaultLimit(uint8_t bus, uint8_t devAddr);
/**
* @brief Sets the Iout overcurrent fault limit on the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param value The Iout overcurrent fault limit.
*/
void setIoutOcFaultLimit(uint8_t bus, uint8_t devAddr, uint16_t value);
/**
* @brief Retrieves the overtemperature fault limit from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint16_t The overtemperature fault limit.
*/
uint16_t getOtFaultLimit(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the PMBus revision from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @return uint8_t The PMBus revision.
*/
uint8_t getPmbusRevision(uint8_t bus, uint8_t devAddr);
/**
* @brief Retrieves the manufacturer ID from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param returnByte The return byte.
* @return std::string The manufacturer ID.
*/
std::string getMfrId(uint8_t bus, uint8_t devAddr, uint8_t returnByte);
/**
* @brief Retrieves the manufacturer model from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param returnByte The return byte.
* @return std::string The manufacturer model.
*/
std::string getMfrModel(uint8_t bus, uint8_t devAddr, uint8_t returnByte);
/**
* @brief Retrieves the manufacturer revision from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param returnByte The return byte.
* @return std::string The manufacturer revision.
*/
std::string getMfrRevision(uint8_t bus, uint8_t devAddr, uint8_t returnByte);
/**
* @brief Retrieves the IC device ID from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param returnByte The return byte.
* @return std::string The IC device ID.
*/
std::string getIcDeviceId(uint8_t bus, uint8_t devAddr, uint8_t returnByte);
/**
* @brief Retrieves the IC device revision from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param returnByte The return byte.
* @return std::string The IC device revision.
*/
std::string getIcDeviceRev(uint8_t bus, uint8_t devAddr, uint8_t returnByte);
/**
* @brief Retrieves the manufacturer date from the device.
*
* @param bus The bus number.
* @param devAddr The device address.
* @param returnByte The return byte.
* @return std::string The manufacturer date.
*/
std::string getMfrDate(uint8_t bus, uint8_t devAddr, uint8_t returnByte);
/**
* @brief Transfers a linear 11-bit value to a double.
*
* @param word The linear 11-bit value.
* @return double The transferred value.
*/
double transferLinear11(uint16_t word);
/**
* @brief Transfers a linear 16-bit value to a double.
*
* @param Y The linear 16-bit value.
* @return double The transferred value.
*/
double transferLinear16(uint16_t y);
/**
* @brief Transfers a direct data format value to a double.
*
* @param m The m value.
* @param Y The Y value.
* @param R The R value.
* @param b The b value.
* @return double The transferred value.
*/
double transferDirectDataFormat(int m, int y, int r, int b);
/**
* @brief Transfers a direct value to a double.
*
* @param Y The Y value.
* @param factor The factor value.
* @return double The transferred value.
*/
double transferDirectValue(int y, double factor);
/**
* @brief Transfers an ASCII array to a string.
*
* @param asciiArray The ASCII array.
* @return std::string The transferred string.
*/
std::string transferAscii(const std::vector<uint8_t>& asciiArray);
/**
* @brief Binds an I2C device with the specified name, bus number, and chip
* address.
*
* @param name The name of the I2C device.
* @param i2cbus The bus number.
* @param chipaddress The chip address.
*/
void bindI2cDevice(const std::string& name, int i2cbus, int chipaddress);
/**
* @brief Unbinds an I2C device with the specified bus number and chip address.
*
* @param i2cbus The bus number.
* @param chipaddress The chip address.
*/
void unbindI2cDevice(int i2cbus, int chipaddress);
} // namespace max34451