本想着自己把tls的psram驱动移植到hal,不过dma那块有点复杂,不知咋搞,请问有大神移植了吗?
这是我自己写的,时钟分频寄存器你可以根据规格书重新计算,我用的不是标准40M晶振
void LL_QPI_Enable4bit(void)
{
LL_QPI_RegWrite(LL_QPI_REG_CTRL,(LL_QPI_RegRead(LL_QPI_REG_CTRL)|LL_QPI_QUAD_ENABLE)); //reset qpi
while((LL_QPI_RegRead(LL_QPI_REG_CTRL)&0x02u)==0); //wait
}
void LL_QspiInit(void)
{
unsigned long regVal;
LL_GpioInitStructDef GpioInit;
LL_QpiState = LL_Qpi_Busy;
LL_PeripheralClockEnable(CLK_QPI);
LL_GpioAfInit(Psram_Ck_Remap,LL_GPIOB,LL_GPIO_P00);
LL_GpioAfInit(Psram_Cs_Remap,LL_GPIOB,LL_GPIO_P27);
LL_GpioAfInit(Psram_D0_Remap,LL_GPIOB,LL_GPIO_P02);
LL_GpioAfInit(Psram_D1_Remap,LL_GPIOB,LL_GPIO_P03);
LL_GpioAfInit(Psram_D2_Remap,LL_GPIOB,LL_GPIO_P04);
LL_GpioAfInit(Psram_D3_Remap,LL_GPIOB,LL_GPIO_P05);
regVal = LL_QPI_RegRead(LL_QPI_REG_CTRL);
LL_QPI_RegWrite(LL_QPI_REG_CTRL,(regVal|LL_QPI_RESET_ENABLE)); //reset qpi
while(1)
{
regVal = LL_QPI_RegRead(LL_QPI_REG_CTRL);
if(~(regVal&0x00000001u))
{
break;
}
}
regVal = LL_QPI_RegRead(LL_QPI_REG_CTRL)&0xFFFFF000u;
LL_QPI_RegWrite(LL_QPI_REG_CTRL,regVal); // reset reg value
regVal = LL_QPI_RegRead(LL_QPI_REG_CTRL)&0xFFFFFF0Fu;
LL_QPI_RegWrite(LL_QPI_REG_CTRL,(regVal|LL_QPI_CLK_DIV)); //set clk div
regVal = LL_QPI_RegRead(LL_QPI_REG_CTRL)&0xFFFFF8FFu;
LL_QPI_RegWrite(LL_QPI_REG_CTRL,(regVal|LL_QPI_tCPH)); //set cCPH time
regVal = LL_QPI_RegRead(LL_QPI_REG_CTRL);
LL_QPI_RegWrite(LL_QPI_REG_CTRL,(regVal|LL_QPI_BURST_ENABLE)); //set burst enable
regVal = LL_QPI_RegRead(LL_QPI_REG_OVTR)&0xFFFFF000u;
LL_QPI_RegWrite(LL_QPI_REG_OVTR,(regVal|LL_QPI_tCEM)); //set cCEM time ,<= 4uS
LL_QPI_Enable4bit();
LL_QpiState = LL_Qpi_Ready;
// 以下用于测试初始化代码是否正确,无其他意义,初始化OK
// (unsigned long )(LL_QPI_BUS) = 0xaaaaaaaa;
// TestData[0]=(unsigned long )(LL_QPI_BUS);
// for(i=0;i<4;i++)
// {
// (unsigned long )(LL_QPI_BUS+(i*4)) = 0xaaaaaaaa;
// }
// for(i=0;i<4;i++)
// {
// TestData[i] = (unsigned long )(LL_QPI_BUS+(i*4));
// }
}