/** * @brief Prepares the picture to be saved in microSD. * @param None * @retval None */ static void Prepare_Picture(void) { uint32_t x_counter = 0, y_counter = 0; uint32_t address = SRAM_DEVICE_ADDR; uint16_t tmp = 0; /* Bypass the bitmap header */ address += (((BSP_LCD_GetXSize() - 80) * (BSP_LCD_GetYSize() - 81)) * 2); BSP_SRAM_Init(); /* Prepare picture */ for(y_counter = 10; y_counter < (BSP_LCD_GetYSize() - 70); y_counter++) { for(x_counter = 70; x_counter < (BSP_LCD_GetXSize() - 10); x_counter++) { /* Write data to the SRAM memory */ tmp = BSP_LCD_ReadPixel(x_counter, y_counter); BSP_SRAM_WriteData(address, &tmp, 1); /* Increment the source and destination buffers */ address += 2; } address -= 4*(BSP_LCD_GetXSize() - 80); } }
/** * @brief Prepares the picture to be Saved in USB. * @param None * @retval None */ static void PicturePrepare(void) { uint32_t address = SRAM_DEVICE_ADDR; uint16_t x = 0; uint16_t y = 0; uint16_t tmp = 0; uint8_t aRGB[4]; /* Go to the address of the last line of BMP file */ address += ((BSP_LCD_GetXSize() * (BSP_LCD_GetYSize() - 1)) * 4); /* Read data from GRAM and swap it into SRAM */ for(y = 0; y < (BSP_LCD_GetYSize()); y++) { for(x = 0; x < (BSP_LCD_GetXSize()); x++) { /* Write data to the SRAM memory */ tmp = BSP_LCD_ReadPixel(x, y); aRGB[0] = RGB565_TO_R(tmp); aRGB[1] = RGB565_TO_G(tmp); aRGB[2] = RGB565_TO_B(tmp); aRGB[3] = 0xFF; if(BSP_SRAM_WriteData(address, (uint16_t *)aRGB, 2) != SRAM_OK) { Error_Handler(); } else { address += 4; } } address -= 8*BSP_LCD_GetXSize(); } }
/** * @brief SRAM Demo * @param None * @retval None */ void SRAM_demo (void) { SRAM_SetHint(); /* Disable the LCD to avoid the refrech from the SDRAM */ BSP_LCD_DisplayOff(); /*##-1- Configure the SRAM device ##########################################*/ /* SRAM device configuration */ if(BSP_SRAM_Init() != SRAM_OK) { ubSramInit++; } /*##-2- SRAM memory read/write access ######################################*/ /* Fill the buffer to write */ Fill_Buffer(sram_aTxBuffer, BUFFER_SIZE, 0xC20F); /* Write data to the SRAM memory */ if(BSP_SRAM_WriteData(SRAM_DEVICE_ADDR + WRITE_READ_ADDR, sram_aTxBuffer, BUFFER_SIZE) != SRAM_OK) { ubSramWrite++; } /* Read back data from the SRAM memory */ if(BSP_SRAM_ReadData(SRAM_DEVICE_ADDR + WRITE_READ_ADDR, sram_aRxBuffer, BUFFER_SIZE) != SRAM_OK) { ubSramRead++; } /*##-3- Checking data integrity ############################################*/ /* Enable the LCD */ BSP_LCD_DisplayOn(); if(ubSramInit != 0) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SRAM Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SRAM Initialization : OK.", LEFT_MODE); } if(ubSramWrite != 0) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM WRITE : OK.", LEFT_MODE); } if(ubSramRead != 0) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM READ : OK.", LEFT_MODE); } if(Buffercmp(sram_aRxBuffer, sram_aTxBuffer, BUFFER_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM Test : OK.", LEFT_MODE); } while (1) { if(CheckForUserInput() > 0) { return; } } }