You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Bernd Walter <ti...@cicely7.cicely.de> on 2022/09/15 10:33:13 UTC

RP2040 SPI in common?

A recent change (e8f4d74ad0c33389c1094c3ca6c10a6336d8fbe7) moved the
individual rp2040_spi.c into the common directory.
How can a board with different chip select GPIO usage have a board
specific setup?
I don't see a way to disable the common implementation.

-- 
B.Walter <be...@bwct.de> https://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.

Re: RP2040 SPI in common?

Posted by Bernd Walter <ti...@cicely7.cicely.de>.
On Thu, Sep 15, 2022 at 09:48:42AM -0300, Alan Carvalho de Assis wrote:
> Actually you can include support for multiple devices of same type in
> the same SPI bus:
> 
> #if defined(LCDxyz) || defined(LCDwku) ...
>   switch (devid)
>     {
>     case SPIDEV_DISPLAY(0):
>       /* Set the GPIO low to select and high to de-select */
> 
>       rp2040_gpio_put(BOARD_RP2040_SPI0_DISPLAY_CS0, !selected);
>       break;

Ok - I see where this is going.
But is it really reasonable to add such a whole bunch of generic code?
I'm used to add it in my own board code, if I have additional devices.

-- 
B.Walter <be...@bwct.de> https://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.

Re: RP2040 SPI in common?

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Actually you can include support for multiple devices of same type in
the same SPI bus:

#if defined(LCDxyz) || defined(LCDwku) ...
  switch (devid)
    {
    case SPIDEV_DISPLAY(0):
      /* Set the GPIO low to select and high to de-select */

      rp2040_gpio_put(BOARD_RP2040_SPI0_DISPLAY_CS0, !selected);
      break;

    case SPIDEV_DISPLAY(1):
      /* Set the GPIO low to select and high to de-select */

      rp2040_gpio_put(BOARD_RP2040_SPI0_DISPLAY_CS1, !selected);
      break;

    case SPIDEV_DISPLAY(2):
      /* Set the GPIO low to select and high to de-select */

      rp2040_gpio_put(BOARD_RP2040_SPI0_DISPLAY_CS2, !selected);
      break;

    case SPIDEV_DISPLAY(3):
      /* Set the GPIO low to select and high to de-select */

      rp2040_gpio_put(BOARD_RP2040_SPI0_DISPLAY_CS3, !selected);
      break;
    }
#endif

Maybe we could implement this solution for other boards that have
common board directory.

BR,

Alan

On 9/15/22, Alan Carvalho de Assis <ac...@gmail.com> wrote:
> Hi Bernd,
>
> Yes, I think the current implementation is fixed to allow only 1 CS
> per RP2040 SPI.
>
> That is not ideal (read: "incorrect").
>
> It is possible to have the rp2040_spi.c as a common boards file, but
> the CS should be extended, i.e.:
>
> #if defined(LCDxyz) || defined(LCDwku) ...
>   rp2040_gpio_put(BOARD_RP2040_SPI0_DISPLAY_CS, !selected);
> #endif
>
> #if defined(AUDIOCODECtqj) || defined(AUDIOCODECcnp) ...
>   rp2040_gpio_put(BOARD_RP2040_SPI0_AUDIO_CS, !selected);
> #endif
>
> etc...
>
> This way the common rp2040_spi.c file could support many more devices
> than current implementation.
>
> BR,
>
> Alan
>
> On 9/15/22, Bernd Walter <ti...@cicely7.cicely.de> wrote:
>> A recent change (e8f4d74ad0c33389c1094c3ca6c10a6336d8fbe7) moved the
>> individual rp2040_spi.c into the common directory.
>> How can a board with different chip select GPIO usage have a board
>> specific setup?
>> I don't see a way to disable the common implementation.
>>
>> --
>> B.Walter <be...@bwct.de> https://www.bwct.de
>> Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
>>
>

Re: RP2040 SPI in common?

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Bernd,

Yes, I think the current implementation is fixed to allow only 1 CS
per RP2040 SPI.

That is not ideal (read: "incorrect").

It is possible to have the rp2040_spi.c as a common boards file, but
the CS should be extended, i.e.:

#if defined(LCDxyz) || defined(LCDwku) ...
  rp2040_gpio_put(BOARD_RP2040_SPI0_DISPLAY_CS, !selected);
#endif

#if defined(AUDIOCODECtqj) || defined(AUDIOCODECcnp) ...
  rp2040_gpio_put(BOARD_RP2040_SPI0_AUDIO_CS, !selected);
#endif

etc...

This way the common rp2040_spi.c file could support many more devices
than current implementation.

BR,

Alan

On 9/15/22, Bernd Walter <ti...@cicely7.cicely.de> wrote:
> A recent change (e8f4d74ad0c33389c1094c3ca6c10a6336d8fbe7) moved the
> individual rp2040_spi.c into the common directory.
> How can a board with different chip select GPIO usage have a board
> specific setup?
> I don't see a way to disable the common implementation.
>
> --
> B.Walter <be...@bwct.de> https://www.bwct.de
> Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
>