Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F769NI
main.cpp
00001 #include "mbed.h" 00002 #include "stm32f769i_discovery_lcd.h" 00003 #include "stm32f769i_discovery_sdram.h" 00004 00005 static void Fill_Buffer(uint32_t *pBuffer, uint32_t uwBufferLenght, uint32_t uwOffset); 00006 static uint8_t Buffercmp(uint32_t *pBuffer1, uint32_t *pBuffer2, uint16_t BufferLength); 00007 00008 #define BUFFER_SIZE ((uint32_t)0x0100) 00009 #define WRITE_READ_ADDR ((uint32_t)0x0800) 00010 #define SDRAM_WRITE_READ_ADDR ((uint32_t)0xC0177000) 00011 00012 uint32_t sdram_aTxBuffer[BUFFER_SIZE]; 00013 uint32_t sdram_aRxBuffer[BUFFER_SIZE]; 00014 00015 int main() 00016 { 00017 printf("\n\n SDRAM EXAMPLE FOR DISCO-F769NI START:\n"); 00018 00019 /* Init LCD and display example information */ 00020 BSP_LCD_Init(); 00021 BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); 00022 BSP_LCD_Clear(LCD_COLOR_WHITE); 00023 BSP_LCD_SetTextColor(LCD_COLOR_BLUE); 00024 BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 40); 00025 BSP_LCD_SetTextColor(LCD_COLOR_WHITE); 00026 BSP_LCD_SetBackColor(LCD_COLOR_BLUE); 00027 BSP_LCD_SetFont(&Font24); 00028 BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"SDRAM basic example", CENTER_MODE); 00029 00030 HAL_Delay(2000); 00031 00032 /* SDRAM device configuration */ 00033 if (BSP_SDRAM_Init() != SDRAM_OK) { 00034 BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SDRAM Initialization : FAILED", LEFT_MODE); 00035 } else { 00036 BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SDRAM Initialization : OK", LEFT_MODE); 00037 } 00038 /* Fill the buffer to write */ 00039 Fill_Buffer(sdram_aTxBuffer, BUFFER_SIZE, 0xA244250F); 00040 00041 HAL_Delay(2000); 00042 00043 /* Write data to the SDRAM memory */ 00044 if (BSP_SDRAM_WriteData(SDRAM_WRITE_READ_ADDR + WRITE_READ_ADDR, sdram_aTxBuffer, BUFFER_SIZE) != SDRAM_OK) { 00045 BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM WRITE : FAILED", LEFT_MODE); 00046 } else { 00047 BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM WRITE : OK", LEFT_MODE); 00048 } 00049 00050 HAL_Delay(2000); 00051 00052 /* Read back data from the SDRAM memory */ 00053 if (BSP_SDRAM_ReadData(SDRAM_WRITE_READ_ADDR + WRITE_READ_ADDR, sdram_aRxBuffer, BUFFER_SIZE) != SDRAM_OK) { 00054 BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SDRAM READ : FAILED", LEFT_MODE); 00055 } else { 00056 BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SDRAM READ : OK", LEFT_MODE); 00057 } 00058 00059 HAL_Delay(2000); 00060 00061 if (Buffercmp(sdram_aTxBuffer, sdram_aRxBuffer, BUFFER_SIZE) > 0) { 00062 BSP_LCD_DisplayStringAt(20, 190, (uint8_t *)"SDRAM COMPARE : FAILED", LEFT_MODE); 00063 } else { 00064 BSP_LCD_DisplayStringAt(20, 190, (uint8_t *)"SDRAM Test : OK", LEFT_MODE); 00065 } 00066 00067 while (1) { 00068 00069 } 00070 } 00071 00072 00073 /** 00074 * @brief Fills buffer with user predefined data. 00075 * @param pBuffer: pointer on the buffer to fill 00076 * @param uwBufferLenght: size of the buffer to fill 00077 * @param uwOffset: first value to fill on the buffer 00078 * @retval None 00079 */ 00080 static void Fill_Buffer(uint32_t *pBuffer, uint32_t uwBufferLenght, uint32_t uwOffset) 00081 { 00082 uint32_t tmpIndex = 0; 00083 00084 /* Put in global buffer different values */ 00085 for (tmpIndex = 0; tmpIndex < uwBufferLenght; tmpIndex++) { 00086 pBuffer[tmpIndex] = tmpIndex + uwOffset; 00087 } 00088 } 00089 00090 /** 00091 * @brief Compares two buffers. 00092 * @param pBuffer1, pBuffer2: buffers to be compared. 00093 * @param BufferLength: buffer's length 00094 * @retval 1: pBuffer identical to pBuffer1 00095 * 0: pBuffer differs from pBuffer1 00096 */ 00097 static uint8_t Buffercmp(uint32_t *pBuffer1, uint32_t *pBuffer2, uint16_t BufferLength) 00098 { 00099 while (BufferLength--) { 00100 if (*pBuffer1 != *pBuffer2) { 00101 return 1; 00102 } 00103 00104 pBuffer1++; 00105 pBuffer2++; 00106 } 00107 00108 return 0; 00109 }
Generated on Wed Jul 13 2022 04:38:10 by
1.7.2