dhgdh
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
main.cpp
00001 #include "test_env.h" 00002 #include "mbed.h" 00003 #include "spifi_rom_api.h" 00004 00005 extern const unsigned char splash_image1[]; extern int splash_image1_sz; 00006 extern const unsigned char splash_image2[]; extern int splash_image2_sz; 00007 extern const unsigned char splash_image3[]; extern int splash_image3_sz; 00008 extern const unsigned char splash_image4[]; extern int splash_image4_sz; 00009 extern const unsigned char splash_image5[]; extern int splash_image5_sz; 00010 extern const unsigned char splash_image6[]; extern int splash_image6_sz; 00011 extern const unsigned char splash_image7[]; extern int splash_image7_sz; 00012 extern const unsigned char splash_image8[]; extern int splash_image8_sz; 00013 extern const unsigned char splash_image9[]; extern int splash_image9_sz; 00014 extern const unsigned char splash_image10[]; extern int splash_image10_sz; 00015 extern const unsigned char splash_image11[]; extern int splash_image11_sz; 00016 extern const unsigned char splash_image12[]; extern int splash_image12_sz; 00017 extern const unsigned char splash_image13[]; extern int splash_image13_sz; 00018 extern const unsigned char splash_image14[]; extern int splash_image14_sz; 00019 extern const unsigned char splash_image15[]; extern int splash_image15_sz; 00020 00021 /* 00022 * The SPIFI_ROM_PTR (0x1FFF1FF8) points to an area where the pointers to 00023 * different drivers in ROM are stored. 00024 */ 00025 typedef struct { 00026 /*const*/ unsigned p_usbd; // USBROMD 00027 /*const*/ unsigned p_clib; 00028 /*const*/ unsigned p_cand; 00029 /*const*/ unsigned p_pwrd; // PWRROMD 00030 /*const*/ unsigned p_promd; // DIVROMD 00031 /*const*/ SPIFI_RTNS *pSPIFID; // SPIFIROMD 00032 /*const*/ unsigned p_dev3; 00033 /*const*/ unsigned p_dev4; 00034 } ROM; 00035 00036 #define ROM_DRIVERS_PTR ((ROM *)(*((unsigned int *)SPIFI_ROM_PTR))) 00037 #define IS_ADDR_IN_SPIFI(__addr) ( (((uint32_t)(__addr)) & 0xff000000) == SPIFI_MEM_BASE ) 00038 #define IS_ADDR_IN_IFLASH(__addr) ( (((uint32_t)(__addr)) & 0xff000000) == 0x10000000 ) 00039 00040 static void initialize_spifi(void) 00041 { 00042 SPIFIobj* obj = (SPIFIobj*)malloc(sizeof(SPIFIobj)); 00043 if (obj == NULL) { 00044 // Failed to allocate memory for ROM data 00045 notify_completion(false); 00046 } 00047 00048 // Turn on SPIFI block as it is disabled on reset 00049 LPC_SC->PCONP |= 0x00010000; 00050 00051 // pinsel for SPIFI 00052 LPC_IOCON->P2_7 = 5; /* SPIFI_CSN @ P2.7 */ 00053 LPC_IOCON->P0_22 = 5; /* SPIFI_CLK @ P0.22 */ 00054 LPC_IOCON->P0_15 = 5; /* SPIFI_IO2 @ P0.15 */ 00055 LPC_IOCON->P0_16 = 5; /* SPIFI_IO3 @ P0.16 */ 00056 LPC_IOCON->P0_17 = 5; /* SPIFI_IO1 @ P0.17 */ 00057 LPC_IOCON->P0_18 = 5; /* SPIFI_IO0 @ P0.18 */ 00058 00059 uint32_t spifi_clk_div = (*((volatile uint32_t*)0x400FC1B4)) & 0x1f; 00060 uint32_t spifi_clk_mhz = (SystemCoreClock / spifi_clk_div) / 1000000; 00061 00062 const SPIFI_RTNS* _spifi = ROM_DRIVERS_PTR->pSPIFID; 00063 00064 /* Typical time tCS is 20 ns min, we give 200 ns to be on safer side */ 00065 int rc = _spifi->spifi_init (obj, spifi_clk_mhz/5, S_FULLCLK+S_RCVCLK, spifi_clk_mhz); 00066 if (rc) { 00067 // Failed to initialize SPIFI 00068 notify_completion(false); 00069 } 00070 } 00071 00072 int main() { 00073 00074 initialize_spifi(); 00075 00076 // Make sure that most files are placed in IFLASH 00077 if (IS_ADDR_IN_SPIFI(splash_image1) || 00078 IS_ADDR_IN_SPIFI(splash_image2) || 00079 IS_ADDR_IN_SPIFI(splash_image3) || 00080 IS_ADDR_IN_SPIFI(splash_image4) || 00081 IS_ADDR_IN_SPIFI(splash_image5) || 00082 IS_ADDR_IN_SPIFI(splash_image6) || 00083 IS_ADDR_IN_SPIFI(splash_image7) || 00084 IS_ADDR_IN_SPIFI(splash_image8) || 00085 IS_ADDR_IN_SPIFI(splash_image9) || 00086 IS_ADDR_IN_SPIFI(splash_image10) || 00087 IS_ADDR_IN_SPIFI(splash_image11) || 00088 IS_ADDR_IN_SPIFI(splash_image12) || 00089 IS_ADDR_IN_SPIFI(splash_image13) || 00090 IS_ADDR_IN_SPIFI(splash_image14)) { 00091 notify_completion(false); 00092 } 00093 00094 // Make sure that splash_image15 is placed in SPIFI 00095 if (!IS_ADDR_IN_SPIFI(splash_image15)) { 00096 notify_completion(false); 00097 } 00098 00099 notify_completion(true); 00100 }
Generated on Tue Jul 12 2022 11:01:54 by
1.7.2
