pimoroni / st7735-python

Python library to control an ST7735 TFT LCD display. Allows simple drawing on the display without installing a kernel module.
MIT License
61 stars 29 forks source link

SPI MISO conflicts with data/command (ROCK 5B and maybe other boards) #32

Open Gadgetoid opened 1 year ago

Gadgetoid commented 1 year ago

After much tinkering I came up with this dtoverlay which configures ROCK 5Bs spi0-m2-cs1 to skip over the MISO pin, so it can be used for data/command:

/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&spi0>;

        __overlay__ {
            status = "okay";
            #address-cells = <1>;
            #size-cells = <0>;
            pinctrl-names = "default";
            pinctrl-0 = <&spi0m2_cs1 &spi0m2_nomiso_pins>;
            max-freq = <50000000>;

            spidev@1 {
                compatible = "rockchip,spidev";
                status = "okay";
                reg = <1>;
                spi-max-frequency = <50000000>;
            };
        };
    };
    fragment@1 {
        target = <&pinctrl>;

        __overlay__ {

            spi0 {

                spi0m2_nomiso_pins: spi0m2-nomiso-pins {
                    rockchip,pins =
                        /* spi0_clk_m2 */
                        <1 11 8 &pcfg_pull_up_drv_level_6>,
                        /* spi0_miso_m2 */
                        /*<1 9 8 &pcfg_pull_up_drv_level_6>,*/
                        /* spi0_mosi_m2 */
                        <1 10 8 &pcfg_pull_up_drv_level_6>;
                };
            };
        };
    };
};

Install with: sudo armbian-add-overlay rk3588-spi0-m2-cs1-nomiso-spidev.dts

Something like this might be needed for Raspberry Pi 5, so I figured out the dtoverlay magic on ROCK while I was waiting for the SPI to be fixed...