1 /* USER CODE BEGIN Header */ 2 /** 3 ****************************************************************************** 4 * @file hci_parser.h 5 * @author VMA RF Application Team 6 * @version V1.0.0 7 * @date July-2015 8 * @brief 9 ****************************************************************************** 10 * @attention 11 * 12 * Copyright (c) 2024 STMicroelectronics. 13 * All rights reserved. 14 * 15 * This software is licensed under terms that can be found in the LICENSE file 16 * in the root directory of this software component. 17 * If no LICENSE file comes with this software, it is provided AS-IS. 18 * 19 ****************************************************************************** 20 */ 21 /* USER CODE END Header */ 22 /* Define to prevent recursive inclusion -------------------------------------*/ 23 #ifndef HCI_PARSER_H 24 #define HCI_PARSER_H 25 26 /* Includes ------------------------------------------------------------------*/ 27 #include <stdint.h> 28 #include "compiler.h" 29 /* Exported macro ------------------------------------------------------------*/ 30 31 /* HCI Packet types */ 32 #define HCI_COMMAND_PKT 0x01 33 #define HCI_ACLDATA_PKT 0x02 34 #define HCI_SCODATA_PKT 0x03 35 #define HCI_EVENT_PKT 0x04 36 #define HCI_ISO_DATA_PKT 0x05 37 #define HCI_COMMAND_EXT_PKT 0x81 38 #define HCI_EVENT_EXT_PKT 0x82 39 #define HCI_VENDOR_PKT 0xFF 40 41 #define HCI_TYPE_OFFSET 0 42 #define HCI_VENDOR_CMDCODE_OFFSET 1 43 #define HCI_VENDOR_LEN_OFFSET 2 44 #define HCI_VENDOR_PARAM_OFFSET 4 45 46 /* Exported constants --------------------------------------------------------*/ 47 48 /* Exported types ------------------------------------------------------------*/ 49 50 typedef enum { 51 WAITING_TYPE, 52 WAITING_HEADER, 53 WAITING_PAYLOAD 54 }hci_state; 55 56 typedef PACKED(struct) _hci_uart_pckt{ 57 uint8_t type; 58 uint8_t data[0]; 59 } hci_uart_pckt; 60 #define HCI_TYPE_SIZE 1 61 62 typedef PACKED(struct) _hci_cmd_hdr{ 63 uint8_t type; 64 uint16_t opcode; 65 uint8_t param_len; 66 } hci_cmd_hdr; 67 68 typedef PACKED(struct) _hci_acl_hdr{ 69 uint8_t type; 70 uint16_t handle; /* Connection handle & Flags(PB, BC) */ 71 uint16_t dlen; 72 } hci_acl_hdr; 73 74 typedef PACKED(struct) _hci_iso_data_hdr{ 75 uint8_t type; 76 uint16_t handle; /* Connection handle & Flags(PB, TS) */ 77 uint16_t dlen; /* ISO Data Load Length (2 msb are reserved) */ 78 } hci_iso_data_hdr; 79 80 typedef PACKED(struct) _hci_cmd_ext_hdr{ 81 uint8_t type; 82 uint16_t opcode; 83 uint16_t param_len; 84 } hci_cmd_ext_hdr; 85 86 typedef PACKED(struct) _hci_vendor_hdr{ 87 uint8_t type; 88 uint8_t opcode; 89 uint16_t param_len; 90 } hci_vendor_hdr; 91 92 #define EVT_LE_META_EVENT 0x3E 93 typedef PACKED(struct) _evt_le_meta_event{ 94 uint8_t subevent; 95 uint8_t data[0]; 96 } evt_le_meta_event; 97 #define EVT_LE_META_EVENT_SIZE 1 98 99 typedef PACKED(struct) _evt_blue_aci{ 100 uint16_t ecode; /**< One of the BlueNRG event codes. */ 101 uint8_t data[0]; 102 } evt_blue_aci; 103 104 /* Exported functions ------------------------------------------------------- */ 105 106 /* HCI library functions. */ 107 extern hci_state hci_input(uint8_t *buff, uint16_t len); 108 109 extern uint8_t buffer_out[]; 110 extern uint16_t buffer_out_len; 111 112 #endif /* HCI_PARSER_H */ 113