nPM1300 Long Press Reset disable

Hi.

I want to disable the restart function when the SHPHLD button is pressed for a long time (10 seconds).

If I understood correctly from the datasheet, the LPRESETCONFIG register (offset - 0x6) is responsible for this. To disable reset, write 0x01 to this register, but that doesn't work for me.  

Program code:

#include <zephyr/drivers/i2c.h>

#define SHIP                     0xB00       // Base address
#define LPRESETCONFIG            0x6         // Long press RESET (nPM1300) config register

static const struct i2c_dt_spec dev_i2c = I2C_DT_SPEC_GET(DT_NODELABEL(npm1300_ek_pmic));

int main(void)
{
	int ret;
	
	if (!device_is_ready(dev_i2c.bus)) {
	printk("I2C bus %s is not ready!\n\r",dev_i2c.bus->name);
	return -1;
	}
	
	uint8_t long_press_reset_config[2] = {SHIP + LPRESETCONFIG, 0x01}; // LP RESET (10s) disabled
	ret = i2c_write_dt(&dev_i2c, long_press_reset_config, sizeof(long_press_reset_config));
	if(ret != 0){
		printk("Failed to write to I2C device address %x at Reg. %x \n", dev_i2c.addr, long_press_reset_config[0]);
		return -1;
	}
	
	printk("Reset button disabled");
	
}

Please help me determine where I am making a mistake.


Thank you.

Parents Reply
  • I'm trying to follow your advice, but I'm getting exactly the same result. 

    #include <zephyr/drivers/mfd/npm1300.h>
    
    #define SHIP_BASE 			  0x0BU
    #define SHIP_OFFSET_LPCONFIG  0x06U
    #define SHIP_OFFSET_CFGSTROBE 0x01U
    
    static const struct device *pmic = DEVICE_DT_GET(DT_NODELABEL(npm1300_ek_pmic));
    
    int main(void)
    {
    	int ret;
    	uint8_t reg;
    	
    	ret = mfd_npm1300_reg_write(pmic, SHIP_BASE, SHIP_OFFSET_LPCONFIG, 0x02);
    	if (ret < 0) {
    		return ret;
    	}
    	
    	ret = mfd_npm1300_reg_write(pmic, SHIP_BASE, SHIP_OFFSET_CFGSTROBE, 0x01);
    	if (ret < 0) {
    		return ret;
    	}
    	
    }

    Unfortunately, the TASKSHPHLDCFGSTROBE register is write-only and I cannot verify that the value 0x01 has been successfully written to it.

Children
Related