野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12542|回复: 1

SPI flash 问题求解?

[复制链接]
发表于 2015-4-14 19:23:22 | 显示全部楼层 |阅读模式
我向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--);
}
//&#214;&#216;&#182;¨&#207;ò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;     /* è&#161;&#184;&#223;8&#206;&#187;êy&#190;Y */
   Low8bit=*(c+1);  /* è&#161;μí8&#206;&#187;êy&#190;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&#182;á3&#246;μ&#196;êy&#190;Yê&#199;: %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);  /* è&#161;×&#214;&#196;£êy&#190;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);  /* ×&#214;·&#251;&#209;&#213;é&#171; */
                        }
                        else
                        {
                                LCD_SetPoint(Xpos+i,Ypos+j,bkColor);  /* ±3&#190;°&#209;&#213;é&#171; */
                        }
                        if ( (buffer[i*2+1] >> 7-j) & 0x01 == 0x01)
                        {
                                LCD_SetPoint(Xpos+i,Ypos+j+8,Color);  /* ×&#214;·&#251;&#209;&#213;é&#171; */
                        }
                        else
                        {
                                LCD_SetPoint(Xpos+i,Ypos+j+8,bkColor);  /* ±3&#190;°&#209;&#213;é&#171; */
                        }
                }
        }                               
}
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ò&#213;y&#212;ú&#212;&#203;DD");
         GUI_Chinese(20,20,"&#206;òê&#199;",YELLOW,BLACK);
         while(1)
        {

  }
}


回复

使用道具 举报

 楼主| 发表于 2015-4-14 19:24:06 | 显示全部楼层
不知道我的注释怎么都没有了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-9-23 01:41 , Processed in 0.037558 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表