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
  • On line 17, you are truncating the address (0xB06 -> 0x06), you need to send the bank address as a separate byte.

    Configuration of this has been added upstream, and will be included in the next release:
    https://github.com/aasinclair/zephyr/blob/e4d53dc565ed440430cfc4b4fa3990264cb2d69e/drivers/mfd/mfd_npm1300.c#L178

  • Hi Andy. Thanks.

    Yes, this example worked for me, I was able to disable RESET. But now I can't enable the two-button reset. Could you please tell me, to enable "Two-button reset", do I need to write 0x02 or 0x03 to the LPRESETCONFIG register? I tried writing both values, but it doesn't work. Writing value 0x02 still performs a reset with SHPHLD single key, and writing 0x03 does not perform a reset when SHPHLD and GPIO0 are pressed.

    #include <zephyr/drivers/mfd/npm1300.h>
    
    #define SHIP_BASE 			  0x0BU
    #define SHIP_OFFSET_LPCONFIG  0x06U
    
    static const struct device *pmic = DEVICE_DT_GET(DT_NODELABEL(npm1300_ek_pmic));
    
    int main(void)
    {
        ret = mfd_npm1300_reg_write(pmic, SHIP_BASE, SHIP_OFFSET_LPCONFIG, 0x02);
    	if (ret < 0) {
    		return ret;
    	}
    
    	ret = mfd_npm1300_reg_read(pmic, SHIP_BASE, SHIP_OFFSET_LPCONFIG, &reg);
    	if (ret < 0) {
    		return ret;
    	}
    	LOG_INF("LPCONFIG = %d", reg);
    
    	if(reg == 2){
    		LOG_INF("Two-button reset activated");
    	}
    )

  • Hi.

    You need to write to a task register to apply this configuration change like this:

    We'll update the docs to make it clearer that this is required.

    #define SHIP_OFFSET_CFGSTROBE 0x01
    
    ...
    
    ret = mfd_npm1300_reg_write(pmic, SHIP_BASE, SHIP_OFFSET_CFGSTROBE, 0x01);
    

  • 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.

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