SD demo

Dependencies:   BSP_DISCO_F413ZH mbed

Committer:
arostm
Date:
Mon May 22 10:25:48 2017 +0200
Revision:
2:db8dcfc87a4a
Parent:
1:8973a7ad5524
Child:
3:3ef082d30ee5
Correction in main.cpp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arostm 0:7708007ed23b 1 #include "mbed.h"
arostm 0:7708007ed23b 2 #include "stm32f413h_discovery.h"
arostm 0:7708007ed23b 3 #include "stm32f413h_discovery_lcd.h"
arostm 0:7708007ed23b 4 #include "stm32f413h_discovery_sd.h"
arostm 0:7708007ed23b 5
arostm 0:7708007ed23b 6 int main()
arostm 0:7708007ed23b 7 {
arostm 0:7708007ed23b 8 uint8_t SD_state = MSD_OK;
arostm 0:7708007ed23b 9 static uint8_t prev_status = 2;
arostm 0:7708007ed23b 10
arostm 0:7708007ed23b 11 /* Init LCD and display example information */
arostm 0:7708007ed23b 12 BSP_LCD_Init();
arostm 0:7708007ed23b 13 BSP_LCD_Clear(LCD_COLOR_WHITE);
arostm 0:7708007ed23b 14 BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
arostm 0:7708007ed23b 15 BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 40);
arostm 0:7708007ed23b 16 BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
arostm 0:7708007ed23b 17 BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
arostm 0:7708007ed23b 18 BSP_LCD_SetFont(&Font16);
arostm 0:7708007ed23b 19
arostm 0:7708007ed23b 20 /* SD init */
arostm 0:7708007ed23b 21 SD_state = BSP_SD_Init();
arostm 0:7708007ed23b 22
arostm 2:db8dcfc87a4a 23 BSP_LCD_DisplayStringAt(0, 15, (uint8_t *)"Insert or Removed SD", CENTER_MODE);
arostm 2:db8dcfc87a4a 24
arostm 0:7708007ed23b 25 while (1) {
arostm 0:7708007ed23b 26 if (BSP_SD_IsDetected() != SD_PRESENT) {
arostm 0:7708007ed23b 27 if(prev_status != SD_NOT_PRESENT) {
arostm 0:7708007ed23b 28 BSP_SD_Init();
arostm 0:7708007ed23b 29 prev_status = SD_NOT_PRESENT;
arostm 0:7708007ed23b 30 BSP_LCD_SetTextColor(LCD_COLOR_RED);
arostm 2:db8dcfc87a4a 31 BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD Not Connected", LEFT_MODE);
arostm 0:7708007ed23b 32 }
arostm 0:7708007ed23b 33 } else if (prev_status != SD_PRESENT) {
arostm 0:7708007ed23b 34 BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
arostm 2:db8dcfc87a4a 35 BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD Connected ", LEFT_MODE);
arostm 0:7708007ed23b 36 prev_status = SD_PRESENT;
arostm 0:7708007ed23b 37 }
arostm 0:7708007ed23b 38
arostm 0:7708007ed23b 39 }
arostm 0:7708007ed23b 40 }