static void spiflash_run_transaction(struct spiflash_transaction *trans) { spi_queue_xfer_sg(&trans->dev->flash_spi_ctx.ctx, trans->dev->cs, trans->flash_tx_sg, trans->flash_rx_sg, spiflash_transaction_dispatched_spi_cb, trans); }
static void send_command(struct nrf_transaction_t *trans, spi_cb *cb, void *data) { struct sg *tx = trans->tx_len ? sg_init(trans->tx_sg, &trans->cmd, 1, trans->tx_data, trans->tx_len) : sg_init(trans->tx_sg, &trans->cmd, 1); struct sg *rx = trans->rx_len ? sg_init(trans->rx_sg, &trans->status, 1, trans->rx_data, trans->rx_len) : sg_init(trans->rx_sg, &trans->status, 1); spi_queue_xfer_sg(&trans->spi_ctx, NRF_SPI_CS, tx, rx, cb, data); }
static size_t program_sector(size_t addr) { static struct spi_ctx_bare sp_ctx; static struct sg tx_sg[2]; static uint8_t header[4]; size_t len = FLASH_SECTOR_SIZE; write_enable(); header[0] = EZPORT_SP; header[1] = addr >> 16; header[2] = addr >> 8; header[3] = addr; sg_init(tx_sg, (void *)header, 4, _binary_payload_bin_start + addr, len); spi_queue_xfer_sg(&sp_ctx, EZPORT_SPI_CS, tx_sg, NULL, NULL, NULL); check_status(); return (addr + len); }