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,<2C><><EFBFBD>ɿƼ<C9BF>
|
||
* All rights reserved.
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QQȺ<51><C8BA>һȺ<D2BB><C8BA>179029047(<28><><EFBFBD><EFBFBD>) <20><>Ⱥ<EFBFBD><C8BA>244861897
|
||
*
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC><EFBFBD><EFBFBD>У<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>;<EFBFBD><CDBE>
|
||
* <20><>ӭ<EFBFBD><D3AD>λʹ<CEBB>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>뱣<EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC>İ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* @file <09><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Э<EFBFBD><D0AD>
|
||
* @company <09>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC><EFBFBD><EFBFBD><EFBFBD>˾
|
||
* @author <09><><EFBFBD>ɿƼ<C9BF>(QQ3184284598)
|
||
* @version <09>鿴doc<6F><63>version<6F>ļ<EFBFBD> <20>汾˵<E6B1BE><CBB5>
|
||
* @Software IAR 8.3 or MDK 5.28
|
||
* @Taobao https://seekfree.taobao.com/
|
||
* @date 2019-04-30
|
||
* @note ʾ<><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ַ<EFBFBD><D6B7>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>ȥ
|
||
}
|
||
|