Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
bitrev.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023, RISE Research Institutes of Sweden AB
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the copyright holder nor the names of its
14
* contributors may be used to endorse or promote products derived
15
* from this software without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
* OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
/**
32
* \addtogroup lib
33
* @{
34
*
35
* \defgroup bitrev Bit Reversal Library
36
*
37
* This library provides functions for reversing bits in bytes and byte arrays.
38
* It's commonly used by radio drivers for protocol compliance (e.g., 802.15.4g).
39
*
40
* @{
41
*/
42
43
/**
44
* \file
45
* Bit reversal library header
46
* \author
47
* Joakim Eriksson <joakim.eriksson@ri.se>
48
*/
49
50
#ifndef BITREV_H_
51
#define BITREV_H_
52
53
#include "contiki.h"
54
55
/**
56
* \brief Reverse the bits in a single byte
57
* \param byte The input byte
58
* \return The byte with bits reversed
59
*
60
* Example: bitrev_byte(0xF0) returns 0x0F
61
*/
62
uint8_t
bitrev_byte
(uint8_t
byte
);
63
64
/**
65
* \brief Reverse bits in all bytes of an array (in-place)
66
* \param data Pointer to the data array
67
* \param len Length of the array in bytes
68
*
69
* This function modifies the input array in-place, reversing the bit
70
* order within each byte. Commonly used for protocol compliance.
71
*/
72
void
bitrev_array
(uint8_t *data,
size_t
len);
73
74
/**
75
* \brief Reverse bits in all bytes of an array (copy to output)
76
* \param input Pointer to the input data array
77
* \param output Pointer to the output data array
78
* \param len Length of the arrays in bytes
79
*
80
* This function copies data from input to output while reversing
81
* the bit order within each byte. Input and output arrays must not overlap.
82
*/
83
void
bitrev_array_copy
(
const
uint8_t *input, uint8_t *output,
size_t
len);
84
85
#endif
/* BITREV_H_ */
86
87
/** @} */
88
/** @} */
bitrev_byte
uint8_t bitrev_byte(uint8_t byte)
Reverse the bits in a single byte.
Definition
bitrev.c:66
bitrev_array_copy
void bitrev_array_copy(const uint8_t *input, uint8_t *output, size_t len)
Reverse bits in all bytes of an array (copy to output).
Definition
bitrev.c:81
bitrev_array
void bitrev_array(uint8_t *data, size_t len)
Reverse bits in all bytes of an array (in-place).
Definition
bitrev.c:72
os
lib
bitrev.h
Generated on
for Contiki-NG by
1.17.0