DavidArmstrong / SCL3300

Arduino library for interfacing with the Murata SCL3300 Inclinometer via SPI
MIT License
20 stars 11 forks source link

Bitwise leftshift will show a warning on some MCU systems #17

Closed DavidArmstrong closed 3 years ago

DavidArmstrong commented 3 years ago

While doing testing, I noticed that it was possible on some MCUs to generate a warning on this source line:

serialNum = (SCL3300_DATA << 16) | serialNum;

It doesn't always happen, as other MCUs, like SAMD chips, handle the bit shift just fine. The solution is to force a conversion as follows:

serialNum = ((unsigned long)SCL3300_DATA << 16) | serialNum;