1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: log OAM pcm producer interface 15 * Author: 16 * Create: 17 */ 18 19 #ifndef LOG_OAM_PCM_H 20 #define LOG_OAM_PCM_H 21 22 #include "log_oam_logger.h" 23 // for IAR compiler 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 #pragma pack(push, 1) 29 30 #define PCM_REPORT_DATA_MAX_SIZE 1200 31 #define BT_SAMPLE_DATA_MAX_SIZE 1200 32 #define OM_PCM_SINK 0x00 33 #define OM_PCM_SOURCE 0x10 34 #define OM_DBG_BUF 0x20 35 #define OM_SNOOP_BUF 0X30 36 #define OM_SNOOP_MAGIC_NUM 0x50 37 38 #define bt_pcm_out_write(msg_id, length, buffer) \ 39 log_oml_bt_sample_data_write(OM_PCM_SOURCE, msg_id, length, buffer) 40 #define bt_pcm_in_write(msg_id, length, buffer) \ 41 log_oml_bt_sample_data_write(OM_PCM_SINK, msg_id, length, buffer) 42 #define bt_pcm_buffer_write(msg_id, length, buffer) \ 43 log_oml_bt_sample_data_write(OM_DBG_BUF, msg_id, length, buffer) 44 #define bt_snoop_buffer_write(msg_id, length, buffer) \ 45 log_oml_bt_sample_data_write(OM_SNOOP_BUF, msg_id, length, buffer) 46 47 typedef enum { 48 OM_BT_SAMPLE_DATA_OPEN, 49 OM_BT_SAMPLE_DATA_CLOSED, 50 } log_om_pcm_report_config_t; 51 52 #if (USE_COMPRESS_LOG_INSTEAD_OF_SDT_LOG == NO) 53 typedef struct { 54 om_msg_header_stru_t header; 55 uint16_t msg_id; 56 uint16_t data_len; 57 } om_pcm_header_t; 58 #else 59 typedef struct { 60 uint32_t magic : 8; 61 uint32_t primeid : 8; 62 uint32_t sn : 16; 63 uint32_t msgid : 16; 64 uint32_t datalen : 16; 65 } om_pcm_header_t; 66 #endif 67 68 typedef enum { 69 SAMPLE_DATA_SNOOP = 00, 70 } om_sample_data_msgid_t; 71 72 typedef void(*log_oml_bt_sdw_handler)(uint8_t mode_id, uint16_t msg_id, uint16_t length, const uint8_t *buffer); 73 void log_oml_bt_sample_data_init(void); 74 void log_oml_bt_sample_data_write(uint8_t mode_id, uint16_t msg_id, uint16_t length, const uint8_t *buffer); 75 void log_oml_bt_sample_data_switch(uint8_t on); 76 void log_oml_bt_sample_data_write_deal(uint8_t mode_id, uint16_t msg_id, uint16_t length, const uint8_t *msg_buffer); 77 void log_oml_bt_sample_data_write_register_callback(log_oml_bt_sdw_handler callback); 78 void log_oml_bt_sample_data_write_unregister_callback(void); 79 void log_oml_bt_sample_data_write_trigger_callback(uint8_t mode_id, uint16_t msg_id, uint16_t length, 80 const uint8_t *buffer); 81 82 #pragma pack(pop) 83 84 #ifdef __cplusplus 85 } 86 #endif 87 88 #endif 89