STM32:
[esp-hosted.git] / esp_hosted_fg / common / include / adapter.h
CommitLineData
b184ca3a
SR
1// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
2/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
3
4#ifndef __ESP_NETWORK_ADAPTER__H
5#define __ESP_NETWORK_ADAPTER__H
6
7#define PRIO_Q_SERIAL 0
8#define PRIO_Q_BT 1
9#define PRIO_Q_OTHERS 2
10#define MAX_PRIORITY_QUEUES 3
11
12/* ESP Payload Header Flags */
13#define MORE_FRAGMENT (1 << 0)
14
15/* Serial interface */
16#define SERIAL_IF_FILE "/dev/esps0"
17
18/* Protobuf related info */
19/* Endpoints registered must have same string length */
20#define CTRL_EP_NAME_RESP "ctrlResp"
21#define CTRL_EP_NAME_EVENT "ctrlEvnt"
22
23struct esp_payload_header {
24 uint8_t if_type:4;
25 uint8_t if_num:4;
26 uint8_t flags;
27 uint16_t len;
28 uint16_t offset;
29 uint16_t checksum;
30 uint16_t seq_num;
31 uint8_t reserved2;
32 /* Position of union field has to always be last,
33 * this is required for hci_pkt_type */
34 union {
35 uint8_t reserved3;
36 uint8_t hci_pkt_type; /* Packet type for HCI interface */
37 uint8_t priv_pkt_type; /* Packet type for priv interface */
38 };
39 /* Do no add anything here */
40} __attribute__((packed));
41
42typedef enum {
43 ESP_STA_IF,
44 ESP_AP_IF,
45 ESP_SERIAL_IF,
46 ESP_HCI_IF,
47 ESP_PRIV_IF,
c732af5e 48 ESP_TEST_IF,
b184ca3a
SR
49 ESP_MAX_IF,
50} ESP_INTERFACE_TYPE;
51
52typedef enum {
53 ESP_OPEN_DATA_PATH,
54 ESP_CLOSE_DATA_PATH,
55 ESP_RESET,
c66259f1 56 ESP_MAX_HOST_INTERRUPT,
b184ca3a
SR
57} ESP_HOST_INTERRUPT;
58
59
60typedef enum {
61 ESP_WLAN_SDIO_SUPPORT = (1 << 0),
62 ESP_BT_UART_SUPPORT = (1 << 1),
63 ESP_BT_SDIO_SUPPORT = (1 << 2),
64 ESP_BLE_ONLY_SUPPORT = (1 << 3),
65 ESP_BR_EDR_ONLY_SUPPORT = (1 << 4),
66 ESP_WLAN_SPI_SUPPORT = (1 << 5),
67 ESP_BT_SPI_SUPPORT = (1 << 6),
c732af5e 68 ESP_CHECKSUM_ENABLED = (1 << 7),
b184ca3a
SR
69} ESP_CAPABILITIES;
70
c732af5e
SR
71typedef enum {
72 ESP_TEST_RAW_TP = (1 << 0),
73 ESP_TEST_RAW_TP__ESP_TO_HOST = (1 << 1)
74} ESP_RAW_TP_MEASUREMENT;
75
b184ca3a
SR
76typedef enum {
77 ESP_PACKET_TYPE_EVENT,
78} ESP_PRIV_PACKET_TYPE;
79
80typedef enum {
81 ESP_PRIV_EVENT_INIT,
82} ESP_PRIV_EVENT_TYPE;
83
84typedef enum {
85 ESP_PRIV_CAPABILITY,
86 ESP_PRIV_SPI_CLK_MHZ,
87 ESP_PRIV_FIRMWARE_CHIP_ID,
c732af5e 88 ESP_PRIV_TEST_RAW_TP
b184ca3a
SR
89} ESP_PRIV_TAG_TYPE;
90
91struct esp_priv_event {
92 uint8_t event_type;
93 uint8_t event_len;
94 uint8_t event_data[0];
95}__attribute__((packed));
96
97
98static inline uint16_t compute_checksum(uint8_t *buf, uint16_t len)
99{
100 uint16_t checksum = 0;
101 uint16_t i = 0;
102
103 while(i < len) {
104 checksum += buf[i];
105 i++;
106 }
107
108 return checksum;
109}
110
111#endif
This page took 0.033183 seconds and 4 git commands to generate.