HWA
Bare metal programming with style
cta_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 
94 #define hwa_configure__cta , _hwa_cfcta
95 
96 /* Mandatory argument `clock`
97  *
98  * Add 2 void arguments to the end of the list so that there are always
99  * 3 arguments following the last non-void argument.
100  */
101 #define _hwa_cfcta(o,a,k,...) \
102  do { HW_B(_hwa_cfcta_kclock_,_hw_is_clock_##k)(o,k,__VA_ARGS__,,) } while(0)
103 
104 #define _hwa_cfcta_kclock_0(o,k,...) HW_E(HW_EM_AN(k,clock))
105 #define _hwa_cfcta_kclock_1(o,k,v,...) HW_B(_hwa_cfcta_vclock_,_hw_c1clk_##v)(o,v,__VA_ARGS__)
106 #define _hwa_cfcta_vclock_0(o,v,...) HW_E(HW_EM_VAL(v,clock,(none,ioclk/8,ioclk/64,ioclk/256,ioclk/1024,external_falling,external_rising)))
107 
108 #define _hwa_cfcta_vclock_1(o,v,k,...) \
109  hwa->o.config.clock = HW_VF(_hw_c1clk_##v); \
110  HW_B(_hwa_cfcta_kmode_,_hw_is_direction_##k)(o,k,__VA_ARGS__)
111 
112 /* Mandatory argument `direction`
113  */
114 #define _hw_cta_direction_up_loop , 1
115 #define _hw_cta_direction_updown_loop , 2
116 
117 #define _hwa_cfcta_kmode_0(o,k,...) HW_E(HW_EM_AN(k,direction))
118 #define _hwa_cfcta_kmode_1(o,k,v,...) HW_B(_hwa_cfcta_vmode_,_hw_cta_direction_##v)(o,v,__VA_ARGS__)
119 #define _hwa_cfcta_vmode_0(o,v,...) HW_E(HW_EM_VAL(v,direction,(up_loop,updown_loop)))
120 #define _hwa_cfcta_vmode_1(o,v,k,...) \
121  hwa->o.config.direction = HW_A1(_hw_cta_direction_##v); \
122  HW_B(_hwa_cfcta_kbottom_,_hw_is_bottom_##k)(o,k,__VA_ARGS__)
123 
124 /* Optionnal argument `bottom`
125  */
126 #define _hwa_cfcta_kbottom_1(o,k,v,...) HW_G2(_hwa_cfcta_vbottom,HW_IS(0,v))(o,v,__VA_ARGS__)
127 #define _hwa_cfcta_vbottom_0(o,v,...) HW_E(HW_EM_VAL(v,bottom,(0)))
128 #define _hwa_cfcta_vbottom_1(o,v,k,...) HW_B(_hwa_cfcta_ktop_,_hw_is_top_##k)(o,k,__VA_ARGS__)
129 #define _hwa_cfcta_kbottom_0(o,k,...) HW_B(_hwa_cfcta_ktop_,_hw_is_top_##k)(o,k,__VA_ARGS__)
130 
131 /* Optionnal argument `top`
132  */
133 #define _hw_cta_top_0xFF , 1
134 #define _hw_cta_top_0x00FF , 1
135 #define _hw_cta_top_255 , 1
136 #define _hw_cta_top_max , 1
137 #define _hw_cta_top_compare0 , 2
138 
139 #define _hwa_cfcta_ktop_1(o,k,v,...) HW_B(_hwa_cfcta_vtop_,_hw_cta_top_##v)(o,v,__VA_ARGS__)
140 #define _hwa_cfcta_vtop_0(o,v,...) HW_E(HW_EM_VAL(v,top,(0xFF,max,compare0)))
141 #define _hwa_cfcta_vtop_1(o,v,k,...) \
142  hwa->o.config.top = HW_A1(_hw_cta_top_##v); \
143  HW_B(_hwa_cfcta_koverflow_,_hw_is_overflow_##k)(o,k,__VA_ARGS__)
144 
145 #define _hwa_cfcta_ktop_0(o,k,...) HW_B(_hwa_cfcta_koverflow_,_hw_is_overflow_##k)(o,k,__VA_ARGS__)
146 
147 /* Optionnal argument `overflow`
148  */
149 #define _hw_cta_overflow_after_bottom , 0
150 #define _hw_cta_overflow_after_top , 1
151 #define _hw_cta_overflow_after_max , 2
152 
153 #define _hwa_cfcta_koverflow_1(o,k,v,...) HW_B(_hwa_cfcta_voverflow_,_hw_cta_overflow_##v)(o,v,__VA_ARGS__)
154 #define _hwa_cfcta_voverflow_0(o,v,...) HW_E(HW_EM_VOAL(v,overflow,(after_bottom,after_top,after_max)))
155 #define _hwa_cfcta_voverflow_1(o,v,...) \
156  if ( hwa->o.config.direction == HW_A1(_hw_cta_direction_up_loop) \
157  && HW_A1(_hw_cta_overflow_##v) == HW_A1(_hw_cta_overflow_after_bottom) ) \
158  HWA_E(HW_EM_VOAL(v,overflow,(after_max,after_top))); \
159  hwa->o.config.overflow = HW_A1(_hw_cta_overflow_##v); HW_EOL(__VA_ARGS__)
160 
161 #define _hwa_cfcta_koverflow_0(o,...) \
162  HW_EOL(__VA_ARGS__)
163 
164 
165 /* Solve and check the configuration of the counter and its compare units.
166  *
167  * Writing code for a HW_INLINE function is more comfortable than for a
168  * function-like macro but functions can not use object names. So, this
169  * function-like macro expands to the HW_INLINE function _hwa_solve_cta() which
170  * uses pointers on objects in the HWA context to compute values to be written
171  * into the registers, stores them into the `solve` structure and returns an
172  * error code that is processed by _hwa_solve__cta() which knows the names of
173  * the objects and then can put computed registers values into the context, even
174  * in the case of external register access, and display accurate error messages.
175  */
176 #define _hwa_solve__cta( o,a ) \
177  do { \
178  uint8_t r = _hwa_solve_cta( &hwa->o, &hwa->o.compare0, &hwa->o.compare1 ); \
179  if ( r == 0 ) { \
180  /* \
181  * Write solved registers \
182  */ \
183  if ( hwa->o.solved.cs != 0xFF ) _hwa_write( o, cs, hwa->o.solved.cs ); \
184  if ( hwa->o.solved.wgm != 0xFF ) _hwa_write( o, wgm, hwa->o.solved.wgm ); \
185  if ( hwa->o.compare0.solved.com != 0xFF ) _hwa_write( o, com0, hwa->o.compare0.solved.com ); \
186  if ( hwa->o.compare1.solved.com != 0xFF ) _hwa_write( o, com1, hwa->o.compare1.solved.com ); \
187  /* \
188  * Configure used compare outputs as i/o outputs \
189  */ \
190  if ( hwa->o.compare0.config.output != 0xFF \
191  && hwa->o.compare0.config.output != HW_A1(_hw_oca_output_disconnected) ) \
192  _hwa( configure, (o,compare0,pin), mode, digital_output ); \
193  if ( hwa->o.compare1.config.output != 0xFF \
194  && hwa->o.compare1.config.output != HW_A1(_hw_oca_output_disconnected) ) \
195  _hwa( configure, (o,compare1,pin), mode, digital_output ); \
196  } \
197  else if ( r == 1 ) \
198  HWA_E(HW_EM_ADOO(update,(o,compare0),(o,compare1))); \
199  else if ( r == 2 ) \
200  HWA_E(HW_EM_XSO(wgm,o)); \
201  else if ( r == 3 ) \
202  HWA_E(HW_EM_COR(o)); \
203  else if ( r == 4 ) \
204  HWA_E(HW_EM_AVOL(mode,compare0, (disconnected, \
205  toggle_after_match, \
206  clear_after_match, \
207  set_after_match))); \
208  else if ( r == 5 ) \
209  HWA_E(HW_EM_AVOL(mode,compare0, (disconnected, \
210  set_at_bottom_clear_after_match, \
211  clear_at_bottom_set_after_match))); \
212  else if ( r == 6 ) \
213  HWA_E(HW_EM_AVOL(mode,compare0, (disconnected, \
214  toggle_after_match, \
215  set_at_bottom_clear_after_match, \
216  clear_at_bottom_set_after_match))); \
217  else if ( r == 7 ) \
218  HWA_E(HW_EM_AVOL(mode,compare0, (disconnected, \
219  clear_after_match_up_set_after_match_down, \
220  set_after_match_up_clear_after_match_down))); \
221  else if ( r == 8 ) \
222  HWA_E(HW_EM_AVOL(mode,compare0, (disconnected, \
223  toggle_after_match, \
224  clear_after_match_up_set_after_match_down, \
225  set_after_match_up_clear_after_match_down))); \
226  else if ( r == 9 ) \
227  HWA_E(HW_EM_AVOL(mode,compare1, (disconnected, \
228  toggle_after_match, \
229  clear_after_match, \
230  set_after_match))); \
231  else if ( r == 10 ) \
232  HWA_E(HW_EM_AVOL(mode,compare1, (disconnected, \
233  set_at_bottom_clear_after_match, \
234  clear_at_bottom_set_after_match))); \
235  else if ( r == 11 ) \
236  HWA_E(HW_EM_AVOL(mode,compare1, (disconnected, \
237  clear_after_match_up_set_after_match_down, \
238  set_after_match_up_clear_after_match_down))); \
239  else if ( r == 12 ) \
240  HWA_E(HW_EM_AOVM(update,o,immediately)); \
241  else if ( r == 13 ) \
242  HWA_E(HW_EM_AOVM(update,o,after_bottom)); \
243  else if ( r == 14 ) \
244  HWA_E(HW_EM_AOVM(update,o,after_top)); \
245  else if ( r == 15 ) \
246  HWA_E(HW_EM_AOVM(overflow,o,after_top)); \
247  else if ( r == 16 ) \
248  HWA_E(HW_EM_AOVM(overflow,o,after_bottom)); \
249  else if ( r == 17 ) \
250  HWA_E(HW_EM_AOVM(overflow,o,after_max)); \
251  else \
252  HWA_E(HW_EM_X(in _hwa_solve__cta: __LINE__)); \
253  }while(0);
254 
255 
256 HW_INLINE uint8_t _hwa_solve_cta ( hwa_cta_t *p, hwa_oca_t *compare0, hwa_oca_t *compare1 )
257 {
258  /* 0xFF == unchanged
259  */
260  p->solved.cs = 0xFF ;
261  p->solved.wgm = 0xFF ;
262  compare0->solved.com = 0xFF ;
263  compare1->solved.com = 0xFF ;
264 
265  if ( p->config.clock == 0xFF )
266  return 0 ;
267 
268  /* Clock selection
269  */
270  p->solved.cs = p->config.clock ;
271 
272  /* Default config for top
273  */
274  if ( p->config.top == 0xFF )
275  p->config.top = HW_A1(_hw_cta_top_max);
276 
277  /* Default config for overflow
278  */
279  uint8_t overflow = p->config.overflow ;
280  if ( overflow == 0xFF && p->config.top == HW_A1(_hw_cta_top_compare0) ) {
281  if ( p->config.direction == HW_A1(_hw_cta_direction_up_loop) )
282  overflow = HW_A1(_hw_cta_overflow_after_top);
283  else /* if ( p->config.direction == HW_A1(_hw_cta_direction_up_loop) ) */
284  overflow = HW_A1(_hw_cta_overflow_after_bottom);
285  }
286 
287  /* Compare update setting
288  */
289  uint8_t compare_update = 0xFF ;
290  if ( compare0->config.update != 0xFF && compare1->config.update != 0xFF
291  && compare0->config.update != compare1->config.update )
292  return 1 ; //("`update` must be the same for both compare units.");
293 
294  compare_update = compare0->config.update ;
295 
296 
297  /* Mode WGM Operation COUNTMODE TOP UPD OVF OCA OCB
298  *
299  * 0 000 Normal LOOP_UP 0xFF IMM MAX+1 DIS,ToM,CoM,SoM DIS,ToM,CoM,SoM
300  * 2 010 CTC LOOP_UP OCRA IMM MAX+1 DIS,ToM,CoM,SoM DIS,ToM,CoM,SoM
301  *
302  * 3 011 Fast PWM LOOP_UP 0xFF BOT MAX DIS,SaBCoM,CaBSoM DIS,SaBCoM,CaBSoM
303  * 7 111 Fast PWM LOOP_UP OCRA BOT TOP DIS,ToM,CoMSaB,SoMCaB DIS,SaBCoM,CaBSoM
304  *
305  * 1 001 PWM, PhC LOOP_UPDOWN 0xFF TOP BOT+1 DIS,CmuSmd,SmuCmd DIS,CmuSmd,SmuCmd
306  * 5 101 PWM, PhC LOOP_UPDOWN OCRA TOP BOT+1 DIS,ToM,CmuSmd,SmuCmd DIS,CmuSmd,SmuCmd
307  *
308  * 4 100 *Reserved*
309  * 6 110 *Reserved*
310  */
311 
312  /* Determine WGM
313  */
314  uint8_t wgm = 0xFF ;
315  if ( p->config.direction == HW_A1(_hw_cta_direction_up_loop) ) {
316  if ( p->config.top == HW_A1(_hw_cta_top_0xFF) ) {
317  if ( compare_update == HW_A1(_hw_oca_update_after_bottom)
318  || compare0->config.output == HW_A1(_hw_oca_output_clear_at_bottom_set_after_match)
319  || compare0->config.output == HW_A1(_hw_oca_output_set_at_bottom_clear_after_match)
320  || compare1->config.output == HW_A1(_hw_oca_output_clear_at_bottom_set_after_match)
321  || compare1->config.output == HW_A1(_hw_oca_output_set_at_bottom_clear_after_match))
322  wgm = 3 ;
323  else
324  wgm = 0 ;
325  }
326  else /* top == ocra */ {
327  /*
328  * FIXME: a change of pin from one of the 4 modes below to
329  * 'disconnected' causes a useless modification of wgm from 7 to 2. As
330  * WGM2 is not in the same register as WGM1:0, this generates useless
331  * code.
332  */
333  if ( compare_update == HW_A1(_hw_oca_update_after_bottom )
334  || overflow == HW_A1(_hw_cta_overflow_after_top)
335  || compare0->config.output == HW_A1(_hw_oca_output_clear_at_bottom_set_after_match)
336  || compare0->config.output == HW_A1(_hw_oca_output_set_at_bottom_clear_after_match)
337  || compare1->config.output == HW_A1(_hw_oca_output_clear_at_bottom_set_after_match)
338  || compare1->config.output == HW_A1(_hw_oca_output_set_at_bottom_clear_after_match))
339  wgm = 7 ;
340  else
341  wgm = 2 ;
342  }
343  }
344  else /* direction == updown_loop */ {
345  if ( p->config.top == HW_A1(_hw_cta_top_0xFF) )
346  wgm = 1 ;
347  else /* top == ocra */
348  wgm = 5 ;
349  }
350 
351  if (wgm == 0xFF) {
352  // ("WGM value could not be solved for _cta class counter.");
353  return 2 ;
354  }
355 
356  p->solved.wgm = wgm ;
357 
358 
359  /* Solve the configuration of compare output A
360  */
361  if ( compare0->config.output != 0xFF ) {
362 
363  uint8_t mode = 0xFF ;
364 
365  if ( compare0->config.output == HW_A1(_hw_oca_output_disconnected) )
366  mode = 0 ;
367  else if ( compare0->config.output == HW_A1(_hw_oca_output_toggle_after_match) )
368  mode = 1 ;
369  else if ( compare0->config.output == HW_A1(_hw_oca_output_clear_after_match)
370  || compare0->config.output == HW_A1(_hw_oca_output_set_at_bottom_clear_after_match)
371  || compare0->config.output == HW_A1(_hw_oca_output_clear_after_match_up_set_after_match_down) )
372  mode = 2 ;
373  else
374  mode = 3 ;
375 
376  compare0->solved.com = mode ;
377  }
378 
379 
380  /* Solve the configuration of compare output B
381  */
382  if ( compare1->config.output != 0xFF ) {
383 
384  uint8_t mode = 0xFF ;
385 
386  if ( compare1->config.output == HW_A1(_hw_oca_output_disconnected) )
387  mode = 0 ;
388  else if ( compare1->config.output == HW_A1(_hw_oca_output_toggle_after_match) )
389  mode = 1 ;
390  else if ( compare1->config.output == HW_A1(_hw_oca_output_clear_after_match)
391  || compare1->config.output == HW_A1(_hw_oca_output_set_at_bottom_clear_after_match)
392  || compare1->config.output == HW_A1(_hw_oca_output_clear_after_match_up_set_after_match_down) )
393  mode = 2 ;
394  else
395  mode = 3 ;
396 
397  compare1->solved.com = mode ;
398  }
399 
400  /* Check the validity of the configuration of compare output A
401  */
402  if ( compare0->config.output != 0xFF ) {
403  if ( wgm==0 || wgm==2 ) {
404  if ( compare0->config.output != HW_A1(_hw_oca_output_disconnected)
405  && compare0->config.output != HW_A1(_hw_oca_output_toggle_after_match)
406  && compare0->config.output != HW_A1(_hw_oca_output_clear_after_match)
407  && compare0->config.output != HW_A1(_hw_oca_output_set_after_match))
408  return 4 ;
409  /* ("compare output A of class _cta counter mode must be " */
410  /* "'disconnected', 'toggle_after_match', 'clear_after_match', or " */
411  /* "'set_after_match'."); */
412 
413  }
414  else if ( wgm==3 ) {
415  if ( compare0->config.output != HW_A1(_hw_oca_output_disconnected)
416  && compare0->config.output != HW_A1(_hw_oca_output_set_at_bottom_clear_after_match)
417  && compare0->config.output != HW_A1(_hw_oca_output_clear_at_bottom_set_after_match) )
418  return 5 ;
419  /* ("compare output A of class _cta counter mode must be " */
420  /* "'disconnected', 'set_at_bottom_clear_after_match', or " */
421  /* "'clear_at_bottom_set_after_match'."); */
422  }
423  else if ( wgm==7 ) {
424  if ( compare0->config.output != HW_A1(_hw_oca_output_disconnected)
425  && compare0->config.output != HW_A1(_hw_oca_output_toggle_after_match)
426  && compare0->config.output != HW_A1(_hw_oca_output_set_at_bottom_clear_after_match)
427  && compare0->config.output != HW_A1(_hw_oca_output_clear_at_bottom_set_after_match) )
428  return 6 ;
429  /* ("compare output A of class _cta counter mode must be " */
430  /* "'disconnected', 'toggle_after_match', " */
431  /* "'set_at_bottom_clear_after_match', or " */
432  /* "'clear_at_bottom_set_after_match'."); */
433  }
434  else if ( wgm==1 ) {
435  if ( compare0->config.output != HW_A1(_hw_oca_output_disconnected)
436  && compare0->config.output != HW_A1(_hw_oca_output_clear_after_match_up_set_after_match_down)
437  && compare0->config.output != HW_A1(_hw_oca_output_set_after_match_up_clear_after_match_down) )
438  /* ("compare output A of class _cta counter mode must be " */
439  /* "'disconnected', 'clear_after_match_up_set_after_match_down', " */
440  /* "or 'set_after_match_up_clear_after_match_down'."); */
441  return 7 ;
442  }
443  else if ( wgm==5 ) {
444  if ( compare0->config.output != HW_A1(_hw_oca_output_disconnected)
445  && compare0->config.output != HW_A1(_hw_oca_output_toggle_after_match)
446  && compare0->config.output != HW_A1(_hw_oca_output_clear_after_match_up_set_after_match_down)
447  && compare0->config.output != HW_A1(_hw_oca_output_set_after_match_up_clear_after_match_down) )
448  /* ("compare output A of class _cta counter mode must be " */
449  /* "'disconnected', 'toggle_after_match', " */
450  /* "'clear_after_match_up_set_after_match_down', " */
451  /* "or 'set_after_match_up_clear_after_match_down'."); */
452  return 8 ;
453  }
454  }
455 
456  /* Check the validity of the configuration of compare output B
457  */
458  if ( compare1->config.output != 0xFF ) {
459  if ( wgm==0 || wgm==2 ) {
460  if ( compare1->config.output != HW_A1(_hw_oca_output_disconnected)
461  && compare1->config.output != HW_A1(_hw_oca_output_toggle_after_match)
462  && compare1->config.output != HW_A1(_hw_oca_output_clear_after_match)
463  && compare1->config.output != HW_A1(_hw_oca_output_set_after_match))
464  /* ("compare output B of class _cta counter mode must be " */
465  /* "'disconnected', 'toggle_after_match', 'clear_after_match', or " */
466  /* "'set_after_match'."); */
467  return 9 ;
468  }
469  else if ( wgm==3 || wgm==7 ) {
470  if ( compare1->config.output != HW_A1(_hw_oca_output_disconnected)
471  && compare1->config.output != HW_A1(_hw_oca_output_set_at_bottom_clear_after_match)
472  && compare1->config.output != HW_A1(_hw_oca_output_clear_at_bottom_set_after_match) )
473  /* ("compare output B of class _cta counter mode must be " */
474  /* "'disconnected', 'set_at_bottom_clear_after_match', or " */
475  /* "'clear_at_bottom_set_after_match'."); */
476  return 10 ;
477  }
478  else if ( wgm==1 || wgm==5 ) {
479  if ( compare1->config.output != HW_A1(_hw_oca_output_disconnected)
480  && compare1->config.output != HW_A1(_hw_oca_output_clear_after_match_up_set_after_match_down)
481  && compare1->config.output != HW_A1(_hw_oca_output_set_after_match_up_clear_after_match_down) )
482  /* ("compare output B of class _cta counter mode must be " */
483  /* "'disconnected', 'clear_after_match_up_set_after_match_down', " */
484  /* "or 'set_after_match_up_clear_after_match_down'."); */
485  return 11 ;
486  }
487  }
488 
489  /* Check the validity of the configuration of update
490  */
491  if ( compare_update != 0xFF ) {
492  if ( wgm==0 || wgm==2 ) {
493  if ( compare_update != HW_A1(_hw_oca_update_immediately) )
494  /* ("optionnal parameter 'update' of class _cta counter must be "\ */
495  /* "'immediately'."); */
496  return 12 ;
497  }
498  else if ( wgm==3 || wgm==7 ) {
499  if ( compare_update != HW_A1(_hw_oca_update_after_bottom) )
500  /* ("optionnal parameter 'update' of class _cta counter must be " */
501  /* "'after_bottom'."); */
502  return 13 ;
503  }
504  else
505  if( compare_update != HW_A1(_hw_oca_update_after_top) )
506  /* ("optionnal parameter 'update' of class _cta counter must be " */
507  /* "'after_top'."); */
508  return 14 ;
509  }
510 
511  /* Check the validity of the configuration of overflow
512  */
513  if ( overflow != 0xFF ) {
514  if ( wgm==7 ) {
515  if ( overflow != HW_A1(_hw_cta_overflow_after_top) )
516  /* ("optionnal parameter 'overflow' of class _cta counter must be " */
517  /* "'after_top'."); */
518  return 15 ;
519  }
520  else if ( (wgm==1 || wgm==5) ) {
521  if ( overflow != HW_A1(_hw_cta_overflow_after_bottom) )
522  /* ("optionnal parameter 'overflow' of class _cta counter must be " */
523  /* "'after_bottom'."); */
524  return 16 ;
525  }
526  else if ( overflow != HW_A1(_hw_cta_overflow_after_max) )
527  /* ("optionnal parameter 'overflow' of class _cta counter must be " */
528  /* "'after_max'."); */
529  return 17 ;
530  }
531 
532  return 0 ;
533 }
534 
535 
555 #define hw_read__cta , _hw_read_cta
556 #define _hw_read_cta(o,a,...) _hw_read(o,count) HW_EOL(__VA_ARGS__)
557 
558 #define hw_write__cta , _hw_write_cta
559 #define _hw_write_cta(o,a,v,...) _hw_write(o,count,v) HW_EOL(__VA_ARGS__)
560 
561 #define hwa_write__cta , _hwa_write_cta
562 #define _hwa_write_cta(o,a,v,...) _hwa_write(o,count,v) HW_EOL(__VA_ARGS__)
563 
564 
574 #define hw_clear__cta , _hw_clear_cta
575 #define _hw_clear_cta(o,a,...) _hw_write(o,count,0) HW_EOL(__VA_ARGS__)
576 
577 
578 /*******************************************************************************
579  * *
580  * Context management *
581  * *
582  *******************************************************************************/
583 
584 #define _hwa_setup__cta(o,a) \
585  /* _hwa_setup_r( o, gtccr); */ \
586  _hwa_setup_r( o, ccra); \
587  _hwa_setup_r( o, ccrb); \
588  _hwa_setup_r( o, count); \
589  _hwa_setup_r( o, imsk); \
590  _hwa_setup_r( o, ifr); \
591  _hwa_setup_r( o, ocr0); \
592  _hwa_setup_r( o, ocr1); \
593  hwa->o.config.clock = 0xFF; \
594  hwa->o.config.direction = 0xFF; \
595  hwa->o.config.top = 0xFF; \
596  hwa->o.config.overflow = 0xFF; \
597  hwa->o.compare0.config.update = 0xFF ; \
598  hwa->o.compare0.config.output = 0xFF ; \
599  hwa->o.compare1.config.update = 0xFF ; \
600  hwa->o.compare1.config.output = 0xFF
601 
602 
603 #define _hwa_init__cta(o,a) \
604  /* _hwa_init_r( o, gtccr, 0x00 ); */ \
605  _hwa_init_r( o, ccra, 0 ); \
606  _hwa_init_r( o, ccrb, 0 ); \
607  _hwa_init_r( o, count, 0 ); \
608  _hwa_init_r( o, imsk, 0 ); \
609  _hwa_init_r( o, ifr, 0 ); \
610  _hwa_init_r( o, ocr0, 0 ); \
611  _hwa_init_r( o, ocr1, 0 )
612 
613 
614 #define _hwa_commit__cta(o,a) \
615  /* _hwa_commit_r( o, gtccr); */ \
616  _hwa_commit_r( o, ccra); \
617  _hwa_commit_r( o, ccrb); \
618  _hwa_commit_r( o, count); \
619  _hwa_commit_r( o, ocr0 ); \
620  _hwa_commit_r( o, ocr1 ); \
621  _hwa_commit_r( o, imsk); \
622  _hwa_commit_r( o, ifr)
623 
624 
HW_A1
#define HW_A1(...)
Element a1 of the list a0,a1,...
Definition: hwa_macros.h:36