avr-libc-corelib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Avr-libc-corelib] Library Design Questions


From: Frédéric Nadeau
Subject: RE: [Avr-libc-corelib] Library Design Questions
Date: Mon, 21 Sep 2009 14:22:05 -0400

>               5. Do we have a one-size fits all approach that
> dynamically adds support for multiple SPI buses for example,
> or are there several different flavors?

My opinion is the following:

use a API like this

int spi_init(a,b,c,d)

Have two or more function like:

int spi_single_init(b,c,d)
and
int spi_multi_init(a,b,c,d)

Where argument 'a' is kind of port select

in the spi.h have something like

#if device support more than 1 SPI
#define spi_init(a,b,c,d) spi_multi_init(a,b,c,d)
#else
define spi_init(a,b,c,d) spi_single_init(b,c,d)

The use is of course not aware of the spi_single/multi. When used
properly, this could allow code to be ported from a device with one
SPI to a device with two SPI in a snip.

Of course same would apply to USART, USI and TWI
-- 
Frédéric Nadeau ing. jr




reply via email to

[Prev in Thread] Current Thread [Next in Thread]