Event for charger connected

Hi!

I am running the software on battery and in most of the time it is in low power mode or powered off. However I want to detect the event in software, when someone connects the charger. My original idea was to wake up the system periodically with vm_pwr_scheduled_startup() and then check the vm_pwr_is_charging() function, but it would be better to use some sort of EVENT so no periodic wakeup would be needed. Is there any solution?

Thanks/ Karoly

Since software events are technically just periodically checking and doing stuff, I don’t have any better idea than yours. If the rtos does not handle it as an event, it’s the only sane way at first sight.

És üdv itt, remélem jóféle cucc amit építesz :slight_smile:

I was more looking for the Always On feature of the MTK2502.
Perhaps I would explain the use case to clarify what i need. I am building a battery powered environmental sensor that would be auto-turned off completely in most of the time to save power. It wakes up periodically twice a day, connects to GSM network and transmits some data. Apparently I want to wake up the sensor when I connect the USB port, so I shall not wait for 12 hours to catch a one-minute time window when the module is awake. And I do not want to use the button on the module’s PCB to wake up the system. I am rather looking for something, that is similar to the logic that detects the chargers on regular mobile phones, even if the phone is switched off.

as you can be noticed, there is such thing on RePhone (it activate mass storage mode on USB connect, and, afair, powers on in that mode even on charger.
Although, that code is in bootloader (just like on mobile phones/smartphones). So, AFAIU, you have nothing to do about that in your VXP program (which is just kinda PID1, i.e. started by bootloader and provided by it’s API, but have nothing to do with direct hardware signals and interrupts).
So, that thing you’re able to write (and upload on mass storage device) will not be started on usb connection from powered off state. There would be started bootloader. And it is programmed (or configured. Unfortunately, there is no source code for it :frowning:) to give 1-2 second access to serial prot and then activate MSM in case of connected USB And do not start VXP.