Closed fustilio closed 4 years ago
The GPIO35 cannot be pulled up for input only. Someone other than GPIO35 will have to do the pull up. However, the circuit has not been pulled up.
The MPU6886 can be pulled up. Try running IMU.Init(). Please note that this is not a formal method.
First: Make imu and rtc int pin value to 1 Then: Clear AXP192 IRQ status Then: you can read axp192 irq
Thanks for the tips @tanakamasayuki @EeeeBin I'll give them a shot! :-) I'll report here/make a PR if I have any findings.
here is example
#include "M5StickC.h"
static void axp192_disableAllIRQ() {
M5.I2C.writeByte(0x34, 0x40, 0x00);
M5.I2C.writeByte(0x34, 0x41, 0x00);
M5.I2C.writeByte(0x34, 0x42, 0x00);
M5.I2C.writeByte(0x34, 0x43, 0x00);
}
static void axp192_clearAllIRQStatus() {
M5.I2C.writeByte(0x34, 0x44, 0xff);
M5.I2C.writeByte(0x34, 0x45, 0xff);
M5.I2C.writeByte(0x34, 0x46, 0xff);
M5.I2C.writeByte(0x34, 0x47, 0xff);
M5.I2C.writeByte(0x34, 0x4d, 0xff);
}
static void axp192_enableBtnIRQ() {
M5.I2C.writeByte(0x34, 0x42, 0x03);
}
static uint8_t axp192_getBtnIRQStatus() {
uint8_t status;
M5.I2C.readByte(0x34, 0x46, &status);
return status;
}
void setup() {
M5.begin();
Wire.begin(21, 22, 400000);
pinMode(35, INPUT);
axp192_disableAllIRQ();
axp192_clearAllIRQStatus();
axp192_enableBtnIRQ();
}
void loop() {
delay(1000);
Serial.printf("axp192 btn status: %d\r\n", axp192_getBtnIRQStatus());
Serial.printf("pin 35 status: %d\r\n", digitalRead(35));
}
@EeeeBin I've tried out the example, the digitalRead of pin35 is always 0.
I gave the problem another in-depth look. šš
The above segment from datasheet seems to indicate two modes of operation "ę¹å¼ A" and "ę¹å¼ B" . It seems the IRQ pin doesn't do anything in "ę¹å¼ B" which was why I investigated further. The following two segments indicate that if LDO1 and SYSEN are connected, AXP192 is in "ę¹å¼ A" otherwise it is in "ę¹å¼ B".
Combining this with the following excerpt from the schematic. If both LDO1 and SYSEN are connected, then it follows that by default "ę¹å¼ A" but when I read the mode from register 0x01, it seems the mode is in "ę¹å¼ B" which is puzzling.
Below is a snippet of the datasheet regarding reading from register 0x01
For now, I'm checking to see if I'm reading from register 0x01 (that indicates the ę¹å¼) correctly and hoping someone from the team can shed some light/join me in my quest for the interrupt.
@fustilio It need set imu Interrupt active value, default active value is high, so pin35 is always low fixed example in https://github.com/m5stack/M5StickC/commit/df5c99f4cea87e5354d2b63f22eb937ffd90a0f3
Thanks @EeeeBin for the example provided. The GPIO pin seems to be working as expected, I should (hopefully) be able to modify it for my needs. Also I've made a PR https://github.com/m5stack/M5StickC/pull/111 that should fix some issues with that example.
I've been trying to receive interrupts from the AXP192 via GPIO35 to (hopefully) detect the power button press as an interrupt. Button A and B have no issues with this as they are directly hooked up to GPIO37 and GPIO39 respectively, Here are some code snippets:
That's the rough gist of the code I'm working with now. Is there anything else I'm missing?