more config init stuff

This commit is contained in:
macphyter 2024-01-28 23:22:35 -07:00 committed by Georges Palauqui
parent b409e8c240
commit a20e2ad87b
No known key found for this signature in database
GPG Key ID: 1E45F544CE4D04A5
3 changed files with 29 additions and 2 deletions

View File

@ -27,6 +27,8 @@ static uint8_t MFR_ID[] = {'B', 'A', 'X'};
static uint8_t MFR_MODEL[] = {'H', 'E', 'X'};
static uint8_t MFR_REVISION[] = {0x00, 0x00, 0x01};
static uint8_t COMPENSATION_CONFIG[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
/**
* @brief SMBus read byte
*/
@ -295,6 +297,7 @@ int TPS546_init(void)
int iout;
uint8_t mfr_revision[3];
int temp;
uint8_t comp_config[5];
ESP_LOGI(TAG, "Initializing the core voltage regulator");
@ -321,6 +324,8 @@ int TPS546_init(void)
ESP_LOGI(TAG, "Config version mismatch, writing new config values");
//TPS546_write_entire_config();
// TODO write new config version here
}
/* Show temperature */
@ -367,6 +372,11 @@ int TPS546_init(void)
ESP_LOGI(TAG, "TOFF_FALL: %d", temp);
ESP_LOGI(TAG, "--------------------------------------");
// Read the compensation config registers
smb_read_block(PMBUS_COMPENSATION_CONFIG, comp_config, 5);
ESP_LOGI(TAG, "COMPENSATION CONFIG");
ESP_LOGI(TAG, "%02x %02x %02x %02x %02x", comp_config[0], comp_config[1],
comp_config[2], comp_config[3], comp_config[4]);
return 0;
}
@ -440,6 +450,19 @@ void TPS546_write_entire_config(void)
smb_write_word(PMBUS_TOFF_DELAY, int_2_slinear11(TPS546_INIT_TOFF_DELAY));
smb_write_word(PMBUS_TOFF_FALL, int_2_slinear11(TPS546_INIT_TOFF_FALL));
/* Stack/sync config */
smb_write_word(PMBUS_STACK_CONFIG, INIT_STACK_CONFIG);
smb_write_word(PMBUS_SYNC_CONFIG, INIT_SYNC_CONFIG);
/* Compensation config */
smb_write_block(PMBUS_COMPENSATION_CONFIG, COMPENSATION_CONFIG, 5);
/* Slave address */
smb_write_byte(PMBUS_SLAVE_ADDRESS, TPS546_I2CADDR);
/* configure the bootup behavior regarding pin detect values vs NVM values */
smb_write_word(PMBUS_PIN_DETECT_OVERRIDE, INIT_PIN_DETECT_OVERRIDE);
/* store configuration in NVM */
smb_write_byte(PMBUS_STORE_USER_ALL, 0xFF);

View File

@ -47,6 +47,10 @@
#define TPS546_INIT_TOFF_DELAY 0
#define TPS546_INIT_TOFF_FALL 0
#define INIT_STACK_CONFIG 0x0000
#define INIT_SYNC_CONFIG 0x0010
#define INIT_PIN_DETECT_OVERRIDE 0x0000
/*-------------------------*/
/* PMBUS_ON_OFF_CONFIG initialization values */

View File

@ -64,8 +64,8 @@
#define PMBUS_MFR_SERIAL 0x9E
#define PMBUS_IC_DEVICE_ID 0xAD
#define PMBUS_IC_DEVICE_REV 0xAE
#define PMBUS_USER_DATA_01 0xB1
#define PMBUS_USER_DATA_05 0xB5
#define PMBUS_COMPENSATION_CONFIG 0xB1
#define PMBUS_POWER_STAGE_CONFIG 0xB5
/* Manufacturer Specific PMBUS commands used by the TPS546D24A */
#define PMBUS_TELEMETRY_CFG 0xD0