ISSDK  1.7
IoT Sensing Software Development Kit
data_format_hdlc.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /**
36 * @file data_format_hdlc.h
37 * @brief The data_format_hdlc.h file contains the Host interface definitions and configuration.
38 */
39 
40 #ifndef DATA_FORMAT_HDLC_H_
41 #define DATA_FORMAT_HDLC_H_
42 
43 /*******************************************************************************
44  * Standard C Includes
45  ******************************************************************************/
46 #include <stdint.h>
47 
48 /*******************************************************************************
49  * ISSDK Includes
50  ******************************************************************************/
51 #include "host_io_uart.h"
52 
53 /*******************************************************************************
54  * Types
55  ******************************************************************************/
56 /*! @brief States for receiving a packet */
57 enum
58 { /* Receiver state: Waiting for a packet marker */
60  /* Receiver state: Receiving data payload */
62 };
63 
64 /*******************************************************************************
65  * APIs
66  ******************************************************************************/
67 /* ===================================================================
68  * @brief Function to handle incomming HDLC encoded bytes form the Host over UART.
69  * @details This function will be called on receipt of every UART Byte
70  * and will do the HDLC combination to create a Host Message.
71  * @param[in] uint8_t c The character in the UART payload.
72  * @param[in] host_rx_packet_t *pHostRxPkt The Host Packet context structure.
73  * @return bool Success/Failure.
74  * @constraints This should be the called only after DEBUG/UART has been initialized.
75  * @reeentrant No
76  * =================================================================== */
77 bool HDLC_Process_Rx_Byte(uint8_t c, host_rx_packet_t *pHostRxPkt);
78 
79 /* ===================================================================
80  * @brief Function to format bytes for HDLC to be sent to Host over UART.
81  * @details This function will encode a Host Protocol formatted Message to be sent to Host over UART.
82  * The encoding adds a start and stop markers and inserts escape sequences for markers inside the packet.
83  * @param[in] uint8_t *pbuffer The handle to the input buffer containing the Host message.
84  * @param[in] uint8_t *pMsg The handle to the output buffer containing the formatted Host message.
85  * @param[in] size_t size The number of bytes to be sent starting form the buffer.
86  * @return size_t Length of the encoded message.
87  * @constraints This should be the called only after DEBUG/UART has been initialized.
88  * @reeentrant No
89  * =================================================================== */
90 size_t HDLC_Process_Tx_Msg(const uint8_t *pBuffer, uint8_t *pMsg, size_t size);
91 
92 #endif // DATA_FORMAT_HDLC_H_
This structure holds information to receive a packet of data to the host.
Definition: host_io_uart.h:75
uint32_t size
size_t HDLC_Process_Tx_Msg(const uint8_t *pBuffer, uint8_t *pMsg, size_t size)
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
bool HDLC_Process_Rx_Byte(uint8_t c, host_rx_packet_t *pHostRxPkt)