Hello,
Some problems I meet when I try to use spi manager in ble_template example to read "who_am_i" register of LIS2DH12. The environment is set as below:
-
nRF52832 DevelopKit with SDK 14.1.0, ble_app_template project.
-
Connect the DevelopKit board to LIS2DH12 board with following pin map
PIN0.03 -> LIS SCK PIN0.04 -> LIS SDI/SDA/SDO PIN0.28 -> LIS SDO/SA0 PIN0.29 -> LIS CS
-
Add following functions in the main.c in the project
static void accl_spi_transfer_done_cb(ret_code_t result, void * p_user_data) { bsp_board_led_on(BSP_BOARD_LED_2); } static ret_code_t init_spi2_master(void) { // SPI2 (with transaction manager) initialization nrf_drv_spi_config_t const m_master2_config = { .sck_pin = ARDUINO_A0_PIN, .mosi_pin = ARDUINO_A1_PIN, .miso_pin = ARDUINO_A2_PIN, .ss_pin = ARDUINO_A3_PIN, .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, .orc = 0xFF, .frequency = NRF_DRV_SPI_FREQ_4M, .mode = NRF_DRV_SPI_MODE_0, .bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST }; return nrf_spi_mngr_init(&m_nrf_spi_mngr, &m_master2_config); } static void read_accl_info(void) { ret_code_t ret_val; uint8_t tx_cmd[] = {0x8F, 0xFF}; nrf_spi_mngr_transfer_t const transfer[] = { NRF_SPI_MNGR_TRANSFER(tx_cmd, sizeof(tx_cmd), &rx_data, sizeof(rx_data)) }; nrf_spi_mngr_transaction_t const trans[] = { { .begin_callback = NULL, .end_callback = accl_spi_transfer_done_cb, .p_user_data = NULL, .p_transfers = &transfer[0], .number_of_transfers = 1, .p_required_spi_cfg = NULL } }; ret_val = nrf_spi_mngr_schedule(&m_nrf_spi_mngr, &trans[0]); APP_ERROR_CHECK(ret_val); }
-
Put the initialization function and read_accl_info function after ble_stack_init() function.
-
Open SPI_MNGR, NRF_QUEUE and SPI_ENABLE in sdk_config.h
-
Add following defines in the head of main.c
#define ACCL_SPI_QUEUE_LENGTH 5 #define ACCL_SPI_INSTANCE_ID 0 NRF_SPI_MNGR_DEF(m_nrf_spi_mngr, ACCL_SPI_QUEUE_LENGTH, ACCL_SPI_INSTANCE_ID); static uint8_t rx_data[2];
Result, the program is seem to be stuck at read_accl_info function. If I comment it, the program runs successfully. I try to add some breakpoints and run into that function, but every thing is ok, the return value is NRF_SUCCESS. I hope that some one can give me some suggestions. Thanks a lot!