HWA
Bare metal programming with style
occ_2.h
Go to the documentation of this file.
1 
2 /* This file is part of the HWA project.
3  * Copyright (c) 2012,2015 Christophe Duparquet.
4  * All rights reserved. Read LICENSE.TXT for details.
5  */
6 
36 #define _hw_occ_update_immediately , 0
37 #define _hw_occ_update_after_bottom , 1
38 #define _hw_occ_update_after_top , 2
39 
40 /* , code, COM value
41  */
42 #define _hw_occ_output_disconnected , 0, 0 /* Non-PWM */
43 #define _hw_occ_output_toggle_after_match , 1, 1 /* Non-PWM */
44 #define _hw_occ_output_clear_after_match , 2, 2 /* Non-PWM */
45 #define _hw_occ_output_set_after_match , 3, 3 /* Non-PWM */
46 
47 #define _hw_occ_output_set_at_bottom_clear_after_match , 4, 2 /* Fast PWM */
48 #define _hw_occ_output_clear_at_bottom_set_after_match , 5, 3
49 
50 #define _hw_occ_output_clear_after_match_up_set_after_match_down , 6, 2 /* Phase correct PWM */
51 #define _hw_occ_output_set_after_match_up_clear_after_match_down , 7, 3
52 
53 
54 #define hw_configure__occ , _hw_cfocc
55 
56 #define _hw_cfocc(o,ct,oc,k,...) \
57  do { \
58  HW_B(_hw_cfocc_xoutput_,_hw_is_output_##k)(o,k,__VA_ARGS__,); \
59  }while(0)
60 
61 #define _hw_cfocc_xoutput_0(o,k,...) \
62  HW_E(HW_EM_AN(k,output))
63 #define _hw_cfocc_xoutput_1(o,k,v,...) \
64  HW_B(_hw_cfocc_voutput_,_hw_occ_output_##v)(o,v,__VA_ARGS__)
65 #define _hw_cfocc_voutput_0(o,v,...) \
66  HW_E(HW_EM_VAL(v,output,(disconnected,toggle_after_match,clear_after_match,set_after_match,set_at_bottom_clear_after_match,clear_at_bottom_set_after_match,clear_after_match_up_set_after_match_down,set_after_match_up_clear_after_match_down)))
67 #define _hw_cfocc_voutput_1(o,v,...) \
68  _hw_write(o, com, HW_A2(_hw_occ_output_##v)) HW_EOL(__VA_ARGS__)
69 
70 
101 #define hwa_configure__occ , _hwa_cfocc
102 
103 #define _hwa_cfocc(o,ct,oc,k,...) \
104  do { \
105  HW_B(_hwa_cfocc_kupdate_,_hw_is_update_##k)(ct,oc,k,__VA_ARGS__,); \
106  }while(0)
107 
108 #define _hwa_cfocc_kupdate_0(ct,oc,k,...) \
109  HW_B(_hwa_cfocc_koutput_,_hw_is_output_##k)(ct,oc,k,__VA_ARGS__)
110 
111 #define _hwa_cfocc_kupdate_1(ct,oc,k,v,...) \
112  HW_B(_hwa_cfocc_vupdate_,_hw_occ_update_##v)(ct,oc,v,__VA_ARGS__)
113 #define _hwa_cfocc_vupdate_0(ct,oc,v,...) \
114  HW_E(HW_EM_VAL(v,update,(immediately,after_bottom,after_top)))
115 
116 #define _hwa_cfocc_vupdate_1(ct,oc,v,k,...) \
117  hwa->ct.compare##oc.config.update = HW_A1(_hw_occ_update_##v); \
118  HW_B(_hwa_cfocc_koutput_,_hw_is_output_##k)(ct,oc,k,__VA_ARGS__)
119 
120 /* Optionnal parameter `output`
121  */
122 #define _hwa_cfocc_koutput_0(ct,oc,...) \
123  HW_EOL(__VA_ARGS__)
124 
125 #define _hwa_cfocc_koutput_1(ct,oc,k,v,...) \
126  HW_B(_hwa_cfocc_voutput_,_hw_occ_output_##v)(ct,oc,v,__VA_ARGS__)
127 
128 #define _hwa_cfocc_voutput_0(ct,oc,v,...) \
129  HW_E(HW_EM_VAL(v,output,(disconnected,toggle_after_match,clear_after_match,set_after_match,set_at_bottom_clear_after_match,clear_at_bottom_set_after_match,clear_after_match_up_set_after_match_down,set_after_match_up_clear_after_match_down)))
130 #define _hwa_cfocc_voutput_1(ct,oc,v,...) \
131  hwa->ct.compare##oc.config.output = HW_A1(_hw_occ_output_##v) HW_EOL(__VA_ARGS__)
132 
133 
153 #define hw_write__occ , _hw_write_occ
154 #define _hw_write_occ(o,ct,oc,v,...) _hw_write(ct,ocr##oc,v) HW_EOL(__VA_ARGS__)
155 
156 #define hwa_write__occ , _hwa_write_occ
157 #define _hwa_write_occ(o,ct,oc,v,...) _hwa_write(ct,ocr##oc,v) HW_EOL(__VA_ARGS__)
158 
159 #define hw_read__occ , _hw_read_occ
160 #define _hw_read_occ(o,ct,oc,...) _hw_read(ct,ocr##oc) HW_EOL(__VA_ARGS__)
161 
162 
176 #define hw_trigger__occ , _hw_trigger_occ
177 #define _hw_trigger_occ(o,ct,oc) _hw_write(ct,foc##oc,1)
178 
179 #define hwa_trigger__occ , _hwa_trigger_occ
180 #define _hwa_trigger_occ(o,ct,oc) _hwa_write(ct,foc##oc,1)
181 
182