This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use SPI_CSx as GPIO in OMAP-L138

Other Parts Discussed in Thread: OMAP-L138

Hello,

I like to use OMAP-L138 in slave mode to wait for incoming signal, and in master mode ONLY when to do transmit.

In doing so, I's like to use all 8 SPI_CSx pins as GPIOs

I'm confused as these pins are configured as GPIO by 2 sources : SPIPCx and PinMux

So which one take precedence, SPI or GPIO module  ?

Thanks,

~Duy-Ky

  • The pinmux controls which module gets connected to outside pins. Choose either the SPI module or the GPIO module but not both.

    If you choose the SPI module, you then have the option of driving the SPI pins as a SPI function and a GPIO function. The GPIO function is part of the SPI module and uses SPI registers. The GPIO module is not involved.

    Note that you might not have all 8 CSs available to the pinmux. On the OMAP-L138, SP0 has 0 to 5 and SP1 has 0 to 7.

    So...you could just control those pins using the GPIO module instead a repurposing the CS pins in the SPI module. Pinmux those pins to the GPIO module.

  • Hello Normal,

    It's clear to me now.

    Thanks so much for your reply.

    Now I have new problem with Slave SPI using RX_Interrupt

    I have 2 OMAPs on board, SPI1 for 1st OMAP as master, I'm able to verify it works as it's connected to Flash

    This same SPI1 is also connected to SPI0 of the 2nd OMAP for communication purpose between 2 OMAPs

    The 2nd OMAP is setup as slave with

    1) SPIGCR1 in slave mode (MASTER=0)

    2) SPIPC3 with CLKFUN = 0

    I guess, as in slave mode, there's nothing to do with SPI_CS, so I just simply wait for SPI INTVEC1 of value 0x12 (Receive Buffer Full). BTW, I found ONLY flag for Receive Buffer Full, and not sure how it's set (how many Rx byte received to set the flag) ?!?

    But I failed to get it work !?!?

    Is there anything wrong , anything missing in my setup ?

    Thanks so much, Norman

    ~Duy-Ky

    As in slave mode

  • I don't have any experience with using SPI in Slave mode. Or with interrupts. I usually just use the drivers in Linux or BIOS. Perhaps you should start a new forum post regarding your new problem. Detail your interrupt setup with reference to "30.2.12 Interrupt Support" of the TRM.  That short section mentions SPILVL and SPIINT configuration.

    One comment though. If OMAP1:SP1 is connected to two devices, flash and OMAP2, then you need to use a CS line to each device. Otherwise both devices will use the bus at the same time.

  • Hi Norman

    I have some trobles in pinmux settings.

    My PSP is: OMAP_L138_arm_1_00_00_08\DaVinci-PSP-SDK-03.20.00.08\

    I tried to add below in /arch/arm/mach-davinci/include/mach/mux.h

    /* GPIO function */

    DA850_GPIO2_6,
    DA850_GPIO2_8,

    DA850_GPIO1_1,//my add

    and add in /arch/arm/mach-davinci/da850.c  in static const struct mux_config da850_pins[] = {}   fuction

    /* GPIO function */
    MUX_CFG(DA850, GPIO2_6, 6, 4, 15, 8, false)
    MUX_CFG(DA850, GPIO2_8, 5, 28, 15, 8, false)

    MUX_CFG(DA850, GPIO1_1, 4, 24, 15, 8, false)  //my add

    after rebuilt the kernel When  I detect the pin GP1[1],  I still can't get the value I set to it .  Is I wrong?   Is there any other place I must modify?

    Regards

    He