6 Replies Latest reply on Jun 19, 2020 1:34 AM by ZhengbaoZ_96

    SPI: How to use GPIO external interrupt

    MaCa_2922036

      Hello,

       

      I create a new topic as my previous one has been locked for an unknown reason.

       

      Initial topic:

      How to use GPIO external interrupt

       

      My response to ZhengbaoZ_96

       

      So what you propose is the same thing as the option 1 of my initial first message, except the fact you use SPI2 and I use SPI5. Could it impact anything to use SPI5 instead of SPI2 ?

       

      I still don't have any interrupt with my code "option 1".

       

      Thanks

        • 1. Re: SPI: How to use GPIO external interrupt
          ZhengbaoZ_96

          Hello:

           

          Sorry, I want a confirm, Are you using a STM32F4xx seriels MCU to communication with 1LD module ?

          And need an Interrupt from module to MCU , and want to configure the SPI CS pin as an  INT input also ..

          • 2. Re: SPI: How to use GPIO external interrupt
            MaCa_2922036

            Hello,

             

            The MCU used to communicate with the 1LD module is a STM32F769.

            The STM32F769 is the master of the SPI and the 1LD module is the slave. So the SPI CS is controlled by the master and I need to activate the interrupt on SPI CS on the 1LD side.

            • 3. Re: SPI: How to use GPIO external interrupt
              ZhengbaoZ_96

              Would you please try SPI5 + external GPIO INT mode for a test ?  I think it is not a must to use CS pin as an interrupt input .

              and it needs to modify the mode in the firmware,  I have no experience before for this request .

              external INT mode should be easy to configure , then you can see if interrupt can be received in your code.

              And this is a default mode in our sdk now.

               

              • 4. Re: SPI: How to use GPIO external interrupt
                ZhengbaoZ_96

                when you compile the target, you need to choose the MCU-WLAN Interface to SPI also.

                Usage: make <target> [download] [run | debug] [JTAG=xxx] [no_dct]

                       make run

                 

                  <target>

                    One each of the following mandatory [and optional] components separated by '-'

                      * Application (apps in sub-directories are referenced by subdir.appname)

                      * Hardware Platform ($(filter-out common  include README.txt,$(notdir $(wildcard WICED/platforms/*))))

                      * [RTOS] ($(notdir $(wildcard WICED/RTOS/*)))

                      * [Network Stack] ($(notdir $(wildcard WICED/network/*)))

                      * [MCU-WLAN Interface Bus] (SDIO SPI)

                • 5. Re: SPI: How to use GPIO external interrupt
                  MaCa_2922036

                  Ok. I will try this.

                  Could you provide me a sample code to easily configure SPI and GPIO external interrupt for the 1LD platform ?

                  Thanks.

                  • 6. Re: SPI: How to use GPIO external interrupt
                    ZhengbaoZ_96

                    Hi :

                      for specific code, please follow 43438wcd1 platform in the sdk release:

                    in platform. c:  we defined SDIO and SPI between STM and 43438 .

                    SDIO and SPI interface is booted with a different hardware setting of strap pin.

                     

                    /* Wi-Fi SDIO bus pins. Used by WICED/platform/STM32F2xx/WWD/wwd_SDIO.c */

                    const platform_gpio_t wifi_sdio_pins[] =

                    {

                        [WWD_PIN_SDIO_OOB_IRQ] = { GPIOC,  6 },

                        [WWD_PIN_SDIO_CLK    ] = { GPIOC, 12 },

                        [WWD_PIN_SDIO_CMD    ] = { GPIOD,  2 },

                        [WWD_PIN_SDIO_D0     ] = { GPIOC,  8 },

                        [WWD_PIN_SDIO_D1     ] = { GPIOC,  9 },

                        [WWD_PIN_SDIO_D2     ] = { GPIOC, 10 },

                        [WWD_PIN_SDIO_D3     ] = { GPIOC, 11 },

                    };

                     

                    /* Wi-Fi gSPI bus pins. Used by WICED/platform/STM32F2xx/WWD/wwd_SPI.c */

                    const platform_gpio_t wifi_spi_pins[] =

                    {

                        [WWD_PIN_SPI_IRQ ] = { GPIOC,  9 },

                        [WWD_PIN_SPI_CS  ] = { GPIOB, 12 },

                        [WWD_PIN_SPI_CLK ] = { GPIOB, 13 },

                        [WWD_PIN_SPI_MOSI] = { GPIOB, 15 },

                        [WWD_PIN_SPI_MISO] = { GPIOB, 14 },

                    };

                     

                    then we can check the WWD_PIN_SPI_IRQ in the code , in the \43xxx_Wi-Fi\WICED\platform\MCU\STM32F4xx\WWD\wwd_spi.c

                    /* Setup the interrupt input for WLAN_IRQ */

                    #ifndef WWD_SPI_IRQ_FALLING_EDGE

                    platform_gpio_init( &wifi_spi_pins[WWD_PIN_SPI_IRQ], INPUT_HIGH_IMPEDANCE );
                    platform_gpio_irq_enable( &wifi_spi_pins[WWD_PIN_SPI_IRQ], IRQ_TRIGGER_RISING_EDGE, spi_irq_handler, 0 );

                    #else /* WWD_SPI_IRQ_FALLING_EDGE */

                    platform_gpio_init( &wifi_spi_pins[WWD_PIN_SPI_IRQ], INPUT_PULL_UP );
                    platform_gpio_irq_enable( &wifi_spi_pins[WWD_PIN_SPI_IRQ], IRQ_TRIGGER_FALLING_EDGE, spi_irq_handler, 0 );

                    #endif /* WWD_SPI_IRQ_FALLING_EDGE */

                     

                    where we have a GPIO IRQ define, and level define.