These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Committer:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Revision:
0:bf7b9fba3924

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frank26080115 0:bf7b9fba3924 1 /***********************************************************************//**
frank26080115 0:bf7b9fba3924 2 * @file ssp_dma.c
frank26080115 0:bf7b9fba3924 3 * @purpose This example describes how to use SPP in Master mode with
frank26080115 0:bf7b9fba3924 4 * loop-back mode (MOSI <-> MISO), using DMA for both Tx and
frank26080115 0:bf7b9fba3924 5 * Rx channel.
frank26080115 0:bf7b9fba3924 6 * @version 2.0
frank26080115 0:bf7b9fba3924 7 * @date 21. May. 2010
frank26080115 0:bf7b9fba3924 8 * @author NXP MCU SW Application Team
frank26080115 0:bf7b9fba3924 9 *---------------------------------------------------------------------
frank26080115 0:bf7b9fba3924 10 * Software that is described herein is for illustrative purposes only
frank26080115 0:bf7b9fba3924 11 * which provides customers with programming information regarding the
frank26080115 0:bf7b9fba3924 12 * products. This software is supplied "AS IS" without any warranties.
frank26080115 0:bf7b9fba3924 13 * NXP Semiconductors assumes no responsibility or liability for the
frank26080115 0:bf7b9fba3924 14 * use of the software, conveys no license or title under any patent,
frank26080115 0:bf7b9fba3924 15 * copyright, or mask work right to the product. NXP Semiconductors
frank26080115 0:bf7b9fba3924 16 * reserves the right to make changes in the software without
frank26080115 0:bf7b9fba3924 17 * notification. NXP Semiconductors also make no representation or
frank26080115 0:bf7b9fba3924 18 * warranty that such application will be suitable for the specified
frank26080115 0:bf7b9fba3924 19 * use without further testing or modification.
frank26080115 0:bf7b9fba3924 20 **********************************************************************/
frank26080115 0:bf7b9fba3924 21 #include "lpc17xx_ssp.h"
frank26080115 0:bf7b9fba3924 22 #include "lpc17xx_libcfg.h"
frank26080115 0:bf7b9fba3924 23 #include "lpc17xx_pinsel.h"
frank26080115 0:bf7b9fba3924 24 #include "lpc17xx_gpdma.h"
frank26080115 0:bf7b9fba3924 25 #include "debug_frmwrk.h"
frank26080115 0:bf7b9fba3924 26
frank26080115 0:bf7b9fba3924 27 /* Example group ----------------------------------------------------------- */
frank26080115 0:bf7b9fba3924 28 /** @defgroup SSP_dma dma
frank26080115 0:bf7b9fba3924 29 * @ingroup SSP_Examples
frank26080115 0:bf7b9fba3924 30 * @{
frank26080115 0:bf7b9fba3924 31 */
frank26080115 0:bf7b9fba3924 32
frank26080115 0:bf7b9fba3924 33 /************************** PRIVATE DEFINITIONS ***********************/
frank26080115 0:bf7b9fba3924 34 /* For DMA controller */
frank26080115 0:bf7b9fba3924 35 #define DMA_DATA_SIZE 65
frank26080115 0:bf7b9fba3924 36
frank26080115 0:bf7b9fba3924 37 /************************** PRIVATE VARIABLES *************************/
frank26080115 0:bf7b9fba3924 38 uint8_t menu1[] =
frank26080115 0:bf7b9fba3924 39 "********************************************************************************\n\r"
frank26080115 0:bf7b9fba3924 40 "Hello NXP Semiconductors \n\r"
frank26080115 0:bf7b9fba3924 41 "SSP demo \n\r"
frank26080115 0:bf7b9fba3924 42 "\t - MCU: LPC17xx \n\r"
frank26080115 0:bf7b9fba3924 43 "\t - Core: ARM Cortex-M3 \n\r"
frank26080115 0:bf7b9fba3924 44 "\t - Communicate via: UART0 - 115200bps \n\r"
frank26080115 0:bf7b9fba3924 45 " This example uses SSP function in MASTER mode \n\r"
frank26080115 0:bf7b9fba3924 46 " with Loop-back mode (MOSI <-> MISO) \n\r"
frank26080115 0:bf7b9fba3924 47 " Transfer 64 bytes of data (in DMA mode for both Tx and Rx \n\r"
frank26080115 0:bf7b9fba3924 48 " channel) \n\r"
frank26080115 0:bf7b9fba3924 49 "********************************************************************************\n\r";
frank26080115 0:bf7b9fba3924 50 uint8_t menu2[] = "Demo terminated! \n\r";
frank26080115 0:bf7b9fba3924 51
frank26080115 0:bf7b9fba3924 52 // SSP Configuration structure variable
frank26080115 0:bf7b9fba3924 53 SSP_CFG_Type SSP_ConfigStruct;
frank26080115 0:bf7b9fba3924 54
frank26080115 0:bf7b9fba3924 55 // Terminal Counter flag for Channel 0
frank26080115 0:bf7b9fba3924 56 __IO uint32_t Channel0_TC;
frank26080115 0:bf7b9fba3924 57
frank26080115 0:bf7b9fba3924 58 // Error Counter flag for Channel 0
frank26080115 0:bf7b9fba3924 59 __IO uint32_t Channel0_Err;
frank26080115 0:bf7b9fba3924 60
frank26080115 0:bf7b9fba3924 61 // Terminal Counter flag for Channel 1
frank26080115 0:bf7b9fba3924 62 __IO uint32_t Channel1_TC;
frank26080115 0:bf7b9fba3924 63
frank26080115 0:bf7b9fba3924 64 // Error Counter flag for Channel 1
frank26080115 0:bf7b9fba3924 65 __IO uint32_t Channel1_Err;
frank26080115 0:bf7b9fba3924 66
frank26080115 0:bf7b9fba3924 67 // DMA source variable
frank26080115 0:bf7b9fba3924 68 uint8_t dma_src[DMA_DATA_SIZE];
frank26080115 0:bf7b9fba3924 69
frank26080115 0:bf7b9fba3924 70 // DMA source variable
frank26080115 0:bf7b9fba3924 71 uint8_t dma_dst[DMA_DATA_SIZE];
frank26080115 0:bf7b9fba3924 72
frank26080115 0:bf7b9fba3924 73
frank26080115 0:bf7b9fba3924 74 /************************** PRIVATE FUNCTIONS *************************/
frank26080115 0:bf7b9fba3924 75 void DMA_IRQHandler (void);
frank26080115 0:bf7b9fba3924 76
frank26080115 0:bf7b9fba3924 77 void print_menu(void);
frank26080115 0:bf7b9fba3924 78 void Buffer_Init(void);
frank26080115 0:bf7b9fba3924 79 void Buffer_Verify(void);
frank26080115 0:bf7b9fba3924 80 void Error_Loop(void);
frank26080115 0:bf7b9fba3924 81
frank26080115 0:bf7b9fba3924 82 /*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
frank26080115 0:bf7b9fba3924 83 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 84 * @brief GPDMA interrupt handler sub-routine
frank26080115 0:bf7b9fba3924 85 * @param[in] None
frank26080115 0:bf7b9fba3924 86 * @return None
frank26080115 0:bf7b9fba3924 87 **********************************************************************/
frank26080115 0:bf7b9fba3924 88 void DMA_IRQHandler (void)
frank26080115 0:bf7b9fba3924 89 {
frank26080115 0:bf7b9fba3924 90 // check GPDMA interrupt on channel 0
frank26080115 0:bf7b9fba3924 91 if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 0)){
frank26080115 0:bf7b9fba3924 92 // Check counter terminal status
frank26080115 0:bf7b9fba3924 93 if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)){
frank26080115 0:bf7b9fba3924 94 // Clear terminate counter Interrupt pending
frank26080115 0:bf7b9fba3924 95 GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
frank26080115 0:bf7b9fba3924 96 Channel0_TC++;
frank26080115 0:bf7b9fba3924 97 }
frank26080115 0:bf7b9fba3924 98 // Check error terminal status
frank26080115 0:bf7b9fba3924 99 if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)){
frank26080115 0:bf7b9fba3924 100 // Clear error counter Interrupt pending
frank26080115 0:bf7b9fba3924 101 GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
frank26080115 0:bf7b9fba3924 102 Channel0_Err++;
frank26080115 0:bf7b9fba3924 103 }
frank26080115 0:bf7b9fba3924 104 }
frank26080115 0:bf7b9fba3924 105 // check GPDMA interrupt on channel 1
frank26080115 0:bf7b9fba3924 106 if (GPDMA_IntGetStatus(GPDMA_STAT_INT, 1)){
frank26080115 0:bf7b9fba3924 107 // Check counter terminal status
frank26080115 0:bf7b9fba3924 108 if(GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 1)){
frank26080115 0:bf7b9fba3924 109 // Clear terminate counter Interrupt pending
frank26080115 0:bf7b9fba3924 110 GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 1);
frank26080115 0:bf7b9fba3924 111 Channel1_TC++;
frank26080115 0:bf7b9fba3924 112 }
frank26080115 0:bf7b9fba3924 113 // Check error terminal status
frank26080115 0:bf7b9fba3924 114 if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 1)){
frank26080115 0:bf7b9fba3924 115 // Clear error counter Interrupt pending
frank26080115 0:bf7b9fba3924 116 GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 1);
frank26080115 0:bf7b9fba3924 117 Channel1_Err++;
frank26080115 0:bf7b9fba3924 118 }
frank26080115 0:bf7b9fba3924 119 }
frank26080115 0:bf7b9fba3924 120 }
frank26080115 0:bf7b9fba3924 121
frank26080115 0:bf7b9fba3924 122 /*-------------------------PRIVATE FUNCTIONS------------------------------*/
frank26080115 0:bf7b9fba3924 123 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 124 * @brief Initialize buffer
frank26080115 0:bf7b9fba3924 125 * @param[in] none
frank26080115 0:bf7b9fba3924 126 * @return None
frank26080115 0:bf7b9fba3924 127 **********************************************************************/
frank26080115 0:bf7b9fba3924 128 void Buffer_Init(void)
frank26080115 0:bf7b9fba3924 129 {
frank26080115 0:bf7b9fba3924 130 uint32_t i;
frank26080115 0:bf7b9fba3924 131 uint8_t *src_addr = (uint8_t *)dma_src;
frank26080115 0:bf7b9fba3924 132 uint8_t *dest_addr = (uint8_t *)dma_dst;
frank26080115 0:bf7b9fba3924 133
frank26080115 0:bf7b9fba3924 134 for ( i = 0; i < DMA_DATA_SIZE; i++ )
frank26080115 0:bf7b9fba3924 135 {
frank26080115 0:bf7b9fba3924 136 *src_addr++ = i;
frank26080115 0:bf7b9fba3924 137 *dest_addr++ = 0;
frank26080115 0:bf7b9fba3924 138 }
frank26080115 0:bf7b9fba3924 139 }
frank26080115 0:bf7b9fba3924 140
frank26080115 0:bf7b9fba3924 141 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 142 * @brief Verify buffer
frank26080115 0:bf7b9fba3924 143 * @param[in] none
frank26080115 0:bf7b9fba3924 144 * @return None
frank26080115 0:bf7b9fba3924 145 **********************************************************************/
frank26080115 0:bf7b9fba3924 146 void Buffer_Verify(void)
frank26080115 0:bf7b9fba3924 147 {
frank26080115 0:bf7b9fba3924 148 uint32_t i;
frank26080115 0:bf7b9fba3924 149 uint8_t *src_addr = (uint8_t *)dma_src;
frank26080115 0:bf7b9fba3924 150 uint8_t *dest_addr = (uint8_t *)dma_dst;
frank26080115 0:bf7b9fba3924 151
frank26080115 0:bf7b9fba3924 152 for ( i = 0; i < DMA_DATA_SIZE; i++ )
frank26080115 0:bf7b9fba3924 153 {
frank26080115 0:bf7b9fba3924 154 if ( *src_addr++ != *dest_addr++ )
frank26080115 0:bf7b9fba3924 155 {
frank26080115 0:bf7b9fba3924 156 /* Call Error Loop */
frank26080115 0:bf7b9fba3924 157 _DBG_("Verify error");
frank26080115 0:bf7b9fba3924 158 Error_Loop();
frank26080115 0:bf7b9fba3924 159 }
frank26080115 0:bf7b9fba3924 160 }
frank26080115 0:bf7b9fba3924 161 }
frank26080115 0:bf7b9fba3924 162
frank26080115 0:bf7b9fba3924 163 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 164 * @brief Error Loop (called by Buffer_Verify() if any error)
frank26080115 0:bf7b9fba3924 165 * @param[in] none
frank26080115 0:bf7b9fba3924 166 * @return None
frank26080115 0:bf7b9fba3924 167 **********************************************************************/
frank26080115 0:bf7b9fba3924 168 void Error_Loop(void)
frank26080115 0:bf7b9fba3924 169 {
frank26080115 0:bf7b9fba3924 170 /* Loop forever */
frank26080115 0:bf7b9fba3924 171 while (1);
frank26080115 0:bf7b9fba3924 172 }
frank26080115 0:bf7b9fba3924 173
frank26080115 0:bf7b9fba3924 174 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 175 * @brief Print Welcome menu
frank26080115 0:bf7b9fba3924 176 * @param[in] none
frank26080115 0:bf7b9fba3924 177 * @return None
frank26080115 0:bf7b9fba3924 178 **********************************************************************/
frank26080115 0:bf7b9fba3924 179 void print_menu(void)
frank26080115 0:bf7b9fba3924 180 {
frank26080115 0:bf7b9fba3924 181 _DBG(menu1);
frank26080115 0:bf7b9fba3924 182 }
frank26080115 0:bf7b9fba3924 183
frank26080115 0:bf7b9fba3924 184 /*-------------------------MAIN FUNCTION------------------------------*/
frank26080115 0:bf7b9fba3924 185 /*********************************************************************//**
frank26080115 0:bf7b9fba3924 186 * @brief c_entry: Main SSP program body
frank26080115 0:bf7b9fba3924 187 * @param[in] None
frank26080115 0:bf7b9fba3924 188 * @return int
frank26080115 0:bf7b9fba3924 189 **********************************************************************/
frank26080115 0:bf7b9fba3924 190 int c_entry(void)
frank26080115 0:bf7b9fba3924 191 {
frank26080115 0:bf7b9fba3924 192 GPDMA_Channel_CFG_Type GPDMACfg;
frank26080115 0:bf7b9fba3924 193 PINSEL_CFG_Type PinCfg;
frank26080115 0:bf7b9fba3924 194
frank26080115 0:bf7b9fba3924 195 /*
frank26080115 0:bf7b9fba3924 196 * Initialize SSP pin connect
frank26080115 0:bf7b9fba3924 197 * P0.15 - SCK;
frank26080115 0:bf7b9fba3924 198 * P0.16 - SSEL
frank26080115 0:bf7b9fba3924 199 * P0.17 - MISO
frank26080115 0:bf7b9fba3924 200 * P0.18 - MOSI
frank26080115 0:bf7b9fba3924 201 */
frank26080115 0:bf7b9fba3924 202 PinCfg.Funcnum = 2;
frank26080115 0:bf7b9fba3924 203 PinCfg.OpenDrain = 0;
frank26080115 0:bf7b9fba3924 204 PinCfg.Pinmode = 0;
frank26080115 0:bf7b9fba3924 205 PinCfg.Portnum = 0;
frank26080115 0:bf7b9fba3924 206 PinCfg.Pinnum = 15;
frank26080115 0:bf7b9fba3924 207 PINSEL_ConfigPin(&PinCfg);
frank26080115 0:bf7b9fba3924 208 PinCfg.Pinnum = 16;
frank26080115 0:bf7b9fba3924 209 PINSEL_ConfigPin(&PinCfg);
frank26080115 0:bf7b9fba3924 210 PinCfg.Pinnum = 17;
frank26080115 0:bf7b9fba3924 211 PINSEL_ConfigPin(&PinCfg);
frank26080115 0:bf7b9fba3924 212 PinCfg.Pinnum = 18;
frank26080115 0:bf7b9fba3924 213 PINSEL_ConfigPin(&PinCfg);
frank26080115 0:bf7b9fba3924 214
frank26080115 0:bf7b9fba3924 215 /* Initialize debug via UART0
frank26080115 0:bf7b9fba3924 216 * – 115200bps
frank26080115 0:bf7b9fba3924 217 * – 8 data bit
frank26080115 0:bf7b9fba3924 218 * – No parity
frank26080115 0:bf7b9fba3924 219 * – 1 stop bit
frank26080115 0:bf7b9fba3924 220 * – No flow control
frank26080115 0:bf7b9fba3924 221 */
frank26080115 0:bf7b9fba3924 222 debug_frmwrk_init();
frank26080115 0:bf7b9fba3924 223
frank26080115 0:bf7b9fba3924 224 // print welcome screen
frank26080115 0:bf7b9fba3924 225 print_menu();
frank26080115 0:bf7b9fba3924 226
frank26080115 0:bf7b9fba3924 227 /* Initializing SSP device section ------------------------------------------------------ */
frank26080115 0:bf7b9fba3924 228 // initialize SSP configuration structure to default
frank26080115 0:bf7b9fba3924 229 SSP_ConfigStructInit(&SSP_ConfigStruct);
frank26080115 0:bf7b9fba3924 230 // Initialize SSP peripheral with parameter given in structure above
frank26080115 0:bf7b9fba3924 231 SSP_Init(LPC_SSP0, &SSP_ConfigStruct);
frank26080115 0:bf7b9fba3924 232
frank26080115 0:bf7b9fba3924 233 // Enable SSP peripheral
frank26080115 0:bf7b9fba3924 234 SSP_Cmd(LPC_SSP0, ENABLE);
frank26080115 0:bf7b9fba3924 235
frank26080115 0:bf7b9fba3924 236
frank26080115 0:bf7b9fba3924 237 /* GPDMA Interrupt configuration section ------------------------------------------------- */
frank26080115 0:bf7b9fba3924 238 /* preemption = 1, sub-priority = 1 */
frank26080115 0:bf7b9fba3924 239 NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
frank26080115 0:bf7b9fba3924 240 /* Enable SSP0 interrupt */
frank26080115 0:bf7b9fba3924 241 NVIC_EnableIRQ(DMA_IRQn);
frank26080115 0:bf7b9fba3924 242
frank26080115 0:bf7b9fba3924 243
frank26080115 0:bf7b9fba3924 244 /* Initializing Buffer section ----------------------------------------------------------- */
frank26080115 0:bf7b9fba3924 245 Buffer_Init();
frank26080115 0:bf7b9fba3924 246
frank26080115 0:bf7b9fba3924 247 /* Initialize GPDMA controller */
frank26080115 0:bf7b9fba3924 248 GPDMA_Init();
frank26080115 0:bf7b9fba3924 249
frank26080115 0:bf7b9fba3924 250
frank26080115 0:bf7b9fba3924 251 /* Setting GPDMA interrupt */
frank26080115 0:bf7b9fba3924 252 // Disable interrupt for DMA
frank26080115 0:bf7b9fba3924 253 NVIC_DisableIRQ (DMA_IRQn);
frank26080115 0:bf7b9fba3924 254 /* preemption = 1, sub-priority = 1 */
frank26080115 0:bf7b9fba3924 255 NVIC_SetPriority(DMA_IRQn, ((0x01<<3)|0x01));
frank26080115 0:bf7b9fba3924 256
frank26080115 0:bf7b9fba3924 257
frank26080115 0:bf7b9fba3924 258 /* Configure GPDMA channel 0 -------------------------------------------------------------*/
frank26080115 0:bf7b9fba3924 259 /* DMA Channel 0 */
frank26080115 0:bf7b9fba3924 260 GPDMACfg.ChannelNum = 0;
frank26080115 0:bf7b9fba3924 261 // Source memory
frank26080115 0:bf7b9fba3924 262 GPDMACfg.SrcMemAddr = (uint32_t) &dma_src;
frank26080115 0:bf7b9fba3924 263 // Destination memory - Not used
frank26080115 0:bf7b9fba3924 264 GPDMACfg.DstMemAddr = 0;
frank26080115 0:bf7b9fba3924 265 // Transfer size
frank26080115 0:bf7b9fba3924 266 GPDMACfg.TransferSize = sizeof(dma_src);
frank26080115 0:bf7b9fba3924 267 // Transfer width - not used
frank26080115 0:bf7b9fba3924 268 GPDMACfg.TransferWidth = 0;
frank26080115 0:bf7b9fba3924 269 // Transfer type
frank26080115 0:bf7b9fba3924 270 GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P;
frank26080115 0:bf7b9fba3924 271 // Source connection - unused
frank26080115 0:bf7b9fba3924 272 GPDMACfg.SrcConn = 0;
frank26080115 0:bf7b9fba3924 273 // Destination connection
frank26080115 0:bf7b9fba3924 274 GPDMACfg.DstConn = GPDMA_CONN_SSP0_Tx;
frank26080115 0:bf7b9fba3924 275 // Linker List Item - unused
frank26080115 0:bf7b9fba3924 276 GPDMACfg.DMALLI = 0;
frank26080115 0:bf7b9fba3924 277 // Setup channel with given parameter
frank26080115 0:bf7b9fba3924 278 GPDMA_Setup(&GPDMACfg);
frank26080115 0:bf7b9fba3924 279
frank26080115 0:bf7b9fba3924 280 /* Reset terminal counter */
frank26080115 0:bf7b9fba3924 281 Channel0_TC = 0;
frank26080115 0:bf7b9fba3924 282 /* Reset Error counter */
frank26080115 0:bf7b9fba3924 283 Channel0_Err = 0;
frank26080115 0:bf7b9fba3924 284
frank26080115 0:bf7b9fba3924 285
frank26080115 0:bf7b9fba3924 286 /* Configure GPDMA channel 1 -------------------------------------------------------------*/
frank26080115 0:bf7b9fba3924 287 /* DMA Channel 1 */
frank26080115 0:bf7b9fba3924 288 GPDMACfg.ChannelNum = 1;
frank26080115 0:bf7b9fba3924 289 // Source memory - not used
frank26080115 0:bf7b9fba3924 290 GPDMACfg.SrcMemAddr = 0;
frank26080115 0:bf7b9fba3924 291 // Destination memory - Not used
frank26080115 0:bf7b9fba3924 292 GPDMACfg.DstMemAddr = (uint32_t) &dma_dst;
frank26080115 0:bf7b9fba3924 293 // Transfer size
frank26080115 0:bf7b9fba3924 294 GPDMACfg.TransferSize = sizeof(dma_dst);
frank26080115 0:bf7b9fba3924 295 // Transfer width - not used
frank26080115 0:bf7b9fba3924 296 GPDMACfg.TransferWidth = 0;
frank26080115 0:bf7b9fba3924 297 // Transfer type
frank26080115 0:bf7b9fba3924 298 GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_P2M;
frank26080115 0:bf7b9fba3924 299 // Source connection
frank26080115 0:bf7b9fba3924 300 GPDMACfg.SrcConn = GPDMA_CONN_SSP0_Rx;
frank26080115 0:bf7b9fba3924 301 // Destination connection - not used
frank26080115 0:bf7b9fba3924 302 GPDMACfg.DstConn = 0;
frank26080115 0:bf7b9fba3924 303 // Linker List Item - unused
frank26080115 0:bf7b9fba3924 304 GPDMACfg.DMALLI = 0;
frank26080115 0:bf7b9fba3924 305 // Setup channel with given parameter
frank26080115 0:bf7b9fba3924 306 GPDMA_Setup(&GPDMACfg);
frank26080115 0:bf7b9fba3924 307
frank26080115 0:bf7b9fba3924 308 /* Reset terminal counter */
frank26080115 0:bf7b9fba3924 309 Channel1_TC = 0;
frank26080115 0:bf7b9fba3924 310 /* Reset Error counter */
frank26080115 0:bf7b9fba3924 311 Channel1_Err = 0;
frank26080115 0:bf7b9fba3924 312
frank26080115 0:bf7b9fba3924 313 _DBG_("Start transfer...");
frank26080115 0:bf7b9fba3924 314
frank26080115 0:bf7b9fba3924 315 // Enable Tx and Rx DMA on SSP0
frank26080115 0:bf7b9fba3924 316 SSP_DMACmd (LPC_SSP0, SSP_DMA_RX, ENABLE);
frank26080115 0:bf7b9fba3924 317 SSP_DMACmd (LPC_SSP0, SSP_DMA_TX, ENABLE);
frank26080115 0:bf7b9fba3924 318
frank26080115 0:bf7b9fba3924 319 // Enable GPDMA channel 0
frank26080115 0:bf7b9fba3924 320 GPDMA_ChannelCmd(0, ENABLE);
frank26080115 0:bf7b9fba3924 321 // Enable GPDMA channel 0
frank26080115 0:bf7b9fba3924 322 GPDMA_ChannelCmd(1, ENABLE);
frank26080115 0:bf7b9fba3924 323
frank26080115 0:bf7b9fba3924 324 // Enable interrupt for DMA
frank26080115 0:bf7b9fba3924 325 NVIC_EnableIRQ (DMA_IRQn);
frank26080115 0:bf7b9fba3924 326
frank26080115 0:bf7b9fba3924 327 /* Wait for GPDMA processing complete */
frank26080115 0:bf7b9fba3924 328 while (((Channel0_TC == 0) && (Channel0_Err == 0)) \
frank26080115 0:bf7b9fba3924 329 || ((Channel1_TC == 0) && (Channel1_Err ==0)));
frank26080115 0:bf7b9fba3924 330
frank26080115 0:bf7b9fba3924 331 /* Verify buffer */
frank26080115 0:bf7b9fba3924 332 Buffer_Verify();
frank26080115 0:bf7b9fba3924 333
frank26080115 0:bf7b9fba3924 334 _DBG_("Verify complete!");
frank26080115 0:bf7b9fba3924 335
frank26080115 0:bf7b9fba3924 336 /* Loop forever */
frank26080115 0:bf7b9fba3924 337 while(1);
frank26080115 0:bf7b9fba3924 338 return 1;
frank26080115 0:bf7b9fba3924 339 }
frank26080115 0:bf7b9fba3924 340
frank26080115 0:bf7b9fba3924 341 /* With ARM and GHS toolsets, the entry point is main() - this will
frank26080115 0:bf7b9fba3924 342 allow the linker to generate wrapper code to setup stacks, allocate
frank26080115 0:bf7b9fba3924 343 heap area, and initialize and copy code and data segments. For GNU
frank26080115 0:bf7b9fba3924 344 toolsets, the entry point is through __start() in the crt0_gnu.asm
frank26080115 0:bf7b9fba3924 345 file, and that startup code will setup stacks and data */
frank26080115 0:bf7b9fba3924 346 int main(void)
frank26080115 0:bf7b9fba3924 347 {
frank26080115 0:bf7b9fba3924 348 return c_entry();
frank26080115 0:bf7b9fba3924 349 }
frank26080115 0:bf7b9fba3924 350
frank26080115 0:bf7b9fba3924 351
frank26080115 0:bf7b9fba3924 352 #ifdef DEBUG
frank26080115 0:bf7b9fba3924 353 /*******************************************************************************
frank26080115 0:bf7b9fba3924 354 * @brief Reports the name of the source file and the source line number
frank26080115 0:bf7b9fba3924 355 * where the CHECK_PARAM error has occurred.
frank26080115 0:bf7b9fba3924 356 * @param[in] file Pointer to the source file name
frank26080115 0:bf7b9fba3924 357 * @param[in] line assert_param error line source number
frank26080115 0:bf7b9fba3924 358 * @return None
frank26080115 0:bf7b9fba3924 359 *******************************************************************************/
frank26080115 0:bf7b9fba3924 360 void check_failed(uint8_t *file, uint32_t line)
frank26080115 0:bf7b9fba3924 361 {
frank26080115 0:bf7b9fba3924 362 /* User can add his own implementation to report the file name and line number,
frank26080115 0:bf7b9fba3924 363 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
frank26080115 0:bf7b9fba3924 364
frank26080115 0:bf7b9fba3924 365 /* Infinite loop */
frank26080115 0:bf7b9fba3924 366 while(1);
frank26080115 0:bf7b9fba3924 367 }
frank26080115 0:bf7b9fba3924 368 #endif
frank26080115 0:bf7b9fba3924 369
frank26080115 0:bf7b9fba3924 370 /*
frank26080115 0:bf7b9fba3924 371 * @}
frank26080115 0:bf7b9fba3924 372 */