kriswiner/BMA280

_intPin1 and _intPin2

vvirag opened this issue · 15 comments

The BMA280 class has a _intPin1 and _intPin2 member, which are set in the constructor.
However, I don't see them being read out afterwards. What are they used for then?

(I'm trying to port this code to another platform, and I'm not sure how to set up the interrupts to set the newData and newTap flags -- since I don't understand which pins should these interrupts coupled to.)

Thanks for any help!

Yes, that's what I thought, thanks :)

I'm still puzzled though where the 4 and 1 come from regarding these lines:
#define intPin1 4 #define intPin2 1

-- since later the newData and newTap flags are getting set based on the interrupts when these 2 pins are rising.

Ah, wait, you're saying these are external GPIOs on the Arduino that you use when you actually want to read out (from the application code) the tap/move states of the accelerometer?

I'm sorry maybe I still don't get it right. This means you are polling accelerometer data from the MCU, right? Meaning that something - that is unrelated to the accelerometer - will pull up the pin1 (=1 on the MCU) and pin2 (=4 on the MCU) whenever you decide you want to read out the accelerometer status.

Or I'm completely wrong..? :)

I have some clue about interrupts, and I'm not even working on Arduino. And yes, it seemed strange, but I just still don't understand how exactly are the

BMA280 interrupts configured.

As far as I can tell that configuration is happening in the BMA280::initBMA280 function. But there are lots of magic (hexa)numbers there, and even though the BMA280 documentation is in front of me, I haven't been able to completely understand it.

And this goes back to my original question on where the 1 and 4 are coming from (as defined in the .ino). And how those values are reflected in that initBMA280 method.

I appreciate your answers, really. And I agree with everything you just said, that's all clear.

I guess I just don't see where (which line in your code) the MCU GPIO1 and MCU GPIO4 gets connected to the INT1 and INT2 interrupts of the BMA280.

Is my question more clear this way?

Oh my, it just hit me. This connection-configuration that I was looking for in the code.. It's not in the code, right? You just have them physically connected, right? Ah.. Sry for the troubles.

looking at page 50 of the data sheet, i don't think this "destination[0] = ((int16_t)rawData[1] << 8) | rawData[0];" is correct. that will give you a 16 bit number (should be 14 bits).; the lower 2 bits of the LSB are as follow: bit 1- undefined, bit 0: new_data flag. should it be something like: destination[0] = ((int16_t)(rawData[1] << 6) | (rawData[0]>>2));" ?