|
ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
|
#include "hdlc_encoder.h"#include <limits.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <stdio.h>#include <string.h>#include "hdlc_common.h"#include "system/common.h"
Go to the source code of this file.
Data Structures | |
| struct | hdlc_encoder_t |
Macros | |
| #define | HDLC_TRY_PUT_BYTE(byte, frame, error_handling) |
| #define | HDLC_BIT_STUFF_ONES_LIMIT 5U |
| #define | SHIFT_IN_BIT(out_byte, bitorder, bit, bitpos) (bitorder) ? ((out_byte) | ((bit) << (bitpos))) : ((out_byte) | ((bit) << (7 - (bitpos)))) |
| #define | ENCODER_TRY_FLUSH_BYTE_OUT(encoder, frame, error_handling) |
| #define | ENCODER_ZERO_PAD_AND_DRAIN(encoder, frame, error_handling) |
Functions | |
| static bool | hdlc_escape_if_needed (uint8_t byte, HDLC_FRAME_T *frame) |
| bool | hdlc_encode_byte (const uint8_t *payload, const size_t payload_length, HDLC_FRAME_T *frame) |
| Encode payload using byte-escaping HDLC compatibility path. | |
| static bool | hdlc_put_bit (hdlc_encoder_t *encoder, bool bit, HDLC_FRAME_T *frame) |
| static bool | hdlc_put_byte (hdlc_encoder_t *encoder, uint8_t byte, HDLC_FRAME_T *frame) |
| bool | hdlc_encode (const uint8_t *payload, const size_t payload_length, HDLC_FRAME_T *frame, bool lsb_first) |
| Encode payload into an HDLC bit-stuffed frame. | |
| #define ENCODER_TRY_FLUSH_BYTE_OUT | ( | encoder, | |
| frame, | |||
| error_handling | |||
| ) |
Definition at line 114 of file hdlc_encoder.c.
| #define ENCODER_ZERO_PAD_AND_DRAIN | ( | encoder, | |
| frame, | |||
| error_handling | |||
| ) |
Definition at line 125 of file hdlc_encoder.c.
| #define HDLC_BIT_STUFF_ONES_LIMIT 5U |
Definition at line 39 of file hdlc_encoder.c.
| #define HDLC_TRY_PUT_BYTE | ( | byte, | |
| frame, | |||
| error_handling | |||
| ) |
Definition at line 29 of file hdlc_encoder.c.
| #define SHIFT_IN_BIT | ( | out_byte, | |
| bitorder, | |||
| bit, | |||
| bitpos | |||
| ) | (bitorder) ? ((out_byte) | ((bit) << (bitpos))) : ((out_byte) | ((bit) << (7 - (bitpos)))) |
Definition at line 111 of file hdlc_encoder.c.
| bool hdlc_encode | ( | const uint8_t * | payload, |
| const size_t | payload_length, | ||
| HDLC_FRAME_T * | frame, | ||
| bool | lsb_first | ||
| ) |
Encode payload into an HDLC bit-stuffed frame.
| payload | Input payload bytes. |
| payload_length | Number of payload bytes. |
| frame | Output frame descriptor and storage. |
| lsb_first | Bit order selector for bit-wise encoding. |
Definition at line 171 of file hdlc_encoder.c.
References HDLC_FRAME_T::capacity, ENCODER_ZERO_PAD_AND_DRAIN, hdlc_crc16(), HDLC_FLAG_BYTE, hdlc_put_byte(), HDLC_TRY_PUT_BYTE, HDLC_FRAME_T::length, LOG_DEBUG, hdlc_encoder_t::out_byte, and HDLC_FRAME_T::payload.
Referenced by tx_queue_enqueue_udp_frame().


| bool hdlc_encode_byte | ( | const uint8_t * | payload, |
| const size_t | payload_length, | ||
| HDLC_FRAME_T * | frame | ||
| ) |
Encode payload using byte-escaping HDLC compatibility path.
| payload | Input payload bytes. |
| payload_length | Number of payload bytes. |
| frame | Output frame descriptor and storage. |
Definition at line 57 of file hdlc_encoder.c.
References HDLC_FRAME_T::capacity, hdlc_crc16(), hdlc_escape_if_needed(), HDLC_FLAG_BYTE, HDLC_TRY_PUT_BYTE, HDLC_FRAME_T::length, LOG_DEBUG, and HDLC_FRAME_T::payload.

|
static |
Definition at line 41 of file hdlc_encoder.c.
References HDLC_ESCAPE_BYTE, HDLC_ESCAPE_XOR, HDLC_FLAG_BYTE, and HDLC_TRY_PUT_BYTE.
Referenced by hdlc_encode_byte().

|
static |
Definition at line 137 of file hdlc_encoder.c.
References ENCODER_TRY_FLUSH_BYTE_OUT, HDLC_BIT_STUFF_ONES_LIMIT, hdlc_encoder_t::lsb_first, hdlc_encoder_t::ones_run, hdlc_encoder_t::out_bits_used, hdlc_encoder_t::out_byte, and SHIFT_IN_BIT.
Referenced by hdlc_put_byte().

|
static |
Definition at line 156 of file hdlc_encoder.c.
References hdlc_put_bit(), and hdlc_encoder_t::lsb_first.
Referenced by hdlc_encode().

