Lines Matching refs:p_cb

143     spi_control_block_t * p_cb  = &m_cb[p_instance->drv_inst_idx];  in nrfx_spi_init()  local
146 if (p_cb->state != NRFX_DRV_STATE_UNINITIALIZED) in nrfx_spi_init()
170 p_cb->handler = handler; in nrfx_spi_init()
171 p_cb->p_context = p_context; in nrfx_spi_init()
175 p_cb->skip_gpio_cfg = p_config->skip_gpio_cfg; in nrfx_spi_init()
176 p_cb->ss_pin = p_config->ss_pin; in nrfx_spi_init()
177 p_cb->orc = p_config->orc; in nrfx_spi_init()
183 p_cb->transfer_in_progress = false; in nrfx_spi_init()
184 p_cb->state = NRFX_DRV_STATE_INITIALIZED; in nrfx_spi_init()
195 spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; in nrfx_spi_reconfigure() local
197 if (p_cb->state == NRFX_DRV_STATE_UNINITIALIZED) in nrfx_spi_reconfigure()
201 if (p_cb->transfer_in_progress) in nrfx_spi_reconfigure()
213 spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; in nrfx_spi_uninit() local
214 NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED); in nrfx_spi_uninit()
217 if (p_cb->handler) in nrfx_spi_uninit()
225 if (!p_cb->skip_gpio_cfg) in nrfx_spi_uninit()
241 if (p_cb->ss_pin != NRFX_SPI_PIN_NOT_USED) in nrfx_spi_uninit()
243 nrf_gpio_cfg_default(p_cb->ss_pin); in nrfx_spi_uninit()
251 p_cb->state = NRFX_DRV_STATE_UNINITIALIZED; in nrfx_spi_uninit()
254 static void finish_transfer(spi_control_block_t * p_cb) in finish_transfer() argument
257 if (p_cb->ss_pin != NRFX_SPI_PIN_NOT_USED) in finish_transfer()
259 nrf_gpio_pin_write(p_cb->ss_pin, 1); in finish_transfer()
264 p_cb->transfer_in_progress = false; in finish_transfer()
266 p_cb->evt.type = NRFX_SPI_EVENT_DONE; in finish_transfer()
267 p_cb->handler(&p_cb->evt, p_cb->p_context); in finish_transfer()
274 static bool transfer_byte(NRF_SPI_Type * p_spi, spi_control_block_t * p_cb) in transfer_byte() argument
280 if (p_cb->bytes_transferred < p_cb->evt.xfer_desc.rx_length) in transfer_byte()
282 p_cb->evt.xfer_desc.p_rx_buffer[p_cb->bytes_transferred] = rx_data; in transfer_byte()
285 ++p_cb->bytes_transferred; in transfer_byte()
294 size_t bytes_used = p_cb->bytes_transferred + 1; in transfer_byte()
296 if (p_cb->abort) in transfer_byte()
298 if (bytes_used < p_cb->evt.xfer_desc.tx_length) in transfer_byte()
300 p_cb->evt.xfer_desc.tx_length = bytes_used; in transfer_byte()
302 if (bytes_used < p_cb->evt.xfer_desc.rx_length) in transfer_byte()
304 p_cb->evt.xfer_desc.rx_length = bytes_used; in transfer_byte()
308 if (bytes_used < p_cb->evt.xfer_desc.tx_length) in transfer_byte()
310 nrf_spi_txd_set(p_spi, p_cb->evt.xfer_desc.p_tx_buffer[bytes_used]); in transfer_byte()
313 else if (bytes_used < p_cb->evt.xfer_desc.rx_length) in transfer_byte()
315 nrf_spi_txd_set(p_spi, p_cb->orc); in transfer_byte()
319 return (p_cb->bytes_transferred < p_cb->evt.xfer_desc.tx_length || in transfer_byte()
320 p_cb->bytes_transferred < p_cb->evt.xfer_desc.rx_length); in transfer_byte()
324 spi_control_block_t * p_cb, in spi_xfer() argument
327 p_cb->bytes_transferred = 0; in spi_xfer()
336 (p_xfer_desc->tx_length > 0 ? p_xfer_desc->p_tx_buffer[0] : p_cb->orc)); in spi_xfer()
348 nrf_spi_txd_set(p_spi, p_cb->orc); in spi_xfer()
356 if (p_cb->handler) in spi_xfer()
366 } while (transfer_byte(p_spi, p_cb)); in spi_xfer()
367 if (p_cb->ss_pin != NRFX_SPI_PIN_NOT_USED) in spi_xfer()
369 nrf_gpio_pin_write(p_cb->ss_pin, 1); in spi_xfer()
378 spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; in nrfx_spi_xfer() local
379 NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED); in nrfx_spi_xfer()
385 if (p_cb->transfer_in_progress) in nrfx_spi_xfer()
395 if (p_cb->handler) in nrfx_spi_xfer()
397 p_cb->transfer_in_progress = true; in nrfx_spi_xfer()
401 p_cb->evt.xfer_desc = *p_xfer_desc; in nrfx_spi_xfer()
402 p_cb->abort = false; in nrfx_spi_xfer()
404 if (p_cb->ss_pin != NRFX_SPI_PIN_NOT_USED) in nrfx_spi_xfer()
406 nrf_gpio_pin_write(p_cb->ss_pin, 0); in nrfx_spi_xfer()
410 p_cb->transfer_in_progress = false; in nrfx_spi_xfer()
415 spi_xfer(p_instance->p_reg, p_cb, p_xfer_desc); in nrfx_spi_xfer()
425 spi_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; in nrfx_spi_abort() local
426 NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED); in nrfx_spi_abort()
427 p_cb->abort = true; in nrfx_spi_abort()
430 static void irq_handler(NRF_SPI_Type * p_spi, spi_control_block_t * p_cb) in irq_handler() argument
432 NRFX_ASSERT(p_cb->handler); in irq_handler()
437 if (!transfer_byte(p_spi, p_cb)) in irq_handler()
439 finish_transfer(p_cb); in irq_handler()