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 <acas...@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.
>>
>

Reply via email to