diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/Display_Avr_3.iml b/.idea/Display_Avr_3.iml
new file mode 100644
index 0000000..bc2cd87
--- /dev/null
+++ b/.idea/Display_Avr_3.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..639da93
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hdlc/hdlc.c b/hdlc/hdlc.c
new file mode 100644
index 0000000..7ffb65f
--- /dev/null
+++ b/hdlc/hdlc.c
@@ -0,0 +1,60 @@
+#include "hdlc.h"
+#include
+
+#include "setup.h"
+
+__weak void uart_putchar(char ch)
+{
+ // implement function to send character via UART
+}
+
+static hdlc_t hdlc;
+
+// Static buffer allocations
+static uint8_t _hdlc_rx_frame[HDLC_MRU]; // rx frame buffer allocation
+static uint8_t _hdlc_tx_frame[HDLC_MRU]; // tx frame buffer allocation
+static uint8_t _hdlc_payload[HDLC_MRU]; // payload buffer allocation
+
+
+
+/** Приватная функция для отправки байтов по uart */
+static void hdlc_tx_byte(uint8_t byte)
+{
+ uart_putchar((char)byte);
+}
+
+/* инициализация конечного автомата HDLC, указателей буфера и переменных состояния */
+void hdlc_init(void)
+{
+ hdlc.rx_frame_index = 0;
+ hdlc.rx_frame_fcs = HDLC_CRC_INIT_VAL;
+ hdlc.p_rx_frame = _hdlc_rx_frame;
+ memset(hdlc.p_rx_frame, 0, HDLC_MRU);
+ hdlc.p_tx_frame = _hdlc_tx_frame;
+ memset(hdlc.p_tx_frame, 0, HDLC_MRU);
+ hdlc.p_payload = _hdlc_payload;
+ memset(hdlc.p_payload, 0, HDLC_MRU);
+ hdlc.state = HDLC_SOF_WAIT;
+ hdlc.own_addr = SETUP_OWNADDRESS;
+}
+
+//Эта функция должна вызываться при получении нового символа через UART
+static void hdlc_esc_tx_byte(uint8_t byte)
+{
+ if((byte == HDLC_CONTROL_ESCAPE) || (byte == HDLC_FLAG_SOF))
+ {
+ hdlc_tx_byte(HDLC_CONTROL_ESCAPE);
+ byte ^= HDLC_ESCAPE_BIT;
+ hdlc_tx_byte(byte);
+ }
+ else
+ hdlc_tx_byte(byte);
+}
+
+void hdlc_process_rx_frame(uint8_t *buf, uint16_t len){
+ return;
+}
+
+void hdlc_tx_frame(const uint8_t *txbuffer, uint8_t len){
+ return;
+}
\ No newline at end of file
diff --git a/hdlc/hdlc.h b/hdlc/hdlc.h
new file mode 100644
index 0000000..9d4d956
--- /dev/null
+++ b/hdlc/hdlc.h
@@ -0,0 +1,43 @@
+#ifndef DISPLAY_AVR_3_HDLC_H
+#define DISPLAY_AVR_3_HDLC_H
+
+#define HDLC_MRU 256
+// HDLC constants --- RFC 1662
+#define HDLC_FLAG_SOF 0x7e // Flag
+#define HDLC_CONTROL_ESCAPE 0x7d // Control Escape octet
+#define HDLC_ESCAPE_BIT 0x20 // Transparency modifier octet (XOR bit)
+#define HDLC_CRC_INIT_VAL 0xffff
+#define HDLC_CRC_MAGIC_VAL 0xf0b8
+#define HDLC_CRC_POLYNOMIAL 0x8408
+#define HDLC_UI_CMD 0x03 // Unnumbered Information with payload
+#define HDLC_FINAL_FLAG 0x10 // F flag
+#define HDLC_POLL_FLAG 0x10 // P flag
+
+typedef enum
+{
+ HDLC_SOF_WAIT,
+ HDLC_DATARX,
+ HDLC_PROC_ESC,
+} hdlc_state_t;
+
+typedef struct
+{
+ uint8_t own_addr;
+ uint8_t src_addr;
+ uint8_t dest_addr;
+ uint8_t ctrl;
+ uint8_t *p_tx_frame; // tx frame buffer
+ uint8_t *p_rx_frame; // rx frame buffer
+ uint8_t *p_payload; // payload pointer
+ uint16_t rx_frame_index;
+ uint16_t rx_frame_fcs;
+ hdlc_state_t state;
+} hdlc_t;
+
+
+void hdlc_init(void);
+
+void hdlc_process_rx_frame(uint8_t *buf, uint16_t len);
+void hdlc_tx_frame(const uint8_t *txbuffer, uint8_t len);
+
+#endif //DISPLAY_AVR_3_HDLC_H