編譯xdma
㈠ WINCE 6.0 SPI驅動如何工作起來
給你一些意見,我自己總結的,不知道對不對!
1,如何編譯出spi.dll文件
BSP默認是不生成spi.dll文件的,可以通過設置smdk210.bat文件中的BSP_NOSPI=1設置為BSP_NOSPI=即可,因為
在source文件中添加了!if "$(BSP_NOSPI)" == "1" SKIPBUILD=1 !endif 選項
2,spi_INIT失敗 Error KernelIoControl問題
找到原因是isri.dwIrq的值 為-1
解決辦法:在DDKReg_GetIsrInfo的定義中看到
// If no IRQ value is specified in the registry, dwIrq will be set to IRQ_UNSPECIFIED.
// If no SYSINTR value is specified in the registry, dwSysintr will be set to SYSINTR_NOP.
這里需要設置注冊表項WRITE_REG_DWORD(DrvKey,L"Irq", DriverIRQ); DriverIRQ為spi的物理中斷號
不需要設置Sysintr,一般採用動態申請的方式。
還要設置WRITE_REG_DWORD(DrvKey,L"DeviceArrayIndex", DriverDeviceArrayIndex);這個是什麼我也不知道
3,對spi的初始化
static void InitSpiConfig(BOOL mode)
{
if (mode)//master
{
spiConfig.dwMode = SPI_MASTER_MODE;
}
else//slave
{
spiConfig.dwMode = SPI_SLAVE_MODE;
}
/*receive & send use interrupt mode, not use DMA mode*/
spiConfig.bUseRxDMA = FALSE;
spiConfig.bUseRxIntr = TRUE;
spiConfig.bUseTxDMA = FALSE;
spiConfig.bUseTxIntr = TRUE;
spiConfig.dwLineStrength = 0;
spiConfig.dwFBClkSel = 0;
spiConfig.Format = SPI_FORMAT_1;
/*setting SPI's pre-fre and time-out value*/
spiConfig.dwTimeOutVal = 0;
spiConfig.dwPrescaler = 120;
if( DeviceIoControl(hdDevice, SPI_IOCTL_SET_CONFIG, &spiConfig, sizeof(spiConfig), NULL, NULL, NULL, NULL)!=TRUE )
{
RETAILMSG(1, (TEXT("[SPI1] SPI_IOCTL_SET_CONFIG fail\r\n")));
}
if( DeviceIoControl(hdDevice, SPI_IOCTL_START, NULL, NULL, NULL, NULL, NULL, NULL)!=TRUE )
{
RETAILMSG(1, (TEXT("[SPI1] SPI_IOCTL_START fail\r\n")));
}
}
如果還是不行的話,再問吧!