| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

bit_utility.h File Reference

#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

Function Documentation

void endian_swap ( unsigned short &  x  )  [inline]

Definition at line 5 of file bit_utility.h.

00006 {
00007    x = (x >> 8) |
00008        (x << 8);
00009 }

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 }

| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:27:03 2011 for RawDataIO by doxygen 1.4.7