danny hack
Diff: Lis2dh12.cpp
- Revision:
- 2:1fa08c7a2a3c
- Parent:
- 1:d89f4b12116b
- Child:
- 3:07ddb07f8b7f
--- a/Lis2dh12.cpp Fri Jan 05 13:32:08 2018 +0000 +++ b/Lis2dh12.cpp Fri Jan 12 16:06:45 2018 +0000 @@ -120,5 +120,44 @@ return 0; } +/* Interrupt activity 1 driven to INT1 pad */ +// TODO: Napraviti tako da postoji samo jedna metoda int1Setup koja prima gro +// parametara: THS, DUR, Latch... +uint8_t Lis2dh12::int1Setup(uint8_t setup){ + char data = setup; + i2c.writeToReg((char)CTRL_REG3, &data, 1); + return 0; +} + +uint8_t Lis2dh12::int1Latch(uint8_t enable){ + char ctrl5Copy; + i2c.readFromReg((char)CTRL_REG5, &ctrl5Copy, 1); + ctrl5Copy |= enable; + i2c.writeToReg((char)CTRL_REG5, &ctrl5Copy, 1); + return 0; +} + +uint8_t Lis2dh12::int1Duration(uint8_t duration){ + char copy = duration; + i2c.writeToReg((char)INT1_DURATION, ©, 1); + return 0; +} + +uint8_t Lis2dh12::int1Threshold(uint8_t threshold){ + char copy = threshold; + i2c.writeToReg((char)INT1_THS, ©, 1); + return 0; +} + +uint8_t Lis2dh12::int1Config(uint8_t config){ + char copy = config; + i2c.writeToReg((char)INT1_CFG, ©, 1); + return 0; +} + +void Lis2dh12::clearIntFlag(){ + char data; + i2c.readFromReg((char)INT1_SRC, (char*)&data, 1); +} \ No newline at end of file