WXK
2024-12-16 78e84fcf264afd731cd66c807d9fcb690fe12126
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
 *******************************************************************************
 * @FileName  : utils.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-02-18
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */
 
#ifndef UTILS_H_
#define UTILS_H_
 
#include "defs_types.h"
 
void *xmemcpy(void *dst, const void *src, uint32_t n);
int   xmemcmp(const void *m1, const void *m2, uint32_t n);
void *xmemset(void *buf, int c, uint32_t n);
 
/**
 * @brief  :  Copy the the buffer 'srx' to the buffer 'dest'.
 *
 * @param :  dest      Pointer to destination buffer
 * @param :  destLen   length of destination buffer
 * @param :  src       Pointer to origin buffer
 * @param :  srclen    length of origin buffer
 *
 * @return: returns   0 if srclen > destLen.
 */
uint32_t x_copy(uint8_t *dest, uint32_t destLen, const uint8_t *src, uint32_t srclen);
 
/**
 * @brief : Set the value 'val' into the buffer 'to', 'len' times.
 *
 * @param : to    Pointer to destination buffer
 * @param : val   value to be set in 'to'
 * @param : len   number of times the value will be copied
 *
 * @return: none.
 */
void x_set(void *to, uint8_t val, uint32_t len);
 
/**
 * @brief : Compare equal.
 * @param : a     Pointer point to data memory.
 * @param : b     Pointer point to data memory.
 * @param : size  length of data.
 * @return: Returns 0 if equal, and non-zero otherwise
 *
 * Note: This function can only compare for equality.
 */
int x_compare(const uint8_t *a, const uint8_t *b, uint32_t size);
 
/**
 * @brief : Reverse data.
 * @param : pdata    Pointer point to data memory.
 * @param : len      length of data.
 * @return: None.
 */
void _reverse(uint8_t *pdata, uint32_t len);
 
/**
 * @brief : Reverse data.
 * @param : from     Pointer point to input data buffer.
 * @param : to       Pointer point to output data buffer.
 * @param : len      length of data.
 * @return: None.
 */
void _swap(uint8_t *from, uint8_t *to, uint32_t len);
 
//XXX:64M system clock
static inline void sleep_us(uint32_t us)
{
    for(int i=0; i<us; i++){
        for(volatile int i=0; i<7; i++){};
    }
}
 
#endif /* UTILS_H_ */