LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cslr.h
Go to the documentation of this file.
1 /*****************************************************\
2  * Copyright 2003-2005 Texas Instruments Incorporated. *
3  * All rights reserved. *
4  * Restricted rights to use, duplicate or disclose *
5  * this code are granted through contract. *
6  * *
7  * "@(#) PSP/CSL 3.0.0.0 (2003-09-30) *
8 \*****************************************************/
9 
10 /* Register layer central -- contains field-manipulation macro definitions */
11 
12 #ifndef _CSLR_H_
13 #define _CSLR_H_
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /* the "expression" macros */
20 
21 /* the Field MaKe macro */
22 #define CSL_FMK(PER_REG_FIELD, val) \
23  (((val) << CSL_##PER_REG_FIELD##_SHIFT) & CSL_##PER_REG_FIELD##_MASK)
24 
25 /* the Field EXTract macro */
26 #define CSL_FEXT(reg, PER_REG_FIELD) \
27  (((reg) & CSL_##PER_REG_FIELD##_MASK) >> CSL_##PER_REG_FIELD##_SHIFT)
28 
29 /* the Field INSert macro */
30 #define CSL_FINS(reg, PER_REG_FIELD, val) \
31  ((reg) = ((reg) & ~CSL_##PER_REG_FIELD##_MASK) \
32  | CSL_FMK(PER_REG_FIELD, val))
33 
34 /* the "token" macros */
35 
36 /* the Field MaKe (Token) macro */
37 #define CSL_FMKT(PER_REG_FIELD, TOKEN) \
38  CSL_FMK(PER_REG_FIELD, CSL_##PER_REG_FIELD##_##TOKEN)
39 
40 /* the Field INSert (Token) macro */
41 #define CSL_FINST(reg, PER_REG_FIELD, TOKEN) \
42  CSL_FINS((reg), PER_REG_FIELD, CSL_##PER_REG_FIELD##_##TOKEN)
43 
44 /* the "raw" macros */
45 
46 /* the Field MaKe (Raw) macro */
47 #define CSL_FMKR(msb, lsb, val) \
48  (((val) & ((1 << ((msb) - (lsb) + 1)) - 1)) << (lsb))
49 
50 /* the Field EXTract (Raw) macro */
51 #define CSL_FEXTR(reg, msb, lsb) \
52  (((reg) >> (lsb)) & ((1 << ((msb) - (lsb) + 1)) - 1))
53 
54 /* the Field INSert (Raw) macro */
55 #define CSL_FINSR(reg, msb, lsb, val) \
56  ((reg) = ((reg) &~ (((1 << ((msb) - (lsb) + 1)) - 1) << (lsb))) \
57  | CSL_FMKR(msb, lsb, val))
58 
59 #ifdef __cplusplus
60 }
61 #endif
62 #endif /* _CSLR_H_ */