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_sd.h" 00004 00005 int main() 00006 { 00007 uint8_t SD_state = MSD_OK; 00008 static uint8_t prev_status = 2; 00009 00010 printf("\n\n SD EXAMPLE FOR DISCO-F769NI START:\n"); 00011 00012 /* Init LCD and display example information */ 00013 BSP_LCD_Init(); 00014 BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); 00015 BSP_LCD_Clear(LCD_COLOR_WHITE); 00016 BSP_LCD_SetTextColor(LCD_COLOR_BLUE); 00017 BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 40); 00018 BSP_LCD_SetTextColor(LCD_COLOR_WHITE); 00019 BSP_LCD_SetBackColor(LCD_COLOR_BLUE); 00020 BSP_LCD_SetFont(&Font24); 00021 BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"SD basic example", CENTER_MODE); 00022 00023 /* SD init */ 00024 SD_state = BSP_SD_Init(); 00025 printf("BSP_SD_Init return %d\n", SD_state); 00026 00027 if (SD_state != MSD_OK) { 00028 BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD shall be inserted before running test", LEFT_MODE); 00029 00030 } else { 00031 BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD Initialization : OK", LEFT_MODE); 00032 00033 SD_state = BSP_SD_Erase(0, (BLOCKSIZE * 50)); 00034 /* Wait until SD card is ready to use for new operation */ 00035 while (BSP_SD_GetCardState() != SD_TRANSFER_OK) { 00036 } 00037 if (SD_state != MSD_OK) { 00038 BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD ERASE : FAILED.", LEFT_MODE); 00039 } else { 00040 BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD ERASE : OK.", LEFT_MODE); 00041 } 00042 } 00043 00044 BSP_LCD_DisplayStringAt(20, 250, (uint8_t *)"SD can be inserted or removed now", LEFT_MODE); 00045 00046 while (1) { 00047 if (BSP_SD_IsDetected() != SD_PRESENT) { 00048 if (prev_status != SD_NOT_PRESENT) { 00049 BSP_SD_Init(); 00050 prev_status = SD_NOT_PRESENT; 00051 BSP_LCD_SetTextColor(LCD_COLOR_RED); 00052 BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize() - 30, (uint8_t *)"SD Not Connected", LEFT_MODE); 00053 } 00054 } else if (prev_status != SD_PRESENT) { 00055 BSP_LCD_SetTextColor(LCD_COLOR_GREEN); 00056 BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize() - 30, (uint8_t *)"SD Connected ", LEFT_MODE); 00057 prev_status = SD_PRESENT; 00058 } 00059 00060 } 00061 }
Generated on Wed Jul 13 2022 08:14:06 by
1.7.2