MR25H40驱动,求助!
时间:10-02
整理:3721RD
点击:
各位大神,最近在研究一个芯片MR25H40,随机存储器件,但是折腾了好几天了一个驱动还没弄好,有没有人有这个芯片用过的驱动呀,可以分享一下吗,谢谢各位了!
我饿的邮箱:i@eamonning.com
还有,这个是我写的代码,大家看看哪里有问题呀,谢谢了!
- void MR25H40_SendByte(INT8U c)
- {
-
- INT8U i;
- for(i=0;i<8;i++){
- if(c&0x80){
- MR25H40_MOSI_1;
- }else{
- MR25H40_MOSI_0;
- }
- //__nop();
- MR25H40_SCK_0;
- //__nop();
- MR25H40_SCK_1;
- c <<= 1;
- }
- }
- INT8U MR25H40_GetByte(void)
- {
- INT8U c=0,i,t;
- for(i=0;i<8;i++){
- c <<= 1;
- t=MR25H40_MISO;
- MR25H40_SCK_1;
- if(t){
- c |= 0x01;
- }
- MR25H40_SCK_0;
- }
- return c;
- }
- INT8U MR25H40_Read(INT32U addr)
- {
- INT8U c;
- MR25H40_CS_0;//Delay(20000);
- MR25H40_SendByte(MR25H40_READ);
- MR25H40_SendByte(((addr & 0x00FFFFFF) >> 16));
- MR25H40_SendByte(((addr & 0x0000FFFF) >> 8));
- MR25H40_SendByte(addr & 0x000000FF);
- c=MR25H40_GetByte();
- MR25H40_CS_1;//Delay(20000);
- return c;
- }
- void MR25H40_Write(INT32U addr,INT8U data)
- {
- MR25H40_CS_0;//Delay(20000);
- MR25H40_SendByte(MR25H40_WRITE);
- MR25H40_SendByte(((addr & 0x00FFFFFF) >> 16));
- MR25H40_SendByte(((addr & 0x0000FFFF) >> 8));
- MR25H40_SendByte(addr & 0x000000FF);
- MR25H40_SendByte(data);
- MR25H40_CS_1;//Delay(20000);
- }
- void MR25H40_Init(void)
- {
-
- GPIO_SetDir(MR25H40_HOLD_PORT, MR25H40_HOLD_MASK, GPIO_DIRECTION_OUTPUT);
- GPIO_SetDir(MR25H40_CS_PORT, MR25H40_CS_MASK, GPIO_DIRECTION_OUTPUT);
- GPIO_SetDir(MR25H40_SCK_PORT, MR25H40_SCK_MASK, GPIO_DIRECTION_OUTPUT);
- GPIO_SetDir(MR25H40_MOSI_PORT, MR25H40_MOSI_MASK, GPIO_DIRECTION_OUTPUT);
- GPIO_SetDir(MR25H40_MISO_PORT, MR25H40_MISO_MASK, GPIO_DIRECTION_INPUT);
- PINSEL_SetPinMode(MR25H40_MISO_PORT,MR25H40_MISO_PIN,PINSEL_BASICMODE_PLAINOUT);
-
-
- //初始化线状态
- MR25H40_HOLD_1;//Delay(20000);
- MR25H40_CS_1;//Delay(20000);
- MR25H40_SCK_1;//Delay(20000);
- MR25H40_MOSI_0;
-
- Delay(200);
-
- //唤醒芯片
- MR25H40_CS_0;
- MR25H40_SendByte(MR25H40_WAKE);
- MR25H40_CS_1;
- //Delay(20000);
-
- Delay(200);
-
- //使能写
- MR25H40_CS_0;
- MR25H40_SendByte(MR25H40_WREN);
- MR25H40_CS_1;
- Delay(200);
-
- //写状态寄存器
- MR25H40_CS_0;
- MR25H40_SendByte(MR25H40_WRSR);
- MR25H40_SendByte(0x02);
- MR25H40_CS_1;
-
- Delay(200);
-
- //读状态寄存器
- //MR25H40_CS_0;
- //__nop();
- //MR25H40_SendByte(MR25H40_RDSR);
- //byte=MR25H40_GetByte();
- //__nop();
- //MR25H40_CS_1;
-
- }
精神上支持吧。
学习