[En-Nut-Discussion] Where to define PIN mapping

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Tue Feb 19 18:35:56 CET 2013


>>>>> "Harald" == Harald Kipp <harald.kipp at egnite.de> writes:

    Harald> On 19.02.2013 14:09, Uwe Bonnes wrote: I'm not sure if I got
    Harald> you. Even early AT91 devices allow to have certain device at
    Harald> alternate pins, this is nothing new.
    >>  So probably arch/arm/dev/atmel/i2cbus_at91.c was a bad example I
    >> looked at?  The datasheet has no alternate pins for I2C, at least I
    >> see no such pins, and I also see no way to choose the pins.

    Harald> Well, OK. I do not know any member of the AT91 family with
    Harald> alternate I2C/UART/etc. pins. But almost all AT91 devices have
    Harald> configurable SPI _hardware: chip selects. Quite often clock and
    Harald> PWM outputs are provided at alternative pins.


    Harald> The board.conf files are responsible to define the pins actually
    Harald> used on a specific board layout.
    >>  Probably we don't have a common understanding. I mean pins like the
    >> UART TX pin. For the STM32 you may use up to at least 3 different
    >> pins for this function . The usart driver needs to know which pin to
    >> connect internally to the uart device. So if board.h would define the
    >> usage, we would again need board.h at library compile time. I am
    >> stuck.

    Harald> To better understand the problem: Why can't this be defined in
    Harald> the board.conf file?

Look e.g. at conf/arch/arm.dev and "LCD_CLK_PIO_ID" and friends. Assigning a
fitting pio_id to LCD_CLK_PIO_ID is what I call (device) pin mapping. The
mapped values is used in arch/arm/dev/atmel/st7036_at91.c like
#if LCD_CLK_PIO_ID == PIOA_ID
#define LCD_CLK_SET() { outr(PIOA_PER, LCD_CLK); outr(PIOA_SODR, LCD_CLK); outr(PIOA_OER, LCD_CLK); }
#define LCD_CLK_CLR() { outr(PIOA_PER, LCD_CLK); outr(PIOA_CODR, LCD_CLK); outr(PIOA_OER, LCD_CLK); }
#elif LCD_CLK_PIO_ID == PIOB_ID
...
#else /* LCD_CLK_BIT */
#define LCD_CLK_SET()
#define LCD_CLK_CLR()
#endif

So to compile st7036_at91.c for the library, you need to know LCD_CLK_PIO_ID
or otherweise the driver compiled fine but is defunct. If you compile with
one value from the configuration and later the user reassigns LCD_CLK_PIO_ID
to another pio_id in board.h, it doesn't change anything.

Bye
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------


More information about the En-Nut-Discussion mailing list