NachtRaveVL / Lepton-FLiR-Arduino

Arduino Library for the Lepton FLiR Thermal Camera Module.
MIT License
59 stars 17 forks source link

Does lepton require the arduino to be little endian? #19

Open GaspTO opened 7 months ago

GaspTO commented 7 months ago

I have a question about this conversion:

(uint16_t *)&value 

in

    void LeptonFLiR::sendCommand(uint16_t cmdCode, uint32_t value) {
    #ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
        Serial.print("  LeptonFLiR::sendCommand cmdCode: 0x");
        Serial.println(cmdCode, HEX);

    #endif

      if (waitCommandBegin(LEPFLIR_GEN_CMD_TIMEOUT)) {

          if (writeCmdRegister(cmdCode, (uint16_t *)&value, 2) == 0) {

              waitCommandFinish(LEPFLIR_GEN_CMD_TIMEOUT);
          }
      }

In the writeCmdRegister, the dataWords argument, which corresponds (uint16_t *)&value, is going to be written to the i2cwire position by position, starting at position 0.

My question is, why does we start at the beginning of dataWords and not in the end? This code seems to work if the arduino stores values using the little endian system, but what if it is stored as big endian? can we trust it never is? Am I getting it wrong?

Thank you

[Edit] After searching a bit, I realized almost every processor is little endian. Still, I'd like to confirm that this code is assuming that just for my own sanity.