#ifndef F_CPU
#define F_CPU 16000000UL
#endif

#include <avr/io.h>

uint16_t dshot_frame(uint16_t value, uint8_t telem){
  uint16_t v = (value<<1) | (telem?1:0);          // 12 бит
  uint8_t crc = (v ^ (v>>4) ^ (v>>8)) & 0x0F;      // CRC4
  return (v<<4) | crc;                             // 16 бит
}
int main(void){
  volatile uint16_t f = dshot_frame(1046, 0);      // пример команды
  (void)f;
  for(;;){}
}
