关于wince 5.0在S3C2440平台下的SPI总线驱动问题
向各位请教wince 5.0在S3C2440平台下的SPI总线驱动问题,目前我的代码如下:
···
{
v_pS3C2440A_SPI_REG = (volatile S3C2440A_SPI_REG*)VirtualAlloc(0, sizeof(S3C2440A_SPI_REG), MEM_RESERVE, PAGE_NOACCESS);
v_pS3C2440A_IOPORT_REG = (volatile S3C2440A_IOPORT_REG*)VirtualAlloc(0, sizeof(S3C2440A_IOPORT_REG), MEM_RESERVE, PAGE_NOACCESS);
v_pS3C2440A_PLLCLK_REG = (volatile S3C2440A_PLLCLK_REG*)VirtualAlloc(0, sizeof(S3C2440A_PLLCLK_REG), MEM_RESERVE, PAGE_NOACCESS);
if ((v_pS3C2440A_IOPORT_REG == NULL)||(v_pS3C2440A_SPI_REG == NULL)||(v_pS3C2440A_PLLCLK_REG == NULL))
{
return TRUE;
}
if ((!VirtualCopy((PVOID)v_pS3C2440A_SPI_REG, (PVOID)(IOP_BASE_SPI), sizeof(S3C2440A_SPI_REG), PAGE_PHYSICAL|PAGE_READWRITE|PAGE_NOCACHE))
||(!VirtualCopy((PVOID)v_pS3C2440A_IOPORT_REG, (PVOID)IOP_BASE_GPIO, sizeof(S3C2440A_IOPORT_REG), PAGE_READWRITE|PAGE_NOCACHE))
||(!VirtualCopy((PVOID)v_pS3C2440A_PLLCLK_REG, (PVOID)(IOP_BASE_PLLCLK), sizeof(S3C2440A_PLLCLK_REG), PAGE_PHYSICAL|PAGE_READWRITE|PAGE_NOCACHE)))
{
return TRUE;
}
···
}
void CSPIDlg::SPIInit()
{
v_pS3C2440A_IOPORT_REG->GPGCON &= ~((3 << 2*CLK)|(3 << 2*MOSI)|(3 << 2*MISO));
v_pS3C2440A_IOPORT_REG->GPGCON |= ((3 << 2*CLK)|(3 << 2*MOSI)|(3 << 2*MISO));
v_pS3C2440A_IOPORT_REG->GPGCON &= ~(3 << 2*nss);
v_pS3C2440A_IOPORT_REG->GPGCON |= (1 << 2*nss);
v_pS3C2440A_IOPORT_REG->GPGUP |= ((0 <<2*CLK)|(0 << 2*MOSI)|(0 << 2*MISO)|(0 << 2*nss));
v_pS3C2440A_PLLCLK_REG->CLKCON |= (1 << 18);
v_pS3C2440A_SPI_REG->SPPRE = 0x18;
v_pS3C2440A_SPI_REG->SPCON &= ~(3 << 3);
v_pS3C2440A_SPI_REG->SPCON |= (3 << 3);
v_pS3C2440A_SPI_REG->SPPIN |= (0 << 2)|(1 << 1)|(0 << 0);
}
char CSPIDlg::SPISendData(char Data)
{
char temp;
if(Data != NULL)
v_pS3C2440A_SPI_REG->SPTDAT = Data;
else
v_pS3C2440A_SPI_REG->SPTDAT = 0xff;
while(!(v_pS3C2440A_SPI_REG->SPSTA & 0x01) );
temp = v_pS3C2440A_SPI_REG->SPRDAT;
return temp;
}
这样写入后,spi没有时钟信号,而且标志位一直为1,刚刚学习2440,请高手帮忙指点!谢谢!
[解决办法]
2440 spi是有bug的(标志位一直为1)
[解决办法]