xt-sdk 文档
v1.0.3
xt-sdk 嵌入式 SDK API 参考
Toggle main menu visibility
载入中...
搜索中...
未找到
xt_utils.h
浏览该文件的文档.
1
12
13
#ifndef __XT_UTILS_H__
14
#define __XT_UTILS_H__
15
22
23
/* ==================== [Includes] ========================================== */
24
25
#include <string.h>
26
#include <stdint.h>
27
28
#include "
xt_bit.h
"
29
#include "
xt_crc.h
"
30
#include "
xt_error.h
"
31
#include "
xt_list.h
"
32
#include "
xt_macro.h
"
33
#include "
xt_rb.h
"
34
35
#ifdef __cplusplus
36
extern
"C"
{
37
#endif
38
45
46
/* ==================== [Defines] =========================================== */
47
48
/* ==================== [Typedefs] ========================================== */
49
50
/* ==================== [Global Prototypes] ================================= */
51
52
static
inline
uint32_t
xt_log2_u32
(uint32_t n)
53
{
54
uint32_t result = 0;
55
/* *INDENT-OFF* */
56
if
(n & 0xffff0000) { result += 16; n >>= 16; }
57
if
(n & 0x0000ff00) { result += 8; n >>= 8; }
58
if
(n & 0x000000f0) { result += 4; n >>= 4; }
59
if
(n & 0x0000000c) { result += 2; n >>= 2; }
60
if
(n & 0x00000002) { result += 1;
/* n >>= 1; */
}
61
/* *INDENT-ON* */
62
return
result;
63
}
64
65
static
inline
uint16_t
xt_bswap16
(uint16_t val16)
66
{
67
return
((val16 << 8) & 0xFF00) | ((val16 >> 8) & 0x00FF);
68
}
69
70
static
inline
uint32_t
xt_bswap32
(uint32_t val32)
71
{
72
return
((val32 & 0x000000FF) << 24) |
73
((val32 & 0x0000FF00) << 8) |
74
((val32 & 0x00FF0000) >> 8) |
75
((val32 & 0xFF000000) >> 24);
76
}
77
78
static
inline
uint16_t
xt_read16p
(
const
void
*ptr16)
79
{
80
return
(((
const
uint8_t *)ptr16)[0]) | (((
const
uint8_t *)ptr16)[1] << 8);
81
}
82
83
static
inline
uint32_t
xt_read32p
(
const
void
*ptr32)
84
{
85
const
uint8_t *p = (
const
uint8_t *)ptr32;
86
return
(uint32_t)p[0] |
87
(uint32_t)p[1] << 8 |
88
(uint32_t)p[2] << 16 |
89
(uint32_t)p[3] << 24;
90
}
91
92
/* ==================== [Macros] ============================================ */
93
/* xt_utils */
95
96
#ifdef __cplusplus
97
}
/* extern "C" */
98
#endif
99
/* xt_std */
101
102
#endif
/* __XT_UTILS_H__ */
xt_read32p
static uint32_t xt_read32p(const void *ptr32)
定义
xt_utils.h:83
xt_bswap16
static uint16_t xt_bswap16(uint16_t val16)
定义
xt_utils.h:65
xt_bswap32
static uint32_t xt_bswap32(uint32_t val32)
定义
xt_utils.h:70
xt_read16p
static uint16_t xt_read16p(const void *ptr16)
定义
xt_utils.h:78
xt_log2_u32
static uint32_t xt_log2_u32(uint32_t n)
定义
xt_utils.h:52
xt_bit.h
XTINY 位操作宏集合
xt_crc.h
Common CRC bitwise operation functions. could verify at http://www.ip33.com/crc.html
xt_error.h
XTINY 错误码定义
xt_list.h
XTINY 双向链表与单向链表操作接口
xt_macro.h
XTINY 通用宏定义(数组大小、对齐、MIN/MAX 等)
xt_rb.h
XTINY 环形缓冲区(Ring Buffer)接口
components
xt_std
xt_utils.h
生成于
, 为 xt-sdk 文档使用
1.17.0