Help on CRC-8 function

Since there is no byte (or 8bit) number type, try anding all shifts and calcs with 0xff.

If you can provide sample data (the value of payload) and an expected CRC value, I'll show you how.