补充tools目录

This commit is contained in:
2024-09-28 14:37:24 +08:00
parent c756587541
commit a96a6fb2ad
434 changed files with 26219 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
/* common includes */
#include "iot_config_api.h"
#include "iot_sg_fr.h"
#include "iot_errno_api.h"
#include "iot_crc_api.h"
/* protocol includes */
#include "proto_crc16.h"
#define PPPGOODFCS16 0xf0b8 /* Good final FCS value */
uint16_t proto_fcs16_check_sum(uint8_t *data, uint16_t length)
{
return (iot_getcrc16_update(0xffff, data, length, 0));
}
uint16_t proto_fcs16_get_check_sum(uint8_t *data, uint16_t length)
{
uint16_t fcs;
fcs = proto_fcs16_check_sum(data, length);
fcs ^= 0xffff;
return (fcs);
}
uint32_t proto_fcs16_check(uint8_t* data, uint16_t len)
{
if (PPPGOODFCS16 == proto_fcs16_check_sum(data, len)) {
/* crc16 check success */
return ERR_OK;
}
/* crc16 check fail */
return ERR_FAIL;
}