ZNY_Pakistan/Anjiehui7_Set_ZNY/User/utils.h

23 lines
502 B
C

#ifndef __UTILS_H
#define __UTILS_H
#include "type.h"
// 颠倒字节顺序
uint16_t ntohs(uint16_t n);
uint32_t ntohl(uint32_t n);
float ntohf(float f);
#define htons(n) ntohs(n)
#define htonl(n) ntohl(n)
#define htonf(f) ntohf(f)
uint16_t Byte2IntS(uint8_t *buf, int pos);
void Int2ByteS(uint8_t *buf, int pos, uint16_t val);
uint32_t Byte2IntL(uint8_t *buf, int pos);
void Int2ByteL(uint8_t *buf, int pos, uint32_t val);
// MODBUS的CRC算法
u16 MODBUS_RTU_CRC16(u8 *puchMsg, u16 usDataLen);
#endif