Hi!. Is there any example on the work of comparator and interrupts?
I'm trying to write a firmware for Xiaomi Door Sensor (see foto).
The bottom contact goes to Gnd.
The top connect to DIO16, DIO17 from resistor.
If I understand correctly:
#define CONNECT_DEVICE_DIO ((1 << (16))|(1 << (17)))
#Enable Input
vAHI_DioSetDirection(CONNECT_DEVICE_DIO, 0 );
#Disable PullUp
vAHI_DioSetPullup(0,CONNECT_DEVICE_DIO);
vAHI_ApConfigure(E_AHI_AP_REGULATOR_ENABLE,
E_AHI_AP_INT_DISABLE,
E_AHI_AP_SAMPLE_2,
E_AHI_AP_CLOCKDIV_500KHZ,
E_AHI_AP_INTREF);
while (!bAHI_APRegulatorEnabled()); /* spin on reg not enabled */
vAHI_ComparatorEnable(E_AHI_AP_COMPARATOR_1, E_AHI_COMP_HYSTERESIS_40MV, E_AHI_COMP_SEL_EXT_INVERSE);
vAHI_ComparatorLowPowerMode(TRUE);
vAHI_ComparatorIntEnable(E_AHI_AP_COMPARATOR_1,TRUE,FALSE);
But everything works somehow wrong, it works on my hand side by side, etc.
Please help or at least push the right thought.