HWA
Bare metal programming with style
cca_1.h
Go to the documentation of this file.
1 #ifndef hw_class__cca
2 
3 /* This file is part of the HWA project.
4  * Copyright (c) 2020 Christophe Duparquet.
5  * All rights reserved. Read LICENSE.TXT for details.
6  */
7 
27 #define hw_class__cca
28 
29 
30 /* Return the counter associated to a _cca.
31  */
32 #define hw__cca_counter , _hw_cca_counter
33 #define _hw_cca_counter(o,c,...) _ioa,o,(c,__VA_ARGS__),counter, HW_XO(c)
34 
35 
36 /* Route logical registers to hardware counter's.
37  * Build the memory definition here as we know the definitions
38  * of the registers and HW_OXR would probably be slower.
39  */
40 #define hw__cca_occe , _hw_ccarg, oc, ce
41 #define hw__cca_ocm , _hw_ccarg, oc, m
42 #define hw__cca_icf , _hw_ccarg, ic, f
43 #define hw__cca_ocpe , _hw_ccarg, oc, pe
44 #define hw__cca_ocfe , _hw_ccarg, oc, fe
45 #define hw__cca_icpsc , _hw_ccarg, ic, psc
46 #define hw__cca_ccs , _hw_ccarg, cc, s
47 #define hw__cca_cce , _hw_ccarg, cc, e
48 #define hw__cca_ccp , _hw_ccarg, cc, p
49 
50 #define hw__cca_ccie , _hw_ccarg, cc, ie
51 #define hw__cca_ccif , _hw_ccarg, cc, if
52 
53 #define _hw_ccarg(a,b,o,n) _hw_ccarg1(HW_RP o, a##n##b)
54 #define _hw_ccarg1(...) _hw_ccarg2(__VA_ARGS__)
55 #define _hw_ccarg2(ct,cn,x) HW_BED(_hw_ccarg2,hw__cta_##x,ct,cn,x)
56 #define _hw_ccarg20(ct,cn,x,...) HW_E(HW_EM_OO(o,x))
57 #define _hw_ccarg21(ct,cn,x,rc,r,bn,bp) _hw_ccarg3(ct,hw_##ct,hw__cta_##r,r,bn,bp)
58 #define _hw_ccarg3(...) _hw_ccarg4(__VA_ARGS__)
59 #define _hw_ccarg4(ct,ctc,cta,rc,ra,rwm,rfm,r,rbn,rbp) _m11,(ct,r),(ct,r,rc,cta+ra,rwm,rfm,rbn,rbp)
60 
61 /* Generate IRQ objects
62  *
63  * _hw_ccairq is called by HW_X():
64  * `o`: channel name "(counterX,channelY)"
65  * `n`: channel definition (Y).
66  * The IRQ object references the counter's registers.
67  */
68 #define hw__cca_irq , _hw_ccairq
69 
70 #define _hw_ccairq(o,n) _hw_ccairq1(HW_RP o, n)
71 #define _hw_ccairq1(...) _hw_ccairq2(__VA_ARGS__)
72 #define _hw_ccairq2(ct,cn,n) _irq, (ct,irq), (cc##n##ie, cc##n##if, 0)
73 
74 
75 #define hwa_read__cca , _hwa_rdcca
76 #define _hwa_rdcca(o,n,...) _hwa_read(HW_A0 o,ccr##n) HW_EOL(__VA_ARGS__)
77 
78 #define hw_read__cca , _hw_rdcca
79 #define _hw_rdcca(o,n,...) _hw_read(HW_A0 o,ccr##n) HW_EOL(__VA_ARGS__)
80 
81 #define hwa_write__cca , _hwa_wrcca
82 #define _hwa_wrcca(o,n,v,...) _hwa_write(HW_A0 o,ccr##n,v) HW_EOL(__VA_ARGS__)
83 
84 #define hw_write__cca , _hw_wrcca
85 #define _hw_wrcca(o,n,v,...) _hw_write(HW_A0 o,ccr##n,v) HW_EOL(__VA_ARGS__)
86 
87 
88 #endif /* ifndef hw_class__cca */