xeye_ atsu
/
DMA_LLI_TEST
LINKED LIST TEST on mbed
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 /***********************************************************************//** 00003 * @file link_list.c 00004 * @purpose This example used to test GPDMA Link list function 00005 * @version 1.0 00006 * @date 16. July. 2010 00007 * @author NXP MCU SW Application Team 00008 *--------------------------------------------------------------------- 00009 * Software that is described herein is for illustrative purposes only 00010 * which provides customers with programming information regarding the 00011 * products. This software is supplied "AS IS" without any warranties. 00012 * NXP Semiconductors assumes no responsibility or liability for the 00013 * use of the software, conveys no license or title under any patent, 00014 * copyright, or mask work right to the product. NXP Semiconductors 00015 * reserves the right to make changes in the software without 00016 * notification. NXP Semiconductors also make no representation or 00017 * warranty that such application will be suitable for the specified 00018 * use without further testing or modification. 00019 **********************************************************************/ 00020 #include "lpc17xx_gpdma.h" 00021 #include "lpc17xx_libcfg.h" 00022 #include "debug_frmwrk.h" 00023 00024 /* Example group ----------------------------------------------------------- */ 00025 /** @defgroup GPDMA_Link_list Link_list 00026 * @ingroup GPDMA_Examples 00027 * @{ 00028 */ 00029 00030 /************************** PRIVATE DEFINTIONS*************************/ 00031 /** DMA transfer size */ 00032 #define DMA_SIZE 32 00033 00034 /************************** PRIVATE VARIABLES *************************/ 00035 uint8_t menu[]= 00036 "********************************************************************************\n\r" 00037 "Hello NXP Semiconductors \n\r" 00038 "GPDMA demo \n\r" 00039 "\t - MCU: LPC17xx \n\r" 00040 "\t - Core: ARM CORTEX-M3 \n\r" 00041 "\t - Communicate via: UART0 - 115200 bps \n\r" 00042 "This example used to test GPDMA link list function \n\r" 00043 "********************************************************************************\n\r"; 00044 uint8_t menu2[] = "Demo terminated! \n\r"; 00045 uint8_t err_menu[] = "Buffer Check fail!\n\r"; 00046 uint8_t compl_menu[] = "Buffer Check success!\n\r"; 00047 00048 uint32_t DMADest_Buffer[DMA_SIZE]; 00049 00050 #if (defined (__ICCARM__)) 00051 #pragma location = "data_init" 00052 uint32_t const DMASrc_Buffer1[DMA_SIZE/2] = 00053 #else 00054 uint32_t DMASrc_Buffer1[DMA_SIZE/2] __attribute__((at(0x2007C000))) = 00055 #endif 00056 { 00057 0x01020304,0x05060708,0x090A0B0C,0x0D0E0F10, 00058 0x11121314,0x15161718,0x191A1B1C,0x1D1E1F20, 00059 0x21222324,0x25262728,0x292A2B2C,0x2D2E2F30, 00060 0x31323334,0x35363738,0x393A3B3C,0x3D3E3F40 00061 }; 00062 00063 // Terminal Counter flag for Channel 0 00064 __IO uint32_t Channel0_TC; 00065 00066 // Error Counter flag for Channel 0 00067 __IO uint32_t Channel0_Err; 00068 00069 #if (defined (__ICCARM__)) 00070 #pragma location = "data_init" 00071 uint32_t const DMASrc_Buffer2[DMA_SIZE/2] = 00072 #else 00073 uint32_t DMASrc_Buffer2[DMA_SIZE/2] __attribute__((at(0x2007C200)))= 00074 #endif 00075 { 00076 0x41424344,0x45464748,0x494A4B4C,0x4D4E4F50, 00077 0x51525354,0x55565758,0x595A5B5C,0x5D5E5F60, 00078 0x61626364,0x65666768,0x696A6B6C,0x6D6E6F70, 00079 0x71727374,0x75767778,0x797A7B7C,0x7D7E7F80 00080 }; 00081 00082 /*-------------------------MAIN FUNCTION------------------------------*/ 00083 extern "C" void DMA_IRQHandler (void); 00084 00085 void print_menu(void); 00086 void Error_Loop(void); 00087 00088 /*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/ 00089 /*********************************************************************//** 00090 * @brief GPDMA interrupt handler sub-routine 00091 * @param[in] None 00092 * @return None 00093 **********************************************************************/ 00094 void DMA_IRQHandler (void) 00095 { 00096 printf("hogehogeIRQ \r\n"); 00097 // check GPDMA interrupt on channel 0 00098 if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){ //check interrupt status on channel 0 00099 // Check counter terminal status 00100 if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){ 00101 // Clear terminate counter Interrupt pending 00102 GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0); 00103 Channel0_TC++; 00104 } 00105 if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){ 00106 // Clear error counter Interrupt pending 00107 GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0); 00108 Channel0_Err++; 00109 } 00110 } 00111 } 00112 00113 /*-------------------------PRIVATE FUNCTIONS-----------------------------*/ 00114 /*********************************************************************//** 00115 * @brief Print Welcome menu 00116 * @param[in] none 00117 * @return None 00118 **********************************************************************/ 00119 void print_menu(void) 00120 { 00121 //_DBG(menu); 00122 } 00123 00124 00125 /*********************************************************************//** 00126 * @brief Verify buffer 00127 * @param[in] none 00128 * @return None 00129 **********************************************************************/ 00130 void Buffer_Verify(void) 00131 { 00132 uint8_t i; 00133 uint32_t *src_addr = (uint32_t *)DMASrc_Buffer1; 00134 uint32_t *dest_addr = (uint32_t *)DMADest_Buffer; 00135 00136 for ( i = 0; i < DMA_SIZE/2; i++ ) 00137 { 00138 if ( *src_addr++ != *dest_addr++ ) 00139 { 00140 /* Call Error Loop */ 00141 Error_Loop(); 00142 } 00143 } 00144 src_addr = (uint32_t *)DMASrc_Buffer2; 00145 for ( i = 0; i < DMA_SIZE/2; i++ ) 00146 { 00147 if ( *src_addr++ != *dest_addr++ ) 00148 { 00149 /* Call Error Loop */ 00150 Error_Loop(); 00151 } 00152 } 00153 } 00154 00155 00156 /*********************************************************************//** 00157 * @brief Error Loop (called by Buffer_Verify() if any error) 00158 * @param[in] none 00159 * @return None 00160 **********************************************************************/ 00161 void Error_Loop(void) 00162 { 00163 //_DBG(err_menu); 00164 00165 /* Loop forever */ 00166 while (1); 00167 } 00168 00169 00170 /*-------------------------MAIN FUNCTION--------------------------------*/ 00171 /*********************************************************************//** 00172 * @brief c_entry: Main program body 00173 * @param[in] None 00174 * @return int 00175 **********************************************************************/ 00176 int c_entry(void) 00177 { 00178 printf("start! \r\n"); 00179 GPDMA_Channel_CFG_Type GPDMACfg; 00180 GPDMA_LLI_Type DMA_LLI_Struct[2]; 00181 00182 /* Initialize debug via UART0 00183 * 115200bps 00184 * 8 data bit 00185 * No parity 00186 * 1 stop bit 00187 * No flow control 00188 */ 00189 //debug_frmwrk_init(); 00190 00191 // print welcome screen 00192 //print_menu(); 00193 printf("Go! \r\n"); 00194 /* GPDMA block section -------------------------------------------- */ 00195 /* Disable GPDMA interrupt */ 00196 NVIC_DisableIRQ(DMA_IRQn ); 00197 /* preemption = 1, sub-priority = 1 */ 00198 NVIC_SetPriority(DMA_IRQn , ((0x01<<3)|0x01)); 00199 00200 /* Initialize GPDMA controller */ 00201 GPDMA_Init(); 00202 00203 /* Init GPDMA link list */ 00204 DMA_LLI_Struct[0].SrcAddr = (uint32_t)&DMASrc_Buffer1; 00205 DMA_LLI_Struct[0].DstAddr = (uint32_t)&DMADest_Buffer; 00206 DMA_LLI_Struct[0].NextLLI = (uint32_t)&DMA_LLI_Struct[1]; 00207 DMA_LLI_Struct[0].Control = (DMA_SIZE/2) 00208 | (2<<18) //source width 32 bit 00209 | (2<<21) //dest. width 32 bit 00210 | (1<<26) //source increment 00211 | (1<<27) 00212 | (1<<31) 00213 ; 00214 DMA_LLI_Struct[1].SrcAddr = (uint32_t)&DMASrc_Buffer2; 00215 DMA_LLI_Struct[1].DstAddr = ((uint32_t)&DMADest_Buffer) + (DMA_SIZE/2)*4; 00216 DMA_LLI_Struct[1].NextLLI = (uint32_t)&DMA_LLI_Struct[0]; 00217 DMA_LLI_Struct[1].Control = (DMA_SIZE/2) 00218 | (2<<18) //source width 32 bit 00219 | (2<<21) //dest. width 32 bit 00220 | (1<<26) //source increment 00221 | (1<<27) 00222 | (1<<31) 00223 ; 00224 00225 // Setup GPDMA channel -------------------------------- 00226 // channel 0 00227 GPDMACfg.ChannelNum = 0; 00228 // Source memory 00229 GPDMACfg.SrcMemAddr = (uint32_t)DMASrc_Buffer1; 00230 // Destination memory 00231 GPDMACfg.DstMemAddr = (uint32_t)DMADest_Buffer; 00232 // Transfer size 00233 GPDMACfg.TransferSize = DMA_SIZE; 00234 // Transfer width 00235 GPDMACfg.TransferWidth = GPDMA_WIDTH_WORD; 00236 // Transfer type 00237 GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2M; 00238 // Source connection - unused 00239 GPDMACfg.SrcConn = 0; 00240 // Destination connection - unused 00241 GPDMACfg.DstConn = 0; 00242 // Linker List Item 00243 GPDMACfg.DMALLI = (uint32_t)&DMA_LLI_Struct[0]; 00244 // Setup channel with given parameter 00245 GPDMA_Setup(&GPDMACfg); 00246 00247 /* Reset terminal counter */ 00248 Channel0_TC = 0; 00249 /* Reset Error counter */ 00250 Channel0_Err = 0; 00251 00252 //_DBG_("Start transfer..."); 00253 00254 // Enable GPDMA channel 0 00255 GPDMA_ChannelCmd(0, ENABLE); 00256 00257 /* Enable GPDMA interrupt */ 00258 NVIC_EnableIRQ(DMA_IRQn ); 00259 00260 /* Wait for GPDMA processing complete */ 00261 while ((Channel0_TC == 0) && (Channel0_Err == 0)); 00262 00263 /* Verify buffer */ 00264 Buffer_Verify(); 00265 00266 //_DBG(compl_menu); 00267 printf("softcontrol end\r\n"); 00268 /* Loop forever */ 00269 while(1); 00270 return 1; 00271 } 00272 00273 /* With ARM and GHS toolsets, the entry point is main() - this will 00274 allow the linker to generate wrapper code to setup stacks, allocate 00275 heap area, and initialize and copy code and data segments. For GNU 00276 toolsets, the entry point is through __start() in the crt0_gnu.asm 00277 file, and that startup code will setup stacks and data */ 00278 int main(void) { 00279 return c_entry(); 00280 } 00281 00282 #ifdef DEBUG 00283 /******************************************************************************* 00284 * @brief Reports the name of the source file and the source line number 00285 * where the CHECK_PARAM error has occurred. 00286 * @param[in] file Pointer to the source file name 00287 * @param[in] line assert_param error line source number 00288 * @return None 00289 *******************************************************************************/ 00290 void check_failed(uint8_t *file, uint32_t line) { 00291 /* User can add his own implementation to report the file name and line number, 00292 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 00293 00294 /* Infinite loop */ 00295 while (1) 00296 ; 00297 } 00298 #endif 00299 00300 /* 00301 * @} 00302 */
Generated on Wed Jul 13 2022 21:13:12 by 1.7.2