82 lines
2.6 KiB
C
82 lines
2.6 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef IOT_UART_ETH_API_H
|
|
#define IOT_UART_ETH_API_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* pack for the structures in the whole file */
|
|
#pragma pack(push) /* save the pack status */
|
|
#pragma pack(1) /* 1 byte align */
|
|
|
|
/* uart frame type definition */
|
|
/* frame of peer to peer */
|
|
#define UART_ETH_TYPE_P2P (0x8080)
|
|
/* frame of plc network */
|
|
#define UART_ETH_TYPE_PLC (0x8081)
|
|
/* frame of state communication */
|
|
#define UART_ETH_TYPE_STATE (0x8082)
|
|
/* frame of query state communication */
|
|
#define UART_ETH_TYPE_QUERY_STATE (0x8083)
|
|
|
|
/* uart frame preamble and backend code definition */
|
|
#define UART_ETH_PREAMBLE_LEN 2
|
|
#define UART_ETH_PREAMBLE_CODE "##"
|
|
#define UART_ETH_BACKEND_LEN 2
|
|
#define UART_ETH_BACKEND_CODE "@@"
|
|
|
|
/* uart frame header */
|
|
typedef struct _uart_eth_header {
|
|
/* type of the uart frame. see UART_ETH_TYPE_XXX */
|
|
uint16_t type;
|
|
/* source mac address of the uart frame, big endian */
|
|
uint8_t src_addr[6];
|
|
/* length of the data */
|
|
uint16_t len;
|
|
/* crc16 of the header */
|
|
uint16_t crc;
|
|
} uart_eth_header_t;
|
|
|
|
/* uart ethernet state message */
|
|
typedef struct _uart_eth_state_msg {
|
|
/* ipv4 address */
|
|
uint32_t ip;
|
|
/* ipv4 netmask */
|
|
uint32_t netmask;
|
|
/* ipv4 gateway */
|
|
uint32_t gateway;
|
|
/* maximum transmission unit */
|
|
uint16_t mtu;
|
|
/* flag to mark if the plc network is ready to be used */
|
|
uint16_t ready :1,
|
|
/* flag to mark if ipv4 address is valid */
|
|
ip_valid:1,
|
|
/* reserved for future */
|
|
rsvd :14;
|
|
/* crc16 of the msg */
|
|
uint16_t crc;
|
|
} uart_eth_state_msg_t;
|
|
|
|
#pragma pack(pop) /* restore the pack status */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* IOT_UART_ETH_API_H */
|