[En-Nut-Discussion] AVR ADC sample fails

Ole Reinhardt ole.reinhardt at embedded-it.de
Tue Jul 7 17:08:38 CEST 2009


Hi!

> > But I'd still vote for 
> > 
> > #define ADC_BUF_TAIL (ADC_BUF_SIZE+1)
> > [...]
> > buf[ADC_BUF_TAIL] = 0;
> > 
> > instead of using 
> > 
> > buf[ADC_BUF_SIZE+1] = 0;
> 
> The disadvantage is, that something is hidden. What's the advantage then?

The advantage is that you know what this array index is used for. On the
other hand it's no good idea to save the head and tail pointer in the
buffer at all. It better should be solved as seperate variables. But
this design allows you to just pass the buffer array to a function
instead of several variables. Yes, we should better put all this stuff
in a struct.

Ole 


-- 
 _____________________________________________________________
|                                                             |
| Embedded-IT                                                 |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt at embedded-it.de |
| Germany              Web:         http://www.embedded-it.de |
|_____________________________________________________________|



More information about the En-Nut-Discussion mailing list