summaryrefslogtreecommitdiff
path: root/support/dktools/dk3bits.ctr
blob: 85cac7a01294ce24dc74f2bed11a40cc4967a2ce (plain)
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
%%	options

copyright owner	=	Dirk Krause
copyright year	=	2011-xxxx
license		=	bsd



%%	header

#ifdef __cplusplus
extern "C" {
#endif

/**	Retrieve one bit.
	@param	i	Index of bit (0=lsb, 15=msb).
	@return	The requested bit.
*/
unsigned short
dk3bits_get(size_t i);

#ifdef __cplusplus
}
#endif



%%	module

#include "dk3conf.h"
#include "dk3types.h"
#include "dk3bits.h"



/**	Masks to set and retrieve single bits.
*/
static unsigned short const dk3bits_values[] = {
0x0001U,
0x0002U,
0x0004U,
0x0008U,
0x0010U,
0x0020U,
0x0040U,
0x0080U,
0x0100U,
0x0200U,
0x0400U,
0x0800U,
0x1000U,
0x2000U,
0x4000U,
0x8000U
};



unsigned short
dk3bits_get(size_t i)
{
  unsigned short	back	= 0U;
  if(i < 16) {
    back = dk3bits_values[i];
  }
  return back;
}