// E2 read = cmd + addr + data = 1 + 2 + 64 ) = 67 ~ 72\r
#define SPI_INTERNAL_MTU 72\r
\r
+/* The depth of the HW FIFO */\r
#define FIFO_DEPTH 5\r
\r
+/* Define for debug purposes, checks that SPI/DMA is ok */\r
//#define STEP_VALIDATION 1\r
\r
#define MODULE_NAME "/driver/Spi"\r
* @param ctar_unit - The ctar unit number to setup\r
* @param width - The width in bits of the data to send with the CTAR\r
*/\r
-static void Spi_SetupCTAR(Spi_HWUnitType unit,\r
- const Spi_ExternalDeviceType *extDev, Spi_ChannelType ctar_unit,\r
- uint8 width) {\r
+static void Spi_SetupCTAR( Spi_HWUnitType unit,\r
+ const Spi_ExternalDeviceType *extDev,\r
+ Spi_ChannelType ctar_unit,\r
+ Spi_TransferStartType transferStart,\r
+ uint8 width)\r
+{\r
uint32 clock;\r
uint32 pre_br;\r
int i;\r
clk_table_asc[spiHw->CTAR[ctar_unit].B.DT]*1000/(clock/1000000));\r
\r
/* Data is transferred MSB first */\r
- spiHw->CTAR[ctar_unit].B.LSBFE = 0;\r
+\r
+ spiHw->CTAR[ctar_unit].B.LSBFE = (transferStart == SPI_TRANSFER_START_MSB ) ? 0 : 1;\r
\r
/* Set mode */\r
spiHw->CTAR[ctar_unit].B.FMSZ = width - 1;\r
chConfig = &Spi_Global.configPtr->SpiChannelConfig[channelIndex];\r
\r
// Form a channel code from\r
- // <external_device_id><channel width>\r
- channelCode = ((jobConfig->DeviceAssignment << 8)\r
- + chConfig->SpiDataWidth);\r
+ // <MSB/LSB><external_device_id><channel width>\r
+ channelCode = ( ((uint32_t)chConfig->SpiTransferStart << 16) +\r
+ (jobConfig->DeviceAssignment << 8) +\r
+ chConfig->SpiDataWidth);\r
\r
for (k = 0; k < 7; k++) {\r
if (spiUnit->channelCodes[k] == channelCode) {\r
// Assign the CTAR index to channel info..\r
DEBUG(DEBUG_LOW,"%s: Channel %d uses CTAR %d@%d . device=%d,width=%d\n",MODULE_NAME,channelIndex,k,jobConfig->SpiHwUnit,jobConfig->DeviceAssignment,chConfig->SpiDataWidth);\r
\r
- Spi_SetupCTAR(jobConfig->SpiHwUnit,\r
- Spi_GetExternalDevicePtrFromIndex(\r
- jobConfig->DeviceAssignment),\r
- (Spi_ChannelType) k, chConfig->SpiDataWidth);\r
+ Spi_SetupCTAR(\r
+ jobConfig->SpiHwUnit,\r
+ Spi_GetExternalDevicePtrFromIndex( jobConfig->DeviceAssignment),\r
+ (Spi_ChannelType) k,\r
+ chConfig->SpiTransferStart,\r
+ chConfig->SpiDataWidth);\r
\r
Spi_ChannelInfo[channelIndex].ctarId = k;\r
break;\r
}\r
}\r
+ /* No more CTARS */\r
+ assert(k<7);\r
}\r
}\r
}\r