![](/media/cache/profiles/98c39996bf1543e974747a2549b3107c.50x50_q85.png)
LINKED LIST TEST on mbed
main.cpp@0:e8bfffbb3ab6, 2011-02-26 (annotated)
- Committer:
- lynxeyed_atsu
- Date:
- Sat Feb 26 03:55:12 2011 +0000
- Revision:
- 0:e8bfffbb3ab6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lynxeyed_atsu | 0:e8bfffbb3ab6 | 1 | #include "mbed.h" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 2 | /***********************************************************************//** |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 3 | * @file link_list.c |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 4 | * @purpose This example used to test GPDMA Link list function |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 5 | * @version 1.0 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 6 | * @date 16. July. 2010 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 7 | * @author NXP MCU SW Application Team |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 8 | *--------------------------------------------------------------------- |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 9 | * Software that is described herein is for illustrative purposes only |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 10 | * which provides customers with programming information regarding the |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 11 | * products. This software is supplied "AS IS" without any warranties. |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 12 | * NXP Semiconductors assumes no responsibility or liability for the |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 13 | * use of the software, conveys no license or title under any patent, |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 14 | * copyright, or mask work right to the product. NXP Semiconductors |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 15 | * reserves the right to make changes in the software without |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 16 | * notification. NXP Semiconductors also make no representation or |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 17 | * warranty that such application will be suitable for the specified |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 18 | * use without further testing or modification. |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 19 | **********************************************************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 20 | #include "lpc17xx_gpdma.h" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 21 | #include "lpc17xx_libcfg.h" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 22 | #include "debug_frmwrk.h" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 23 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 24 | /* Example group ----------------------------------------------------------- */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 25 | /** @defgroup GPDMA_Link_list Link_list |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 26 | * @ingroup GPDMA_Examples |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 27 | * @{ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 28 | */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 29 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 30 | /************************** PRIVATE DEFINTIONS*************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 31 | /** DMA transfer size */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 32 | #define DMA_SIZE 32 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 33 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 34 | /************************** PRIVATE VARIABLES *************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 35 | uint8_t menu[]= |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 36 | "********************************************************************************\n\r" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 37 | "Hello NXP Semiconductors \n\r" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 38 | "GPDMA demo \n\r" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 39 | "\t - MCU: LPC17xx \n\r" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 40 | "\t - Core: ARM CORTEX-M3 \n\r" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 41 | "\t - Communicate via: UART0 - 115200 bps \n\r" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 42 | "This example used to test GPDMA link list function \n\r" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 43 | "********************************************************************************\n\r"; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 44 | uint8_t menu2[] = "Demo terminated! \n\r"; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 45 | uint8_t err_menu[] = "Buffer Check fail!\n\r"; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 46 | uint8_t compl_menu[] = "Buffer Check success!\n\r"; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 47 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 48 | uint32_t DMADest_Buffer[DMA_SIZE]; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 49 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 50 | #if (defined (__ICCARM__)) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 51 | #pragma location = "data_init" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 52 | uint32_t const DMASrc_Buffer1[DMA_SIZE/2] = |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 53 | #else |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 54 | uint32_t DMASrc_Buffer1[DMA_SIZE/2] __attribute__((at(0x2007C000))) = |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 55 | #endif |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 56 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 57 | 0x01020304,0x05060708,0x090A0B0C,0x0D0E0F10, |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 58 | 0x11121314,0x15161718,0x191A1B1C,0x1D1E1F20, |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 59 | 0x21222324,0x25262728,0x292A2B2C,0x2D2E2F30, |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 60 | 0x31323334,0x35363738,0x393A3B3C,0x3D3E3F40 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 61 | }; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 62 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 63 | // Terminal Counter flag for Channel 0 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 64 | __IO uint32_t Channel0_TC; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 65 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 66 | // Error Counter flag for Channel 0 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 67 | __IO uint32_t Channel0_Err; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 68 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 69 | #if (defined (__ICCARM__)) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 70 | #pragma location = "data_init" |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 71 | uint32_t const DMASrc_Buffer2[DMA_SIZE/2] = |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 72 | #else |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 73 | uint32_t DMASrc_Buffer2[DMA_SIZE/2] __attribute__((at(0x2007C200)))= |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 74 | #endif |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 75 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 76 | 0x41424344,0x45464748,0x494A4B4C,0x4D4E4F50, |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 77 | 0x51525354,0x55565758,0x595A5B5C,0x5D5E5F60, |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 78 | 0x61626364,0x65666768,0x696A6B6C,0x6D6E6F70, |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 79 | 0x71727374,0x75767778,0x797A7B7C,0x7D7E7F80 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 80 | }; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 81 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 82 | /*-------------------------MAIN FUNCTION------------------------------*/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 83 | extern "C" void DMA_IRQHandler (void); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 84 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 85 | void print_menu(void); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 86 | void Error_Loop(void); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 87 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 88 | /*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 89 | /*********************************************************************//** |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 90 | * @brief GPDMA interrupt handler sub-routine |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 91 | * @param[in] None |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 92 | * @return None |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 93 | **********************************************************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 94 | void DMA_IRQHandler (void) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 95 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 96 | printf("hogehogeIRQ \r\n"); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 97 | // check GPDMA interrupt on channel 0 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 98 | if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){ //check interrupt status on channel 0 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 99 | // Check counter terminal status |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 100 | if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 101 | // Clear terminate counter Interrupt pending |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 102 | GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 103 | Channel0_TC++; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 104 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 105 | if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 106 | // Clear error counter Interrupt pending |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 107 | GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 108 | Channel0_Err++; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 109 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 110 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 111 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 112 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 113 | /*-------------------------PRIVATE FUNCTIONS-----------------------------*/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 114 | /*********************************************************************//** |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 115 | * @brief Print Welcome menu |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 116 | * @param[in] none |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 117 | * @return None |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 118 | **********************************************************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 119 | void print_menu(void) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 120 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 121 | //_DBG(menu); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 122 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 123 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 124 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 125 | /*********************************************************************//** |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 126 | * @brief Verify buffer |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 127 | * @param[in] none |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 128 | * @return None |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 129 | **********************************************************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 130 | void Buffer_Verify(void) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 131 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 132 | uint8_t i; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 133 | uint32_t *src_addr = (uint32_t *)DMASrc_Buffer1; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 134 | uint32_t *dest_addr = (uint32_t *)DMADest_Buffer; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 135 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 136 | for ( i = 0; i < DMA_SIZE/2; i++ ) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 137 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 138 | if ( *src_addr++ != *dest_addr++ ) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 139 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 140 | /* Call Error Loop */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 141 | Error_Loop(); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 142 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 143 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 144 | src_addr = (uint32_t *)DMASrc_Buffer2; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 145 | for ( i = 0; i < DMA_SIZE/2; i++ ) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 146 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 147 | if ( *src_addr++ != *dest_addr++ ) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 148 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 149 | /* Call Error Loop */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 150 | Error_Loop(); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 151 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 152 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 153 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 154 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 155 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 156 | /*********************************************************************//** |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 157 | * @brief Error Loop (called by Buffer_Verify() if any error) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 158 | * @param[in] none |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 159 | * @return None |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 160 | **********************************************************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 161 | void Error_Loop(void) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 162 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 163 | //_DBG(err_menu); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 164 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 165 | /* Loop forever */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 166 | while (1); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 167 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 168 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 169 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 170 | /*-------------------------MAIN FUNCTION--------------------------------*/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 171 | /*********************************************************************//** |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 172 | * @brief c_entry: Main program body |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 173 | * @param[in] None |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 174 | * @return int |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 175 | **********************************************************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 176 | int c_entry(void) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 177 | { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 178 | printf("start! \r\n"); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 179 | GPDMA_Channel_CFG_Type GPDMACfg; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 180 | GPDMA_LLI_Type DMA_LLI_Struct[2]; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 181 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 182 | /* Initialize debug via UART0 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 183 | * 115200bps |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 184 | * 8 data bit |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 185 | * No parity |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 186 | * 1 stop bit |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 187 | * No flow control |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 188 | */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 189 | //debug_frmwrk_init(); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 190 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 191 | // print welcome screen |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 192 | //print_menu(); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 193 | printf("Go! \r\n"); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 194 | /* GPDMA block section -------------------------------------------- */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 195 | /* Disable GPDMA interrupt */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 196 | NVIC_DisableIRQ(DMA_IRQn); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 197 | /* preemption = 1, sub-priority = 1 */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 198 | NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01)); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 199 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 200 | /* Initialize GPDMA controller */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 201 | GPDMA_Init(); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 202 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 203 | /* Init GPDMA link list */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 204 | DMA_LLI_Struct[0].SrcAddr = (uint32_t)&DMASrc_Buffer1; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 205 | DMA_LLI_Struct[0].DstAddr = (uint32_t)&DMADest_Buffer; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 206 | DMA_LLI_Struct[0].NextLLI = (uint32_t)&DMA_LLI_Struct[1]; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 207 | DMA_LLI_Struct[0].Control = (DMA_SIZE/2) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 208 | | (2<<18) //source width 32 bit |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 209 | | (2<<21) //dest. width 32 bit |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 210 | | (1<<26) //source increment |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 211 | | (1<<27) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 212 | | (1<<31) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 213 | ; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 214 | DMA_LLI_Struct[1].SrcAddr = (uint32_t)&DMASrc_Buffer2; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 215 | DMA_LLI_Struct[1].DstAddr = ((uint32_t)&DMADest_Buffer) + (DMA_SIZE/2)*4; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 216 | DMA_LLI_Struct[1].NextLLI = (uint32_t)&DMA_LLI_Struct[0]; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 217 | DMA_LLI_Struct[1].Control = (DMA_SIZE/2) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 218 | | (2<<18) //source width 32 bit |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 219 | | (2<<21) //dest. width 32 bit |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 220 | | (1<<26) //source increment |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 221 | | (1<<27) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 222 | | (1<<31) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 223 | ; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 224 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 225 | // Setup GPDMA channel -------------------------------- |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 226 | // channel 0 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 227 | GPDMACfg.ChannelNum = 0; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 228 | // Source memory |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 229 | GPDMACfg.SrcMemAddr = (uint32_t)DMASrc_Buffer1; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 230 | // Destination memory |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 231 | GPDMACfg.DstMemAddr = (uint32_t)DMADest_Buffer; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 232 | // Transfer size |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 233 | GPDMACfg.TransferSize = DMA_SIZE; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 234 | // Transfer width |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 235 | GPDMACfg.TransferWidth = GPDMA_WIDTH_WORD; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 236 | // Transfer type |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 237 | GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2M; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 238 | // Source connection - unused |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 239 | GPDMACfg.SrcConn = 0; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 240 | // Destination connection - unused |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 241 | GPDMACfg.DstConn = 0; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 242 | // Linker List Item |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 243 | GPDMACfg.DMALLI = (uint32_t)&DMA_LLI_Struct[0]; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 244 | // Setup channel with given parameter |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 245 | GPDMA_Setup(&GPDMACfg); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 246 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 247 | /* Reset terminal counter */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 248 | Channel0_TC = 0; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 249 | /* Reset Error counter */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 250 | Channel0_Err = 0; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 251 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 252 | //_DBG_("Start transfer..."); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 253 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 254 | // Enable GPDMA channel 0 |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 255 | GPDMA_ChannelCmd(0, ENABLE); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 256 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 257 | /* Enable GPDMA interrupt */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 258 | NVIC_EnableIRQ(DMA_IRQn); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 259 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 260 | /* Wait for GPDMA processing complete */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 261 | while ((Channel0_TC == 0) && (Channel0_Err == 0)); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 262 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 263 | /* Verify buffer */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 264 | Buffer_Verify(); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 265 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 266 | //_DBG(compl_menu); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 267 | printf("softcontrol end\r\n"); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 268 | /* Loop forever */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 269 | while(1); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 270 | return 1; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 271 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 272 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 273 | /* With ARM and GHS toolsets, the entry point is main() - this will |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 274 | allow the linker to generate wrapper code to setup stacks, allocate |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 275 | heap area, and initialize and copy code and data segments. For GNU |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 276 | toolsets, the entry point is through __start() in the crt0_gnu.asm |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 277 | file, and that startup code will setup stacks and data */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 278 | int main(void) { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 279 | return c_entry(); |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 280 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 281 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 282 | #ifdef DEBUG |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 283 | /******************************************************************************* |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 284 | * @brief Reports the name of the source file and the source line number |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 285 | * where the CHECK_PARAM error has occurred. |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 286 | * @param[in] file Pointer to the source file name |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 287 | * @param[in] line assert_param error line source number |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 288 | * @return None |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 289 | *******************************************************************************/ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 290 | void check_failed(uint8_t *file, uint32_t line) { |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 291 | /* User can add his own implementation to report the file name and line number, |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 292 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 293 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 294 | /* Infinite loop */ |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 295 | while (1) |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 296 | ; |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 297 | } |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 298 | #endif |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 299 | |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 300 | /* |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 301 | * @} |
lynxeyed_atsu | 0:e8bfffbb3ab6 | 302 | */ |