mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
88 lines
3.0 KiB
C
88 lines
3.0 KiB
C
|
/*********************************************************************************************************************
|
|||
|
* COPYRIGHT NOTICE
|
|||
|
* Copyright (c) 2018,<EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>
|
|||
|
* All rights reserved.
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QQȺ<EFBFBD><EFBFBD>һȺ<EFBFBD><EFBFBD>179029047(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>) <EFBFBD><EFBFBD>Ⱥ<EFBFBD><EFBFBD>244861897
|
|||
|
*
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>;<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD>λʹ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>뱣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD>İ<EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @file <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>
|
|||
|
* @company <EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾
|
|||
|
* @author <EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>(QQ3184284598)
|
|||
|
* @version <EFBFBD>鿴doc<EFBFBD><EFBFBD>version<EFBFBD>ļ<EFBFBD> <EFBFBD>汾˵<EFBFBD><EFBFBD>
|
|||
|
* @Software IAR 8.3 or MDK 5.28
|
|||
|
* @Taobao https://seekfree.taobao.com/
|
|||
|
* @date 2019-04-30
|
|||
|
* @note ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ַ<EFBFBD><EFBFBD>https://pan.baidu.com/s/198CMXTZsbI3HAEqNXDngBw<42><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>廪ֱ<E5BBAA><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>
|
|||
|
********************************************************************************************************************/
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#include "zf_uart.h"
|
|||
|
#include "SEEKFREE_VIRSCO.h"
|
|||
|
|
|||
|
|
|||
|
uint8 virtual_scope_data[10];
|
|||
|
|
|||
|
//-------------------------------------------------------------------------------------------------------------------
|
|||
|
// @brief CRCУ<43>飨<EFBFBD>ڲ<EFBFBD>ʹ<EFBFBD>ã<EFBFBD><C3A3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>
|
|||
|
// @param Buf <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>CRC<52><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
|
|||
|
// @param CRC_CNT <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>CRC<52><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
|||
|
// @return void
|
|||
|
// @since v1.0
|
|||
|
// Sample usage:
|
|||
|
//-------------------------------------------------------------------------------------------------------------------
|
|||
|
uint16 CRC_CHECK(uint8 *Buf, uint8 CRC_CNT)
|
|||
|
{
|
|||
|
uint16 CRC_Temp;
|
|||
|
uint8 i,j;
|
|||
|
CRC_Temp = 0xffff;
|
|||
|
|
|||
|
for (i=0;i<CRC_CNT; i++){
|
|||
|
CRC_Temp ^= Buf[i];
|
|||
|
for (j=0;j<8;j++) {
|
|||
|
if (CRC_Temp & 0x01)
|
|||
|
CRC_Temp = (CRC_Temp >>1 ) ^ 0xa001;
|
|||
|
else
|
|||
|
CRC_Temp = CRC_Temp >> 1;
|
|||
|
}
|
|||
|
}
|
|||
|
return(CRC_Temp);
|
|||
|
}
|
|||
|
|
|||
|
//-------------------------------------------------------------------------------------------------------------------
|
|||
|
// @brief <20><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// @param data1 Ҫ<><D2AA><EFBFBD>͵ĵ<CDB5>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// @param data2 Ҫ<><D2AA><EFBFBD>͵ĵڶ<C4B5><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// @param data3 Ҫ<><D2AA><EFBFBD>͵ĵ<CDB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// @param data4 Ҫ<><D2AA><EFBFBD>͵ĵ<CDB5><C4B5>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// @param *dat ת<><D7AA>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĵ<DDB5>ַ
|
|||
|
// @return void
|
|||
|
// @since v1.0
|
|||
|
// Sample usage:
|
|||
|
//-------------------------------------------------------------------------------------------------------------------
|
|||
|
void data_conversion(int16 data1, int16 data2, int16 data3, int16 data4, uint8 *dat)
|
|||
|
{
|
|||
|
uint16 CRC16 = 0;
|
|||
|
|
|||
|
dat[0] = (uint8)((uint16)data1&0xff);
|
|||
|
dat[1] = (uint8)((uint16)data1>>8);
|
|||
|
|
|||
|
dat[2] = (uint8)((uint16)data2&0xff);
|
|||
|
dat[3] = (uint8)((uint16)data2>>8);
|
|||
|
|
|||
|
dat[4] = (uint8)((uint16)data3&0xff);
|
|||
|
dat[5] = (uint8)((uint16)data3>>8);
|
|||
|
|
|||
|
dat[6] = (uint8)((uint16)data4&0xff);
|
|||
|
dat[7] = (uint8)((uint16)data4>>8);
|
|||
|
|
|||
|
CRC16 = CRC_CHECK(dat,8);
|
|||
|
dat[8] = (uint8)(CRC16&0xff);
|
|||
|
dat[9] = (uint8)(CRC16>>8);
|
|||
|
|
|||
|
//uart_putbuff(UART_0,dat,10); //<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>ʹ<EFBFBD>ô<EFBFBD><C3B4>ڷ<EFBFBD><DAB7>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7>ͳ<EFBFBD>ȥ
|
|||
|
}
|
|||
|
|