编的程序 , 有待完善 , 共同探讨!!!!!
顺便 秀一下 MAQ PC91 的无线耳麦, 下午刚到!!!共同交流!!!
extern void WRITE_M_BYTE(uint8_t M_BYTE ) //write instruction to flash
{
uint8_t j,commd;
flash_cs0;
asm("nop");
asm("nop");
flash_sclk0;
for(j=0;j<8;j++)
{
commd=(M_BYTE>>j)%2;
if(commd==0x01)
{
flash_din1;
}
else
flash_din0;
flash_sclk1; //the instructions are latched on the rising edge //of serial clock
asm("nop");
asm("nop");
asm("nop");
asm("nop");
flash_sclk0;
asm("nop");
asm("nop");
}
}
extern uint8_t READ_M_BYTE() //read one byte from flash
{
uint8_t i ,R_flash_data;
for(i=0;i<8;i++)
{
asm("nop");
asm("nop");
dr= LPC_GPIO[PORT3]->MASKED_ACCESS[(1<<0)];
dr=(dr>>8)%2;
din[0]=dr;
if(din[0]==0x01)
{
R_flash_data<<=1;
R_flash_data|=0x01;
}
else
{
R_flash_data<<=1;
R_flash_data|=0x00;
}
flash_sclk1; //data is shifted out on the falling edge of
//serial clock.
asm("nop");
asm("nop");
asm("nop");
asm("nop");
flash_sclk0;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
}
return R_flash_data;
}
extern void flash_busy() //busy or not
{
uint8_t busy=0x01;
flash_cs1;
WRITE_M_BYTE(RDSR) ; //Read status register instruction
do{
busy=0x01;
busy=READ_M_BYTE() ; //Read status byte.
busy&=0x01;
}
while(busy==0x01);
flash_cs1;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
}
extern void R_gps_flash(uint8_t count,uint8_t *address) //read the gps information form flash
{
uint8_t i;
WRITE_M_BYTE(WREN) ; //write Enable instruction;
flash_busy(); //busy or not
flash_cs1;
WRITE_M_BYTE(READ);
write_flashadd(address); //WRITE THE INITIAL ADDRESS FOR READING
for(i=0;i<count;i++)
{
gps905=READ_M_BYTE();
}
flash_cs1;
flash_busy();
//WRITE_M_BYTE(WRDI) ; //the write disable instruction resets the write enable latch bit.
}