SPI on Beaglebone black running glued

103 views
Skip to first unread message

Bjørn Spockeli

unread,
Jan 20, 2015, 11:10:58 AM1/20/15
to lsts-to...@googlegroups.com

Hi,

I want to enable the SPI interfaces on the beaglebone and I have looking into the changes that would have to be made to the device tree file. See below


+    /* SPI0 /*
+    bb_spi0_pins: pinmux_bb_spi0_pins {
+       pinctrl-single,pins = <
+            0x150 0x30      /* spi0_sclk.spi0_sclk,     INPUT_PULLUP  | MODE0 */
+            0x154 0x30      /* spi0_d0.spi0_d0,         INPUT_PULLUP  | MODE0 */
+             0x158 0x10      /* spi0_d1.spi0_d1,         OUTPUT_PULLUP | MODE0 */
+             0x15c 0x10      /* spi0_cs0.spi0_cs0,       OUTPUT_PULLUP | MODE0 */
+         >;
+     };
+
+    /* SPI1. */
+    bb_spi1_pins: pinmux_bb_spi1_pins {
+        pinctrl-single,pins = <
+              0x190 0x33      /* mcasp0_aclkx.spi1_sclk,      INPUT_PULLUP  | MODE3 */
+              0x194 0x33      /* mcasp0_fsx.spi1_d0,          INPUT_PULLUP  | MODE3 */
+             0x198 0x13      /* mcasp0_axr0.spi1_d1,         OUTPUT_PULLUP | MODE3 */
+           0x19c 0x13      /* mcasp0_ahclkr.spi1_cs0,      OUTPUT_PULLUP | MODE3 */
+        >;
+    };
+};
+
+/* Enable SPI0. */
+&spi0 {         
+    status          = "okay";
+   pinctrl-names   = "default";
+   pinctrl-0       = <&bb_spi0_pins>;
+};
+
+/* Enable SPI1. */
+&spi1 {         
+    status          = "okay";
+   pinctrl-names   = "default";
+   pinctrl-0       = <&bb_spi1_pins>;
+};

Does this look right?
It is based the .dts for http://blacklib.yigityuce.com/ that i plan to use to communicate with a IMU over SPI. I have appended the  original .dts file below.


/dts-v1/;
/plugin/;

/ {
    compatible      = "ti,beaglebone", "ti,beaglebone-black";

    part-number     = "BLACKLIB-SPI1";
    version         = "00A0";

    exclusive-use   =
        "P9.31",    /* spi1_sclk */
        "P9.29",    /* spi1_d0 */
        "P9.30",    /* spi1_d1 */
        "P9.28",    /* spi1_cs0 */
        // "P9.42",    /* spi1_cs1 */
        "spi1";     /* the hardware ip uses */

    fragment@0 {
        target      = <&am33xx_pinmux>;
        __overlay__ {
            bb_spi1_pins: pinmux_bb_spi1_pins {
                pinctrl-single,pins = <
                    0x190 0x33      /* mcasp0_aclkx.spi1_sclk,      INPUT_PULLUP  | MODE3 */
                    0x194 0x33      /* mcasp0_fsx.spi1_d0,          INPUT_PULLUP  | MODE3 */
                    0x198 0x13      /* mcasp0_axr0.spi1_d1,         OUTPUT_PULLUP | MODE3 */
                    0x19c 0x13      /* mcasp0_ahclkr.spi1_cs0,      OUTPUT_PULLUP | MODE3 */
                    // 0x164 0x12   /* eCAP0_in_PWM0_out.spi1_cs1   OUTPUT_PULLUP | MODE2 */
                >;
            };
        };
    };

    fragment@1 {
        target = <&spi1>;
        __overlay__ {
            #address-cells  = <1>;
            #size-cells     = <0>;

            status          = "okay";
            pinctrl-names   = "default";
            pinctrl-0       = <&bb_spi1_pins>;   

            spidev@0{
                compatible          = "spidev";
                reg                 = <0>;
                spi-max-frequency   = <24000000>;
            };
            spidev@1{
                compatible          = "spidev";
                reg                 = <1>;
                spi-max-frequency   = <24000000>;
            };           
        };
    };
};



