[En-Nut-Discussion] RFC: New driver interface for TWI, I2C and others
Ulrich Prinz
uprinz2 at netscape.net
Thu May 5 21:02:39 CEST 2011
Hihi...
My fault... or at least a bit imprecise.
stm32_twi.h says
#ifndef DEF_TWIBUS
#ifdef I2CBUS1_AS_DEFAULT
#define DEF_TWIBUS Stm32TwiBus_1
#else
#define DEF_TWIBUS Stm32TwiBus_2
#endif
#endif
So if you like to have the other one as default use this:
#define DEF_TWIBUS Stm32TwiBus_2
before stm32_twi.h is included.
I'll think I change this in nutconf to be more precise...
Ah, ok, that is the reason for the inconvenience:
Nutconf cannot have more subdirectories of features like
options = {
options = {
...
}
}
So I cannot give a selection like
I2C Bus
Select Default I2C Bus
I2C Bus 1
options
I2C Bus 2
options
So I added it as first selectable option into the different i2c of the
STM32.
I2C Bus 1
select this as defualt
option 2
option 3
I2C Bus 2
select this as defualt
option 2
option 3
In the USART it is done differently as there is a debug uart as a
separate device what simply lets you choose one of the x USARTs the STM
has.
If you like to use the API directly, use
NutRegisterTwiBus( &Stm32TwiBus_2, 0);
And have a look for the other NutTwixxx functions in stm32_twi.c.
Calling is identical to Twxxx functions but you must add the Bus as
first parameter. So
TwMasterRegRead( chip, addr, addrl, buf, len, tout);
is now
NutTwMasterRegRead( bus, chip, addr, addrl, buf, len, tout);
Thats all.
Ulrich
More information about the En-Nut-Discussion
mailing list