2024年4月26日发(作者:)
71 void NAND512_IO_Init(void)
72 {
73 GPIO_InitTypeDef GPIO_InitStructure;
74
75 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD
76 | RCC_APB2Periph_GPIOE, ENABLE);
77
78 /*CL*/
79 GPIO__Pin = NAND512_CL_PIN;
80 GPIO__Speed = GPIO_Speed_50MHz;
81 GPIO__Mode = GPIO_Mode_Out_PP;
82 GPIO_Init(NAND512_CL_PORT, &GPIO_InitStructure);
83
84 /*AL*/
85 GPIO__Pin = NAND512_AL_PIN;
86 GPIO_Init(NAND512_AL_PORT, &GPIO_InitStructure);
87
88 /*W*/
89 GPIO__Pin = NAND512_W_PIN;
90 GPIO_Init(NAND512_W_PORT, &GPIO_InitStructure);
91
92 /*R*/
93 GPIO__Pin = NAND512_R_PIN;
94 GPIO_Init(NAND512_R_PORT, &GPIO_InitStructure);
95
96 /*CE*/
97 GPIO__Pin = NAND512_CE_PIN;
98 GPIO_Init(NAND512_CE_PORT, &GPIO_InitStructure);
99
100 /*R/B*/
101 GPIO__Pin = NAND512_RB_PIN;
102 GPIO__Speed = GPIO_Speed_50MHz;
103 GPIO__Mode = GPIO_Mode_IPU;
104 GPIO_Init(NAND512_RB_PORT, &GPIO_InitStructure);
105
106 NAND512_CL_LOW;
107 NAND512_AL_LOW;
108 NAND512_R_HIGH;
109 NAND512_W_HIGH;
110 NAND512_CE_HIGH;
111 }
112
113 //读状态寄存器信息
114 char NAND512_Read_Status(void)
115 {
116 char dat;
117
118 NAND512_CL_LOW;
119 NAND512_W_HIGH;
120 NAND512_R_HIGH;
121 NAND512_CE_HIGH;
122 NOP;
123
124 NAND512_Delay_uS(5);
125 NAND512_CL_HIGH;
126 NOP;
127 NOP;
128 NAND512_CE_LOW;
129 NOP;
130 NOP;
131 NOP;
132 NAND512_W_LOW;
133 NAND512_DB_Write(0x70);
134 NOP;
135 NAND512_W_HIGH;
136
137 NAND512_Delay_uS(5);
138 NAND512_CL_LOW;
139 NOP;
140 NOP;
141 //CE状态保持不变
142
143 NAND512_Delay_uS(10);
144 NAND512_R_LOW;
145 NOP;
146 dat = NAND512_DB_Read();
147 NAND512_Delay_uS(5);
148 NAND512_R_LOW;
149 NAND512_Delay_uS(5);
150 NAND512_CE_HIGH;
151 NAND512_Delay_uS(20);
152
153 return dat;
154 }
发布评论