Ricardo Martins

unread,
Jan 27, 2015, 4:56:57 PM1/27/15
to Bjørn Spockeli, lsts-to...@googlegroups.com
Hi Bjørn

It looks good if you are going to communicate with the IMU in kernel-space. If you are going to do it in user-space then I think you need to add spidev compatible sections to your &spi* sections. Is the IMU an ADIS164XX ? If so linux 3.14.16 already has kernel-space drivers for it.

--
You received this message because you are subscribed to the Google Groups "LSTS Toolchain" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lsts-toolchai...@googlegroups.com.
Visit this group at http://groups.google.com/group/lsts-toolchain.
To view this discussion on the web visit https://groups.google.com/d/msgid/lsts-toolchain/05f0ad7e-7961-4860-8409-55840e163be1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bjørn Spockeli

unread,
Feb 19, 2015, 5:52:11 AM2/19/15
to lsts-to...@googlegroups.com, bjorn.s...@gmail.com
Hi Ricardo,

Yes, the IMU is an ADIS16488 and I want to communicate with it in user-space, using Dune. Im not very familiar with device trees and dts files so bear with me.  What do I need to add in the &spi* sections in order to communicate with the IMU in Dune?

Bjørn

Ricardo Martins

unread,
Feb 19, 2015, 6:24:49 AM2/19/15
to Bjørn Spockeli, lsts-to...@googlegroups.com
Hi Bjørn,

The LSTS uses the same IMU in some of their vehicles and buoys but they don't use SPI. They designed a board (with MCU) that interacts with the IMU over SPI, does a few computations (Euler Angles for instance), and outputs data at configurable rates over RS232. This board also allows the data output to be triggered by a GPIO or synchronized with PPS. There are two form-factors of the board, the photo I attach is from the largest, the other is only slightly bigger than the IMU itself. If they have one of these boards in stock and if you're interested maybe they can send you one. I'll be out of the office for a week, on my return and depending on my workload I can probably write a DTS file for your use case, but I cannot test it, you'll have to trust me :).

Regards,
Ricardo

20150219_110529.jpg

Bjørn Spockeli

unread,
Feb 19, 2015, 1:02:26 PM2/19/15
to lsts-to...@googlegroups.com, bjorn.s...@gmail.com
Hi Ricardo, 

that board is exactly what im trying to implement and if its possible to get hold of one that would be perfect! I dont want to reinvent the wheel if I dont have to. I think that both form factors would fit inside our UAV, but the smaller the better. Who should I contact about getting one sent to Trondheim?

Bjørn

José Braga

unread,
Feb 20, 2015, 12:05:03 PM2/20/15
to Bjørn Spockeli, lsts-to...@googlegroups.com, Tor Arne Johansen, Joao Borges de Sousa, Bruno Loureiro
Hi Bjorn,

I talked with Bruno Loureiro (CC'ed), the head of our electronics department. He'll assemble one PCB with the components, less the ADIS16488.
Once it's ready we'll send it to you. Then, using DUNE, all you'll have to do is use the Sensors/LIMU task which already processes the data.

If you need further information let us know.

Regards,
José Braga

Kristian Klausen

unread,
Feb 23, 2015, 3:39:13 AM2/23/15
to lsts-to...@googlegroups.com, bjorn.s...@gmail.com
Hi Ricardo,

Even though Bjørn will use the external board, we have a couple of other applications that will need SPI support. So, it would be great if you found the time to write that DTS file anyway :)

Kristian

Kristian Klausen

unread,
Feb 27, 2015, 6:59:58 AM2/27/15
to lsts-to...@googlegroups.com, bjorn.s...@gmail.com
Hi Ricardo,

I managed to get the DTS file working myselves. I will create a PR later.

Kristian
Reply all
Reply to author
Forward
0 new messages