/******************************************************************************* * DISCLAIMER * This software is supplied by Renesas Electronics Corporation and is only * intended for use with Renesas products. No other uses are authorized. This * software is owned by Renesas Electronics Corporation and is protected under * all applicable laws, including copyright laws. * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * Renesas reserves the right, without notice, to make changes to this software * and to discontinue the availability of this software. By using this software, * you agree to the additional terms and conditions found by accessing the * following link: * http://www.renesas.com/disclaimer * (c) 2014 Renesas Electronics Corporation All rights reserved. *******************************************************************************/ /****************************************************************************** * File Name : r_dma.c * Version : 1.0 * Device(s) : R7F701007 RH850/F1L * Tool-Chain : IAR Embedded Workbench 1.30.1 * Description : This file is a sample of the DMA. * Operation : - ******************************************************************************* ******************************************************************************* * History : DD.MM.YYYY Version Description * : 20.03.2014 1.00 First Release ******************************************************************************/ /****************************************************************************** Includes ******************************************************************************/ #include "r_typedefs.h" #include "iodefine.h" #ifdef __ghs__ #include "device.h" #endif #ifdef __IAR_SYSTEMS_ICC__ #include #endif /****************************************************************************** Imported global variables and functions (from other files) ******************************************************************************/ /****************************************************************************** Macro definitions ******************************************************************************/ /****************************************************************************** Exported global variables and functions (to be accessed by other files) ******************************************************************************/ void R_DMA_Init( void ); void R_DMA_clear_tc( void ); /****************************************************************************** Private global variables and functions ******************************************************************************/ uint32_t dma_destination_buff[8]; /****************************************************************************** * Function Name : void R_DMA_Init( void ) * Description : This function initialize DMA0. * Argument : none * Return Value : none ******************************************************************************/ void R_DMA_Init( void ) { /* Set interrupt flags */ MKDMA0 = 1U; RFDMA0 = 0U; TBDMA0 = 0U; DMCM0 = 0x0000U; /* Supervisor mode is assigned as the master */ DTS0DTE = 0U; /* Disables DMA transfer */ DSA0 = (uint32_t)&ADCA0.DIR00.UINT32; /* Set the DMA source address (ADCA0.DIR00) */ DDA0 = (uint32_t)&dma_destination_buff[0]; /* Set the DMA destination address (RAM) */ DTC0 = 0x0008U; /* Transfer executed 8 */ /* Set the transfer data size , address count direction and loop enable. DTCTm - DMA Transfer Control Register b15 - Reserved set to 0 b14:b13 DTCTmDSn - DMA transfer data size - 32 bits data. Set to 10'b. b12 DTCTmLE - Loop enable - Disable. Set to 0'b. b11:b 8 - Reserved set to 0 b 7 DTCTmSACM1 - DMA transfer source address counting direction - Increment. Set to 0'b. b 6 - Reserved set to 0 b 5 DTCTmDACM1 - DMA transfer destination address counting direction - Increment. Set to 0'b. b 4:b 0 - Reserved set to 0 */ DTCT0 = 0x4000U; DRQCLR = 0x0001U; /* DMA0 Request Clear */ DTFR0 = 0x8000U + 0x04U; /* Enables the generation of the DMA trigger factor. */ /* DMA Trigger Interrupt = INTADCA0I0 */ DTS0DTE = 1U; /* Enables DMA transfer */ MKDMA0 = 0U; /* Enable INTDMA0 interrupt */ } /****************************************************************************** * Function Name : void R_DMA_clear_tc( void ) * Description : TC bit clear * Argument : none * Return Value : none ******************************************************************************/ void R_DMA_clear_tc( void ) { while ( DTS0TC != 1U ) { #if !defined(__IAR_SYSTEMS_ICC__) __nop(); #endif #ifdef __IAR_SYSTEMS_ICC__ __asm( "nop"); #endif } DTS0TC = 0U; /* clear DMA transfer end status */ }