#include "bsp_flash.h"
#include "W25Q64.h"
// #include "bsp_oled.h"
#include "mw_oled.h"

void bsp_flash_init(void)
{
	uint8_t MID;							//定义用于存放MID号的变量
uint16_t DID;							//定义用于存放DID号的变量

uint8_t ArrayWrite[] = {0x01, 0x02, 0x04, 0x08};	//定义要写入数据的测试数组
uint8_t ArrayRead[4];								//定义要读取数据的测试数组

    W25Q64_Init();						//W25Q64初始化
	
	/*显示静态字符串*/
    
	oled_drv.show_string(1, 1, "MID:   DID:");
	oled_drv.show_string(2, 1, "W:");
	oled_drv.show_string(3, 1, "R:");
	
	/*显示ID号*/
	W25Q64_ReadID(&MID, &DID);			//获取W25Q64的ID号
    
	oled_drv.show_hex_num(1, 5, MID, 2);		//显示MID
	oled_drv.show_hex_num(1, 12, DID, 4);		//显示DID
	
	/*W25Q64功能函数测试*/
	W25Q64_SectorErase(0x000000);					//扇区擦除
	W25Q64_PageProgram(0x000000, ArrayWrite, 4);	//将写入数据的测试数组写入到W25Q64中
	
	W25Q64_ReadData(0x000000, ArrayRead, 4);		//读取刚写入的测试数据到读取数据的测试数组中
	
	/*显示数据*/
	oled_drv.show_hex_num(2, 3, ArrayWrite[0], 2);		//显示写入数据的测试数组
	oled_drv.show_hex_num(2, 6, ArrayWrite[1], 2);
	oled_drv.show_hex_num(2, 9, ArrayWrite[2], 2);
	oled_drv.show_hex_num(2, 12, ArrayWrite[3], 2);
	
	oled_drv.show_hex_num(3, 3, ArrayRead[0], 2);			//显示读取数据的测试数组
	oled_drv.show_hex_num(3, 6, ArrayRead[1], 2);
	oled_drv.show_hex_num(3, 9, ArrayRead[2], 2);
	oled_drv.show_hex_num(3, 12, ArrayRead[3], 2);
}
