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

  • Hi.

    Is this using an EK or your own HW?
    Can you observe the GPIO0 pin state with a scope?

    GPIO0 has a weak pull down by default, you can try disabling this (GPIOPDEN), and enabling the weak pulup (GPIOPUEN).

  • Hi Andy.

    I'm using EK and a custom board as the host. Following your advice, I changed the GPIO0 configuration and it worked. Thank you very much!

    Now the reset is carried out only after pressing SHPHLD and GPIO0, this can be seen in the screenshot -->

    Please tell me whether it is possible to change the tRESETBUT time or is it constant (10 seconds)?

    Thanks.

Related