Convenience method. Oftentimes we need to set a range of registers
        to represent an int. This method will automatically set @numBytes registers
        starting at @addr. It will convert the int @val into an array of bytes.

def _set_as_int(self, addr, val, numBytes = 1):
        """Convenience method. Oftentimes we need to set a range of registers
        to represent an int. This method will automatically set @numBytes registers
        starting at @addr. It will convert the int @val into an array of bytes."""
        if not isinstance(val, int):
            raise ValueError("val must be an int. You provided: %s" % str(val))
        buf = []
        for i in range(numBytes):
            buf.append(cast_to_byte(val >> 8 * i))
        self.set_register(addr, buf)