How to do SPIM with handshakes

I'm using SDK15.3 on an nRF52840 with FreeRTOS and specifically non-preemptive scheduling.

I want to so some transfers on SPIM (it's configure with DMA but that's not a requirement)... I've got a part I'm talking to that has a READY handshake signal coming back from it that kicks in during long transfers... basically it's implementing XON/XOFF for the regular SPI transaction.

Got any hints at how to handle that?

  • How does this code know which edge is active and which is not? I'm looking for a down edge as suspend and an up edge as resume..

  • Hi Randy

    Susheel is currently out of office, and will be back on Monday next week. We're currently working through our backlog after the Christmas period, so we'll get back to you before Monday if we find the time to read through and explain the code snippet. If not you'll hear back from Susheel on Monday.

    Best regards,

    Simon

  • Hi Randy,

    The key lies in the configuration of the GPIOTE input:

        nrf_drv_gpiote_in_config_t ready_pin_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);

    Here, a preset configuration was used. The preset configurations can be found in modules/nrfx/drivers/include/nrfx_gpiote.h.

    /**
     * @brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect low-to-high transition.
     * @details Set hi_accu to true to use IN_EVENT.
     */
    #define NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(hi_accu) \
    {                                                   \
        .sense = NRF_GPIOTE_POLARITY_LOTOHI,            \
        .pull = NRF_GPIO_PIN_NOPULL,                    \
        .is_watcher = false,                            \
        .hi_accuracy = hi_accu,                         \
        .skip_gpio_setup = false,                       \
    }
    
    /**
     * @brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect high-to-low transition.
     * @details Set hi_accu to true to use IN_EVENT.
     */
    #define NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(hi_accu) \
    {                                                   \
        .sense = NRF_GPIOTE_POLARITY_HITOLO,            \
        .pull = NRF_GPIO_PIN_NOPULL,                    \
        .is_watcher = false,                            \
        .hi_accuracy = hi_accu,                         \
        .skip_gpio_setup = false,                       \
    }
    
    /**
     * @brief Macro for configuring a pin to use a GPIO IN or PORT EVENT to detect any change on the pin.
     * @details Set hi_accu to true to use IN_EVENT.
     */
    #define NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(hi_accu) \
    {                                                   \
        .sense = NRF_GPIOTE_POLARITY_TOGGLE,            \
        .pull = NRF_GPIO_PIN_NOPULL,                    \
        .is_watcher = false,                            \
        .hi_accuracy = hi_accu,                         \
        .skip_gpio_setup = false,                       \
    }

    You might notice the symbols are named a little different. That's because they are given aliases in integration/nrfx/legacy/nrf_drv_gpiote.h.

    /** @brief Macro for forwarding the new implementation. */
    #define GPIOTE_CONFIG_IN_SENSE_LOTOHI     NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI
    /** @brief Macro for forwarding the new implementation. */
    #define GPIOTE_CONFIG_IN_SENSE_HITOLO     NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO
    /** @brief Macro for forwarding the new implementation. */
    #define GPIOTE_CONFIG_IN_SENSE_TOGGLE     NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE

    These aliases are to adapt usage of the old nrf_drv APIs to new nrfx APIs.

    Hieu

Related