EmbeddedArtists AB
/
app_lcdboard_demo_cube
Example for the LPC4088 QSB Base Board
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /****************************************************************************** 00002 * Includes 00003 *****************************************************************************/ 00004 00005 #include "mbed.h" 00006 00007 #include "LcdController.h" 00008 #include "EaLcdBoard.h" 00009 #include "sdram.h" 00010 00011 #include "CubeDemo.h" 00012 00013 00014 /****************************************************************************** 00015 * Typedefs and defines 00016 *****************************************************************************/ 00017 00018 #define RESET_FLAG \ 00019 do { \ 00020 if (abortTest) { \ 00021 abortTest = false; \ 00022 wait(0.04); \ 00023 } \ 00024 } while(false) 00025 00026 /****************************************************************************** 00027 * Local variables 00028 *****************************************************************************/ 00029 00030 static InterruptIn buttonInterrupt(P2_10); 00031 static DigitalOut led(LED1); 00032 00033 /****************************************************************************** 00034 * Global variables 00035 *****************************************************************************/ 00036 00037 EaLcdBoard lcdBoard(P0_27, P0_28); 00038 bool abortTest = false; 00039 00040 /****************************************************************************** 00041 * Interrupt functions 00042 *****************************************************************************/ 00043 00044 void trigger() { 00045 abortTest = true; 00046 } 00047 00048 /****************************************************************************** 00049 * Main 00050 *****************************************************************************/ 00051 00052 int main (void) { 00053 00054 EaLcdBoard::Result result; 00055 LcdController::Config lcdCfg; 00056 uint32_t frameBuf1; 00057 00058 printf("EA LCD Board Cube Demo\n"); 00059 00060 // Listen for button presses 00061 buttonInterrupt.mode(PullUp); 00062 buttonInterrupt.fall(&trigger); 00063 00064 do { 00065 // framebuffer is put in SDRAM 00066 if (sdram_init() == 1) { 00067 printf("Failed to initialize SDRAM\n"); 00068 break; 00069 } 00070 00071 result = lcdBoard.open(NULL, NULL); 00072 if (result != EaLcdBoard::Ok) { 00073 printf("Failed to open display: %d\n", result); 00074 break; 00075 } 00076 00077 result = lcdBoard.getLcdConfig(&lcdCfg); 00078 if (result != EaLcdBoard::Ok) { 00079 printf("Failed to get LCD configuration: %d\n", result); 00080 break; 00081 } 00082 00083 // Prepare 3 consequtive framebuffers (2 will be used for background buffers) 00084 frameBuf1 = (uint32_t)malloc(lcdCfg.width*lcdCfg.height*2 *3); 00085 if (frameBuf1 == NULL) { 00086 printf("Failed to allocate memory for the frame buffer\n"); 00087 break; 00088 } 00089 memset((void*)frameBuf1, 0x0, lcdCfg.width*lcdCfg.height*2 *3); 00090 00091 result = lcdBoard.setFrameBuffer(frameBuf1); 00092 if (result != EaLcdBoard::Ok) { 00093 printf("Failed to activate frameBuffer: %d\n", result); 00094 break; 00095 } 00096 00097 CubeDemo cubeDemo((uint8_t *)frameBuf1, lcdCfg.width, lcdCfg.height); 00098 while (1) { 00099 cubeDemo.run(750, 20); 00100 RESET_FLAG; 00101 } 00102 } while(0); 00103 00104 // Blink to indicate error 00105 while (1) { 00106 led = 0; 00107 wait(0.2); 00108 led = 1; 00109 wait(0.2); 00110 } 00111 }
Generated on Fri Jul 15 2022 14:51:32 by 1.7.2