OpenBIC
OpenSource Bridge-IC
mp2985.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <logging/log.h>
#include "sensor.h"
#include "hal_i2c.h"
#include "pmbus.h"
#include "mp2985.h"
#include "util_pmbus.h"
Include dependency graph for mp2985.c:

Classes

struct  mp2985_data
 
struct  mp2985_config
 

Macros

#define ENABLE_LOW_POWER_MODE_BIT   BIT(0)
 
#define ENABLE_PROGRAM_MODE_BIT   BIT(2)
 
#define PASSWORD_MATCH_BIT   BIT(3)
 
#define MFR_TEST_MODE_EN_BIT   BIT(7)
 
#define MP2985_VENDOR_ID   0x4D5053
 
#define MP2985_MODULE_ID   0x0185
 
#define CR_ASCII   0x0D
 
#define TAB_ASCII   0x09
 
#define NEW_LINE_ASCII   0x0A
 
#define MP2985_DATA_END_TAG   "END"
 
#define MP2985_PRODUCT_ID_TAG   "Product ID: "
 
#define MP2985_4_DIGITAL_TAG   "4-digital Code: "
 
#define MP2985_CRC_CHECK_START_TAG   "CRC_CHECK_START"
 
#define MP2985_PRODUCT_ID   "MP2985H"
 

Enumerations

enum  MP2985_REG {
  MP2985_MFR_DEBUG = 0x04 , MP2985_PAGE_PLUS_WRITE = 0x05 , MP2985_STORE_USER_CODE = 0x15 , MP2985_MFR_VR_CONFIG2 = 0x35 ,
  MP2985_PAGE3_DISABLE_STORE_FAULT = 0x51 , MP2985_MFR_ID = 0x99 , MP2985_MFR_MODULE = 0x9A , MP2985_MFR_REVISION = 0x9B ,
  MP2985_GET_USER_DATA = 0xB8 , MP2985_USER_PWD_CHECK_CMD = 0xC7 , MP2985_MFR_USER_PWD = 0xC9
}
 
enum  MP2985_CONFIG_FILE_COLUMN {
  ATE_CONF_ID , ATE_PAGE_NUM , ATE_REG_ADDR_HEX , ATE_REG_ADDR_DEC ,
  ATE_REG_NAME , ATE_REG_DATA_HEX , ATE_REG_DATA_DEC , ATE_WRITE_TYPE ,
  ATE_COLUMN_MAX
}
 
enum  ENTER_PAGE3_CONTROL_OPTION { DISABLE_ENTER_PAGE3 = false , ENABLE_ENTER_PAGE = true }
 

Functions

 LOG_MODULE_REGISTER (mp2985)
 
int mp2985_line_split (char **str, uint8_t *image_buf, uint32_t start_index, uint32_t end_index, int max_size)
 
int mp2985_parse_file (struct mp2985_config *config, uint8_t *image_buf, uint32_t image_size)
 
int program_mp2985 (uint8_t bus, uint8_t addr, struct mp2985_config *config)
 
bool mp2985_fwupdate (uint8_t bus, uint8_t addr, uint8_t *img_buff, uint32_t img_size)
 
int mp2985_set_power_regular_mode (uint8_t bus, uint8_t addr)
 
bool mp2985_get_checksum (uint8_t bus, uint8_t addr, uint8_t *checksum)
 
uint8_t mp2985_read (sensor_cfg *cfg, int *reading)
 
uint8_t mp2985_init (sensor_cfg *cfg)
 

Macro Definition Documentation

◆ CR_ASCII

#define CR_ASCII   0x0D

◆ ENABLE_LOW_POWER_MODE_BIT

#define ENABLE_LOW_POWER_MODE_BIT   BIT(0)

◆ ENABLE_PROGRAM_MODE_BIT

#define ENABLE_PROGRAM_MODE_BIT   BIT(2)

◆ MFR_TEST_MODE_EN_BIT

#define MFR_TEST_MODE_EN_BIT   BIT(7)

◆ MP2985_4_DIGITAL_TAG

#define MP2985_4_DIGITAL_TAG   "4-digital Code: "

◆ MP2985_CRC_CHECK_START_TAG

#define MP2985_CRC_CHECK_START_TAG   "CRC_CHECK_START"

◆ MP2985_DATA_END_TAG

#define MP2985_DATA_END_TAG   "END"

◆ MP2985_MODULE_ID

#define MP2985_MODULE_ID   0x0185

◆ MP2985_PRODUCT_ID

#define MP2985_PRODUCT_ID   "MP2985H"

◆ MP2985_PRODUCT_ID_TAG

#define MP2985_PRODUCT_ID_TAG   "Product ID: "

◆ MP2985_VENDOR_ID

#define MP2985_VENDOR_ID   0x4D5053

◆ NEW_LINE_ASCII

#define NEW_LINE_ASCII   0x0A

◆ PASSWORD_MATCH_BIT

#define PASSWORD_MATCH_BIT   BIT(3)

◆ TAB_ASCII

#define TAB_ASCII   0x09

Enumeration Type Documentation

◆ ENTER_PAGE3_CONTROL_OPTION

Enumerator
DISABLE_ENTER_PAGE3 
ENABLE_ENTER_PAGE 

◆ MP2985_CONFIG_FILE_COLUMN

Enumerator
ATE_CONF_ID 
ATE_PAGE_NUM 
ATE_REG_ADDR_HEX 
ATE_REG_ADDR_DEC 
ATE_REG_NAME 
ATE_REG_DATA_HEX 
ATE_REG_DATA_DEC 
ATE_WRITE_TYPE 
ATE_COLUMN_MAX 

◆ MP2985_REG

enum MP2985_REG
Enumerator
MP2985_MFR_DEBUG 
MP2985_PAGE_PLUS_WRITE 
MP2985_STORE_USER_CODE 
MP2985_MFR_VR_CONFIG2 
MP2985_PAGE3_DISABLE_STORE_FAULT 
MP2985_MFR_ID 
MP2985_MFR_MODULE 
MP2985_MFR_REVISION 
MP2985_GET_USER_DATA 
MP2985_USER_PWD_CHECK_CMD 
MP2985_MFR_USER_PWD 

Function Documentation

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( mp2985  )

◆ mp2985_fwupdate()

bool mp2985_fwupdate ( uint8_t  bus,
uint8_t  addr,
uint8_t *  img_buff,
uint32_t  img_size 
)
Here is the call graph for this function:

◆ mp2985_get_checksum()

bool mp2985_get_checksum ( uint8_t  bus,
uint8_t  addr,
uint8_t *  checksum 
)
Here is the call graph for this function:

◆ mp2985_init()

uint8_t mp2985_init ( sensor_cfg cfg)
Here is the call graph for this function:

◆ mp2985_line_split()

int mp2985_line_split ( char **  str,
uint8_t *  image_buf,
uint32_t  start_index,
uint32_t  end_index,
int  max_size 
)
Here is the call graph for this function:

◆ mp2985_parse_file()

int mp2985_parse_file ( struct mp2985_config config,
uint8_t *  image_buf,
uint32_t  image_size 
)
Here is the call graph for this function:

◆ mp2985_read()

uint8_t mp2985_read ( sensor_cfg cfg,
int *  reading 
)
Here is the call graph for this function:

◆ mp2985_set_power_regular_mode()

int mp2985_set_power_regular_mode ( uint8_t  bus,
uint8_t  addr 
)
Here is the call graph for this function:

◆ program_mp2985()

int program_mp2985 ( uint8_t  bus,
uint8_t  addr,
struct mp2985_config config 
)