HWA
Bare metal programming with style
cca_2.h
Go to the documentation of this file.
1 #ifndef hw_configure__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 
52 #define hw_configure__cca , _hw_cfcca
53 #define hwa_configure__cca , _hwa_cfcca
54 
55 /* At least one keyword
56  */
57 #define _hw_cfcca(o,n,k,...) do{ HW_B(_hwx_cfcca,k)(_hw,HW_A0 o,n,k,__VA_ARGS__) }while(0)
58 #define _hwa_cfcca(o,n,k,...) do{ HW_B(_hwx_cfcca,k)(_hwa,HW_A0 o,n,k,__VA_ARGS__) }while(0)
59 
60 #define _hwx_cfcca1(...) HW_E(HW_EM_AML((function,level)))
61 
62 /* Mandatory argument 'function'
63  */
64 #define _hwx_cfcca0(h,c,n,k,...) HW_BW(_hwx_cfcca_fun,function,k)(h,c,n,k,__VA_ARGS__)
65 #define _hwx_cfcca_fun0(h,c,n,k,...) HW_E(HW_EM_AN(k,function))
66 #define _hwx_cfcca_fun1(h,c,n,k,v,...) HW_BW(_hwx_cfcca_fun1,compare,v)(h,c,n,v,__VA_ARGS__)
67 #define _hwx_cfcca_fun10(h,c,n,v,...) HW_E(HW_EM_TBD(v,function)
68 #define _hwx_cfcca_fun11(h,c,n,v,k,...) h##_write(c,cc##n##s,0); HW_BW(_hwx_cfcca_res,level,k)(h,c,n,k,__VA_ARGS__)
69 
70 /* Mandatory argument 'level'
71  */
72 #define _hwx_cfcca_res0(h,c,n,k,...) HW_E(HW_EM_AN(k,level))
73 #define _hwx_cfcca_res1(h,c,n,k,v,...) HW_BV(_hwx_cfcca_res1,ccares_,v,h,c,n)(h,c,n,__VA_ARGS__) // PUSH
74 #define _hwx_cfcca_res10(v,...) HW_E(HW_EM_VAL(v,level,(frozen, set_on_match, clear_on_match, \
75  toggle_on_match, low, high, \
76  clear_on_match_up_set_on_match_down, \
77  set_on_match_up_clear_on_match_down))) HW_EAT // POP
78 #define _hwx_cfcca_res1_(v,h,c,n) h##_write(c,oc##n##m,v); _hwx_cfcca_coe // POP
79 #define _hwx_cfcca_res11(v,h,c,n) h##_write(c,oc##n##m,v); _hwx_cfcca_coe // POP
80 
81 
82 #define _hw_ccares_frozen , 0
83 #define _hw_ccares_set_on_match , 1
84 #define _hw_ccares_clear_on_match , 2
85 #define _hw_ccares_toggle_on_match , 3
86 #define _hw_ccares_low , 4
87 #define _hw_ccares_high , 5
88 #define _hw_ccares_clear_on_match_up_set_on_match_down , 6
89 #define _hw_ccares_set_on_match_up_clear_on_match_down , 7
90 
91 /* Optionnal argument 'clear_on_etr'
92  */
93 #define _hw_is_clear_on_etr_clear_on_etr , 1
94 
95 #define _hwx_cfcca_coe(h,c,n,k,...) HW_BW(_hwx_cfcca_coe,clear_on_etr,k)(h,c,n,k,__VA_ARGS__)
96 #define _hwx_cfcca_coe0(h,c,n,k,...) HW_BW(_hwx_cfcca_lat,latch,k)(h,c,n,k,__VA_ARGS__)
97 #define _hwx_cfcca_coe1(h,c,n,k,v,...) HW_BV(_hwx_cfcca_coe1,state_,v,h,c,n)(h,c,n,__VA_ARGS__)//PUSH
98 #define _hwx_cfcca_coe10(v,...) HW_E(HW_EM_ST(v)) HW_EAT
99 #define _hwx_cfcca_coe1_(v,h,c,n) h##_write(c,oc##n##ce,v); _hwx_cfcca_lat//POP
100 #define _hwx_cfcca_coe11(v,h,c,n) h##_write(c,oc##n##ce,v); _hwx_cfcca_lat//POP
101 
102 
103 /* Optionnal argument 'latch'
104  */
105 #define _hwx_cfcca_lat(h,c,n,k,...) HW_BW(_hwx_cfcca_lat,k,latch)(h,c,n,k,__VA_ARGS__)
106 #define _hwx_cfcca_lat0(h,c,n,k,...) HW_BW(_hwx_cfcca_fst,k,fast)(h,c,n,k,__VA_ARGS__)
107 #define _hwx_cfcca_lat1(h,c,n,k,v,...) HW_BV(_hwx_cfcca_lat1,state_,v,h,c,n)(h,c,n,__VA_ARGS__)
108 #define _hwx_cfcca_lat10(v,...) HW_E(HW_EM_ST(v)) HW_EAT
109 #define _hwx_cfcca_lat1_(v,h,c,n) h##_write(c,oc##n##pe,v); _hwx_cfcca_fst
110 #define _hwx_cfcca_lat11(v,h,c,n) h##_write(c,oc##n##pe,v); _hwx_cfcca_fst
111 
112 
113 /* Optionnal argument 'fast'
114  */
115 #define _hwx_cfcca_fst(h,c,n,k,...) HW_BW(_hwx_cfcca_fst,fast,k)(h,c,n,k,__VA_ARGS__)
116 #define _hwx_cfcca_fst0(h,c,n,k,...) HW_BW(_hwx_cfcca_pol,k,polarity)(h,c,n,k,__VA_ARGS__)
117 #define _hwx_cfcca_fst1(h,c,n,k,v,...) HW_BV(_hwx_cfcca_fst1,state_,v,h,c,n)(h,c,n,__VA_ARGS__)
118 #define _hwx_cfcca_fst10(v,...) HW_E(HW_EM_ST(v)) HW_EAT
119 #define _hwx_cfcca_fst1_(v,h,c,n) h##_write(c,oc##n##fe,r); _hwx_cfcca_pol
120 #define _hwx_cfcca_fst11(v,h,c,n) h##_write(c,oc##n##fe,r); _hwx_cfcca_pol
121 
122 /* Optionnal argument 'polarity'
123  */
124 #define _hwx_cfcca_pol(h,c,n,k,...) HW_BW(_hwx_cfcca_pol,k,polarity)(h,c,n,k,__VA_ARGS__)
125 #define _hwx_cfcca_pol0(h,c,n,k,...) HW_BW(_hwx_cfcca_out,k,output)(h,c,n,k,__VA_ARGS__)
126 #define _hwx_cfcca_pol1(h,c,n,k,v,...) HW_BV(_hwx_cfcca_pol1,ccapol_,v,h,c,n)(h,c,n,__VA_ARGS__)
127 #define _hwx_cfcca_pol10(v,...) HW_E(HW_EM_VAL(v,polarity(normal,reversed))) HW_EAT
128 #define _hwx_cfcca_pol1_(v,h,c,n) h##_write(c,cc##n##p,v); _hwx_cfcca_out
129 #define _hwx_cfcca_pol11(v,h,c,n) h##_write(c,cc##n##p,v); _hwx_cfcca_out
130 
131 
132 #define _hw_ccapol_normal , 0
133 #define _hw_ccapol_reversed , 1
134 
135 /* Mandatory argument 'output'
136  */
137 #define _hwx_cfcca_out(h,c,n,k,...) HW_BW(_hwx_cfcca_out,k,output)(h,c,n,k,__VA_ARGS__)
138 #define _hwx_cfcca_out0(h,c,n,k,...) HW_E(HW_EM_AM(output))
139 #define _hwx_cfcca_out1(h,c,n,k,v,...) HW_BW(_hwx_cfcca_out1,connected,v)(h,c,n,v,__VA_ARGS__)
140 #define _hwx_cfcca_out11(h,c,n,v,...) h##_write(c,cc##n##e,1);
141 #define _hwx_cfcca_out10(h,c,n,v,...) HW_BW(_hwx_cfcca_out2,disconnected,v)(h,c,n,v,__VA_ARGS__)
142 #define _hwx_cfcca_out21(h,c,n,v,...) h##_write(c,cc##n##e,0);
143 #define _hwx_cfcca_out20(h,c,n,v,...) HW_E(HW_EM_VAL(v,output,(connected,disconnected)))
144 
145 
146 #endif /* ifndef hw_configure__cca */