大学生
最后登录1970-1-1
在线时间 小时
注册时间2015-1-25
|
我向spi flash里面写入汉字字库,但是取不出来我也不知道烧成功了没有。求大神解答啊??
#include "stm32f10x_conf.h"
#include "bsp_ili9341_lcd.h"
#include "bsp_led.h"
//#include "tupian.h"
#include "spi_flash.h"
#include "bsp_usart1.h"
#include "stdio.h"
void Delay(uint32_t N)
{
int i;
for(i=0;i<N;i--);
}
//Öض¨Ïòoˉêy usart1
int fputc(int ch, FILE *f)
{
/* ?????????USART1 */
USART_SendData(USART1, (uint8_t) ch);
/* ?????? */
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_ClearFlag( USART1, USART_FLAG_TXE);
return (ch);
}
///???c???scanf?USART1
int fgetc(FILE *f)
{
/* ????1???? */
while (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET);
USART_ClearFlag(USART1,USART_FLAG_RXNE);
return (int)USART_ReceiveData(USART1);
}
void GetGBKCode(unsigned char* pBuffer,unsigned char * c)
{
unsigned char High8bit,Low8bit;
High8bit=*c; /* 衸ß8λêy¾Y */
Low8bit=*(c+1); /* è¡μí8λêy¾Y */
SPI_FLASH_PageWrite(pBuffer,(94*(High8bit-0xa0-1)+(Low8bit-0xa0-1))*32,32);
// SPI_FLASH_BufferWrite(pBuffer,((High8bit-0xb0)*94+Low8bit-0xa1)*64,64);
printf("\r\n ′óW25x16 SPI FLASH¶á3öμÄêy¾YêÇ: %s",pBuffer);
}
void PutChinese(uint16_t Xpos,uint16_t Ypos,uint8_t *str,uint16_t Color,uint16_t bkColor)
{
uint8_t i=0,j=0;
uint8_t buffer[32];
GetGBKCode(buffer,str); /* è¡×ÖÄ£êy¾Y */
for (i=0;i<16;i++)
{
for(j=0;j<8;j++)
{
if ( (buffer[i*2] >> 7-j) & 0x01 == 0x01)
{
LCD_SetPoint(Xpos+i,Ypos+j,Color); /* ×Ö·ûÑÕé« */
}
else
{
LCD_SetPoint(Xpos+i,Ypos+j,bkColor); /* ±3¾°ÑÕé« */
}
if ( (buffer[i*2+1] >> 7-j) & 0x01 == 0x01)
{
LCD_SetPoint(Xpos+i,Ypos+j+8,Color); /* ×Ö·ûÑÕé« */
}
else
{
LCD_SetPoint(Xpos+i,Ypos+j+8,bkColor); /* ±3¾°ÑÕé« */
}
}
}
}
void GUI_Chinese(uint16_t Xpos, uint16_t Ypos, uint8_t *str,uint16_t Color, uint16_t bkColor)
{
do
{
PutChinese(Xpos,Ypos,str++,Color,bkColor);
str++;
if (Ypos<304)
{
Ypos+=16;
}
else if (Xpos<224)
{
Ypos=0;
Xpos+=16;
}
else
{
Xpos=0;
Ypos=0;
}
}
while(*str!=0);
}
int main()
{
// int i,num;
LCD_Init();
Lcd_GramScan(1);
LED_GPIO_Config();
LCD_Clear(0,0,240,320,BLUE);
USART1_Config();
NVIC_Config();
SPI_GPIO_Config();
// SPI_flash_Sectorall();
LED1_ON;
LED2_ON;
LED3_ON;
printf("3ìDòÕyÔúÔËDD");
GUI_Chinese(20,20,"ÎòêÇ",YELLOW,BLACK);
while(1)
{
}
}
|
|