#include <stdint.h>
Include dependency graph for bit_utility.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
void | endian_swap (unsigned short &x) |
void | endian_swap (unsigned int &x) |
unsigned int | get_bits (const uint32_t &word, const unsigned int &offset, const unsigned int &nbits) |
______________________________________________________________________ read bits | |
bool | test_bit (const uint32_t &word, const unsigned int &bit) |
______________________________________________________________________ check a bit, 1=true, 0=false | |
unsigned int | bcd2dec (const unsigned int code) |
______________________________________________________________________ BCD to DEC |
void endian_swap | ( | unsigned short & | x | ) | [inline] |
void endian_swap | ( | unsigned int & | x | ) | [inline] |
Definition at line 11 of file bit_utility.h.
00012 { 00013 x = (x >> 24) | 00014 ((x << 8) & 0x00FF0000) | 00015 ((x >> 8) & 0x0000FF00) | 00016 (x << 24); 00017 }
unsigned int get_bits | ( | const uint32_t & | word, | |
const unsigned int & | offset, | |||
const unsigned int & | nbits | |||
) | [inline] |
______________________________________________________________________ read bits
Definition at line 36 of file bit_utility.h.
00037 { 00038 uint32_t mask = 0; 00039 for (unsigned int i = 0; i < nbits; i++) 00040 mask = (mask << 1) + 1; 00041 return (word >> offset) & mask; 00042 }
bool test_bit | ( | const uint32_t & | word, | |
const unsigned int & | bit | |||
) | [inline] |
______________________________________________________________________ check a bit, 1=true, 0=false
Definition at line 46 of file bit_utility.h.
00047 { 00048 uint32_t mask=1; 00049 mask = mask << bit; 00050 return (word & mask) == mask; 00051 }
unsigned int bcd2dec | ( | const unsigned int | code | ) | [inline] |
______________________________________________________________________ BCD to DEC
Definition at line 55 of file bit_utility.h.
00056 { 00057 unsigned int dec = 0; 00058 unsigned int bcd = code; 00059 int index = 1; 00060 while(bcd != 0) { 00061 dec += (bcd & 0xf) * index; 00062 bcd = bcd >> 4; 00063 index *= 10; 00064 } 00065 return dec; 00066 }