ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
Loading...
Searching...
No Matches
hdlc_common.c File Reference
#include "hdlc_common.h"
#include <stddef.h>
#include <stdint.h>
Include dependency graph for hdlc_common.c:

Go to the source code of this file.

Macros

#define HDLC_CRC16_CCITT_INIT   0xFFFFu
 
#define HDLC_CRC16_CCITT_POLY   0x1021u
 
#define HDLC_CRC16_CCITT_MSB_MASK   0x8000u
 
#define HDLC_CRC16_BITS_PER_BYTE   8u
 

Functions

static uint16_t crc16_ccitt_false (const uint8_t *payload, size_t num_bytes)
 
uint16_t hdlc_crc16 (const uint8_t *payload, size_t num_bytes)
 Compute HDLC CRC16 (FCS) over a payload.
 

Macro Definition Documentation

◆ HDLC_CRC16_BITS_PER_BYTE

#define HDLC_CRC16_BITS_PER_BYTE   8u

Definition at line 26 of file hdlc_common.c.

◆ HDLC_CRC16_CCITT_INIT

#define HDLC_CRC16_CCITT_INIT   0xFFFFu

Definition at line 23 of file hdlc_common.c.

◆ HDLC_CRC16_CCITT_MSB_MASK

#define HDLC_CRC16_CCITT_MSB_MASK   0x8000u

Definition at line 25 of file hdlc_common.c.

◆ HDLC_CRC16_CCITT_POLY

#define HDLC_CRC16_CCITT_POLY   0x1021u

Definition at line 24 of file hdlc_common.c.

Function Documentation

◆ crc16_ccitt_false()

static uint16_t crc16_ccitt_false ( const uint8_t *  payload,
size_t  num_bytes 
)
static

Definition at line 28 of file hdlc_common.c.

References HDLC_CRC16_BITS_PER_BYTE, HDLC_CRC16_CCITT_INIT, HDLC_CRC16_CCITT_MSB_MASK, and HDLC_CRC16_CCITT_POLY.

Referenced by hdlc_crc16().

Here is the caller graph for this function:

◆ hdlc_crc16()

uint16_t hdlc_crc16 ( const uint8_t *  payload,
size_t  num_bytes 
)

Compute HDLC CRC16 (FCS) over a payload.

Parameters
payloadInput data bytes.
num_bytesNumber of bytes in payload.
Returns
Computed CRC16 value.

Definition at line 45 of file hdlc_common.c.

References crc16_ccitt_false().

Referenced by hdlc_decode(), hdlc_decode_byte(), hdlc_encode(), and hdlc_encode_byte().

Here is the call graph for this function:
Here is the caller graph for this function: