编译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")));
}
}
如果还是不行的话,再问吧!