ISSDK  1.8
IoT Sensing Software Development Kit
data_format_hdlc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /**
10 * @file data_format_hdlc.h
11 * @brief The data_format_hdlc.h file contains the Host interface definitions and configuration.
12 */
13 
14 #ifndef DATA_FORMAT_HDLC_H_
15 #define DATA_FORMAT_HDLC_H_
16 
17 /*******************************************************************************
18  * Standard C Includes
19  ******************************************************************************/
20 #include <stdint.h>
21 
22 /*******************************************************************************
23  * ISSDK Includes
24  ******************************************************************************/
25 #include "host_io_uart.h"
26 
27 /*******************************************************************************
28  * Types
29  ******************************************************************************/
30 /*! @brief States for receiving a packet */
31 enum
32 { /* Receiver state: Waiting for a packet marker */
34  /* Receiver state: Receiving data payload */
36 };
37 
38 /*******************************************************************************
39  * APIs
40  ******************************************************************************/
41 /* ===================================================================
42  * @brief Function to handle incomming HDLC encoded bytes form the Host over UART.
43  * @details This function will be called on receipt of every UART Byte
44  * and will do the HDLC combination to create a Host Message.
45  * @param[in] uint8_t c The character in the UART payload.
46  * @param[in] host_rx_packet_t *pHostRxPkt The Host Packet context structure.
47  * @return bool Success/Failure.
48  * @constraints This should be the called only after DEBUG/UART has been initialized.
49  * @reeentrant No
50  * =================================================================== */
51 bool HDLC_Process_Rx_Byte(uint8_t c, host_rx_packet_t *pHostRxPkt);
52 
53 /* ===================================================================
54  * @brief Function to format bytes for HDLC to be sent to Host over UART.
55  * @details This function will encode a Host Protocol formatted Message to be sent to Host over UART.
56  * The encoding adds a start and stop markers and inserts escape sequences for markers inside the packet.
57  * @param[in] uint8_t *pbuffer The handle to the input buffer containing the Host message.
58  * @param[in] uint8_t *pMsg The handle to the output buffer containing the formatted Host message.
59  * @param[in] size_t size The number of bytes to be sent starting form the buffer.
60  * @return size_t Length of the encoded message.
61  * @constraints This should be the called only after DEBUG/UART has been initialized.
62  * @reeentrant No
63  * =================================================================== */
64 size_t HDLC_Process_Tx_Msg(const uint8_t *pBuffer, uint8_t *pMsg, size_t size);
65 
66 #endif // DATA_FORMAT_HDLC_H_
uint32_t size
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
This structure holds information to receive a packet of data to the host.
Definition: host_io_uart.h:49
size_t HDLC_Process_Tx_Msg(const uint8_t *pBuffer, uint8_t *pMsg, size_t size)
bool HDLC_Process_Rx_Byte(uint8_t c, host_rx_packet_t *pHostRxPkt)