crc16 AVR MCU

原文链接:http://www.cnblogs.com/van9ogh/archive/2012/04/25/2470476.html static __inline__ uint16_t
_crc16_update(uint16_t __crc, uint8_t __data)
{
        uint8_t __tmp;
        uint16_t __ret;

        __asm__ __volatile__ (
                "eor %A0,%2" "\n\t"
                "mov %1,%A0" "\n\t"
                "swap %1" "\n\t"
                "eor %1,%A0" "\n\t"
                "mov __tmp_reg__,%1" "\n\t"
                "lsr %1" "\n\t"
                "lsr %1" "\n\t"
                "eor %1,__tmp_reg__" "\n\t"
                "mov __tmp_reg__,%1" "\n\t"
                "lsr %1" "\n\t"
                "eor %1,__tmp_reg__" "\n\t"
                "andi %1,0x07" "\n\t"
                "mov __tmp_reg__,%A0" "\n\t"
                "mov %A0,%B0" "\n\t"
                "lsr %1" "\n\t"
                "ror __tmp_reg__" "\n\t"
                "ror %1" "\n\t"
                "mov %B0,__tmp_reg__" "\n\t"
                "eor %A0,%1" "\n\t"
                "lsr __tmp_reg__" "\n\t"
                "ror %1" "\n\t"
                "eor %B0,__tmp_reg__" "\n\t"
                "eor %A0,%1"
                : "=r" (__ret), "=d" (__tmp)
                : "r" (__data), "0" (__crc)
                : "r0"
        );  
        return __ret;
}

转载于:https://www.cnblogs.com/van9ogh/archive/2012/04/25/2470476.html

上一篇:VSCode配置arduino+esp8266开发环境全教程


下一篇:Android上的蓝牙控制信号(DTR,DSR,RTS,CTS)