This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Don't find the definition and the use of this structure NRF_SPIM_Type !!!!!!!!!!!!!!!!!!!

Hi,

 I'm sorry but i cannot find in the discussion the definition of this structure NRF_SPIM_Type

it is not defined in nrf_spim.h

typedef struct
{
    NRF_SPIM_Type * p_reg;        ///< Pointer to a structure with SPIM registers.
    uint8_t         drv_inst_idx; ///< Index of the driver instance. For internal use only.
} nrfx_spim_t;

ok, what is a structure of SPIM registers and ho to use it!!!

i don't know what is a SPIM register.

My aim is to use the following class provided by adafruit I think


class SPIClass {
  public:
    SPIClass(NRF_SPIM_Type *p_spi, uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI);

....

and i need to provide to the constructor a p_spi....

thank you

Vincent

Parents
  • Hello,

    I am not familiar with the adafruit libraries (looks like C++). In our SDK, you can take a look at the example found in:

    SDK\examples\peripheral\spi.

    In main() you will see:

        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.ss_pin   = SPI_SS_PIN;
        spi_config.miso_pin = SPI_MISO_PIN;
        spi_config.mosi_pin = SPI_MOSI_PIN;
        spi_config.sck_pin  = SPI_SCK_PIN;
        APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));

    NRF_DRV_SPI_DEFAULT_CONFIG will set spi_config.mode to NRF_DRV_SPI_MODE_0 by default, if you want to change the mode to e.g. mode 3, you can add the line:

    spi_config.mode = NRF_DRV_SPI_MODE_3;

    before APP_ERROR_CHECK(nrf_drv_spi_init(...));

    But again, I am not familiar with adafruit's libraries. If you have questions regarding these, I suggest you ask adafruit.

    Best regards,

    Edvin

Reply
  • Hello,

    I am not familiar with the adafruit libraries (looks like C++). In our SDK, you can take a look at the example found in:

    SDK\examples\peripheral\spi.

    In main() you will see:

        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.ss_pin   = SPI_SS_PIN;
        spi_config.miso_pin = SPI_MISO_PIN;
        spi_config.mosi_pin = SPI_MOSI_PIN;
        spi_config.sck_pin  = SPI_SCK_PIN;
        APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));

    NRF_DRV_SPI_DEFAULT_CONFIG will set spi_config.mode to NRF_DRV_SPI_MODE_0 by default, if you want to change the mode to e.g. mode 3, you can add the line:

    spi_config.mode = NRF_DRV_SPI_MODE_3;

    before APP_ERROR_CHECK(nrf_drv_spi_init(...));

    But again, I am not familiar with adafruit's libraries. If you have questions regarding these, I suggest you ask adafruit.

    Best regards,

    Edvin

Children
No Data
Related