porting function for IP5306 chip to micropython

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
newb
Posts: 43
Joined: Wed Jan 10, 2018 8:19 pm
Location: Bulgaria

porting function for IP5306 chip to micropython

Post by newb » Tue May 11, 2021 3:25 am

Hello,

I'm struggling waking up a TTGO t-call board from deep sleep when board is powered only on battery. It appears the power chip ip5306 (an i2c device) powers down the whole circuit if the current is minimal, such as the case with deep sleep of the onboard esp32. There seems to be a solution by flipping a bit on an ip5306 register which solves the issue. Can someone help and port this small function into native micropython i2c.write/i2c.writeto_mem function?

User avatar
russ_h
Posts: 88
Joined: Thu Oct 03, 2019 2:26 am
Contact:

Re: porting function for IP5306 chip to micropython

Post by russ_h » Tue May 11, 2021 6:33 am

I wont guarantee it, but something like:

Code: Select all

from machine import Pin, SoftI2C

IP5306_ADDR = const(117)  # 0x75
IP5306_REG_SYS_CTL0 = const(0x00)
BOOST_OUT_BIT = const (0x02)

def setPowerBoostKeepOn(i2c, en):
    data_in = i2c.readfrom_mem(IP5306_ADDR, IP5306_REG_SYS_CTL0, 1)
    data_out = bytes([data_in[0] | BOOST_OUT_BIT if en else data_in[0] & ~BOOST_OUT_BIT])
    i2c.writeto_mem(IP5306_ADDR, IP5306_REG_SYS_CTL0, data_out)

i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
setPowerBoostKeepOn(i2c, True)

Post Reply