![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
printovanje sa sd kartice
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI SD_DISCO_F469NI mbed
Diff: main.cpp
- Revision:
- 0:578693ea5eda
- Child:
- 1:402194ce99cc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 11 23:27:58 2017 +0000 @@ -0,0 +1,107 @@ +#include "mbed.h" +#include "SD_DISCO_F469NI.h" +#include "LCD_DISCO_F469NI.h" +#include "LogoBitmap.h" + +SD_DISCO_F469NI sd; +LCD_DISCO_F469NI lcd; +Serial pc(USBTX, USBRX); + +#define START_ADDR 0 + +const uint32_t LogoHeight=200; +const uint32_t LogoWidth=400; +uint32_t LogoMemory=LogoHeight*LogoWidth*4; +uint32_t BitmapSD[LogoHeight*LogoWidth]; +uint32_t StartXPos=0; +uint32_t StartYPos=0; + +void WriteLogo(SD_DISCO_F469NI sd); +void PrintLogo(); + +int main(){ + + uint8_t SD_state = MSD_OK; + pc.printf("SD\n"); + SD_state = sd.Init(); + if(SD_state != MSD_OK){ + if(SD_state == MSD_ERROR_SD_NOT_PRESENT){ + pc.printf("SD shall be inserted before running test\n"); + } else { + pc.printf("SD Initialization : FAIL.\n"); + } + pc.printf("SD Test Aborted.\n"); + } else { + pc.printf("SD Initialization : OK.\n"); + }; + + uint32_t p,q; + uint32_t BlockBuffer[128]; + uint16_t xpos=0,ypos=0; + for(p=0;p<625;p++){ + sd.ReadBlocks(BlockBuffer,START_ADDR+p*512,1,SD_DATATIMEOUT); + pc.printf("BlockBuffer %d copied from SD\n",p); + for(q=0;q<128;q++){ + //pc.printf("%x",BlockBuffer[q]); + if(ypos<LogoHeight){ + lcd.DrawPixel(StartXPos+xpos,StartYPos+ypos,BlockBuffer[q]); + ypos++; + } + else{ + xpos++; + lcd.DrawPixel(StartXPos+xpos,StartYPos+ypos,BlockBuffer[q]); + ypos=1; + } + //pc.printf("Drawed\n"); + } + } + + + while(1){ + }; +}; + +void WriteLogo(SD_DISCO_F469NI sd){ + uint32_t p,q; + uint32_t BlockBuffer[128]; + for (p=0;p<625;p++){ + for(q=0;q<128;q++){ + BlockBuffer[q]=LogoBitmap[p*128+q]; + pc.printf("Blockbuffer[%d]=%x\n",q,BlockBuffer[q]); + }; + if(sd.WriteBlocks(BlockBuffer,START_ADDR+p*512,1,SD_DATATIMEOUT)!=MSD_OK){ + pc.printf("Blockbuffer copy to SD failed."); + }; + pc.printf("BlockBuffer %d copied\n",p); + }; + pc.printf("Bitmap copied to SD"); +}; + + + +void PrintLogo(){ + uint32_t p,q; + uint32_t BlockBuffer[128]; + uint16_t xpos=0,ypos=0; + for(p=0;p<625;p++){ + sd.ReadBlocks(BlockBuffer,START_ADDR+p*512,1,SD_DATATIMEOUT); + for(q=0;q<128;q++){ + if(ypos<LogoHeight){ + lcd.DrawPixel(StartXPos+xpos,StartYPos+ypos,BlockBuffer[q]); + } + else{ + xpos++; + lcd.DrawPixel(StartXPos+xpos,StartYPos+ypos,BlockBuffer[q]); + } + } + } +}; + + + + + + + + + \ No newline at end of file