https://github.com/adafruit/adafruit-beaglebone-io-python/blob/e981c59c6b080781c493cbb72dae63d330243890/source/common.c#L172