![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Basic Example / test application for the on-board MICRON QSPI-Flash. Ported from DISCO_L476VG_QSPI. Added printing on serial output and LCD screen.
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG QSPI_DISCO_F746NG TS_DISCO_F746NG mbed
Diff: main.cpp
- Revision:
- 5:9b9fbd929243
- Parent:
- 4:95cde28a5cf1
diff -r 95cde28a5cf1 -r 9b9fbd929243 main.cpp --- a/main.cpp Sun Nov 15 14:31:04 2015 +0000 +++ b/main.cpp Sun Nov 15 15:32:02 2015 +0000 @@ -1,5 +1,7 @@ #include "main.h" +//#define DEBUG + LCD_DISCO_F746NG lcd; TS_DISCO_F746NG ts; DigitalOut myled(LED1); @@ -7,8 +9,6 @@ Serial pc(USBTX, USBRX); // DEBUG -// TODO : add Ticker function - int main() { TS_StateTypeDef TS_State; @@ -46,16 +46,22 @@ QSPI_Info pQSPI_Info; uint8_t WriteBuffer[BUFFER_SIZE] = "Hello World !!!"; uint8_t ReadBuffer[BUFFER_SIZE]; + + #ifdef DEBUG pc.printf("\n\nQSPI demo started\n\r"); + #endif // DEBUG + uint8_t init_return = qspi.Init(); - pc.printf("Return: %d\n\r", init_return); + #ifdef DEBUG + pc.printf("Init return value: %d\n\r", init_return); + #endif // DEBUG - //if (qspi.Init() != QSPI_OK) if (init_return != QSPI_OK) { - //error("QSPI Initialization FAILED\n"); + #ifdef DEBUG pc.printf("QSPI Initialization FAILED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -63,7 +69,9 @@ } else { + #ifdef DEBUG pc.printf("QSPI Initialization PASSED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_GREEN); lcd.SetBackColor(LCD_COLOR_GREEN); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -80,8 +88,9 @@ (pQSPI_Info.EraseSectorsNumber != N25Q128A_SUBSECTOR_SIZE) || (pQSPI_Info.ProgPagesNumber != N25Q128A_SECTOR_SIZE)) { - //error("QSPI informations FAILED\n"); + #ifdef DEBUG pc.printf("QSPI informations FAILED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -89,8 +98,9 @@ } else { - //printf("QSPI informations PASSED\n"); + #ifdef DEBUG pc.printf("QSPI informations PASSED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_GREEN); lcd.SetBackColor(LCD_COLOR_GREEN); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -102,8 +112,9 @@ // Erase memory if (qspi.Erase_Block(WRITE_READ_ADDR) != QSPI_OK) { - //error("QSPI erase FAILED\n"); + #ifdef DEBUG pc.printf("QSPI erase FAILED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -111,8 +122,9 @@ } else { - //printf("QSPI erase PASSED\n"); + #ifdef DEBUG pc.printf("QSPI erase PASSED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_GREEN); lcd.SetBackColor(LCD_COLOR_GREEN); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -124,8 +136,9 @@ // Write memory if (qspi.Write(WriteBuffer, WRITE_READ_ADDR, 15) != QSPI_OK) { - //error("QSPI write FAILED\n"); + #ifdef DEBUG pc.printf("QSPI write FAILED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -133,8 +146,9 @@ } else { - //printf("QSPI write PASSED\n"); + #ifdef DEBUG pc.printf("QSPI write PASSED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_GREEN); lcd.SetBackColor(LCD_COLOR_GREEN); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -146,8 +160,9 @@ // Read memory if (qspi.Read(ReadBuffer, WRITE_READ_ADDR, 11) != QSPI_OK) { - //error("QSPI read FAILED\n"); + #ifdef DEBUG pc.printf("QSPI read FAILED\n\r"); + #endif // DEBUG lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_WHITE); @@ -155,12 +170,16 @@ } else { - //printf("QSPI read PASSED - [%s]\n", ReadBuffer); - pc.printf("QSPI read PASSED\n\r"); + #ifdef DEBUG + pc.printf("QSPI read PASSED - [%s]\n\r", ReadBuffer); + #endif // DEBUG lcd.Clear(LCD_COLOR_GREEN); lcd.SetBackColor(LCD_COLOR_GREEN); lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"QSPI read PASSED", CENTER_MODE); + //lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"QSPI read PASSED", CENTER_MODE); + + sprintf((char*)text, "QSPI read PASSED - [%s]\n\r", ReadBuffer); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)&text, CENTER_MODE); } wait (2);