Quantcast
Channel: Embedded Software (Read Only)
Viewing all articles
Browse latest Browse all 25965

Forum Post: RE: TI-RTOS - SPI and DMA Examples

$
0
0

Glenn,

Here's some pseudo code that I just added to the SPI loopback example.

Void spiCallback (SPI_Handle handle, SPI_Transaction *transaction) {     if (moreDataToSend) {         transaction->txBuf = nextBuffer;         SPI_transfer(handle, transaction);     } }  /*  *  ======== masterTaskFxn ========  *  Task function for master task.  *  *  This task runs at a lower priority after the slave  *  task to ensure it is ready for a transaction.  *  Master SPI sends a message to slave and also  *  receives message from slave. Task for this function  *  is created statically. See the project's .cfg  *  file.  */ Void masterTaskFxn (UArg arg0, UArg arg1) {     SPI_Handle masterSpi;     SPI_Transaction masterTransaction;     SPI_Params params;     UInt transferOK;      /* Initialize SPI handle as default master */     SPI_Params_init(&params);     params.dataSize = 16;     params.transferMode = SPI_MODE_CALLBACK;     params.transferCallbackFxn = spiCallback;     masterSpi = SPI_open(Board_SPI0, NULL);     if (masterSpi == NULL) {         System_abort("Error initializing SPI\n");     }     else {         System_printf("SPI initialized\n");     }      /* Initialize master SPI transaction structure */     masterTransaction.count = SPI_MSG_LENGTH;     masterTransaction.txBuf = (Ptr)masterTxBuffer;     masterTransaction.rxBuf = (Ptr)masterRxBuffer;      /* Initiate SPI transfer */     transferOK = SPI_transfer(masterSpi, &masterTransaction);      if(transferOK) {         /* Print contents of master receive buffer */         System_printf("Master: %s\n", masterRxBuffer);     }     else {         System_printf("Unsuccessful master SPI transfer");     }
...
}

[quote user="Glenn Vassallo"]Was your statement regarding direct access to Flash in reference to the SPIMessageQ module or uDMA and TI-RTOS in general?[/quote]

Yes. :) The uDMA in general.


Viewing all articles
Browse latest Browse all 25965

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>