WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
diag_adapt_layer.h
浏览该文件的文档.
1/*
2 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2021-2023. All rights reserved.
3 */
4
5#ifndef DIAG_ADAPT_LAYER_H
6#define DIAG_ADAPT_LAYER_H
7
8#include "time.h"
9#include "diag_config.h"
10#include "diag_common.h"
11#include "diag_channel.h"
12#include "dfx_adapt_layer.h"
13
14#define DIAG_HSO_MAX_MUX_PKT_SIZE 512
15#define DIAG_HSO_VER_DEFAULT 0
16#define DIAG_HSO_THIS_VER 0x11
17
18#define USER_CMD_LIST_NUM 10 /* Maximum number of non-system command lists */
19
20static inline uint32_t diag_adapt_get_msg_time(void)
21{
22 return (uint32_t)uapi_systick_get_ms();
23}
24
25static inline uint64_t diag_adapt_get_msg_time_ms(void)
26{
27 return uapi_systick_get_ms();
28}
29
30static inline uint32_t diag_adapt_get_msg_local_time(void)
31{
32 uint64_t time_ms = uapi_systick_get_ms();
33 time_t time_s = (time_t)(time_ms / 1000); /* 1 second = 1000 milliseconds */
34
35 struct tm tm = { 0 };
36 if (localtime_r(&time_s, &tm) == NULL) {
37 return 0;
38 }
39
40 uint32_t local_time = ((uint32_t)tm.tm_mon + 1) << 28; /* 28~31 bit: month */
41 /* 1 day = 24 hours, 1 hour = 60 minutes, 1 minute = 60 seconds, 1 second = 100 * 10 milliseconds */
42 local_time += (uint32_t)(((tm.tm_mday * 24 + tm.tm_hour) * 60 + tm.tm_min) * 60 + tm.tm_sec) * 100;
43 local_time += (uint32_t)((time_ms / 10) % 100); /* 1 second = 100 * 10 milliseconds */
44 return local_time;
45}
46
47static inline errcode_t diag_adapt_sync_tx_sem_wait(void)
48{
49 return ERRCODE_FAIL;
50}
51
52static inline void diag_adapt_sync_tx_sem_signal(void)
53{
54 return;
55}
56
57#ifdef SUPPORT_DIAG_V2_PROTOCOL
58static inline uint8_t diag_adapt_get_default_dst(void)
59{
60 return DIAG_FRAME_FID_UART;
61}
62
63static inline diag_channel_id_t diag_adapt_addr_2_channel_id(diag_frame_fid_t addr)
64{
65 if (addr == DIAG_FRAME_FID_UART) {
66 return DIAG_CHANNEL_ID_0;
67 } else if (addr == DIAG_FRAME_FID_BLE_GATT) {
68 return DIAG_CHANNEL_ID_1;
69 }
71}
72
73static inline diag_frame_fid_t diag_adapt_channel_id_2_addr(diag_channel_id_t id)
74{
75 if (id == DIAG_CHANNEL_ID_0) {
76 return DIAG_FRAME_FID_UART;
77 } else if (id == DIAG_CHANNEL_ID_1) {
78 return DIAG_FRAME_FID_BLE_GATT;
79 }
80 return DIAG_FRAME_FID_MAX;
81}
82
83static inline diag_frame_fid_t diag_adapt_get_local_addr(void)
84{
85 return DIAG_FRAME_FID_LOCAL;
86}
87
88#else /* SUPPORT_DIAG_V2_PROTOCOL */
89
90#define DIAG_LOCAL_ADDR 100
91#define DIAG_UART_CONNECT_HSO_ADDR 200
92
93static inline uint8_t diag_adapt_get_default_dst(void)
94{
96}
97
98static inline diag_channel_id_t diag_adapt_dst_2_channel_id(diag_addr addr)
99{
100 if (addr == DIAG_UART_CONNECT_HSO_ADDR) {
101 return DIAG_CHANNEL_ID_0;
102 }
104}
105
106static inline diag_addr diag_adapt_get_local_addr(void)
107{
108 return DIAG_LOCAL_ADDR;
109}
110
111static inline diag_addr_attribute_t diag_adapt_addr_2_attribute(diag_addr addr)
112{
113 if (addr == DIAG_UART_CONNECT_HSO_ADDR) {
115 } else if (addr == DIAG_LOCAL_ADDR) {
117 } else {
118 return 0;
119 }
120}
121#endif /* SUPPORT_DIAG_V2_PROTOCOL */
122
123static inline bool diag_adapt_is_in_unblocking_context(void)
124{
125 return false;
126}
127
128#endif /* DIAG_ADAPT_LAYER_H */
#define NULL
Definition common_def.h:21
uint8_t diag_addr
Definition dfx_resource_id.h:35
diag_channel_id_t
Definition dfx_resource_id.h:27
@ DIAG_CHANNEL_ID_INVALID
Definition dfx_resource_id.h:32
@ DIAG_CHANNEL_ID_0
Definition dfx_resource_id.h:28
@ DIAG_CHANNEL_ID_1
Definition dfx_resource_id.h:29
#define DIAG_LOCAL_ADDR
Definition diag_adapt_layer.h:90
#define DIAG_UART_CONNECT_HSO_ADDR
Definition diag_adapt_layer.h:91
diag_addr_attribute_t
Definition diag_common.h:30
@ DIAG_ADDR_ATTRIBUTE_VALID
Definition diag_common.h:31
@ DIAG_ADDR_ATTRIBUTE_HSO_CONNECT
Definition diag_common.h:33
uint32_t errcode_t
Definition of error code.
Definition errcode.h:30
#define ERRCODE_FAIL
Definition errcode.h:36
uint64_t uapi_systick_get_ms(void)
获取Systick计数毫秒值。
Definition systick.c:90
unsigned long long uint64_t
Definition osal_types.h:35